public function send_invoicemail() { $redshopMail = new redshopMail(); $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'get', 'array'); $tmpl = JRequest::getVar('tmpl', '', 'request', 'string'); if ($redshopMail->sendInvoiceMail($cid[0])) { $msg = JText::_('COM_REDSHOP_INVOICE_MAIL_HAS_BEEN_SENT'); } else { $msg = JText::_('COM_REDSHOP_ERROR_INVOICE_MAIL_FAIL'); } if ($tmpl) { $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0] . '&tmpl=' . $tmpl, $msg); } else { $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0], $msg); } }
public function update_status_all() { $app = JFactory::getApplication(); $helper = new redhelper(); $stockroomhelper = new rsstockroomhelper(); $producthelper = new producthelper(); $newstatus = JRequest::getVar('order_status_all'); $option = JRequest::getVar('option'); $return = JRequest::getVar('return'); $cid = JRequest::getVar('cid', array(0), 'method', 'array'); $data['order_status'] = $newstatus; $data['date_changed'] = time(); $invociepdfname = ""; for ($i = 0; $i < count($cid); $i++) { $oid = array((int) $cid[$i]); $nc = JRequest::getVar('nc' . $oid[0]); $c_note = JRequest::getVar('customer_note' . $oid[0]); $isproduct = JRequest::getVar('isproduct'); // Add status log... $order_log = JTable::getInstance('order_status_log', 'Table'); $data['order_id'] = $oid[0]; $data['customer_note'] = $c_note; if (!$order_log->bind($data)) { return JError::raiseWarning(500, $order_log->getError()); } if (!$order_log->store()) { JError::raiseError(500, $order_log->getError()); } // Changing the status of the order $this->updateOrderStatus($oid[0], $newstatus); $paymentstatus = JRequest::getVar('order_paymentstatus' . $oid[0]); if (isset($paymentstatus)) { $this->updateOrderPaymentStatus($oid[0], $paymentstatus); } if ($paymentstatus == "Paid") { JModel::addIncludePath(JPATH_SITE . '/components/com_redshop/models'); $checkoutModelcheckout = JModel::getInstance('checkout', 'checkoutModel'); $checkoutModelcheckout->sendGiftCard($oid[0]); // Send the Order mail $redshopMail = new redshopMail(); if (ORDER_MAIL_AFTER) { $redshopMail->sendOrderMail($oid[0]); } elseif (INVOICE_MAIL_ENABLE) { $redshopMail->sendInvoiceMail($oid[0]); } } if ($paymentstatus == "Paid" && $newstatus == 'S') { // For shipped pdf generaton $order_shipped_id = $oid[0]; $invociepdfname = $this->createShippedInvoicePdf($order_shipped_id); // For Consignor Label generation JPluginHelper::importPlugin('redshop_shippinglabel'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onChangeStatusToShipped', array($oid[0], $newstatus, $paymentstatus)); } // For Webpack Postdk Label Generation $this->createWebPacklabel($oid[0], $specifiedSendDate, $newstatus, $paymentstatus); // Changing the status of the order end $helper->clickatellSMS($data['order_id']); // If changing the status of the order then there item status need to change if ($isproduct != 1) { $this->updateOrderItemStatus($oid[0], 0, $newstatus); } // If order is cancelled then, putting stock in the container from where it was dedcuted if ($newstatus == 'X') { $orderproducts = $this->getOrderItemDetail($oid[0]); for ($j = 0; $j < count($orderproducts); $j++) { $conid = $orderproducts[$j]->container_id; $prodid = $orderproducts[$j]->product_id; $prodqty = $orderproducts[$j]->stockroom_quantity; // When the order is set to "cancelled",product will return to stock $stockroomhelper->manageStockAmount($prodid, $prodqty, $orderproducts[$j]->stockroom_id); $producthelper->makeAttributeOrder($orderproducts[$j]->order_item_id, 0, $prodid, 1); // If order is cancelled then, putting stock in the container from where it was dedcuted end if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } // If any of the item from the order is returuned back then, // change the status of whole order and also put back to stock. if ($newstatus == 'RT') { if ($isproduct) { $pid = JRequest::getVar('product_id'); $orderproductdetail = $this->getOrderItemDetail($oid[0], $pid); $conid = $orderproductdetail[0]->container_id; $prodid = $orderproductdetail[0]->product_id; $prodqty = $orderproductdetail[0]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } // Changing the status of the order item to Returned $this->updateOrderItemStatus($oid[0], $prodid, "RT"); // Changing the status of the order to Partially Returned $this->updateOrderStatus($oid[0], "PRT"); } else { $orderproducts = $this->getOrderItemDetail($oid[0]); for ($k = 0; $k < count($orderproducts); $k++) { $conid = $orderproducts[$k]->container_id; $prodid = $orderproducts[$k]->product_id; $prodqty = $orderproducts[$k]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } } // If any of the item from the order is reclamation back then, // change the status of whole order and also put back to stock. if ($newstatus == 'RC') { if ($isproduct) { $pid = JRequest::getVar('product_id'); // Changing the status of the order item to Reclamation $this->updateOrderItemStatus($oid[0], $pid, "RC"); // Changing the status of the order to Partially Reclamation $this->updateOrderStatus($oid[0], "PRC"); } else { $orderproducts = $this->getOrderItemDetail($oid[0]); for ($l = 0; $l < count($orderproducts); $l++) { $conid = $orderproducts[$l]->container_id; $prodid = $orderproducts[$l]->product_id; $prodqty = $orderproducts[$l]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } } // If any of the item from the order is reclamation back then, // change the status of whole order and also put back to stock. if ($newstatus == 'S') { if ($isproduct) { $pid = JRequest::getVar('product_id'); // Changing the status of the order item to Reclamation $this->updateOrderItemStatus($oid[0], $pid, "S"); // Changing the status of the order to Partially Reclamation $this->updateOrderStatus($oid[0], "PS"); } } // Mail to customer of order status change $this->changeOrderStatusMail($oid[0], $newstatus, $c_note); $this->createBookInvoice($oid[0], $newstatus); } if ($return == 'order') { $link = 'index.php?option=' . $option . '&view=' . $return; } else { $link = 'index.php?option=' . $option . '&view=' . $return . '&cid[]=' . $oid[0]; } ?> <script type="text/javascript"> <?php if ($invociepdfname != "") { if (file_exists(REDSHOP_FRONT_DOCUMENT_RELPATH . "invoice/" . $invociepdfname . ".pdf")) { ?> window.open("<?php echo REDSHOP_FRONT_DOCUMENT_ABSPATH; ?> invoice/<?php echo $invociepdfname; ?> .pdf"); <?php } } ?> window.parent.location = '<?php echo $link; ?> '; </script> <?php }