public function updateOrderStatus() { $session = JFactory::getSession(); $post = $session->get('updateOrderIdPost'); $merge_invoice_arr = $session->get('merge_invoice_arr'); $rand_invoice_name = JRequest::getVar('rand_invoice_name', ''); $order_functions = new order_functions(); $cnt = JRequest::getInt('cnt', 0); $order_id = $post['cid']; $responcemsg = ""; for ($i = $cnt, $j = 0; $j < 1; $j++) { if (!isset($order_id[$i])) { $pdf = new PDFMerger(); $merge_invoice_arr = $session->get('merge_invoice_arr'); for ($m = 0; $m < count($merge_invoice_arr); $m++) { if (file_exists(JPATH_SITE . '/components/com_redshop/assets/document' . '/invoice/shipped_' . $merge_invoice_arr[$m] . '.pdf')) { $pdf->addPDF(JPATH_SITE . '/components/com_redshop/assets/document' . '/invoice/shipped_' . $merge_invoice_arr[$m] . '.pdf', 'all'); } } $pdf->merge('file', JPATH_SITE . '/components/com_redshop/assets/document' . '/invoice/shipped_' . $rand_invoice_name . '.pdf'); for ($m = 0; $m < count($merge_invoice_arr); $m++) { if (file_exists(JPATH_SITE . '/components/com_redshop/assets/document' . '/invoice/shipped_' . $merge_invoice_arr[$m] . '.pdf')) { unlink(JPATH_ROOT . '/components/com_redshop/assets/document/invoice/shipped_' . $merge_invoice_arr[$m] . '.pdf'); } } $session->set('merge_invoice_arr', null); break; } $returnmsg = $order_functions->orderStatusUpdate($order_id[$i], $post); // For shipped pdf generation if ($post['order_status_all'] == "S" && $post['order_paymentstatus' . $order_id[$i]] == "Paid") { $pdfObj = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A5', true, 'UTF-8', false); $pdfObj->SetTitle('Shipped'); $pdfObj->SetAuthor('redSHOP'); $pdfObj->SetCreator('redSHOP'); $pdfObj->SetMargins(8, 8, 8); $font = 'times'; $pdfObj->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdfObj->setHeaderFont(array($font, '', 8)); $pdfObj->SetFont($font, "", 6); $invoice = $order_functions->createShippedInvoicePdf($order_id[$i]); $session->set('merge_invoice_arr', $order_id[$i]); $pdfObj->AddPage(); $pdfObj->WriteHTML($invoice, true, false, true, false, ''); $invoice_pdfName = "shipped_" . $order_id[$i]; $merge_invoice_arr[] = $order_id[$i]; $session->set('merge_invoice_arr', $merge_invoice_arr); $pdfObj->Output(JPATH_SITE . '/components/com_redshop/assets/document' . '/invoice/' . $invoice_pdfName . ".pdf", "F"); } $responcemsg .= "<div>" . ($i + 1) . ": " . JText::_('COM_REDSHOP_ORDER_ID') . " " . $order_id[$i] . " -> "; $errmsg = ''; if ($returnmsg) { $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_ORDER_STATUS_SUCCESSFULLY_UPDATED') . $errmsg . "</span>"; } else { $responcemsg .= "<span style='color: #ff0000'>" . JText::_('COM_REDSHOP_ORDER_STATUS_UPDATE_FAIL') . $errmsg . "</span>"; } $responcemsg .= "</div>"; } $responcemsg = "<div id='sentresponse'>" . $responcemsg . "</div>"; echo $responcemsg; exit; }