function getRefundHistory() { global $osC_Database, $osC_Language, $toC_Json; $osC_Currencies = new osC_Currencies_Admin(); $osC_Order = new osC_Order($_REQUEST['orders_id']); $Qrefunds = $osC_Database->query('select * from :table_orders_refunds where orders_id = :orders_id'); $Qrefunds->bindTable(':table_orders_refunds', TABLE_ORDERS_REFUNDS); $Qrefunds->bindInt(':orders_id', $_REQUEST['orders_id']); $Qrefunds->execute(); $records = array(); while ($Qrefunds->next()) { $Qproducts = $osC_Database->query('select * from :table_orders_refunds_products where orders_refunds_id = :orders_refunds_id'); $Qproducts->bindTable(':table_orders_refunds_products', TABLE_ORDERS_REFUNDS_PRODUCTS); $Qproducts->bindInt(':orders_refunds_id', $Qrefunds->valueInt('orders_refunds_id')); $Qproducts->execute(); $total_products = 0; $products = array(); $products_table = '<table width="100%">'; while ($Qproducts->next()) { foreach ($osC_Order->getProducts() as $product) { if ($Qproducts->valueInt('orders_products_id') == $product['orders_products_id']) { $total_products += $Qproducts->valueInt('products_quantity'); $product_info = $Qproducts->valueInt('products_quantity') . ' x ' . $product['name']; if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('messages') . ': ' . $product['messages'] . '</i></nobr>'; } if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) { foreach ($product['variants'] as $variants) { $product_info .= '<br /><nobr> <i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>'; } } $products[] = $product_info; $products_table .= '<tr><td>' . $product_info . '</td><td width="60" valign="top" align="right">' . $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()) . '</td></tr>'; } } } $products_table .= '</table>'; $order_total = '<table width="100%">'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_sub_total") . ' </td><td width="60">' . $osC_Currencies->format($Qrefunds->value('sub_total')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_shipping_fee") . ' </td><td width="60">' . $osC_Currencies->format($Qrefunds->value('shipping')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_handling") . ' </td><td width="60">' . $osC_Currencies->format($Qrefunds->value('handling')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_refund_total") . ' </td><td width="60">' . $osC_Currencies->format($Qrefunds->value('refund_total')) . '</td></tr>'; $order_total .= '</table>'; $records[] = array('orders_refunds_id' => $Qrefunds->valueInt('orders_refunds_id'), 'orders_refunds_type' => $Qrefunds->valueInt('orders_refunds_type') == ORDERS_RETURNS_TYPE_CREDIT_SLIP ? $osC_Language->get('text_credit_slip') : $osC_Language->get('text_store_credit'), 'total_products' => $total_products, 'total_refund' => $osC_Currencies->format($Qrefunds->value('refund_total')), 'sub_total' => $osC_Currencies->format($Qrefunds->value('sub_total')), 'date_added' => osC_DateTime::getShort($Qrefunds->value('date_added')), 'comments' => $Qrefunds->value('comments'), 'products' => $products_table, 'totals' => $order_total); } $response = array(EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
function listCreditsMemo() { global $toC_Json, $osC_Database, $osC_Language; $osC_Currencies = new osC_Currencies_Admin(); $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start']; $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit']; $Qslips = $osC_Database->query('select r.* from :table_orders_refunds r '); if (isset($_REQUEST['customers_id']) && !empty($_REQUEST['customers_id'])) { $Qslips->appendQuery(', ' . TABLE_ORDERS . ' o where r.orders_id = o.orders_id and o.customers_id = :customers_id and r.orders_refunds_type = :orders_refunds_type'); $Qslips->bindInt(':customers_id', $_REQUEST['customers_id']); } else { $Qslips->appendQuery('where orders_refunds_type = :orders_refunds_type'); } if (isset($_REQUEST['orders_id']) && !empty($_REQUEST['orders_id'])) { $Qslips->appendQuery('and orders_id = :orders_id '); $Qslips->bindInt(':orders_id', $_REQUEST['orders_id']); } $Qslips->bindTable(':table_orders_refunds', TABLE_ORDERS_REFUNDS); $Qslips->bindInt(':orders_refunds_type', ORDERS_RETURNS_TYPE_CREDIT_SLIP); $Qslips->setExtBatchLimit($start, $limit); $Qslips->execute(); $records = array(); while ($Qslips->next()) { $orders_refunds_id = $Qslips->value('orders_refunds_id'); $Qproducts = $osC_Database->query("select orders_products_id, products_quantity from :table_orders_refunds_products where orders_refunds_id = :orders_refunds_id"); $Qproducts->bindTable(':table_orders_refunds_products', TABLE_ORDERS_REFUNDS_PRODUCTS); $Qproducts->bindInt(':orders_refunds_id', $orders_refunds_id); $Qproducts->execute(); $products_ids = array(); $products_qty = array(); while ($Qproducts->next()) { $products_ids[] = $Qproducts->valueInt('orders_products_id'); $products_qty[$Qproducts->valueInt('orders_products_id')] = $Qproducts->valueInt('products_quantity'); } $total = 0; $quantity = 0; $products = array(); $osC_Order = new osC_Order($Qslips->valueInt('orders_id')); $products_table = '<table width="100%">'; foreach ($osC_Order->getProducts() as $product) { if (in_array($product['orders_products_id'], $products_ids)) { $product_info = $products_qty[$product['orders_products_id']] . ' x ' . $product['name']; if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('messages') . ': ' . $product['messages'] . '</i></nobr>'; } if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) { foreach ($product['variants'] as $variants) { $product_info .= '<br /><nobr> <i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>'; } } $products[] = $product_info; $quantity += $products_qty[$product['orders_products_id']]; $products_table .= '<tr><td>' . $product_info . '</td><td width="60" valign="top" align="right">' . $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()) . '</td></tr>'; } } $products_table .= '</table>'; $order_total = '<table width="100%">'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_sub_total") . ' </td><td width="60" align="right">' . $osC_Currencies->format($Qslips->value('sub_total')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_shipping_fee") . ' </td><td width="60" align="right">' . $osC_Currencies->format($Qslips->value('shipping')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_handling") . ' </td><td width="60" align="right">' . $osC_Currencies->format($Qslips->value('handling')) . '</td></tr>'; $order_total .= '<tr><td align="right">' . $osC_Language->get("field_refund_total") . ' </td><td width="60" align="right">' . $osC_Currencies->format($Qslips->value('refund_total')) . '</td></tr>'; $order_total .= '</table>'; $records[] = array('orders_refunds_id' => $Qslips->valueInt('orders_refunds_id'), 'credit_slips_id' => $Qslips->valueInt('credit_slips_id'), 'orders_id' => $Qslips->valueInt('orders_id'), 'customers_name' => $osC_Order->getCustomer('name'), 'total_products' => $quantity, 'total_refund' => $osC_Currencies->format($Qslips->value('refund_total')), 'sub_total' => $osC_Currencies->format($Qslips->value('sub_total')), 'date_added' => osC_DateTime::getShort($Qslips->value('date_added')), 'shipping_address' => osC_Address::format($osC_Order->getDelivery(), '<br />'), 'shipping_method' => $osC_Order->getDeliverMethod(), 'billing_address' => osC_Address::format($osC_Order->getBilling(), '<br />'), 'payment_method' => $osC_Order->getPaymentMethod(), 'comments' => $Qslips->value('comments'), 'products' => $products_table, 'totals' => $order_total); } $response = array(EXT_JSON_READER_TOTAL => $Qslips->getBatchSize(), EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
function render() { global $osC_Language; //New Page $this->_pdf->AddPage(); //Title $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TITLE_FONT_SIZE); $this->_pdf->SetY(TOC_PDF_POS_HEADING_TITLE_Y); $this->_pdf->MultiCell(70, 4, $osC_Language->get('pdf_invoice_heading_title'), 0, 'L'); //Date purchase & order ID field title $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE); $this->_pdf->SetY(TOC_PDF_POS_DOC_INFO_FIELD_Y); $this->_pdf->SetX(135); $this->_pdf->MultiCell(55, 4, $osC_Language->get('operation_heading_invoice_number') . ':' . "\n" . $osC_Language->get('operation_heading_invoice_date') . ':' . "\n" . $osC_Language->get('operation_heading_order_id') . ':', 0, 'L'); //Date purchase & order ID field value $this->_pdf->SetFont(TOC_PDF_FONT, '', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE); $this->_pdf->SetY(TOC_PDF_POS_DOC_INFO_VALUE_Y); $this->_pdf->SetX(150); $this->_pdf->MultiCell(40, 4, $this->_order->getInvoiceNumber() . "\n" . osC_DateTime::getShort($this->_order->getInvoiceDate()) . "\n" . $this->_order->getOrderID(), 0, 'R'); //Products $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TABLE_HEADING_FONT_SIZE); $this->_pdf->SetY(TOC_PDF_POS_PRODUCTS_TABLE_HEADING_Y); $this->_pdf->Cell(8, 6, '', 'TB', 0, 'R', 0); $this->_pdf->Cell(78, 6, $osC_Language->get('table_heading_products'), 'TB', 0, 'C', 0); $this->_pdf->Cell(35, 6, $osC_Language->get('table_heading_quantity'), 'TB', 0, 'C', 0); $this->_pdf->Cell(30, 6, $osC_Language->get('table_heading_price'), 'TB', 0, 'R', 0); $this->_pdf->Cell(30, 6, $osC_Language->get('table_heading_total'), 'TB', 0, 'R', 0); $this->_pdf->Ln(); $i = 0; $y_table_position = TOC_PDF_POS_PRODUCTS_TABLE_CONTENT_Y; $osC_Currencies = new osC_Currencies_Admin(); foreach ($this->_order->getProducts() as $products) { $rowspan = 1; //Pos $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TABLE_CONTENT_FONT_SIZE); $this->_pdf->SetY($y_table_position); $this->_pdf->MultiCell(8, 4, $i + 1, 0, 'C'); //Product $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(30); $product_info = $products['name']; if ($products['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $product_info .= "\n" . ' -' . $osC_Language->get('senders_name') . ': ' . $products['senders_name']; if ($products['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= "\n" . ' -' . $osC_Language->get('senders_email') . ': ' . $products['senders_email']; $rowspan++; } $product_info .= "\n" . ' -' . $osC_Language->get('recipients_name') . ': ' . $products['recipients_name']; if ($products['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= "\n" . ' -' . $osC_Language->get('recipients_email') . ': ' . $products['recipients_email']; $rowspan++; } $rowspan += 3; $product_info .= "\n" . ' -' . $osC_Language->get('messages') . ': ' . $products['messages']; } if (isset($products['variants']) && sizeof($products['variants']) > 0) { foreach ($products['variants'] as $variant) { $product_info .= "\n" . $variant['groups_name'] . ": " . $variant['values_name']; $rowspan++; } } $this->_pdf->MultiCell(100, 4, $product_info, 0, 'L'); //Quantity $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(110); $this->_pdf->MultiCell(5, 4, $products['quantity'], 0, 'C'); //Price $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(135); $price = $osC_Currencies->displayPriceWithTaxRate($products['final_price'], $products['tax'], 1, $this->_order->getCurrency(), $this->_order->getCurrencyValue()); $price = str_replace(' ', ' ', $price); $this->_pdf->MultiCell(20, 4, $price, 0, 'R'); //Total $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(165); $total = $osC_Currencies->displayPriceWithTaxRate($products['final_price'], $products['tax'], $products['quantity'], $this->_order->getCurrency(), $this->_order->getCurrencyValue()); $total = str_replace(' ', ' ', $total); $this->_pdf->MultiCell(20, 4, $total, 0, 'R'); $y_table_position += $rowspan * TOC_PDF_TABLE_CONTENT_HEIGHT; //products list exceed page height, create a new page if ($y_table_position - TOC_PDF_POS_CONTENT_Y - 6 > 160) { $this->_pdf->AddPage(); $y_table_position = TOC_PDF_POS_CONTENT_Y + 6; $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TABLE_HEADING_FONT_SIZE); $this->_pdf->SetY(TOC_PDF_POS_CONTENT_Y); $this->_pdf->Cell(8, 6, '', 'TB', 0, 'R', 0); $this->_pdf->Cell(78, 6, $osC_Language->get('table_heading_products'), 'TB', 0, 'C', 0); $this->_pdf->Cell(35, 6, $osC_Language->get('table_heading_quantity'), 'TB', 0, 'C', 0); $this->_pdf->Cell(30, 6, $osC_Language->get('table_heading_price'), 'TB', 0, 'R', 0); $this->_pdf->Cell(30, 6, $osC_Language->get('table_heading_total'), 'TB', 0, 'R', 0); $this->_pdf->Ln(); } $i++; } $this->_pdf->SetY($y_table_position + 1); $this->_pdf->Cell(180, 7, '', 'T', 0, 'C', 0); //Order Totals $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TABLE_CONTENT_FONT_SIZE); foreach ($this->_order->getTotals() as $totals) { $y_table_position += 4; $this->_pdf->SetFont(TOC_PDF_FONT, 'B', 8); $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(40); $this->_pdf->MultiCell(120, 5, $totals['title'], 0, 'R'); $this->_pdf->SetFont(TOC_PDF_FONT, 'B', 8); $this->_pdf->SetY($y_table_position); $this->_pdf->SetX(145); $this->_pdf->MultiCell(40, 5, strip_tags($totals['text']), 0, 'R'); } $this->_pdf->Output("Invoice", "I"); }
function listOrders() { global $toC_Json, $osC_Database, $osC_Language; require_once 'includes/classes/order.php'; require_once 'includes/classes/currencies.php'; $osC_Currencies = new osC_Currencies_Admin(); $Qorders = $osC_Database->query('select o.orders_id, o.date_purchased, s.orders_status_name, ot.text as order_total from :table_orders o, :table_orders_total ot, :table_orders_status s where o.orders_id = ot.orders_id and ot.class = "total" and o.orders_status = s.orders_status_id and o.customers_email_address = :customers_email_address and s.language_id = :language_id '); $Qorders->bindTable(':table_orders', TABLE_ORDERS); $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); $Qorders->bindTable(':table_orders_status', TABLE_ORDERS_STATUS); $Qorders->bindValue(':customers_email_address', $_REQUEST['email']); $Qorders->bindInt(':language_id', $osC_Language->getID()); $Qorders->execute(); $records = array(); while ($Qorders->next()) { $osC_Order = new osC_Order($Qorders->valueInt('orders_id')); $products_table = '<table width="100%">'; foreach ($osC_Order->getProducts() as $product) { $product_info = $product['name']; if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>'; if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $product_info .= '<br /><nobr> <i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>'; } $product_info .= '<br /><nobr> <i>' . $osC_Language->get('messages') . ': ' . $product['messages'] . '</i></nobr>'; } if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) { foreach ($product['variants'] as $variants) { $product_info .= '<br /><nobr> <i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>'; } } $products_table .= '<tr><td width="15">' . $product['quantity'] . ' x ' . '</td><td>' . $product_info . '</td><td valign="top" align="right" width="50">' . $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()) . '</td></tr>'; } $products_table .= '</table>'; $order_total = '<table width="100%">'; foreach ($osC_Order->getTotals() as $total) { $order_total .= '<tr><td align="right">' . $total['title'] . ' </td><td width="60" align="right">' . $total['text'] . '</td></tr>'; } $order_total .= '</table>'; $records[] = array('orders_id' => $Qorders->valueInt('orders_id'), 'order_total' => strip_tags($Qorders->value('order_total')), 'date_purchased' => osC_DateTime::getShort($Qorders->value('date_purchased')), 'orders_status_name' => $Qorders->value('orders_status_name'), 'products' => $products_table, 'totals' => $order_total); } $response = array(EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }