Example #1
0
 function listInvoices()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $osC_Tax = new osC_Tax_Admin();
     $osC_Currencies = new osC_Currencies_Admin();
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qinvoices = $osC_Database->query('select o.orders_id, o.customers_ip_address, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, o.invoice_number, o.invoice_date, 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 s.language_id = :language_id and o.invoice_number IS NOT NULL');
     if (isset($_REQUEST['orders_id']) && is_numeric($_REQUEST['orders_id'])) {
         $Qinvoices->appendQuery(' and o.orders_id = :orders_id ');
         $Qinvoices->bindInt(':orders_id', $_REQUEST['orders_id']);
     }
     if (isset($_REQUEST['customers_id']) && is_numeric($_REQUEST['customers_id'])) {
         $Qinvoices->appendQuery(' and o.customers_id = :customers_id ');
         $Qinvoices->bindInt(':customers_id', $_REQUEST['customers_id']);
     }
     if (isset($_REQUEST['status']) && is_numeric($_REQUEST['status'])) {
         $Qinvoices->appendQuery(' and s.orders_status_id = :orders_status_id ');
         $Qinvoices->bindInt(':orders_status_id', $_REQUEST['status']);
     }
     $Qinvoices->appendQuery('order by o.date_purchased desc, o.last_modified desc, o.invoice_number desc');
     $Qinvoices->bindTable(':table_orders', TABLE_ORDERS);
     $Qinvoices->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
     $Qinvoices->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
     $Qinvoices->bindInt(':language_id', $osC_Language->getID());
     $Qinvoices->setExtBatchLimit($start, $limit);
     $Qinvoices->execute();
     $records = array();
     while ($Qinvoices->next()) {
         $osC_Order = new osC_Order($Qinvoices->valueInt('orders_id'));
         $products_table = '<table width="100%">';
         foreach ($osC_Order->getProducts() as $product) {
             $product_info = $product['quantity'] . '&nbsp;x&nbsp;' . $product['name'];
             if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>';
                 if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>';
                 if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<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>&nbsp;&nbsp;&nbsp;<i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>';
                 }
             }
             $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%">';
         foreach ($osC_Order->getTotals() as $total) {
             $order_total .= '<tr><td align="right">' . $total['title'] . '&nbsp;&nbsp;&nbsp;</td><td width="60" align="right">' . $total['text'] . '</td></tr>';
         }
         $order_total .= '</table>';
         $records[] = array('orders_id' => $Qinvoices->valueInt('orders_id'), 'customers_name' => $Qinvoices->valueProtected('customers_name'), 'order_total' => strip_tags($Qinvoices->value('order_total')), 'date_purchased' => osC_DateTime::getShort($Qinvoices->value('date_purchased')), 'orders_status_name' => $Qinvoices->value('orders_status_name'), 'invoices_number' => $Qinvoices->value('invoice_number'), 'invoices_date' => osC_DateTime::getShort($Qinvoices->value('invoice_date')), '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(), 'products' => $products_table, 'totals' => $order_total);
     }
     $Qinvoices->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => $Qinvoices->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Example #2
0
 function listOrdersEditProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_ShoppingCart, $osC_Currencies, $osC_Weight, $osC_Tax;
     $osC_Tax = new osC_Tax_Admin();
     $osC_Weight = new osC_Weight();
     $osC_Currencies = new osC_Currencies();
     $osC_Order = new osC_Order($_REQUEST['orders_id']);
     $records = array();
     foreach ($osC_Order->getProducts() as $products_id_string => $product) {
         $product_info = $product['name'];
         if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) {
             foreach ($product['variants'] as $variants) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>';
             }
         }
         if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             $product_info .= '&nbsp;(' . $product['gift_certificates_code'] . ')';
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>';
             if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>';
             }
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>';
             if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>';
             }
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('messages') . ': ' . $product['messages'] . '</i></nobr>';
         }
         $osC_Product = new osC_Product($product['id'], $osC_Order->getCustomer('customers_id'));
         $records[] = array('orders_products_id' => $product['orders_products_id'], 'products_id' => $product['id'], 'products_type' => $product['type'], 'products' => $product_info, 'quantity' => $product['quantity'] > 0 ? $product['quantity'] : '', 'qty_in_stock' => $osC_Product->getQuantity($products_id_string), 'sku' => $product['sku'], 'tax' => $osC_Tax->displayTaxRateValue($product['tax']), 'price_net' => round($product['final_price'] * $osC_Order->getCurrencyValue(), 2), 'price_gross' => $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'total_net' => $osC_Currencies->format($product['final_price'] * $product['quantity'], $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'total_gross' => $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], $product['quantity'], $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'action' => array('class' => 'icon-delete-record', 'qtip' => ''));
     }
     $order_totals = '<table cellspacing="5" cellpadding="5" width="300" border="0">';
     foreach ($osC_Order->getTotals() as $totals) {
         $order_totals .= '<tr><td align="right">' . $totals['title'] . '&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="60">' . $totals['text'] . '</td></tr>';
     }
     $order_totals .= '</table>';
     $response = array(EXT_JSON_READER_ROOT => $records, 'totals' => $order_totals, 'shipping_method' => $osC_Order->getDeliverMethod());
     echo $toC_Json->encode($response);
 }
Example #3
0
 function listOrdersEditProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_ShoppingCart, $osC_Currencies, $osC_Weight, $osC_Tax;
     $osC_Tax = new osC_Tax_Admin();
     $osC_Weight = new osC_Weight();
     $osC_Currencies = new osC_Currencies();
     $osC_Order = new osC_Order($_REQUEST['orders_id']);
     $records = array();
     foreach ($osC_Order->getProducts() as $products_id_string => $product) {
         $product_info = $product['name'];
         if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) {
             foreach ($product['variants'] as $variants) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>';
             }
         }
         if (isset($product['customizations']) && !empty($product['customizations'])) {
             $product_info .= '<p>';
             foreach ($product['customizations'] as $key => $customization) {
                 $product_info .= '<div style="float: left">' . $customization['qty'] . ' x ' . '</div>';
                 $product_info .= '<div style="margin-left: 25px">';
                 foreach ($customization['fields'] as $orders_products_customizations_values_id => $field) {
                     if ($field['customization_type'] == CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT) {
                         $product_info .= $field['customization_fields_name'] . ': ' . $field['customization_value'] . '<br />';
                     } else {
                         $product_info .= $field['customization_fields_name'] . ': <a href="' . osc_href_link_admin(FILENAME_JSON, 'module=orders&action=download_customization_file&file=' . $field['customization_value'] . '&cache_file=' . $field['cache_filename']) . '">' . $field['customization_value'] . '</a>' . '<br />';
                     }
                 }
                 $product_info .= '</div>';
             }
             $product_info .= '</p>';
         }
         if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             $product_info .= '&nbsp;(' . $product['gift_certificates_code'] . ')';
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>';
             if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>';
             }
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>';
             if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>';
             }
             $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('messages') . ': ' . $product['messages'] . '</i></nobr>';
         }
         $osC_Product = new osC_Product($product['id'], $osC_Order->getCustomer('customers_id'));
         $records[] = array('orders_products_id' => $product['orders_products_id'], 'products_id' => $product['id'], 'products_type' => $product['type'], 'products' => $product_info, 'quantity' => $product['quantity'] > 0 ? $product['quantity'] : '', 'qty_in_stock' => $osC_Product->getQuantity($products_id_string), 'sku' => $product['sku'], 'tax' => $osC_Tax->displayTaxRateValue($product['tax']), 'price_net' => round($product['final_price'] * $osC_Order->getCurrencyValue(), 2), 'price_gross' => $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'total_net' => $osC_Currencies->format($product['final_price'] * $product['quantity'], $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'total_gross' => $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], $product['quantity'], $osC_Order->getCurrency(), $osC_Order->getCurrencyValue()), 'action' => array('class' => 'icon-delete-record', 'qtip' => ''));
     }
     $order_totals = '<table cellspacing="5" cellpadding="5" width="300" border="0">';
     foreach ($osC_Order->getTotals() as $totals) {
         $order_totals .= '<tr><td align="right">' . $totals['title'] . '&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="60">' . $totals['text'] . '</td></tr>';
     }
     $order_totals .= '</table>';
     $response = array(EXT_JSON_READER_ROOT => $records, 'totals' => $order_totals, 'shipping_method' => $osC_Order->getDeliverMethod());
     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']] . '&nbsp;x&nbsp;' . $product['name'];
                 if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_name') . ': ' . $product['senders_name'] . '</i></nobr>';
                     if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                         $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_email') . ': ' . $product['senders_email'] . '</i></nobr>';
                     }
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['recipients_name'] . '</i></nobr>';
                     if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                         $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_email') . ': ' . $product['recipients_email'] . '</i></nobr>';
                     }
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<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>&nbsp;&nbsp;&nbsp;<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") . '&nbsp;&nbsp;&nbsp;</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") . '&nbsp;&nbsp;&nbsp;</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") . '&nbsp;&nbsp;&nbsp;</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") . '&nbsp;&nbsp;&nbsp;</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);
 }