Exemplo n.º 1
0
 function render()
 {
     global $osC_Database, $osC_Language;
     //New Page
     $this->_pdf->AddPage();
     //Title
     $this->_pdf->SetFont(TOC_PDF_FONT_B, 'B', TOC_PDF_TITLE_FONT_SIZE);
     $this->_pdf->SetY(TOC_PDF_POS_HEADING_TITLE_Y);
     $Qinvoices = $osC_Database->query('select invoice_number from :table_orders where orders_id = :orders_id');
     $Qinvoices->bindTable(':table_orders', TABLE_ORDERS);
     $Qinvoices->bindInt(':orders_id', $_REQUEST['orders_id']);
     $Qinvoices->execute();
     if ($Qinvoices->value('invoice_number') > 0) {
         //Title
         $this->_pdf->MultiCell(0, 4, $osC_Language->get('pdf_invoice_heading_title') . ' کالا و خدمات', 0, 'C');
     } else {
         //Title
         $this->_pdf->MultiCell(0, 4, $osC_Language->get('pdf_order_heading_title') . ' کالا و خدمات', 0, 'C');
     }
     //Date purchase & order ID field title
     $this->_pdf->SetFont(TOC_PDF_FONT_B, 'B', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->SetY(TOC_PDF_POS_DOC_INFO_FIELD_Y);
     $this->_pdf->SetX(150);
     if ($Qinvoices->value('invoice_number') > 0) {
         $this->_pdf->MultiCell(25, 5, $osC_Language->get('operation_heading_invoice_number') . "\n" . $osC_Language->get('operation_heading_invoice_date') . "\n" . $osC_Language->get('operation_heading_order_id'), 0, 'R');
     } else {
         $this->_pdf->MultiCell(25, 5, $osC_Language->get('operation_heading_order_date') . "\n" . $osC_Language->get('operation_heading_order_id'), 0, 'R');
     }
     //Date purchase & order ID field value
     $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->SetY(TOC_PDF_POS_DOC_INFO_VALUE_Y);
     $this->_pdf->SetX(175);
     if ($Qinvoices->value('invoice_number') > 0) {
         $this->_pdf->MultiCell(45, 5, $this->_order->getInvoiceNumber() . "\n" . osC_DateTime::getShort($this->_order->getInvoiceDate()) . "\n" . $this->_order->getOrderID(), 0, 'R');
     } else {
         $this->_pdf->MultiCell(45, 5, osC_DateTime::getShort($this->_order->getDateCreated()) . "\n" . $this->_order->getOrderID(), 0, 'R');
     }
     //Products
     $this->_pdf->SetFont(TOC_PDF_FONT_B, 'B', TOC_PDF_TABLE_HEADING_FONT_SIZE);
     $this->_pdf->SetY(TOC_PDF_POS_PRODUCTS_TABLE_HEADING_Y);
     $this->_pdf->Cell(10, 6, '', 'TB', 0, 'R', 0);
     $this->_pdf->Cell(80, 6, $osC_Language->get('heading_products_name'), 'TB', 0, 'C', 0);
     $this->_pdf->Cell(37, 6, $osC_Language->get('heading_products_quantity'), 'TB', 0, 'C', 0);
     $this->_pdf->Cell(32, 6, $osC_Language->get('heading_products_price'), 'TB', 0, 'C', 0);
     $this->_pdf->Cell(32, 6, $osC_Language->get('heading_products_total'), 'TB', 0, 'C', 0);
     $this->_pdf->Ln();
     $i = 0;
     $y_table_position = TOC_PDF_POS_PRODUCTS_TABLE_CONTENT_Y;
     $osC_Currencies = new osC_Currencies();
     foreach ($this->_order->getProducts() as $index => $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 (strlen($products['name']) > 70) {
             $rowspan = 2;
         }
         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(80, 4, $product_info, 0, 'R');
         //Quantity
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(113);
         $this->_pdf->MultiCell(10, 4, $products['qty'], 0, 'C');
         //Price
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(143);
         $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, 'C');
         //Total
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(171);
         $total = $osC_Currencies->displayPriceWithTaxRate($products['final_price'], $products['tax'], $products['qty'], $this->_order->getCurrency(), $this->_order->getCurrencyValue());
         $total = str_replace(' ', ' ', $total);
         $this->_pdf->MultiCell(30, 4, $total, 0, 'C');
         $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, 'B', TOC_PDF_TABLE_HEADING_FONT_SIZE);
             $this->_pdf->SetY(TOC_PDF_POS_CONTENT_Y);
             $this->_pdf->Cell(10, 6, '', 'TB', 0, 'C', 0);
             $this->_pdf->Cell(80, 6, $osC_Language->get('heading_products_name'), 'TB', 0, 'C', 0);
             $this->_pdf->Cell(37, 6, $osC_Language->get('heading_products_quantity'), 'TB', 0, 'C', 0);
             $this->_pdf->Cell(32, 6, $osC_Language->get('heading_products_price'), 'TB', 0, 'C', 0);
             $this->_pdf->Cell(32, 6, $osC_Language->get('heading_products_total'), 'TB', 0, 'C', 0);
             $this->_pdf->Ln();
         }
         $i++;
     }
     $this->_pdf->SetY($y_table_position + 1);
     $this->_pdf->Cell(191, 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, 'B', TOC_PDF_TOTAL_FONT_SIZE);
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(40);
         $this->_pdf->MultiCell(120, 5, $totals['title'], 0, 'L');
         $total_text = str_replace(' ', ' ', $totals['value']);
         $total_text = $osC_Currencies->format($total_text, $this->_order->getCurrency(), $this->_order->getCurrencyValue());
         $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TOTAL_FONT_SIZE);
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(165);
         $this->_pdf->MultiCell(40, 5, strip_tags($total_text), 0, 'C');
     }
     if ($Qinvoices->value('invoice_number') > 0) {
         $this->_pdf->Output("Invoice.pdf", "I");
     } else {
         $this->_pdf->Output("Orders.pdf", "I");
     }
 }
Exemplo n.º 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 (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);
 }
Exemplo n.º 3
0
 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('credit_slip_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_credit_slip_id') . "\n" . $osC_Language->get('operation_heading_credit_slip_date') . "\n" . $osC_Language->get('operation_heading_order_id') . "\n" . $osC_Language->get('operation_heading_order_date'), 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->_credit_slip->getCreditSlipId() . "\n" . osC_DateTime::getShort($this->_credit_slip->getDateAdded()) . "\n" . $this->_credit_slip->getOrdersId() . "\n" . osC_DateTime::getShort($this->_credit_slip->getDatePurchased()), 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('heading_products_name'), 'TB', 0, 'C', 0);
     $this->_pdf->Cell(35, 6, $osC_Language->get('heading_products_quantity'), 'TB', 0, 'C', 0);
     $this->_pdf->Cell(30, 6, $osC_Language->get('heading_products_price'), 'TB', 0, 'R', 0);
     $this->_pdf->Cell(30, 6, $osC_Language->get('heading_products_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();
     foreach ($this->_credit_slip->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['qty'], 0, 'C');
         //Price
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(135);
         $price = $osC_Currencies->displayPriceWithTaxRate($products['final_price'], $products['tax'], 1, $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue());
         $price = str_replace('&nbsp;', ' ', $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['qty'], $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue());
         $total = str_replace('&nbsp;', ' ', $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('heading_products_name'), 'TB', 0, 'C', 0);
             $this->_pdf->Cell(35, 6, $osC_Language->get('heading_products_quantity'), 'TB', 0, 'C', 0);
             $this->_pdf->Cell(30, 6, $osC_Language->get('heading_products_price'), 'TB', 0, 'R', 0);
             $this->_pdf->Cell(30, 6, $osC_Language->get('heading_products_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);
     $y_table_position += 4;
     $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_TOTAL);
     $this->_pdf->SetY($y_table_position);
     $this->_pdf->SetX(40);
     $this->_pdf->MultiCell(120, 5, $osC_Language->get('refund_sub_total') . "\n" . $osC_Language->get('refund_shipping') . "\n" . $osC_Language->get('refund_handling') . "\n" . $osC_Language->get('refund_total') . "\n", 0, 'R');
     $this->_pdf->SetY($y_table_position);
     $this->_pdf->SetX(145);
     $this->_pdf->MultiCell(40, 5, $osC_Currencies->format($this->_credit_slip->getSubTotal(), $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue()) . "\n" . $osC_Currencies->format($this->_credit_slip->getShippingFee(), $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue()) . "\n" . $osC_Currencies->format($this->_credit_slip->getHandlingFee(), $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue()) . "\n" . $osC_Currencies->format($this->_credit_slip->getTotal(), $this->_credit_slip->getCurrency(), $this->_credit_slip->getCurrencyValue()), 0, 'R');
     $this->_pdf->Output("Order", "I");
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 function listOnlineCustomers()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     require_once 'includes/classes/currencies.php';
     $osC_Currencies = new osC_Currencies();
     require_once 'includes/classes/geoip.php';
     $osC_GeoIP = osC_GeoIP_Admin::load();
     if ($osC_GeoIP->isInstalled()) {
         $osC_GeoIP->activate();
     }
     $active_time = 300;
     $track_time = 900;
     osC_WhosOnline_Admin::removeExpiredEntries($track_time);
     $xx_mins_ago_active = time() - $active_time;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qwho = $osC_Database->query('select customer_id, full_name, ip_address, time_entry, time_last_click, session_id, referrer_url from :table_whos_online ');
     $Qwho->bindTable(':table_whos_online', TABLE_WHOS_ONLINE);
     if ($_REQUEST['customers_filter'] == 'customers') {
         $Qwho->appendQuery('where customer_id >= 1 ');
     } else {
         if ($_REQUEST['customers_filter'] == 'guests') {
             $Qwho->appendQuery('where customer_id = 0 ');
         } else {
             if ($_REQUEST['customers_filter'] == 'customers_guests') {
                 $Qwho->appendQuery('where customer_id >= 0 ');
             } else {
                 if ($_REQUEST['customers_filter'] == 'bots') {
                     $Qwho->appendQuery('where customer_id = -1 ');
                 }
             }
         }
     }
     $Qwho->appendQuery('order by time_last_click desc');
     $Qwho->setExtBatchLimit($start, $limit);
     $Qwho->execute();
     $record = array();
     while ($Qwho->next()) {
         $session_data = osC_WhosOnline_Admin::getSessionData($Qwho->value('session_id'));
         $navigation = unserialize(osc_get_serialized_variable($session_data, 'osC_NavigationHistory_data', 'array'));
         if (is_array($navigation)) {
             $last_page = end($navigation);
         }
         $currency = unserialize(osc_get_serialized_variable($session_data, 'currency', 'string'));
         $cart = unserialize(osc_get_serialized_variable($session_data, 'osC_ShoppingCart_data', 'array'));
         $status = '';
         if ($Qwho->value('customer_id') < 0) {
             if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                 $status = osc_icon('status_green.png', $osC_Language->get('text_status_inactive_bot'));
             } else {
                 $status = osc_icon('status_red.png', $osC_Language->get('text_status_active_bot'));
             }
         } else {
             if (is_array($cart['contents']) && sizeof($cart['contents']) > 0) {
                 if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                     $status = osc_icon('cart_red.png', $osC_Language->get('text_status_inactive_cart'));
                 } else {
                     $status = osc_icon('cart_green.png', $osC_Language->get('text_status_active_cart'));
                 }
             } else {
                 if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                     $status = osc_icon('people_red.png', $osC_Language->get('text_status_inactive_nocart'));
                 } else {
                     $status = osc_icon('people_green.png', $osC_Language->get('text_status_active_nocart'));
                 }
             }
         }
         $geoip = '';
         $iso_code_2 = $osC_GeoIP->getCountryISOCode2($Qwho->value('ip_address'));
         if ($osC_GeoIP->isActive() && $osC_GeoIP->isValid($Qwho->value('ip_address')) && !empty($iso_code_2)) {
             $geoip = osc_image('../images/worldflags/' . $iso_code_2 . '.png', $osC_GeoIP->getCountryName($Qwho->value('ip_address')) . ', ' . $Qwho->value('ip_address'), 18, 12) . '&nbsp;' . $Qwho->value('ip_address');
         } else {
             $geoip = $Qwho->value('ip_address');
         }
         $customers_info = '<table width="100%">';
         $customers_info .= '<tr><td width="120"><b>' . $osC_Language->get('field_session_id') . '</b></td><td>' . $Qwho->value('session_id') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_customer_name') . '</b></td><td>' . $Qwho->value('full_name') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_ip_address') . '</b></td><td>' . $Qwho->value('ip_address') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_entry_time') . '</b></td><td>' . date('H:i:s', $Qwho->value('time_entry')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_last_click') . '</b></td><td>' . date('H:i:s', $Qwho->value('time_last_click')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_time_online') . '</b></td><td>' . gmdate('H:i:s', time() - $Qwho->value('time_entry')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_referrer_url') . '</b></td><td>' . $Qwho->value('referrer_url') . '</td></tr>';
         $customers_info .= '</table>';
         $products_table = '<table width="100%">';
         foreach ($cart['contents'] 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['gc_data']['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['gc_data']['senders_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['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['gc_data']['recipients_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('messages') . ': ' . $product['gc_data']['message'] . '</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, $currency) . '</td></tr>';
         }
         $products_table .= '</table>';
         $customers_name = $Qwho->value('full_name') . ' (' . $Qwho->valueInt('customer_id') . ')';
         $customers_name .= ' -- ' . ($geoip === $_SERVER['REMOTE_ADDR'] ? $osC_Language->get('text_administrator') : '');
         $record[] = array('session_id' => $Qwho->value('session_id'), 'status' => $status, 'geoip' => $geoip, 'online_time' => gmdate('H:i:s', time() - $Qwho->value('time_entry')), 'last_url' => $last_page['page'], 'custormers_name' => $customers_name, 'customers_info' => $customers_info, 'products' => $products_table, 'total' => $osC_Currencies->format($cart['total_cost'], true, $currency));
     }
     if ($osC_GeoIP->isActive()) {
         $osC_GeoIP->deactivate();
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qwho->getBatchSize(), EXT_JSON_READER_ROOT => $record);
     echo $toC_Json->encode($response);
 }