Exemplo n.º 1
0
 function listPolls()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qpolls = $osC_Database->query('select p.polls_id, p.polls_type, p.polls_status, p.votes_count, p.date_added, pd.polls_title from :table_polls p left join :table_polls_description pd on (p.polls_id = pd.polls_id and pd.languages_id = :languages_id)');
     $Qpolls->bindTable(':table_polls', TABLE_POLLS);
     $Qpolls->bindTable(':table_polls_description', TABLE_POLLS_DESCRIPTION);
     $Qpolls->bindInt(':languages_id', $osC_Language->getID());
     if (isset($_REQUEST['search']) && !empty($_REQUEST['search'])) {
         $Qpolls->appendQuery('where pd.polls_title like :polls_title');
         $Qpolls->bindValue(':polls_title', '%' . $_REQUEST['search'] . '%');
     }
     $Qpolls->appendQuery('order by pd.polls_title');
     $Qpolls->setExtBatchLimit($start, $limit);
     $Qpolls->execute();
     $records = array();
     while ($Qpolls->next()) {
         $polls_info = '<table width="100%" CELLSPACING="5" style="margin-left: 50px">' . '<tbody>' . '<tr>
             <td width="120">' . $osC_Language->get('field_polls_type') . '</td>
             <td>' . ($Qpolls->valueInt('polls_type') == '0' ? $osC_Language->get('field_polls_single_choice') : $osC_Language->get('field_polls_multiple_choice')) . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_polls_number_of_responses') . '</td>
             <td>' . $Qpolls->value('votes_count') . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_polls_date_created') . '</td>
             <td>' . osC_DateTime::getShort($Qpolls->value('date_added')) . '</td>
           </tr>' . '</tbody>' . '</table>';
         $records[] = array('polls_id' => $Qpolls->valueInt('polls_id'), 'polls_title' => $Qpolls->value('polls_title'), 'polls_status' => $Qpolls->valueInt('polls_status'), 'polls_info' => $polls_info);
     }
     $Qpolls->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => $Qpolls->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 2
0
 function buildMessage()
 {
     global $osC_Database, $osC_Language, $osC_Currencies;
     $Qorder = $osC_Database->query('select * from :table_orders where orders_id = :orders_id limit 1');
     $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     $Qorder->bindInt(':orders_id', $this->_order_id);
     $Qorder->execute();
     if ($Qorder->numberOfRows() === 1) {
         $order_number = $this->_order_id;
         $date_ordered = osC_DateTime::getShort();
         $payment_method = $Qorder->value('payment_method');
         $customer_name = $Qorder->value('billing_name');
         $customer_phone = $Qorder->value('billing_telephone');
         $Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
         $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qstatus->bindInt(':orders_status_id', $Qorder->valueInt('orders_status'));
         $Qstatus->bindInt(':language_id', $osC_Language->getID());
         $Qstatus->execute();
         $order_status = $Qstatus->value('orders_status_name');
         unset($Qstatus);
         $replaces = array($order_number, $date_ordered, $payment_method, $customer_name, $order_status, STORE_NAME);
         $this->_sms_text = str_replace($this->_keywords, $replaces, $this->_content);
         $this->addRecipient($customer_phone);
     }
     unset($Qorder);
 }
Exemplo n.º 3
0
 function listPurchasedDownloadables()
 {
     global $osC_Database, $toC_Json, $osC_Language, $osC_Currencies;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qdownloadables = $osC_Database->query('select opd.orders_products_download_id, op.products_name, opd.orders_products_filename, o.customers_name, o.date_purchased, opd.status from :table_orders o, :table_orders_products op, :table_orders_products_download opd where o.orders_id =  op.orders_id and op.orders_products_id = opd.orders_products_id ');
     if (!empty($_REQUEST['search'])) {
         $Qdownloadables->appendQuery('and o.customers_name like :customers_name');
         $Qdownloadables->bindValue(':customers_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qdownloadables->bindTable(':table_orders', TABLE_ORDERS);
     $Qdownloadables->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
     $Qdownloadables->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
     $Qdownloadables->setExtBatchLimit($start, $limit);
     $Qdownloadables->execute();
     $records = array();
     while ($Qdownloadables->next()) {
         $Qhistory = $osC_Database->query('select * from :table_products_download_history where orders_products_download_id = :orders_products_download_id');
         $Qhistory->bindTable(':table_products_download_history', TABLE_PRODUCTS_DOWNLOAD_HISTORY);
         $Qhistory->bindInt(':orders_products_download_id', $Qdownloadables->ValueInt('orders_products_download_id'));
         $Qhistory->execute();
         $total_downloads = 0;
         $history = '<table style="padding-left: 20px;" cellspacing="5">
                  <tr><td>' . $osC_Language->get('table_heading_download_date') . '</td></tr>';
         while ($Qhistory->next()) {
             $history .= '<tr><td>' . osC_DateTime::getShort($Qhistory->Value('download_date')) . '</td></tr>';
             $total_downloads++;
         }
         $history .= '</table>';
         $Qhistory->freeResult();
         $records[] = array('orders_products_download_id' => $Qdownloadables->ValueInt('orders_products_download_id'), 'products_name' => $Qdownloadables->Value('products_name'), 'file_name' => $Qdownloadables->Value('orders_products_filename'), 'customer' => $Qdownloadables->Value('customers_name'), 'date_purchased' => osC_DateTime::getShort($Qdownloadables->Value('date_purchased'), true), 'total_downloads' => $total_downloads, 'status' => $Qdownloadables->Value('status'), 'history' => $history);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qdownloadables->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 4
0
 function listCache()
 {
     global $toC_Json;
     $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_WORK);
     $osC_DirectoryListing->setIncludeDirectories(false);
     $osC_DirectoryListing->setCheckExtension('cache');
     $response = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $last_modified = filemtime(DIR_FS_WORK . '/' . $file['name']);
         if (strpos($file['name'], '-') !== false) {
             $code = substr($file['name'], 0, strpos($file['name'], '-'));
         } else {
             $code = substr($file['name'], 0, strpos($file['name'], '.'));
         }
         if (isset($cached_files[$code])) {
             $cached_files[$code]['total']++;
             if ($last_modified > $cached_files[$code]['last_modified']) {
                 $cached_files[$code]['last_modified'] = $last_modified;
             }
         } else {
             $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified);
         }
         $response[] = array('code' => $code, 'total' => $cached_files[$code]['total'], 'last_modified' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($cached_files[$code]['last_modified']), true));
     }
     $response = array(EXT_JSON_READER_ROOT => $response);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 5
0
 function listAbandonedCart()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $osC_Currencies = new osC_Currencies();
     $customers_id = osc_get_session_customers_id();
     $Qcustomers = $osC_Database->query("select SQL_CALC_FOUND_ROWS DISTINCT cb.customers_id, cb.products_id, cb.customers_basket_quantity, max(cb.customers_basket_date_added) date_added, c.customers_firstname, c.customers_lastname, c.customers_telephone phone, c.customers_email_address email, c.abandoned_cart_last_contact_date date_contacted from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_CUSTOMERS . " c where c.customers_id not in ('" . implode(',', $customers_id) . "') and cb.customers_id = c.customers_id  group by cb.customers_id order by cb.customers_id, cb.customers_basket_date_added desc ");
     $Qcustomers->setExtBatchLimit($start, $limit);
     $Qcustomers->execute();
     $records = array();
     while ($Qcustomers->next()) {
         $action = array();
         $action[] = array('class' => 'icon-send-email-record', 'qtip' => $osC_Language->get('icon_email_send'));
         $action[] = array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash'));
         $cart_contents = toC_Abandoned_Cart_Admin::getCartContents($Qcustomers->valueInt('customers_id'));
         $total = 0;
         $products = array();
         foreach ($cart_contents as $product) {
             $total += $product['price'] * $product['qty'];
             $products[] = $product['qty'] . '&nbsp;x&nbsp;' . $product['name'];
         }
         $date_contacted = $Qcustomers->value('date_contacted');
         $records[] = array('customers_id' => $Qcustomers->valueInt('customers_id'), 'products' => implode('<br />', $products), 'date_contacted' => empty($date_contacted) ? '---' : osC_DateTime::getShort($date_contacted), 'date_added' => osC_DateTime::getShort($Qcustomers->value('date_added')), 'customers_name' => $Qcustomers->value('customers_firstname') . '&nbsp;' . $Qcustomers->value('customers_lastname'), 'email' => $Qcustomers->value('email'), 'action' => $action, 'total' => $osC_Currencies->format($total));
     }
     $Qcustomers->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 6
0
 function listDirectory()
 {
     global $osC_Language, $toC_Json, $osC_MessageStack;
     $directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH;
     if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) {
         $directory .= '/' . urldecode($_REQUEST['directory']);
     } elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) {
         $directory .= '/' . urldecode($_REQUEST['goto']);
     }
     $osC_DirectoryListing = new osC_DirectoryListing($directory);
     $osC_DirectoryListing->setStats(true);
     $records = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-';
         $group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-';
         if ($file['is_directory'] === true) {
             $entry_icon = osc_icon('folder_red.png');
             $action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         } else {
             $entry_icon = osc_icon('file.png');
             $action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         }
         $records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
 function listAdministratorsLog()
 {
     global $toC_Json, $osC_Database;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qlog = $osC_Database->query('select SQL_CALC_FOUND_ROWS count(al.id) as total, al.id, al.module, al.module_action, al.module_id, al.action, a.user_name, unix_timestamp(al.datestamp) as datestamp from :table_administrators_log al, :table_administrators a where');
     if (!empty($_REQUEST['fm']) && in_array($_REQUEST['fm'], $_SESSION['admin']['access'])) {
         $Qlog->appendQuery('al.module = :module');
         $Qlog->bindValue(':module', $_REQUEST['fm']);
     } else {
         $Qlog->appendQuery('al.module in (":modules")');
         $Qlog->bindRaw(':modules', implode('", "', $_SESSION['admin']['access']));
     }
     $Qlog->appendQuery('and');
     if (is_numeric($_REQUEST['fu']) && !empty($_REQUEST['fu'])) {
         $Qlog->appendQuery('al.administrators_id = :administrators_id and');
         $Qlog->bindInt(':administrators_id', $_REQUEST['fu']);
     }
     $Qlog->appendQuery('al.administrators_id = a.id group by al.id order by al.id desc');
     $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
     $Qlog->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
     $Qlog->setExtBatchLimit($start, $limit);
     $Qlog->execute();
     $records = array();
     while ($Qlog->next()) {
         $records[] = array('administrators_log_id' => $Qlog->valueInt('id'), 'administrators_id' => $Qlog->valueInt('administrators_id'), 'module' => $Qlog->value('module') . ' (' . $Qlog->valueInt('total') . ')', 'module_id' => $Qlog->valueInt('module_id'), 'module_action' => $Qlog->valueProtected('module_action'), 'user_name' => $Qlog->valueProtected('user_name'), 'date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($Qlog->value('datestamp')), true), 'logo_info_title' => osc_icon('info.png') . ' ' . $Qlog->valueProtected('user_name') . ' &raquo; ' . $Qlog->valueProtected('module_action') . ' &raquo; ' . $Qlog->value('module') . ' &raquo; ' . $Qlog->valueInt('module_id'));
     }
     $Qlog->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => $Qlog->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 8
0
 function listBestOrders()
 {
     global $osC_Database, $toC_Json;
     $Qorders = $osC_Database->query('select o.orders_id, o.customers_id, o.customers_name, ot.value, o.date_purchased from :table_orders o, :table_orders_total ot where o.orders_id = ot.orders_id and ot.class = :class ');
     if (!empty($_REQUEST['start_date'])) {
         $Qorders->appendQuery('and o.date_purchased >= :start_date ');
         $Qorders->bindValue(':start_date', $_REQUEST['start_date']);
     }
     if (!empty($_REQUEST['end_date'])) {
         $Qorders->appendQuery('and o.date_purchased <= :end_date ');
         $Qorders->bindValue(':end_date', $_REQUEST['end_date']);
     }
     $Qorders->appendQuery(' order by value desc');
     $Qorders->bindTable(':table_orders', TABLE_ORDERS);
     $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
     $Qorders->bindValue(':class', 'total');
     $Qorders->setExtBatchLimit($start, MAX_DISPLAY_SEARCH_RESULTS);
     $Qorders->execute();
     $records = array();
     while ($Qorders->next()) {
         $records[] = array('orders_id' => $Qorders->ValueInt('orders_id'), 'customers_id' => $Qorders->ValueInt('customers_id'), 'customers_name' => osc_icon('orders.png') . '&nbsp;' . $Qorders->Value('customers_name'), 'date_purchased' => osC_DateTime::getShort($Qorders->value('date_purchased'), true), 'value' => (double) $Qorders->Value('value'));
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qorders->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 9
0
 function loadReviews()
 {
     global $toC_Json;
     $data = osC_Reviews_Admin::getData($_REQUEST['reviews_id']);
     $data['date_added'] = osC_DateTime::getShort($data['date_added']);
     $response = array('success' => true, 'data' => $data);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 10
0
/**
 * Retrieve web server and database server information
 *
 * @access public
 */
function osc_get_system_information()
{
    global $osC_Database;
    $Qdb_date = $osC_Database->query('select now() as datetime');
    $Qdb_uptime = $osC_Database->query('show status like "Uptime"');
    @(list($system, $host, $kernel) = preg_split('/[\\s,]+/', @exec('uname -a'), 5));
    $db_uptime = intval($Qdb_uptime->valueInt('Value') / 3600) . ':' . str_pad(intval($Qdb_uptime->valueInt('Value') / 60 % 60), 2, '0', STR_PAD_LEFT);
    return array('date' => osC_DateTime::getShort(null, true), 'system' => $system, 'kernel' => $kernel, 'host' => $host, 'ip' => gethostbyname($host), 'uptime' => @exec('uptime'), 'http_server' => $_SERVER['SERVER_SOFTWARE'], 'php' => PHP_VERSION, 'zend' => function_exists('zend_version') ? zend_version() : '', 'db_server' => DB_SERVER, 'db_ip' => gethostbyname(DB_SERVER), 'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''), 'db_date' => osC_DateTime::getShort($Qdb_date->value('datetime'), true), 'db_uptime' => $db_uptime);
}
Exemplo n.º 11
0
 function listGiftCertificates()
 {
     global $osC_Database, $toC_Json, $osC_Language, $osC_Currencies;
     $osC_Currencies = new osC_Currencies_Admin();
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qcertificates = $osC_Database->query('select gc.*, o.customers_name, o.date_purchased from :table_gift_certificates gc, :table_orders o, :table_orders_products op where gc.orders_products_id = op.orders_products_id and op.orders_id = o.orders_id ');
     if (!empty($_REQUEST['search'])) {
         $Qcertificates->appendQuery('and o.customers_name like :customers_name');
         $Qcertificates->bindValue(':customers_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qcertificates->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES);
     $Qcertificates->bindTable(':table_orders', TABLE_ORDERS);
     $Qcertificates->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
     $Qcertificates->setExtBatchLimit($start, $limit);
     $Qcertificates->execute();
     $records = array();
     while ($Qcertificates->next()) {
         $Qhistory = $osC_Database->query('select gcrh.*, o.customers_name from :table_gift_certificates_redeem_history gcrh, :table_orders o where gcrh.orders_id = o.orders_id and gcrh.gift_certificates_id = :gift_certificates_id');
         $Qhistory->bindTable(':table_gift_certificates_redeem_history', TABLE_GIFT_CERTIFICATES_REDEEM_HISTORY);
         $Qhistory->bindTable(':table_orders', TABLE_ORDERS);
         $Qhistory->bindInt(':gift_certificates_id', $Qcertificates->ValueInt('gift_certificates_id'));
         $Qhistory->execute();
         $history = '<table style="padding-left: 20px;" cellspacing="5">
                  <tr>
                    <td>' . $osC_Language->get('table_heading_customer') . '</td>
                    <td>' . $osC_Language->get('table_heading_redeem_date') . '</td>
                    <td>' . $osC_Language->get('table_heading_redeem_amount') . '</td>
                  </tr>';
         $redeem_amount = 0;
         while ($Qhistory->next()) {
             $redeem_amount += $Qhistory->Value('redeem_amount');
             $history .= '<tr><td>' . $Qhistory->Value('customers_name') . '</td>
                        <td>' . osC_DateTime::getShort($Qhistory->Value('redeem_date')) . '</td>
                        <td>' . $osC_Currencies->format($Qhistory->Value('redeem_amount')) . '</td></tr>';
         }
         $history .= '</table>';
         $Qhistory->freeResult();
         $certificate_details = '<table style="padding-left: 20px" cellspacing="5">';
         $certificate_details .= '<tr><td>' . $osC_Language->get('field_recipient_name') . '</td><td>' . $Qcertificates->Value('recipients_name') . '</td></tr>';
         if ($Qcertificates->valueInt('gift_certificates_type') == GIFT_CERTIFICATE_TYPE_EMAIL) {
             $certificate_details .= '<tr><td>' . $osC_Language->get('field_recipient_email') . '</td><td>' . $Qcertificates->Value('recipients_email') . '</td></tr>';
         }
         $certificate_details .= '<tr><td>' . $osC_Language->get('field_recipient_sender_name') . '</td><td>' . $Qcertificates->Value('senders_name') . '</td></tr>';
         if ($Qcertificates->valueInt('gift_certificates_type') == GIFT_CERTIFICATE_TYPE_EMAIL) {
             $certificate_details .= '<tr><td>' . $osC_Language->get('field_recipient_sender_email') . '</td><td>' . $Qcertificates->Value('senders_email') . '</td></tr>';
         }
         $certificate_details .= '<tr><td>' . $osC_Language->get('field_message') . '</td><td>' . $Qcertificates->Value('messages') . '</td></tr>';
         $certificate_details .= '</table>';
         $records[] = array('gift_certificates_id' => $Qcertificates->ValueInt('gift_certificates_id'), 'orders_products_id' => $Qcertificates->ValueInt('orders_products_id'), 'gift_certificates_code' => $Qcertificates->Value('gift_certificates_code'), 'gift_certificates_customer' => $Qcertificates->Value('customers_name'), 'gift_certificates_amount' => $osC_Currencies->format($Qcertificates->Value('amount')), 'gift_certificates_balance' => $osC_Currencies->format($Qcertificates->Value('amount') - $redeem_amount), 'gift_certificates_date_purchased' => osC_DateTime::getShort($Qcertificates->Value('date_purchased')), 'gift_certificates_date_status' => $Qcertificates->Value('status'), 'recipients_name' => $Qcertificates->Value('recipients_name'), 'recipients_email' => $Qcertificates->Value('recipients_email'), 'senders_name' => $Qcertificates->Value('senders_name'), 'senders_email' => $Qcertificates->Value('senders_email'), 'messages' => $Qcertificates->Value('messages'), 'certificate_details' => $certificate_details, 'history' => $history);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qcertificates->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 12
0
 function renderData()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $Qreviews = $osC_Database->query('select r.reviews_id, r.products_id, greatest(r.date_added, ifnull(r.last_modified, 0)) as date_last_modified, r.reviews_rating, pd.products_name, l.name as languages_name, l.code as languages_code from :table_reviews r left join :table_products_description pd on (r.products_id = pd.products_id and r.languages_id = pd.language_id), :table_languages l where r.languages_id = l.languages_id order by date_last_modified desc limit 6');
     $Qreviews->bindTable(':table_reviews', TABLE_REVIEWS);
     $Qreviews->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qreviews->bindTable(':table_languages', TABLE_LANGUAGES);
     $Qreviews->execute();
     $records = array();
     while ($Qreviews->next()) {
         $records[] = array('reviews_id' => $Qreviews->valueInt('reviews_id'), 'products_name' => $Qreviews->value('products_name'), 'languages_code' => $osC_Language->showImage($Qreviews->value('languages_code')), 'reviews_rating' => osc_image('../images/stars_' . $Qreviews->valueInt('reviews_rating') . '.png', $Qreviews->valueInt('reviews_rating') . '/5'), 'date_last_modified' => osC_DateTime::getShort($Qreviews->value('date_last_modified')));
     }
     $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 13
0
 function renderData()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $Qorders = $osC_Database->query('select o.orders_id, o.customers_name, greatest(o.date_purchased, ifnull(o.last_modified, 0)) as date_last_modified, 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 order by date_last_modified desc limit 4');
     $Qorders->bindTable(':table_orders', TABLE_ORDERS);
     $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
     $Qorders->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
     $Qorders->bindInt(':language_id', $osC_Language->getID());
     $Qorders->execute();
     $records = array();
     while ($Qorders->next()) {
         $records[] = array('orders_id' => $Qorders->valueInt('orders_id'), 'customers_name' => $Qorders->valueProtected('customers_name'), 'order_total' => strip_tags($Qorders->value('order_total')), 'date_purchased' => osC_DateTime::getShort($Qorders->value('date_last_modified')), 'orders_status_name' => $Qorders->value('orders_status_name'));
     }
     $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 14
0
 function setData($data)
 {
     global $osC_Currencies;
     $x_labels = array();
     foreach ($data as $date => $order_total) {
         $this->_bar->add($order_total);
         $x_labels[] = osC_DateTime::getShort($date);
     }
     $this->_graph->set_x_labels($x_labels);
     if (!is_object($osC_Currencies)) {
         $osC_Currencies = new osC_Currencies();
     }
     $this->_graph->set_tool_tip(' #x_label# <br>' . $osC_Currencies->getSymbolLeft() . ' #val#');
     $max_total = (int) (floor(max($this->_bar->data) / 100 + 1) * 100);
     $this->_graph->set_y_min(0);
     $this->_graph->set_y_max($max_total);
     $this->_graph->data_sets[] = $this->_bar;
 }
 function listProductsExpected()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qproducts = $osC_Database->query('select p.products_id, p.products_date_available, pd.products_name from :table_products p, :table_products_description pd where p.products_date_available is not null and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_available');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $record = array();
     while ($Qproducts->next()) {
         $record[] = array('products_id' => $Qproducts->valueInt('products_id'), 'products_name' => $Qproducts->value('products_name'), 'products_date_available' => osC_DateTime::getShort($Qproducts->value('products_date_available')));
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $record);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 16
0
 function renderData()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $Qcustomers = $osC_Database->query('select customers_id, customers_gender, customers_lastname, customers_firstname, customers_status, date_account_created from :table_customers order by date_account_created desc limit 6');
     $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcustomers->execute();
     $records = array();
     while ($Qcustomers->next()) {
         $customer_icon = osc_icon('people.png');
         if (ACCOUNT_GENDER > -1) {
             switch ($Qcustomers->value('customers_gender')) {
                 case 'm':
                     $customer_icon = osc_icon('user_male.png');
                     break;
                 case 'f':
                     $customer_icon = osc_icon('user_female.png');
                     break;
             }
         }
         $records[] = array('customers_name' => $customer_icon . '&nbsp;' . $Qcustomers->valueProtected('customers_firstname') . ' ' . $Qcustomers->valueProtected('customers_lastname'), 'date_account_created' => osC_DateTime::getShort($Qcustomers->value('date_account_created')), 'customers_status' => osc_icon($Qcustomers->valueInt('customers_status') === 1 ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'));
     }
     $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 17
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('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('&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['quantity'], $this->_order->getCurrency(), $this->_order->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('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");
 }
Exemplo n.º 18
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('&nbsp;', ' ', $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('&nbsp;', ' ', $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('&nbsp;', ' ', $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.º 19
0
 function add($products_id, $variants = array())
 {
     global $osC_Database, $osC_Services, $osC_Customer, $osC_Product;
     //if wishlist empty, create a new wishlist
     if (!$this->hasWishlistID()) {
         $token = $this->generateToken();
         $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)');
         $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS);
         $Qnew->bindInt(':customers_id', $osC_Customer->getID());
         $Qnew->bindValue(':wishlists_token', $token);
         $Qnew->execute();
         $this->_wishlists_id = $osC_Database->nextID();
         $this->_token = $token;
         $Qnew->freeResult();
     }
     if (!isset($osC_Product)) {
         $osC_Product = new osC_Product($products_id);
     }
     if ($osC_Product->getID() > 0) {
         if (!$this->exists($products_id)) {
             $product_price = $osC_Product->getPrice();
             $product_name = $osC_Product->getTitle();
             $product_image = $osC_Product->getImage();
             if ($osC_Services->isStarted('specials')) {
                 global $osC_Specials;
                 if ($new_price = $osC_Specials->getPrice($products_id)) {
                     $price = $new_price;
                 }
             }
             //if the product has variants, set the image, price etc according to the variants
             if ($osC_Product->hasVariants()) {
                 $products_variants = $osC_Product->getVariants();
                 if (is_array($variants) && !osc_empty($variants)) {
                     $product_id_string = osc_get_product_id_string($products_id, $variants);
                     $products_variant = $products_variants[$product_id_string];
                 } else {
                     $products_variant = $osC_Product->getDefaultVariant();
                 }
                 $variants_groups_id = $products_variant['groups_id'];
                 $variants_groups_name = $products_variant['groups_name'];
                 if (!osc_empty($variants_groups_name)) {
                     $product_name .= '<br />';
                     foreach ($variants_groups_name as $group_name => $value_name) {
                         $product_name .= '<em>' . $group_name . ': ' . $value_name . '</em>' . '<br />';
                     }
                 }
                 $product_price = $products_variant['price'];
                 $product_image = $products_variant['image'];
             }
             $this->_contents[$products_id] = array('products_id' => $products_id, 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'variants' => $variants, 'comments' => '');
             //insert into wishlist products
             $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id, date_added, comments) values (:wishlists_id, :products_id, now(), :comments)');
             $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS);
             $Qnew->bindInt(':wishlists_id', $this->_wishlists_id);
             $Qnew->bindInt(':products_id', $products_id);
             $Qnew->bindValue(':comments', '');
             $Qnew->execute();
             $wishlists_products_id = $osC_Database->nextID();
             $Qnew->freeResult();
             //if the wishlists products has variants
             $products_variants_groups_id = array();
             $products_variants_groups_name = array();
             if (isset($variants_groups_id) && isset($variants_groups_name)) {
                 foreach ($variants_groups_id as $groups_id => $values_id) {
                     $products_variants_groups_id[] = array('groups_id' => $groups_id, 'values_id' => $values_id);
                 }
                 foreach ($variants_groups_name as $groups_name => $values_name) {
                     $products_variants_groups_name[] = array('groups_name' => $groups_name, 'values_name' => $values_name);
                 }
             }
             if (!osc_empty($products_variants_groups_id)) {
                 foreach ($products_variants_groups_id as $key => $groups_id) {
                     $Qinsert = $osC_Database->query('insert into :table_wishlists_products_variants (wishlists_id, wishlists_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:wishlists_id, :wishlists_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values)');
                     $Qinsert->bindTable(':table_wishlists_products_variants', TABLE_WISHLISTS_PRODUCTS_VARIANTS);
                     $Qinsert->bindInt(':wishlists_id', $this->_wishlists_id);
                     $Qinsert->bindInt(':wishlists_products_id', $wishlists_products_id);
                     $Qinsert->bindInt(':products_variants_groups_id', $groups_id['groups_id']);
                     $Qinsert->bindInt(':products_variants_values_id', $groups_id['values_id']);
                     $Qinsert->bindValue(':products_variants_groups', $products_variants_groups_name[$key]['groups_name']);
                     $Qinsert->bindValue(':products_variants_values', $products_variants_groups_name[$key]['values_name']);
                     $Qinsert->execute();
                 }
             }
         }
     }
 }
Exemplo n.º 20
0
 function getOrdersReturns()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $osC_Order = new osC_Order($Qreturns->valueInt('orders_id'));
     $Qreturns = $osC_Database->query('select r.orders_returns_id, r.orders_id, r.orders_returns_status_id, r.customers_comments, r.date_added, o.customers_name, ors.orders_returns_status_name from :table_orders o, :table_orders_returns r, :table_orders_returns_status ors where r.orders_id = o.orders_id and r.orders_returns_status_id = ors.orders_returns_status_id and r.orders_id = :orders_id and ors.languages_id = :languages_id');
     $Qreturns->bindTable(':table_orders', TABLE_ORDERS);
     $Qreturns->bindTable(':table_orders_returns', TABLE_ORDERS_RETURNS);
     $Qreturns->bindTable(':table_orders_returns_status', TABLE_ORDERS_RETURNS_STATUS);
     $Qreturns->bindInt(':orders_id', $_REQUEST['orders_id']);
     $Qreturns->bindInt(':languages_id', $osC_Language->getID());
     $Qreturns->execute();
     $records = array();
     while ($Qreturns->next()) {
         $orders_returns_id = $Qreturns->value('orders_returns_id');
         $Qproducts = $osC_Database->query("select orders_products_id, products_quantity from :table_orders_returns_products where orders_returns_id = :orders_returns_id");
         $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
         $Qproducts->bindTable(':table_orders_returns_products', TABLE_ORDERS_RETURNS_PRODUCTS);
         $Qproducts->bindInt(':orders_returns_id', $orders_returns_id);
         $Qproducts->execute();
         $return_products_ids = array();
         $return_products_qty = array();
         while ($Qproducts->next()) {
             $return_products_ids[] = $Qproducts->valueInt('orders_products_id');
             $return_products_qty[$Qproducts->valueInt('orders_products_id')] = $Qproducts->valueInt('products_quantity');
         }
         $total = 0;
         $quantity = 0;
         $products = array();
         foreach ($osC_Order->getProducts() as $product) {
             if (in_array($product['orders_products_id'], $return_products_ids)) {
                 $product_info = $return_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;
                 $total += $return_products_qty[$product['orders_products_id']] * $product['final_price'];
                 $quantity += $return_products_qty[$product['orders_products_id']];
             }
         }
         $records[] = array('orders_returns_id' => $orders_returns_id, 'orders_id' => $Qreturns->valueInt('orders_id'), 'orders_returns_customer' => $Qreturns->value('customers_name'), 'quantity' => $quantity, 'date_added' => osC_DateTime::getShort($Qreturns->value('date_added')), 'status' => $Qreturns->value('orders_returns_status_name'), 'status_id' => $orders_returns_status_id, 'products' => implode('<br />', $products), 'admin_comments' => $Qreturns->value('admin_comments'), 'customers_comments' => $Qreturns->value('customers_comments'), 'total' => $total);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qreturns->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
    ?>

<div class="moduleBox">
    <h6><?php 
    echo $osC_Language->get('order_history_heading');
    ?>
</h6>
    
    <div class="content">
    	<table border="0" width="100%" cellspacing="0" cellpadding="2">
            <?php 
    while ($Qstatus->next()) {
        ?>
            <tr>
                <td valign="top" width="70"><?php 
        echo osC_DateTime::getShort($Qstatus->value('date_added'));
        ?>
</td>
                <td valign="top" width="200"><?php 
        echo $Qstatus->value('orders_status_name');
        ?>
</td>
                <td valign="top"><?php 
        echo !osc_empty($Qstatus->valueProtected('comments')) ? nl2br($Qstatus->valueProtected('comments')) : '&nbsp;';
        ?>
</td>
            </tr>
            <?php 
    }
    ?>
    	</table>
 function listLog()
 {
     global $toC_Json, $osC_Database;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qlog = $osC_Database->query('select email_address, date_sent from :table_newsletters_log where newsletters_id = :newsletters_id order by date_sent desc');
     $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
     $Qlog->bindInt(':newsletters_id', $_REQUEST['newsletters_id']);
     $Qlog->setExtBatchLimit($start, $limit);
     $Qlog->execute();
     $records = array();
     while ($Qlog->next()) {
         $records[] = array('email_address' => $Qlog->valueProtected('email_address'), 'sent' => osc_icon(!osc_empty($Qlog->value('date_sent')) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif', null, null), 'date_sent' => osC_DateTime::getShort($Qlog->value('date_sent'), true));
     }
     $Qlog->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => $Qlog->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 23
0
      <td onclick="document.getElementById('batch<?php 
    echo $cache;
    ?>
').checked = !document.getElementById('batch<?php 
    echo $cache;
    ?>
').checked;"><?php 
    echo $cache;
    ?>
</td>
      <td align="center"><?php 
    echo $stats['total'];
    ?>
</td>
      <td align="right"><?php 
    echo osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($stats['last_modified']), true);
    ?>
</td>
      <td align="right"><?php 
    echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&block=' . $cache . '&action=delete'), osc_icon('trash.png'));
    ?>
</td>
      <td align="center"><?php 
    echo osc_draw_checkbox_field('batch[]', $cache, null, 'id="batch' . $cache . '"');
    ?>
</td>
    </tr>

<?php 
}
?>
Exemplo n.º 24
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('return_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_return_id') . "\n" . $osC_Language->get('operation_heading_return_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->_order_return->getOrdersReturnsId() . "\n" . osC_DateTime::getShort($this->_order_return->getReturnDate()) . "\n" . $this->_order_return->getOrdersId() . "\n" . osC_DateTime::getShort($this->_order_return->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 + $pos);
     $this->_pdf->Cell(12, 6, '', 'TB', 0, 'R', 0);
     $this->_pdf->Cell(140, 6, $osC_Language->get('heading_products_name'), 'TB', 0, 'L', 0);
     $this->_pdf->Cell(24, 6, $osC_Language->get('heading_products_quantity'), 'TB', 0, 'L', 0);
     $this->_pdf->Ln();
     $i = 0;
     $y_table_position = TOC_PDF_POS_PRODUCTS_TABLE_CONTENT_Y + $pos;
     foreach ($this->_order_return->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(12, 4, $i + 1, 0, 'C');
         //Product
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(24);
         $product_info = $products['name'];
         if (strlen($products['name']) > 60) {
             $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++;
             }
             $product_info .= "\n" . '   -' . $osC_Language->get('messages') . ': ' . $products['messages'];
             $rowspan += 3;
         }
         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(120, 4, $product_info, 0, 'L');
         //Quantity
         $this->_pdf->SetY($y_table_position);
         $this->_pdf->SetX(164);
         $this->_pdf->MultiCell(5, 4, $products['qty'], 0, 'C');
         $y_table_position += $rowspan * TOC_PDF_TABLE_CONTENT_HEIGHT;
         $i++;
     }
     $this->_pdf->SetY($y_table_position + 1);
     $this->_pdf->Cell(175, 7, '', 'T', 0, 'C', 0);
     //Comments:
     $this->_pdf->ln();
     $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->Cell(55, 4, $osC_Language->get('operation_heading_comments'), 0, 'L');
     $this->_pdf->ln();
     $this->_pdf->SetFont(TOC_PDF_FONT, '', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->MultiCell(175, 4, $this->_order_return->getComment(), 0, 'L');
     $this->_pdf->ln(10);
     $this->_pdf->SetFont(TOC_PDF_FONT, 'B', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->MultiCell(175, 4, $osC_Language->get('operation_heading_reminder'), '', 'L');
     $this->_pdf->ln();
     $this->_pdf->SetFont(TOC_PDF_FONT, '', TOC_PDF_FIELD_DATE_PURCHASE_FONT_SIZE);
     $this->_pdf->MultiCell(175, 4, str_replace('<br />', "\n", $osC_Language->get('return_slip_reminder')), 'LTRB', 'L');
     $this->_pdf->Output("Return Slip", "I");
 }
 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);
 }
Exemplo n.º 26
0
 function getDateOrTime($date)
 {
     $day_start = mktime(0, 0, 0);
     $day_end = mktime(0, 0, 0, date('m'), date('d') + 1);
     if ($date > $day_start && $date < $day_end) {
         $date = date('H:i', $date);
     } else {
         $date = osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($date));
     }
     return $date;
 }
Exemplo n.º 27
0
 function listOrdersReturns()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qreturns = $osC_Database->query('select r.orders_returns_id, r.orders_id, r.orders_returns_status_id, r.customers_comments, r.admin_comments, r.date_added, o.customers_name, ors.orders_returns_status_name from :table_orders o, :table_orders_returns r, :table_orders_returns_status ors where r.orders_id = o.orders_id and r.orders_returns_status_id = ors.orders_returns_status_id and ors.languages_id = :languages_id');
     if (isset($_REQUEST['orders_id']) && !empty($_REQUEST['orders_id'])) {
         $Qreturns->appendQuery('and r.orders_id = :orders_id ');
         $Qreturns->bindInt(':orders_id', $_REQUEST['orders_id']);
     }
     if (isset($_REQUEST['customers_id']) && !empty($_REQUEST['customers_id'])) {
         $Qreturns->appendQuery('and o.customers_id = :customers_id ');
         $Qreturns->bindInt(':customers_id', $_REQUEST['customers_id']);
     }
     if (isset($_REQUEST['orders_returns_status_id']) && !empty($_REQUEST['orders_returns_status_id'])) {
         $Qreturns->appendQuery('and r.orders_returns_status_id = :orders_returns_status_id ');
         $Qreturns->bindInt(':orders_returns_status_id', $_REQUEST['orders_returns_status_id']);
     }
     $Qreturns->appendQuery('order by r.orders_returns_id desc ');
     $Qreturns->bindTable(':table_orders', TABLE_ORDERS);
     $Qreturns->bindTable(':table_orders_returns', TABLE_ORDERS_RETURNS);
     $Qreturns->bindTable(':table_orders_returns_status', TABLE_ORDERS_RETURNS_STATUS);
     $Qreturns->bindInt(':languages_id', $osC_Language->getID());
     $Qreturns->setExtBatchLimit($start, $limit);
     $Qreturns->execute();
     $records = array();
     while ($Qreturns->next()) {
         $orders_returns_id = $Qreturns->value('orders_returns_id');
         $Qproducts = $osC_Database->query("select orders_products_id, products_quantity from :table_orders_returns_products where orders_returns_id = :orders_returns_id");
         $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
         $Qproducts->bindTable(':table_orders_returns_products', TABLE_ORDERS_RETURNS_PRODUCTS);
         $Qproducts->bindInt(':orders_returns_id', $orders_returns_id);
         $Qproducts->execute();
         $return_products_ids = array();
         $return_products_qty = array();
         while ($Qproducts->next()) {
             $return_products_ids[] = $Qproducts->valueInt('orders_products_id');
             $return_products_qty[$Qproducts->valueInt('orders_products_id')] = $Qproducts->valueInt('products_quantity');
         }
         $total = 0;
         $quantity = 0;
         $products = array();
         $return_quantity = array();
         $osC_Order = new osC_Order($Qreturns->valueInt('orders_id'));
         foreach ($osC_Order->getProducts() as $product) {
             if (in_array($product['orders_products_id'], $return_products_ids)) {
                 $product_info = $return_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;
                 $total += $return_products_qty[$product['orders_products_id']] * $product['final_price'] * (1 + $product['tax'] / 100);
                 $quantity += $return_products_qty[$product['orders_products_id']];
                 $return_quantity[] = $product['orders_products_id'] . ':' . $return_products_qty[$product['orders_products_id']];
             }
         }
         $action = array();
         $orders_returns_status_id = $Qreturns->value('orders_returns_status_id');
         if ($orders_returns_status_id == ORDERS_RETURNS_STATUS_REFUNDED_CREDIT_MEMO || $orders_returns_status_id == ORDERS_RETURNS_STATUS_REFUNDED_STORE_CREDIT || $orders_returns_status_id == ORDERS_RETURNS_STATUS_REJECT) {
             $action[] = array('class' => 'icon-edit-gray-record', 'qtip' => $osC_Language->get('icon_edit'));
             $action[] = array('class' => 'icon-credit-slip-gray-record', 'qtip' => $osC_Language->get('icon_credit_slip'));
             $action[] = array('class' => 'icon-store-credit-gray-record', 'qtip' => $osC_Language->get('icon_issue_store_credit'));
         } else {
             $action[] = array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit'));
             $action[] = array('class' => 'icon-credit-slip-record', 'qtip' => $osC_Language->get('icon_credit_slip'));
             $action[] = array('class' => 'icon-store-credit-record', 'qtip' => $osC_Language->get('icon_issue_store_credit'));
         }
         $records[] = array('orders_returns_id' => $orders_returns_id, 'orders_id' => $Qreturns->valueInt('orders_id'), 'orders_returns_customer' => $Qreturns->value('customers_name'), 'quantity' => $quantity, 'date_added' => osC_DateTime::getShort($Qreturns->value('date_added')), 'status' => $Qreturns->value('orders_returns_status_name'), 'status_id' => $orders_returns_status_id, 'products' => implode('<br />', $products), 'return_quantity' => implode(';', $return_quantity), 'billing_address' => osC_Address::format($osC_Order->getBilling(), '<br />'), 'customers_comments' => $Qreturns->value('customers_comments'), 'admin_comments' => $Qreturns->value('admin_comments'), 'total' => number_format($total, 2, '.', ''), 'action' => $action);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qreturns->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 28
0
 /**
  * Add a product or variant product into the wishlist
  * 
  * @access public
  * @param mixed products id or products id string including the variants such as 1#1:1;2:3
  * @return boolean
  */
 function add($products_id_string)
 {
     global $osC_Database, $osC_Services, $osC_Customer, $osC_Product;
     //flag to reprent the action performed or not
     $error = false;
     // if wishlist empty, create a new wishlist
     if (!$this->hasWishlistID()) {
         $token = $this->generateToken();
         $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)');
         $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS);
         $Qnew->bindInt(':customers_id', $osC_Customer->getID());
         $Qnew->bindValue(':wishlists_token', $token);
         $Qnew->execute();
         $this->_wishlists_id = $osC_Database->nextID();
         $this->_token = $token;
         $Qnew->freeResult();
     }
     if (!isset($osC_Product)) {
         $osC_Product = new osC_Product($products_id_string);
     }
     if ($osC_Product->getID() > 0) {
         if (!$this->exists($products_id_string)) {
             $product_price = $osC_Product->getPrice();
             $product_name = $osC_Product->getTitle();
             $product_image = $osC_Product->getImage();
             if ($osC_Services->isStarted('specials')) {
                 global $osC_Specials;
                 if ($new_price = $osC_Specials->getPrice($products_id)) {
                     $price = $new_price;
                 }
             }
             // if the product has variants, set the image, price etc according to the variants
             if ($osC_Product->hasVariants()) {
                 $variant_product = $this->_updateProduct($products_id_string, $osC_Product, $product_name);
                 $product_name = $variant_product['name'];
                 $product_price = $variant_product['price'];
                 $product_image = $variant_product['image'];
             }
             $this->_contents[$products_id_string] = array('products_id_string' => $products_id_string, 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'comments' => '');
             // insert into wishlist products only if there isn't the same product existing in the table
             $QnewCheck = $osC_Database->query('select * from :table_wishlist_products where products_id_string = :products_id_string limit 1');
             $QnewCheck->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS);
             $QnewCheck->bindValue(':products_id_string', $products_id_string);
             $QnewCheck->execute();
             if ($QnewCheck->numberOfRows() < 1) {
                 $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id_string, date_added, comments) values (:wishlists_id, :products_id_string, now(), :comments)');
                 $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS);
                 $Qnew->bindInt(':wishlists_id', $this->_wishlists_id);
                 $Qnew->bindValue(':products_id_string', $products_id_string);
                 $Qnew->bindValue(':comments', '');
                 $Qnew->execute();
                 $wishlists_products_id = $osC_Database->nextID();
             } else {
                 $wishlists_products_id = $QnewCheck->valueInt('wishlists_products_id');
             }
             $QnewCheck->freeResult();
         } else {
             $error = true;
         }
     }
     if ($error === true) {
         return false;
     }
     return true;
 }
$Qstatus = $order->getStatusListing();
if ($Qstatus->numberOfRows() > 0) {
    ?>

<div class="moduleBox">
  <h6><?php 
    echo $osC_Language->get('order_history_heading');
    ?>
</h6>

  <div class="content">
    <table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php 
    while ($Qstatus->next()) {
        echo '    <tr>' . "\n" . '      <td valign="top" width="70">' . osC_DateTime::getShort($Qstatus->value('date_added')) . '</td>' . "\n" . '      <td valign="top" width="200">' . $Qstatus->value('orders_status_name') . '</td>' . "\n" . '      <td valign="top">' . (!osc_empty($Qstatus->valueProtected('comments')) ? nl2br($Qstatus->valueProtected('comments')) : '&nbsp;') . '</td>' . "\n" . '    </tr>' . "\n";
    }
    ?>

    </table>
  </div>
</div>

<?php 
}
?>
<div class="submitFormButtons">
  <?php 
echo osc_link_object(osc_href_link(FILENAME_ACCOUNT, 'orders' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'SSL'), osc_draw_image_button('button_back.gif', $osC_Language->get('button_back')));
?>
</div>
Exemplo n.º 30
0
 function add($products_id_string, $variants = null, $quantity = null, $gift_certificates_data = null, $action = 'add')
 {
     global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image, $toC_Wishlist;
     $products_id = osc_get_product_id($products_id_string);
     $osC_Product = new osC_Product($products_id);
     if ($osC_Product->isGiftCertificate()) {
         if ($variants == null || empty($variants)) {
             $products_id_string = $products_id . '#' . time();
         } else {
             $products_id_string = $products_id . '#' . $variants;
             //set variants to null
             $variants = null;
         }
     } else {
         $products_id_string = osc_get_product_id_string($products_id_string, $variants);
     }
     if ($osC_Product->getID() > 0) {
         if ($toC_Wishlist->hasProduct($products_id)) {
             $toC_Wishlist->deleteProduct($products_id);
         }
         if ($this->exists($products_id_string)) {
             if (!is_numeric($quantity)) {
                 $quantity = $this->getQuantity($products_id_string) + 1;
             } else {
                 if (is_numeric($quantity) && $quantity == 0) {
                     $this->remove($products_id_string);
                     return;
                 } else {
                     if ($action == 'add') {
                         $quantity = $this->getQuantity($products_id_string) + $quantity;
                     } else {
                         if ($action == 'update') {
                             $quantity = $quantity;
                         }
                     }
                 }
             }
             if ($osC_Product->isGiftCertificate()) {
                 if ($quantity > 1) {
                     $quantity = 1;
                     $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one');
                 }
             }
             //check minimum order quantity
             $products_moq = $osC_Product->getMOQ();
             if ($quantity < $products_moq) {
                 $quantity = $products_moq;
                 $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq);
             }
             //check maximum order quantity
             $products_max_order_quantity = $osC_Product->getMaxOrderQuantity();
             if ($products_max_order_quantity > 0) {
                 if ($quantity > $products_max_order_quantity) {
                     $quantity = $products_max_order_quantity;
                     $error = sprintf($osC_Language->get('error_maximum_order_quantity'), $osC_Product->getTitle(), $products_max_order_quantity);
                 }
             }
             //check order increment
             $increment = $osC_Product->getOrderIncrement();
             if (($quantity - $products_moq) % $increment != 0) {
                 $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment;
                 $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment);
             }
             //set error to session
             if (isset($error) && !empty($error)) {
                 $this->_contents[$products_id_string]['error'] = $error;
             }
             if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
                 $price = $this->_contents[$products_id_string]['price'];
             } else {
                 $price = $osC_Product->getPrice($variants, $quantity);
                 if ($osC_Services->isStarted('specials')) {
                     global $osC_Specials;
                     if ($new_price = $osC_Specials->getPrice($products_id)) {
                         $price = $new_price;
                     }
                 }
             }
             $this->_contents[$products_id_string]['quantity'] = $quantity;
             $this->_contents[$products_id_string]['price'] = $price;
             $this->_contents[$products_id_string]['final_price'] = $price;
             // update database
             if ($osC_Customer->isLoggedOn()) {
                 $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity, gift_certificates_data = :gift_certificates_data where customers_id = :customers_id and products_id = :products_id');
                 $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
                 $Qupdate->bindInt(':customers_basket_quantity', $quantity);
                 if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                     $Qupdate->bindValue(':gift_certificates_data', serialize($gift_certificates_data));
                 } else {
                     $Qupdate->bindRaw(':gift_certificates_data', 'null');
                 }
                 $Qupdate->bindInt(':customers_id', $osC_Customer->getID());
                 $Qupdate->bindValue(':products_id', $products_id_string);
                 $Qupdate->execute();
             }
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             if ($osC_Product->isGiftCertificate()) {
                 if ($quantity > 1) {
                     $quantity = 1;
                     $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one');
                 }
             }
             //check minimum order quantity
             $products_moq = $osC_Product->getMOQ();
             if ($quantity < $products_moq) {
                 $quantity = $products_moq;
                 $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq);
             }
             //check order increment
             $increment = $osC_Product->getOrderIncrement();
             if (($quantity - $products_moq) % $increment != 0) {
                 $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment;
                 $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment);
             }
             if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
                 $price = $gift_certificates_data['price'];
             } else {
                 $price = $osC_Product->getPrice($variants, $quantity);
                 if ($osC_Services->isStarted('specials')) {
                     global $osC_Specials;
                     if ($new_price = $osC_Specials->getPrice($products_id)) {
                         $price = $new_price;
                     }
                 }
             }
             $this->_contents[$products_id_string] = array('id' => $products_id_string, 'name' => $osC_Product->getTitle(), 'type' => $osC_Product->getProductType(), 'keyword' => $osC_Product->getKeyword(), 'sku' => $osC_Product->getSKU($variants), 'image' => $osC_Product->getImage(), 'price' => $price, 'final_price' => $price, 'quantity' => $quantity, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'weight_class_id' => $osC_Product->getWeightClass(), 'gc_data' => $gift_certificates_data);
             //set error to session
             if (isset($error) && !empty($error)) {
                 $this->_contents[$products_id_string]['error'] = $error;
             }
             // insert into database
             if ($osC_Customer->isLoggedOn()) {
                 $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, gift_certificates_data, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :gift_certificates_data, now())');
                 $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
                 $Qnew->bindInt(':customers_id', $osC_Customer->getID());
                 $Qnew->bindValue(':products_id', $products_id_string);
                 $Qnew->bindInt(':customers_basket_quantity', $quantity);
                 if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                     $Qnew->bindValue(':gift_certificates_data', serialize($gift_certificates_data));
                 } else {
                     $Qnew->bindRaw(':gift_certificates_data', 'null');
                 }
                 $Qnew->execute();
             }
             if (is_array($variants) && !empty($variants)) {
                 foreach ($variants as $group_id => $value_id) {
                     $Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :language_id and pvv.language_id = :language_id');
                     $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                     $Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
                     $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
                     $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
                     $Qvariants->bindInt(':products_id', $osC_Product->getID());
                     $Qvariants->bindInt(':groups_id', $group_id);
                     $Qvariants->bindInt(':variants_values_id', $value_id);
                     $Qvariants->bindInt(':language_id', $osC_Language->getID());
                     $Qvariants->bindInt(':language_id', $osC_Language->getID());
                     $Qvariants->execute();
                     $this->_contents[$products_id_string]['variants'][$group_id] = array('groups_id' => $group_id, 'variants_values_id' => $value_id, 'groups_name' => $Qvariants->value('products_variants_groups_name'), 'values_name' => $Qvariants->value('products_variants_values_name'));
                 }
             }
         }
         $this->_cleanUp();
         $this->_calculate();
     }
 }