\n";
print "\n";
print "\n";
?>
\n";
print "\n";
print "\n";
?>
customers_id); ?>
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
\ No newline at end of file
diff --git a/src/catalog/admin/create_order_process.php b/src/catalog/admin/create_order_process.php
new file mode 100644
index 0000000..0769e71
--- /dev/null
+++ b/src/catalog/admin/create_order_process.php
@@ -0,0 +1,158 @@
+
+ $customer_id,
+ 'customers_name' => $firstname . ' ' . $lastname,
+ 'customers_company' => $company,
+ 'customers_street_address' => $street_address,
+ 'customers_suburb' => $suburb,
+ 'customers_city' => $city,
+ 'customers_postcode' => $postcode,
+ 'customers_state' => $state,
+ 'customers_country' => $country,
+ 'customers_telephone' => $telephone,
+ 'customers_email_address' => $email_address,
+ 'customers_address_format_id' => $format_id,
+ 'delivery_name' => $firstname . ' ' . $lastname,
+ 'delivery_company' => $company,
+ 'delivery_street_address' => $street_address,
+ 'delivery_suburb' => $suburb,
+ 'delivery_city' => $city,
+ 'delivery_postcode' => $postcode,
+ 'delivery_state' => $state,
+ 'delivery_country' => $country,
+ 'delivery_address_format_id' => $format_id,
+ 'billing_name' => $firstname . ' ' . $lastname,
+ 'billing_company' => $company,
+ 'billing_street_address' => $street_address,
+ 'billing_suburb' => $suburb,
+ 'billing_city' => $city,
+ 'billing_postcode' => $postcode,
+ 'billing_state' => $state,
+ 'billing_country' => $country,
+ 'billing_address_format_id' => $format_id,
+ 'date_purchased' => 'now()',
+ 'orders_status' => DEFAULT_ORDERS_STATUS_ID,
+ 'currency' => $currency,
+ 'currency_value' => $currency_value,
+ 'payment_method' => $payment_method
+ );
+
+
+
+
+
+ //old
+ tep_db_perform(TABLE_ORDERS, $sql_data_array);
+ $insert_id = tep_db_insert_id();
+
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ //Comment out line you don't need
+ //'new_value' => $new_value, //for 2.2
+ 'orders_status_id' => $new_value, //for MS1 or MS2
+ 'date_added' => 'now()');
+ tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
+
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ 'title' => TEXT_SUBTOTAL,
+ 'text' => $temp_amount,
+ 'value' => "0.00",
+ 'class' => "ot_subtotal",
+ 'sort_order' => "1");
+ tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
+
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ 'title' => TEXT_DISCOUNT,
+ 'text' => $temp_amount,
+ 'value' => "0.00",
+ 'class' => "ot_customer_discount",
+ 'sort_order' => "2");
+ tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ 'title' => TEXT_DELIVERY,
+ 'text' => $temp_amount,
+ 'value' => "0.00",
+ 'class' => "ot_shipping",
+ 'sort_order' => "3");
+ tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ 'title' => TEXT_TAX,
+ 'text' => $temp_amount,
+ 'value' => "0.00",
+ 'class' => "ot_tax",
+ 'sort_order' => "4");
+ tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
+
+ $sql_data_array = array('orders_id' => $insert_id,
+ 'title' => TEXT_TOTAL,
+ 'text' => $temp_amount,
+ 'value' => "0.00",
+ 'class' => "ot_total",
+ 'sort_order' => "5");
+ tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
+
+
+ tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $insert_id, 'SSL'));
+
+
+ require(DIR_WS_INCLUDES . 'application_bottom.php');
+?>
\ No newline at end of file
diff --git a/src/catalog/admin/currencies.php b/src/catalog/admin/currencies.php
new file mode 100644
index 0000000..90c5836
--- /dev/null
+++ b/src/catalog/admin/currencies.php
@@ -0,0 +1,288 @@
+ $title,
+ 'code' => $code,
+ 'symbol_left' => $symbol_left,
+ 'symbol_right' => $symbol_right,
+ 'decimal_point' => $decimal_point,
+ 'thousands_point' => $thousands_point,
+ 'decimal_places' => $decimal_places,
+ 'value' => $value);
+
+ if ($action == 'insert') {
+ tep_db_perform(TABLE_CURRENCIES, $sql_data_array);
+ $currency_id = tep_db_insert_id();
+ } elseif ($action == 'save') {
+ tep_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "currencies_id = '" . (int)$currency_id . "'");
+ }
+
+ if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
+ tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_CURRENCY'");
+ }
+
+ tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $currency_id));
+ break;
+ case 'deleteconfirm':
+ $currencies_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
+
+ $currency_query = tep_db_query("select currencies_id from " . TABLE_CURRENCIES . " where code = '" . DEFAULT_CURRENCY . "'");
+ $currency = tep_db_fetch_array($currency_query);
+
+ if ($currency['currencies_id'] == $currencies_id) {
+ tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
+ }
+
+ tep_db_query("delete from " . TABLE_CURRENCIES . " where currencies_id = '" . (int)$currencies_id . "'");
+
+ tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page']));
+ break;
+ case 'update':
+ $server_used = CURRENCY_SERVER_PRIMARY;
+
+ $currency_query = tep_db_query("select currencies_id, code, title from " . TABLE_CURRENCIES);
+ while ($currency = tep_db_fetch_array($currency_query)) {
+ $quote_function = 'quote_' . CURRENCY_SERVER_PRIMARY . '_currency';
+ $rate = $quote_function($currency['code']);
+
+ if (empty($rate) && (tep_not_null(CURRENCY_SERVER_BACKUP))) {
+ $messageStack->add_session(sprintf(WARNING_PRIMARY_SERVER_FAILED, CURRENCY_SERVER_PRIMARY, $currency['title'], $currency['code']), 'warning');
+
+ $quote_function = 'quote_' . CURRENCY_SERVER_BACKUP . '_currency';
+ $rate = $quote_function($currency['code']);
+
+ $server_used = CURRENCY_SERVER_BACKUP;
+ }
+
+ if (tep_not_null($rate)) {
+ tep_db_query("update " . TABLE_CURRENCIES . " set value = '" . $rate . "', last_updated = now() where currencies_id = '" . (int)$currency['currencies_id'] . "'");
+
+ $messageStack->add_session(sprintf(TEXT_INFO_CURRENCY_UPDATED, $currency['title'], $currency['code'], $server_used), 'success');
+ } else {
+ $messageStack->add_session(sprintf(ERROR_CURRENCY_INVALID, $currency['title'], $currency['code'], $server_used), 'error');
+ }
+ }
+
+ tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID']));
+ break;
+ case 'delete':
+ $currencies_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
+
+ $currency_query = tep_db_query("select code from " . TABLE_CURRENCIES . " where currencies_id = '" . (int)$currencies_id . "'");
+ $currency = tep_db_fetch_array($currency_query);
+
+ $remove_currency = true;
+ if ($currency['code'] == DEFAULT_CURRENCY) {
+ $remove_currency = false;
+ $messageStack->add(ERROR_REMOVE_DEFAULT_CURRENCY, 'error');
+ }
+ break;
+ }
+ }
+?>
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+currencies_id) ) {
+ echo ' ' . "\n";
+ } else {
+ echo ' ' . "\n";
+ }
+
+ if (DEFAULT_CURRENCY == $currency['code']) {
+ echo ' ' . $currency['title'] . ' (' . TEXT_DEFAULT . ') ' . "\n";
+ } else {
+ echo ' ' . $currency['title'] . ' ' . "\n";
+ }
+?>
+
+
+ currencies_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } ?>
+
+
+
+
+
+ display_count($currency_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CURRENCIES); ?>
+ display_links($currency_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
+
+
+
+ currencies_id . '&action=update') . '">' . tep_image_button('button_update_currencies.gif', IMAGE_UPDATE_CURRENCIES) . ''; } ?>
+ currencies_id . '&action=new') . '">' . tep_image_button('button_new_currency.gif', IMAGE_NEW_CURRENCY) . ''; ?>
+
+
+
+
+
+ '' . TEXT_INFO_HEADING_NEW_CURRENCY . ' ');
+
+ $contents = array('form' => tep_draw_form('currencies', FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . (isset($cInfo) ? '&cID=' . $cInfo->currencies_id : '') . '&action=insert'));
+ $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_TITLE . ' ' . tep_draw_input_field('title'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_CODE . ' ' . tep_draw_input_field('code'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . ' ' . tep_draw_input_field('symbol_left'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_SYMBOL_RIGHT . ' ' . tep_draw_input_field('symbol_right'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_DECIMAL_POINT . ' ' . tep_draw_input_field('decimal_point'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_THOUSANDS_POINT . ' ' . tep_draw_input_field('thousands_point'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_DECIMAL_PLACES . ' ' . tep_draw_input_field('decimal_places'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_VALUE . ' ' . tep_draw_input_field('value'));
+ $contents[] = array('text' => ' ' . tep_draw_checkbox_field('default') . ' ' . TEXT_INFO_SET_AS_DEFAULT);
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'edit':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_CURRENCY . ' ');
+
+ $contents = array('form' => tep_draw_form('currencies', FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->currencies_id . '&action=save'));
+ $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_TITLE . ' ' . tep_draw_input_field('title', $cInfo->title));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_CODE . ' ' . tep_draw_input_field('code', $cInfo->code));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . ' ' . tep_draw_input_field('symbol_left', $cInfo->symbol_left));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_SYMBOL_RIGHT . ' ' . tep_draw_input_field('symbol_right', $cInfo->symbol_right));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_DECIMAL_POINT . ' ' . tep_draw_input_field('decimal_point', $cInfo->decimal_point));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_THOUSANDS_POINT . ' ' . tep_draw_input_field('thousands_point', $cInfo->thousands_point));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_DECIMAL_PLACES . ' ' . tep_draw_input_field('decimal_places', $cInfo->decimal_places));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_VALUE . ' ' . tep_draw_input_field('value', $cInfo->value));
+ if (DEFAULT_CURRENCY != $cInfo->code) $contents[] = array('text' => ' ' . tep_draw_checkbox_field('default') . ' ' . TEXT_INFO_SET_AS_DEFAULT);
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'delete':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_CURRENCY . ' ');
+
+ $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
+ $contents[] = array('text' => '' . $cInfo->title . ' ');
+ $contents[] = array('align' => 'center', 'text' => ' ' . (($remove_currency) ? '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ' : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ default:
+ if (is_object($cInfo)) {
+ $heading[] = array('text' => '' . $cInfo->title . ' ');
+
+ $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ');
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_TITLE . ' ' . $cInfo->title);
+ $contents[] = array('text' => TEXT_INFO_CURRENCY_CODE . ' ' . $cInfo->code);
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . ' ' . $cInfo->symbol_left);
+ $contents[] = array('text' => TEXT_INFO_CURRENCY_SYMBOL_RIGHT . ' ' . $cInfo->symbol_right);
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_DECIMAL_POINT . ' ' . $cInfo->decimal_point);
+ $contents[] = array('text' => TEXT_INFO_CURRENCY_THOUSANDS_POINT . ' ' . $cInfo->thousands_point);
+ $contents[] = array('text' => TEXT_INFO_CURRENCY_DECIMAL_PLACES . ' ' . $cInfo->decimal_places);
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_LAST_UPDATED . ' ' . tep_date_short($cInfo->last_updated));
+ $contents[] = array('text' => TEXT_INFO_CURRENCY_VALUE . ' ' . number_format($cInfo->value, 8));
+ $contents[] = array('text' => ' ' . TEXT_INFO_CURRENCY_EXAMPLE . ' ' . $currencies->format('30', false, DEFAULT_CURRENCY) . ' = ' . $currencies->format('30', true, $cInfo->code));
+ }
+ break;
+ }
+
+ if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
+ echo ' ' . "\n";
+
+ $box = new box;
+ echo $box->infoBox($heading, $contents);
+
+ echo ' ' . "\n";
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalog/admin/customers.php b/src/catalog/admin/customers.php
new file mode 100644
index 0000000..ff58b23
--- /dev/null
+++ b/src/catalog/admin/customers.php
@@ -0,0 +1,826 @@
+ 0);
+ if ($entry_state_has_zones == true) {
+ $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'");
+ if (tep_db_num_rows($zone_query) == 1) {
+ $zone_values = tep_db_fetch_array($zone_query);
+ $entry_zone_id = $zone_values['zone_id'];
+ } else {
+ $error = true;
+ $entry_state_error = true;
+ }
+ } else {
+ if ($entry_state == false) {
+ $error = true;
+ $entry_state_error = true;
+ }
+ }
+ }
+ }
+
+ if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
+ $error = true;
+ $entry_telephone_error = true;
+ } else {
+ $entry_telephone_error = false;
+ }
+
+ $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");
+ if (tep_db_num_rows($check_email)) {
+ $error = true;
+ $entry_email_address_exists = true;
+ } else {
+ $entry_email_address_exists = false;
+ }
+
+ if ($error == false) {
+
+ $sql_data_array = array('customers_firstname' => $customers_firstname,
+ 'customers_lastname' => $customers_lastname,
+ 'customers_email_address' => $customers_email_address,
+ 'customers_telephone' => $customers_telephone,
+ 'customers_fax' => $customers_fax,
+ 'customers_newsletter' => $customers_newsletter);
+
+ if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;
+ if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);
+
+ tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");
+
+ tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");
+
+ if ($entry_zone_id > 0) $entry_state = '';
+
+ $sql_data_array = array('entry_firstname' => $customers_firstname,
+ 'entry_lastname' => $customers_lastname,
+ 'entry_street_address' => $entry_street_address,
+ 'entry_postcode' => $entry_postcode,
+ 'entry_city' => $entry_city,
+ 'entry_country_id' => $entry_country_id);
+
+ if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;
+ if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;
+
+ if (ACCOUNT_STATE == 'true') {
+ if ($entry_zone_id > 0) {
+ $sql_data_array['entry_zone_id'] = $entry_zone_id;
+ $sql_data_array['entry_state'] = '';
+ } else {
+ $sql_data_array['entry_zone_id'] = '0';
+ $sql_data_array['entry_state'] = $entry_state;
+ }
+ }
+
+ tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");
+
+ tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));
+
+ } else if ($error == true) {
+ $cInfo = new objectInfo($HTTP_POST_VARS);
+ $processed = true;
+ }
+
+ break;
+ case 'deleteconfirm':
+ $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
+
+ if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {
+ $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
+ while ($reviews = tep_db_fetch_array($reviews_query)) {
+ tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");
+ }
+
+ tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
+ } else {
+ tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'");
+ }
+
+ tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");
+ tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");
+
+ tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));
+ break;
+ default:
+ $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
+ $customers = tep_db_fetch_array($customers_query);
+ $cInfo = new objectInfo($customers);
+ }
+ }
+?>
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ '1', 'text' => ENTRY_NEWSLETTER_YES),
+ array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));
+?>
+
+
+
+
+
+
+ customers_default_address_id); ?>
+
+
+
+
+
+
+
+
+customers_gender) . ' ' . MALE . ' ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . ' ' . FEMALE . ' ' . ENTRY_GENDER_ERROR;
+ } else {
+ echo ($cInfo->customers_gender == 'm') ? MALE : FEMALE;
+ echo tep_draw_hidden_field('customers_gender');
+ }
+ } else {
+ echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . ' ' . MALE . ' ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . ' ' . FEMALE;
+ }
+?>
+
+
+
+
+
+customers_firstname, 'maxlength="32"') . ' ' . ENTRY_FIRST_NAME_ERROR;
+ } else {
+ echo $cInfo->customers_firstname . tep_draw_hidden_field('customers_firstname');
+ }
+ } else {
+ echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"', true);
+ }
+?>
+
+
+
+
+customers_lastname, 'maxlength="32"') . ' ' . ENTRY_LAST_NAME_ERROR;
+ } else {
+ echo $cInfo->customers_lastname . tep_draw_hidden_field('customers_lastname');
+ }
+ } else {
+ echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"', true);
+ }
+?>
+
+
+
+
+
+
+customers_dob), 'maxlength="10"') . ' ' . ENTRY_DATE_OF_BIRTH_ERROR;
+ } else {
+ echo $cInfo->customers_dob . tep_draw_hidden_field('customers_dob');
+ }
+ } else {
+ echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"', true);
+ }
+?>
+
+
+
+
+
+customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;
+ } elseif ($entry_email_address_check_error == true) {
+ echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;
+ } elseif ($entry_email_address_exists == true) {
+ echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;
+ } else {
+ echo $customers_email_address . tep_draw_hidden_field('customers_email_address');
+ }
+ } else {
+ echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"', true);
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+entry_company, 'maxlength="32"') . ' ' . ENTRY_COMPANY_ERROR;
+ } else {
+ echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');
+ }
+ } else {
+ echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"');
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+entry_street_address, 'maxlength="64"') . ' ' . ENTRY_STREET_ADDRESS_ERROR;
+ } else {
+ echo $cInfo->entry_street_address . tep_draw_hidden_field('entry_street_address');
+ }
+ } else {
+ echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"', true);
+ }
+?>
+
+
+
+
+
+entry_suburb, 'maxlength="32"') . ' ' . ENTRY_SUBURB_ERROR;
+ } else {
+ echo $cInfo->entry_suburb . tep_draw_hidden_field('entry_suburb');
+ }
+ } else {
+ echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'maxlength="32"');
+ }
+?>
+
+
+
+
+
+entry_postcode, 'maxlength="8"') . ' ' . ENTRY_POST_CODE_ERROR;
+ } else {
+ echo $cInfo->entry_postcode . tep_draw_hidden_field('entry_postcode');
+ }
+ } else {
+ echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true);
+ }
+?>
+
+
+
+
+entry_city, 'maxlength="32"') . ' ' . ENTRY_CITY_ERROR;
+ } else {
+ echo $cInfo->entry_city . tep_draw_hidden_field('entry_city');
+ }
+ } else {
+ echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"', true);
+ }
+?>
+
+
+
+
+
+entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);
+ if ($error == true) {
+ if ($entry_state_error == true) {
+ if ($entry_state_has_zones == true) {
+ $zones_array = array();
+ $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name");
+ while ($zones_values = tep_db_fetch_array($zones_query)) {
+ $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
+ }
+ echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR;
+ } else {
+ echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR;
+ }
+ } else {
+ echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');
+ }
+ } else {
+ echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state));
+ }
+
+?>
+
+
+
+
+
+entry_country_id) . ' ' . ENTRY_COUNTRY_ERROR;
+ } else {
+ echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id');
+ }
+ } else {
+ echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id);
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+customers_telephone, 'maxlength="32"') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;
+ } else {
+ echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone');
+ }
+ } else {
+ echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"', true);
+ }
+?>
+
+
+
+
+customers_fax . tep_draw_hidden_field('customers_fax');
+ } else {
+ echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"');
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+customers_newsletter == '1') {
+ echo ENTRY_NEWSLETTER_YES;
+ } else {
+ echo ENTRY_NEWSLETTER_NO;
+ }
+ echo tep_draw_hidden_field('customers_newsletter');
+ } else {
+ echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));
+ }
+?>
+
+
+
+
+
+
+
+ ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+customers_id)) {
+ echo ' ' . "\n";
+ } else {
+ echo ' ' . "\n";
+ }
+?>
+
+
+
+ customers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } ?>
+
+
+
+
+
+ display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?>
+ display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?>
+
+
+
+ ' . tep_image_button('button_reset.gif', IMAGE_RESET) . ''; ?>
+
+
+
+
+
+ '' . TEXT_INFO_HEADING_DELETE_CUSTOMER . ' ');
+
+ $contents = array('form' => tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=deleteconfirm'));
+ $contents[] = array('text' => TEXT_DELETE_INTRO . '' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ' ');
+ if (isset($cInfo->number_of_reviews) && ($cInfo->number_of_reviews) > 0) $contents[] = array('text' => ' ' . tep_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews));
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ default:
+ if (isset($cInfo) && is_object($cInfo)) {
+ $heading[] = array('text' => '' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ' ');
+
+ $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_orders.gif', IMAGE_ORDERS) . ' ' . tep_image_button('button_email.gif', IMAGE_EMAIL) . ' ');
+ $contents[] = array('text' => ' ' . TEXT_DATE_ACCOUNT_CREATED . ' ' . tep_date_short($cInfo->date_account_created));
+ $contents[] = array('text' => ' ' . TEXT_DATE_ACCOUNT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->date_account_last_modified));
+ $contents[] = array('text' => ' ' . TEXT_INFO_DATE_LAST_LOGON . ' ' . tep_date_short($cInfo->date_last_logon));
+ $contents[] = array('text' => ' ' . TEXT_INFO_NUMBER_OF_LOGONS . ' ' . $cInfo->number_of_logons);
+ $contents[] = array('text' => ' ' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);
+ $contents[] = array('text' => ' ' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews);
+ }
+ break;
+ }
+
+ if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
+ echo ' ' . "\n";
+
+ $box = new box;
+ echo $box->infoBox($heading, $contents);
+
+ echo ' ' . "\n";
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalog/admin/define_language.php b/src/catalog/admin/define_language.php
new file mode 100644
index 0000000..96d4558
--- /dev/null
+++ b/src/catalog/admin/define_language.php
@@ -0,0 +1,193 @@
+ $languages[$i]['directory'],
+ 'text' => $languages[$i]['name']);
+ }
+
+ if (!$lng_exists) $HTTP_GET_VARS['lngdir'] = $language;
+?>
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+reset();
+ $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $file), 'error');
+ echo $messageStack->output();
+ }
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+ ' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+
+
+
+
+
+
+read()) {
+ if (substr($file, strrpos($file, '.')) == $file_extension) {
+ echo ' ' . $file . ' ' . "\n";
+ if (!$left) {
+ echo ' ' . "\n" .
+ ' ' . "\n";
+ }
+ $left = !$left;
+ }
+ }
+ $dir->close();
+ }
+?>
+
+
+
+
+
+
+
+ ' . tep_image_button('button_file_manager.gif', IMAGE_FILE_MANAGER) . ''; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalog/admin/easypopulate.php b/src/catalog/admin/easypopulate.php
new file mode 100644
index 0000000..794699b
--- /dev/null
+++ b/src/catalog/admin/easypopulate.php
@@ -0,0 +1,2541 @@
+ Escape character conversion ****
+// If you have extensive html in your descriptions and it's getting mangled on upload, turn this off
+// set to 1 = replace quotes with escape characters
+// set to 0 = no quote replacement
+global $replace_quotes;
+$replace_quotes = false;
+
+// **** Field Separator ****
+// change this if you can't use the default of tabs
+// Tab is the default, comma and semicolon are commonly supported by various progs
+// Remember, if your descriptions contain this character, you will confuse EP!
+global $separator;
+$separator = "\t"; // tab is default
+//$separator = ","; // comma
+//$separator = ";"; // semi-colon
+//$separator = "~"; // tilde
+//$separator = "-"; // dash
+//$separator = "*"; // splat
+
+// *** Excel safe output ***
+// this setting will supersede the previous $separator setting and create a file
+// that excel will import without spanning cells from embedded commas.
+global $excel_safe_output;
+$excel_safe_output = false; // default is: false
+if ($excel_safe_output == true) { $separator = ","; }
+
+// *** Preserve Tabs, Carriage returns and Line feeds ***
+// this setting will preserve the special chars that can cause problems in
+// a text based output. When used with $excel_safe_output, it will safely
+// preserve these elements in the export and import.
+global $preserve_tabs_cr_lf;
+$preserve_tabs_cr_lf = false; // default is: false
+
+// **** Max Category Levels ****
+// change this if you need more or fewer categories
+global $max_categories;
+$max_categories = 3; // 7 is default
+
+// VJ product attributes begin
+// **** Product Attributes ****
+// change this to false, if do not want to download product attributes
+global $products_with_attributes;
+$products_with_attributes = true;
+
+// change this to true, if you use QTYpro and want to set attributes stock with EP.
+global $products_attributes_stock;
+$products_attributes_stock = false;
+
+
+// change this if you want to download selected product options
+// this might be handy, if you have a lot of product options, and your output file exceeds 256 columns (which is the max. limit MS Excel is able to handle)
+global $attribute_options_select;
+//$attribute_options_select = array('Size', 'Model'); // uncomment and fill with product options name you wish to download // comment this line, if you wish to download all product options
+// VJ product attributes end
+
+// *** Show settings on EP page ***
+global $show_ep_settings;
+$show_ep_settings = false; // default is: false
+
+
+
+// ****************************************
+// Froogle configuration variables
+// -- YOU MUST CONFIGURE THIS! IT WON'T WORK OUT OF THE BOX!
+// ****************************************
+
+// **** Froogle product info page path ****
+// We can't use the tep functions to create the link, because the links will point to the admin, since that's where we're at.
+// So put the entire path to your product_info.php page here
+global $froogle_product_info_path;
+$froogle_product_info_path = "http://www.yourdomain.com/catalog/product_info.php";
+
+// **** Froogle product image path ****
+// Set this to the path to your images directory
+global $froogle_image_path;
+$froogle_image_path = "http://www.yourdomain.com/catalog/images/";
+
+// **** Froogle - search engine friendly setting
+// if your store has SEARCH ENGINE FRIENDLY URLS set, then turn this to true
+// I did it this way because I'm having trouble with the code seeing the constants
+// that are defined in other places.
+global $froogle_SEF_urls;
+$froogle_SEF_urls = false;
+
+
+// ****************************************
+// End Froogle configuration variables
+// ****************************************
+
+//*******************************
+//*******************************
+// E N D
+// C O N F I G U R A T I O N
+// V A R I A B L E S
+//*******************************
+//*******************************
+
+
+//*******************************
+//*******************************
+// S T A R T
+// INITIALIZATION
+//*******************************
+//*******************************
+
+
+//*******************************
+// If you are running a pre-Nov1-2002 snapshot of OSC, then we need this include line to avoid
+// errors like:
+// undefined function tep_get_uploaded_file
+ if (!function_exists(tep_get_uploaded_file)){
+ include ('easypopulate_functions.php');
+ }
+//*******************************
+
+// modify tableBlock for use here.
+ class epbox extends tableBlock {
+ // constructor
+ function epbox($contents, $direct_ouput = true) {
+ $this->table_width = '';
+ if (!empty($contents) && $direct_ouput == true) {
+ echo $this->tableBlock($contents);
+ }
+ }
+ // only member function
+ function output($contents) {
+ return $this->tableBlock($contents);
+ }
+ }
+
+
+// VJ product attributes begin
+global $attribute_options_array;
+$attribute_options_array = array();
+
+if ($products_with_attributes == true) {
+ if (is_array($attribute_options_select) && (count($attribute_options_select) > 0)) {
+ foreach ($attribute_options_select as $value) {
+ $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = '" . $value . "'";
+
+ $attribute_options_values = tep_db_query($attribute_options_query);
+
+ if ($attribute_options = tep_db_fetch_array($attribute_options_values)){
+ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']);
+ }
+ }
+ } else {
+ $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id";
+
+ $attribute_options_values = tep_db_query($attribute_options_query);
+
+ while ($attribute_options = tep_db_fetch_array($attribute_options_values)){
+ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']);
+ }
+ }
+}
+// VJ product attributes end
+
+global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders;
+
+// these are the fields that will be defaulted to the current values in the database if they are not found in the incoming file
+global $default_these;
+$default_these = array(
+ 'v_products_image',
+ #'v_products_mimage',
+ #'v_products_bimage',
+ #'v_products_subimage1',
+ #'v_products_bsubimage1',
+ #'v_products_subimage2',
+ #'v_products_bsubimage2',
+ #'v_products_subimage3',
+ #'v_products_bsubimage3',
+ 'v_categories_id',
+ 'v_products_price',
+ 'v_products_quantity',
+ 'v_products_weight',
+ 'v_date_avail',
+ 'v_instock',
+ 'v_tax_class_title',
+ 'v_manufacturers_name',
+ 'v_manufacturers_id',
+ 'v_products_dim_type',
+ 'v_products_length',
+ 'v_products_width',
+ 'v_products_height',
+ 'v_products_upc'
+ );
+
+//elari check default language_id from configuration table DEFAULT_LANGUAGE
+$epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'");
+if (tep_db_num_rows($epdlanguage_query)) {
+ $epdlanguage = tep_db_fetch_array($epdlanguage_query);
+ $epdlanguage_id = $epdlanguage['languages_id'];
+ $epdlanguage_name = $epdlanguage['name'];
+} else {
+ Echo 'Strange but there is no default language to work... That may not happen, just in case... ';
+}
+
+$langcode = ep_get_languages();
+
+if ( $dltype != '' ){
+ // if dltype is set, then create the filelayout. Otherwise it gets read from the uploaded file
+ ep_create_filelayout($dltype); // get the right filelayout for this download
+}
+
+//*******************************
+//*******************************
+// E N D
+// INITIALIZATION
+//*******************************
+//*******************************
+
+
+if ( $download == 'stream' or $download == 'activestream' or $download == 'tempfile' ){
+ //*******************************
+ //*******************************
+ // DOWNLOAD FILE
+ //*******************************
+ //*******************************
+ $filestring = ""; // this holds the csv file we want to download
+ $result = tep_db_query($filelayout_sql);
+ $row = tep_db_fetch_array($result);
+
+ // $EXPORT_TIME=time(); // start export time when export is started.
+ $EXPORT_TIME = strftime('%Y%b%d-%H%I');
+ if ($dltype=="froogle"){
+ $EXPORT_TIME = "FroogleEP" . $EXPORT_TIME;
+ } else {
+ $EXPORT_TIME = "EP" . $EXPORT_TIME;
+ }
+
+ // Here we need to allow for the mapping of internal field names to external field names
+ // default to all headers named like the internal ones
+ // the field mapping array only needs to cover those fields that need to have their name changed
+ if ( count($fileheaders) != 0 ){
+ $filelayout_header = $fileheaders; // if they gave us fileheaders for the dl, then use them
+ } else {
+ $filelayout_header = $filelayout; // if no mapping was spec'd use the internal field names for header names
+ }
+ //We prepare the table heading with layout values
+ foreach( $filelayout_header as $key => $value ){
+ $filestring .= $key . $separator;
+ }
+ // now lop off the trailing tab
+ $filestring = substr($filestring, 0, strlen($filestring)-1);
+
+ // set the type
+ if ( $dltype == 'froogle' ){
+ $endofrow = "\n";
+ } else {
+ // default to normal end of row
+ $endofrow = $separator . 'EOREOR' . "\n";
+ }
+ $filestring .= $endofrow;
+
+ if ($download == 'activestream'){
+ header("Content-type: application/vnd.ms-excel");
+ header("Content-disposition: attachment; filename=$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".txt"));
+ // Changed if using SSL, helps prevent program delay/timeout (add to backup.php also)
+ // header("Pragma: no-cache");
+ if ($request_type== 'NONSSL'){
+ header("Pragma: no-cache");
+ } else {
+ header("Pragma: ");
+ }
+ header("Expires: 0");
+ echo $filestring;
+ }
+
+ $num_of_langs = count($langcode);
+ while ($row){
+
+
+ // if the filelayout says we need a products_name, get it
+ // build the long full froogle image path
+ $row['v_products_fullpath_image'] = $froogle_image_path . $row['v_products_image'];
+ // Other froogle defaults go here for now
+ $row['v_froogle_instock'] = 'Y';
+ $row['v_froogle_shipping'] = '';
+ $row['v_froogle_upc'] = '';
+ $row['v_froogle_color'] = '';
+ $row['v_froogle_size'] = '';
+ $row['v_froogle_quantitylevel'] = '';
+ $row['v_froogle_manufacturer_id'] = '';
+ $row['v_froogle_exp_date'] = '';
+ $row['v_froogle_product_type'] = 'OTHER';
+ $row['v_froogle_delete'] = '';
+ $row['v_froogle_currency'] = 'USD';
+ $row['v_froogle_offer_id'] = $row['v_products_model'];
+ $row['v_froogle_product_id'] = $row['v_products_model'];
+
+ // names and descriptions require that we loop thru all languages that are turned on in the store
+ foreach ($langcode as $key => $lang){
+ $lid = $lang['id'];
+
+ // for each language, get the description and set the vals
+ $sql2 = "SELECT *
+ FROM ".TABLE_PRODUCTS_DESCRIPTION."
+ WHERE
+ products_id = " . $row['v_products_id'] . " AND
+ language_id = '" . $lid . "'
+ ";
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+
+ // I'm only doing this for the first language, since right now froogle is US only.. Fix later!
+ // adding url for froogle, but it should be available no matter what
+ if ($froogle_SEF_urls){
+ // if only one language
+ if ($num_of_langs == 1){
+ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id'];
+ } else {
+ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id'] . '/language/' . $lid;
+ }
+ } else {
+ if ($num_of_langs == 1){
+ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id'];
+ } else {
+ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id'] . '&language=' . $lid;
+ }
+ }
+
+ $row['v_products_name_' . $lid] = $row2['products_name'];
+ $row['v_products_description_' . $lid] = $row2['products_description'];
+ $row['v_products_url_' . $lid] = $row2['products_url'];
+
+ // froogle advanced format needs the quotes around the name and desc
+ $row['v_froogle_products_name_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_name'])) . '"';
+ $row['v_froogle_products_description_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_description'])) . '"';
+
+ // support for Linda's Header Controller 2.0 here
+ if(isset($filelayout['v_products_head_title_tag_' . $lid])){
+ $row['v_products_head_title_tag_' . $lid] = $row2['products_head_title_tag'];
+ $row['v_products_head_desc_tag_' . $lid] = $row2['products_head_desc_tag'];
+ $row['v_products_head_keywords_tag_' . $lid] = $row2['products_head_keywords_tag'];
+ }
+ // end support for Header Controller 2.0
+ }
+
+ // for the categories, we need to keep looping until we find the root category
+
+ // start with v_categories_id
+ // Get the category description
+ // set the appropriate variable name
+ // if parent_id is not null, then follow it up.
+ // we'll populate an aray first, then decide where it goes in the
+ $thecategory_id = $row['v_categories_id'];
+ $fullcategory = ''; // this will have the entire category stack for froogle
+ for( $categorylevel=1; $categorylevel<$max_categories+1; $categorylevel++){
+ if ($thecategory_id){
+ $sql2 = "SELECT categories_name
+ FROM ".TABLE_CATEGORIES_DESCRIPTION."
+ WHERE
+ categories_id = " . $thecategory_id . " AND
+ language_id = " . $epdlanguage_id ;
+
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+ // only set it if we found something
+ $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name'];
+ // now get the parent ID if there was one
+ $sql3 = "SELECT parent_id
+ FROM ".TABLE_CATEGORIES."
+ WHERE
+ categories_id = " . $thecategory_id;
+ $result3 = tep_db_query($sql3);
+ $row3 = tep_db_fetch_array($result3);
+ $theparent_id = $row3['parent_id'];
+ if ($theparent_id != ''){
+ // there was a parent ID, lets set thecategoryid to get the next level
+ $thecategory_id = $theparent_id;
+ } else {
+ // we have found the top level category for this item,
+ $thecategory_id = false;
+ }
+ //$fullcategory .= " > " . $row2['categories_name'];
+ $fullcategory = $row2['categories_name'] . " > " . $fullcategory;
+ } else {
+ $temprow['v_categories_name_' . $categorylevel] = '';
+ }
+ }
+ // now trim off the last ">" from the category stack
+ $row['v_category_fullpath'] = substr($fullcategory,0,strlen($fullcategory)-3);
+
+ // temprow has the old style low to high level categories.
+ $newlevel = 1;
+ // let's turn them into high to low level categories
+ for( $categorylevel=6; $categorylevel>0; $categorylevel--){
+ if ($temprow['v_categories_name_' . $categorylevel] != ''){
+ $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel];
+ }
+ }
+ // if the filelayout says we need a manufacturers name, get it
+ if (isset($filelayout['v_manufacturers_name'])){
+ if ($row['v_manufacturers_id'] != ''){
+ $sql2 = "SELECT manufacturers_name
+ FROM ".TABLE_MANUFACTURERS."
+ WHERE
+ manufacturers_id = " . $row['v_manufacturers_id']
+ ;
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+ $row['v_manufacturers_name'] = $row2['manufacturers_name'];
+ }
+ }
+
+
+ // If you have other modules that need to be available, put them here
+
+ // VJ product attribs begin
+ if (isset($filelayout['v_attribute_options_id_1'])){
+ $languages = tep_get_languages();
+
+ $attribute_options_count = 1;
+ foreach ($attribute_options_array as $attribute_options) {
+ $row['v_attribute_options_id_' . $attribute_options_count] = $attribute_options['products_options_id'];
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $attribute_options_languages_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' and language_id = '" . (int)$lid . "'";
+
+ $attribute_options_languages_values = tep_db_query($attribute_options_languages_query);
+
+ $attribute_options_languages = tep_db_fetch_array($attribute_options_languages_values);
+
+ $row['v_attribute_options_name_' . $attribute_options_count . '_' . $lid] = $attribute_options_languages['products_options_name'];
+ }
+
+ $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' order by products_options_values_id";
+
+ $attribute_values_values = tep_db_query($attribute_values_query);
+
+ $attribute_values_count = 1;
+ while ($attribute_values = tep_db_fetch_array($attribute_values_values)) {
+ $row['v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values['products_options_values_id'];
+
+ $attribute_values_price_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$row['v_products_id'] . "' and options_id = '" . (int)$attribute_options['products_options_id'] . "' and options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "'";
+
+ $attribute_values_price_values = tep_db_query($attribute_values_price_query);
+
+ $attribute_values_price = tep_db_fetch_array($attribute_values_price_values);
+
+ $row['v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values_price['price_prefix'] . $attribute_values_price['options_values_price'];
+
+ //// attributes stock add start
+ if ( $products_attributes_stock == true ) {
+ $stock_attributes = $attribute_options['products_options_id'].'-'.$attribute_values['products_options_values_id'];
+
+ $stock_quantity_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$row['v_products_id'] . "' and products_stock_attributes = '" . $stock_attributes . "'");
+ $stock_quantity = tep_db_fetch_array($stock_quantity_query);
+
+ $row['v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count] = $stock_quantity['products_stock_quantity'];
+ }
+ //// attributes stock add end
+
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $attribute_values_languages_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "' and language_id = '" . (int)$lid . "'";
+
+ $attribute_values_languages_values = tep_db_query($attribute_values_languages_query);
+
+ $attribute_values_languages = tep_db_fetch_array($attribute_values_languages_values);
+
+ $row['v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid] = $attribute_values_languages['products_options_values_name'];
+ }
+
+ $attribute_values_count++;
+ }
+
+ $attribute_options_count++;
+ }
+ }
+ // VJ product attribs end
+
+ // this is for the separate price per customer module
+ if (isset($filelayout['v_customer_price_1'])){
+ $sql2 = "SELECT
+ customers_group_price,
+ customers_group_id
+ FROM
+ ".TABLE_PRODUCTS_GROUPS."
+ WHERE
+ products_id = " . $row['v_products_id'] . "
+ ORDER BY
+ customers_group_id"
+ ;
+ $result2 = tep_db_query($sql2);
+ $ll = 1;
+ $row2 = tep_db_fetch_array($result2);
+ while( $row2 ){
+ $row['v_customer_group_id_' . $ll] = $row2['customers_group_id'];
+ $row['v_customer_price_' . $ll] = $row2['customers_group_price'];
+ $row2 = tep_db_fetch_array($result2);
+ $ll++;
+ }
+ }
+ if ($dltype == 'froogle'){
+ // For froogle, we check the specials prices for any applicable specials, and use that price
+ // by grabbing the specials id descending, we always get the most recently added special price
+ // I'm checking status because I think you can turn off specials
+ $sql2 = "SELECT
+ specials_new_products_price
+ FROM
+ ".TABLE_SPECIALS."
+ WHERE
+ products_id = " . $row['v_products_id'] . " and
+ status = 1 and
+ expires_date < CURRENT_TIMESTAMP
+ ORDER BY
+ specials_id DESC"
+ ;
+ $result2 = tep_db_query($sql2);
+ $ll = 1;
+ $row2 = tep_db_fetch_array($result2);
+ if( $row2 ){
+ // reset the products price to our special price if there is one for this product
+ $row['v_products_price'] = $row2['specials_new_products_price'];
+ }
+ }
+
+ //elari -
+ //We check the value of tax class and title instead of the id
+ //Then we add the tax to price if $price_with_tax is set to 1
+ $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']);
+ $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']);
+ $row['v_products_price'] = round($row['v_products_price'] +
+ ($price_with_tax * $row['v_products_price'] * $row_tax_multiplier / 100),2);
+
+
+ // Now set the status to a word the user specd in the config vars
+ if ( $row['v_status'] == '1' ){
+ $row['v_status'] = $active;
+ } else {
+ $row['v_status'] = $inactive;
+ }
+
+ // remove any bad things in the texts that could confuse EasyPopulate
+ $therow = '';
+ foreach( $filelayout as $key => $value ){
+ //echo "The field was $key ";
+
+ $thetext = $row[$key];
+ // kill the carriage returns and tabs in the descriptions, they're killing me!
+ if ($preserve_tabs_cr_lf == false || $dltype == 'froogle') {
+ $thetext = str_replace("\r",' ',$thetext);
+ $thetext = str_replace("\n",' ',$thetext);
+ $thetext = str_replace("\t",' ',$thetext);
+ }
+ if ($excel_safe_output == true && $dltype != 'froogle') {
+ // use quoted values and escape the embedded quotes for excel safe output.
+ $therow .= '"'.str_replace('"','""',$thetext).'"' . $separator;
+ } else {
+ // and put the text into the output separated by $separator defined above
+ $therow .= $thetext . $separator;
+ }
+ }
+
+ // lop off the trailing tab, then append the end of row indicator
+ $therow = substr($therow,0,strlen($therow)-1) . $endofrow;
+
+ if ($download == 'activestream'){
+ echo $therow;
+ } else {
+ $filestring .= $therow;
+ }
+ // grab the next row from the db
+ $row = tep_db_fetch_array($result);
+ }
+
+ // now either stream it to them or put it in the temp directory
+ if ($download == 'activestream'){
+ die();
+ } elseif ($download == 'stream'){
+ //*******************************
+ // STREAM FILE
+ //*******************************
+ header("Content-type: application/vnd.ms-excel");
+ header("Content-disposition: attachment; filename=$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".txt"));
+ // Changed if using SSL, helps prevent program delay/timeout (add to backup.php also)
+ // header("Pragma: no-cache");
+ if ($request_type== 'NONSSL'){
+ header("Pragma: no-cache");
+ } else {
+ header("Pragma: ");
+ }
+ header("Expires: 0");
+ echo $filestring;
+ die();
+ } elseif ($download == 'tempfile') {
+ //*******************************
+ // PUT FILE IN TEMP DIR
+ //*******************************
+ $tmpfname = $tempdir . "$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".txt");
+ //unlink($tmpfname);
+ $fp = fopen( $tmpfname, "w+");
+ fwrite($fp, $filestring);
+ fclose($fp);
+ echo "You can get your file in the Tools/File Manager here: " . $tempdir . "EP" . $EXPORT_TIME . (($excel_safe_output == true)?".csv":".txt");
+ die();
+ }
+} // *** END *** download section
+?>
+
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+";
+ echo "File uploaded. ";
+ echo "Temporary filename: " . $usrfl . " ";
+ echo "User filename: " . $usrfl_name . " ";
+ echo "Size: " . $usrfl_size . " ";
+
+ // get the entire file into an array
+ $readed = file($tempdir . $usrfl_name);
+ }
+ if ($localfile){
+ // move the file to where we can work with it
+ $file = tep_get_uploaded_file('usrfl');
+
+ $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id";
+ $attribute_options_values = tep_db_query($attribute_options_query);
+ $attribute_options_count = 1;
+ //while ($attribute_options = tep_db_fetch_array($attribute_options_values)){
+
+ if (is_uploaded_file($file['tmp_name'])) {
+ tep_copy_uploaded_file($file, $tempdir);
+ }
+
+ echo "
";
+ echo "Filename: " . $localfile . " ";
+
+ // get the entire file into an array
+ $readed = file($tempdir . $localfile);
+ }
+
+ if ($excel_safe_output == true) {
+ // do excel safe input
+ unset($readed); // kill array setup with above code
+ $readed = array(); // start a new one for excel_safe_output
+ $fp = fopen($tempdir . ($usrfl?$usrfl_name:$localfile),'r') or die('##Can not open CSV file for reading. Script will terminate. '); // open file
+ while($line = fgetcsv($fp,32768,$separator)) // read new line (max 32K bytes)
+ {
+ unset($line[(sizeof($line)-1)]); // remove EOREOR at the end of the array
+ $readed[] = $line; // add to array we will process later
+ }
+ $theheaders_array = $readed[0]; // pull out header line
+ fclose($fp); // close file
+
+ } else {
+ // do normal EP input
+ // now we string the entire thing together in case there were carriage returns in the data
+ $newreaded = "";
+ foreach ($readed as $read){
+ $newreaded .= $read;
+ }
+
+ // now newreaded has the entire file together without the carriage returns.
+ // if for some reason excel put qoutes around our EOREOR, remove them then split into rows
+ $newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded);
+ $readed = explode( $separator . 'EOREOR',$newreaded);
+
+ // Now we'll populate the filelayout based on the header row.
+ $theheaders_array = explode( $separator, $readed[0] ); // explode the first row, it will be our filelayout
+ }
+
+ $lll = 0;
+ $filelayout = array();
+ foreach( $theheaders_array as $header ){
+ $cleanheader = str_replace( '"', '', $header);
+ // echo "Fileheader was $header ";
+ $filelayout[ $cleanheader ] = $lll++; //
+ }
+ unset($readed[0]); // we don't want to process the headers with the data
+
+ // now we've got the array broken into parts by the expicit end-of-row marker.
+ array_walk($readed, 'walk');
+
+}
+
+if (is_uploaded_file($usrfl) && $split==1) {
+ //*******************************
+ //*******************************
+ // UPLOAD AND SPLIT FILE
+ //*******************************
+ //*******************************
+ // move the file to where we can work with it
+ $file = tep_get_uploaded_file('usrfl');
+ //echo "Trying to move file...";
+ if (is_uploaded_file($file['tmp_name'])) {
+ tep_copy_uploaded_file($file, $tempdir);
+ }
+
+ $infp = fopen($tempdir . $usrfl_name, "r");
+
+ //toprow has the field headers
+ $toprow = fgets($infp,32768);
+
+ $filecount = 1;
+
+ echo "Creating file EP_Split" . $filecount . ".txt ... ";
+ $tmpfname = $tempdir . "EP_Split" . $filecount . ".txt";
+ $fp = fopen( $tmpfname, "w+");
+ fwrite($fp, $toprow);
+
+ $linecount = 0;
+ $line = fgets($infp,32768);
+ while ($line){
+ // walking the entire file one row at a time
+ // but a line is not necessarily a complete row, we need to split on rows that have "EOREOR" at the end
+ $line = str_replace('"EOREOR"', 'EOREOR', $line);
+ fwrite($fp, $line);
+ if (strpos($line, 'EOREOR')){
+ // we found the end of a line of data, store it
+ $linecount++; // increment our line counter
+ if ($linecount >= $maxrecs){
+ echo "Added $linecount records and closing file... ";
+ $linecount = 0; // reset our line counter
+ // close the existing file and open another;
+ fclose($fp);
+ // increment filecount
+ $filecount++;
+ echo "Creating file EP_Split" . $filecount . ".txt ... ";
+ $tmpfname = $tempdir . "EP_Split" . $filecount . ".txt";
+ //Open next file name
+ $fp = fopen( $tmpfname, "w+");
+ fwrite($fp, $toprow);
+ }
+ }
+ $line=fgets($infp,32768);
+ }
+ echo "Added $linecount records and closing file... ";
+ fclose($fp);
+ fclose($infp);
+
+ echo "You can download your split files in the Tools/Files under " . $tempdir;
+
+}
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+ Export EP or Froogle Products File
+
+
+
+ array( "id" => 'activestream', 'text' => 'Download on-the-fly' ), 1 => array( "id" => 'stream', 'text' => 'Create then Download' ), 2 => array( "id" => 'tempfile', 'text' => 'Create in Temp Dir' )));
+ echo ' a ' . tep_draw_pull_down_menu('dltype',array( 0 => array( "id" => 'full', 'text' => 'Complete' ), 1 => array( "id" => 'custom', 'text' => 'Custom' ), 2 => array( "id" => 'priceqty', 'text' => 'Price/Qty' ), 3 => array( "id" => 'catagory', 'text' => 'Categories' ), 4 => array( "id" => 'attrib', 'text' => 'Attributes' ), 5 => array( "id" => 'froogle', 'text' => 'Froogle' )),'custom','onChange="return switchForm(this);"');
+ echo ' ' . (($excel_safe_output == true)?".csv":".txt") . ' file (model number is always included).';
+
+ $cells = array();
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_name', 'show', true) . ' name' . '
');
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_description', 'show', (!empty($_GET['epcust_description'])?true:false)) . ' description' . '
');
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_url', 'show', (!empty($_GET['epcust_url'])?true:false)) . ' url' . '
');
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_image', 'show', (!empty($_GET['epcust_image'])?true:false)) . ' image' . '
');
+ if ($products_with_attributes == true) {
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_attributes', 'show', (!empty($_GET['epcust_attributes'])?true:false)) . ' attributes' . '
');
+ }
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_category', 'show', (!empty($_GET['epcust_category'])?true:false)) . ' categories' . '
');
+ $cells[0][] = array('text' => '' . tep_draw_checkbox_field('epcust_manufacturer', 'show', (!empty($_GET['epcust_manufacturer'])?true:false)) . ' manufacturer' . '
');
+
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_price', 'show', true) . ' price' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_quantity', 'show', (!empty($_GET['epcust_quantity'])?true:false)) . ' quantity' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_weight', 'show', (!empty($_GET['epcust_weight'])?true:false)) . ' weight' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_tax_class', 'show', (!empty($_GET['epcust_tax_class'])?true:false)) . ' tax class' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_avail', 'show', (!empty($_GET['epcust_avail'])?true:false)) . ' available' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_date_added', 'show', (!empty($_GET['epcust_date_added'])?true:false)) . ' date added' . '
');
+ $cells[1][] = array('text' => '' . tep_draw_checkbox_field('epcust_status', 'show', (!empty($_GET['epcust_status'])?true:false)) . ' status' . '
');
+
+ $bigbox = new epbox('',false);
+ $bigbox->table_parameters = 'id="customtable" style="border: 1px solid #CCCCCC; padding: 2px; margin: 3px;"';
+ echo $bigbox->output($cells);
+
+ $manufacturers_array = array();
+ $manufacturers_array[] = array( "id" => '', 'text' => '- manufacturer -' );
+ $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
+ while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
+ $manufacturers_array[] = array( "id" => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name'] );
+ }
+
+ $status_array = array(array( "id" => '', 'text' => '- status -' ),array( "id" => '1', 'text' => 'active' ),array( "id" => '0', 'text' => 'disabled' ));
+
+ echo 'filter by: ' . tep_draw_pull_down_menu('epcust_category_filter', array_merge(array( 0 => array( "id" => '', 'text' => '- category -' )), tep_get_category_tree()));
+ echo ' ' . tep_draw_pull_down_menu('epcust_manufacturer_filter', $manufacturers_array) . ' ';
+ echo ' ' . tep_draw_pull_down_menu('epcust_status_filter', $status_array) . ' ';
+
+ echo tep_draw_input_field('submit', 'Build File', ' style="padding: 0px"', false, 'submit');
+ ?>
+
+
+
+
+ Quick Links
+
+
+
+
+
+ Settings
+
+ Temp Dir:
+
+ Split files on:
+ records
+ Model Num Size:
+
+ Price with tax:
+
+ Replace quotes:
+
+ Field seperator:
+
+ Excel safe output:
+
+ Preserve tab/cr/lf:
+
+ Category depth:
+
+ Enable attributes:
+
+ SEF Froogle URLS:
+
+
+
+ Please see the manual in this contribution's package for help in changing these settings.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $ep_languages['languages_id'],
+ 'code' => $ep_languages['code']
+ );
+ }
+ return $ep_languages_array;
+};
+
+function tep_get_tax_class_rate($tax_class_id) {
+ $tax_multiplier = 0;
+ $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " WHERE tax_class_id = '" . $tax_class_id . "' GROUP BY tax_priority");
+ if (tep_db_num_rows($tax_query)) {
+ while ($tax = tep_db_fetch_array($tax_query)) {
+ $tax_multiplier += $tax['tax_rate'];
+ }
+ }
+ return $tax_multiplier;
+};
+
+function tep_get_tax_title_class_id($tax_class_title) {
+ $classes_query = tep_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'" );
+ $tax_class_array = tep_db_fetch_array($classes_query);
+ $tax_class_id = $tax_class_array['tax_class_id'];
+ return $tax_class_id ;
+}
+
+function print_el( $item2 ) {
+ echo " | " . substr(strip_tags($item2), 0, 10);
+};
+
+function print_el1( $item2 ) {
+ echo sprintf("| %'.4s ", substr(strip_tags($item2), 0, 80));
+};
+//////
+//////
+// ep_create_filelayout()
+///////////////////////////////////////
+function ep_create_filelayout($dltype){
+ global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders, $max_categories;
+ global $attribute_options_array;
+ // depending on the type of the download the user wanted, create a file layout for it.
+ $fieldmap = array(); // default to no mapping to change internal field names to external.
+
+ // build filters
+ $sql_filter = '';
+ if (!empty($_GET['epcust_category_filter'])) {
+ $sub_categories = array();
+ $categories_query_addition = 'ptoc.categories_id = ' . (int)$_GET['epcust_category_filter'] . '';
+ tep_get_sub_categories($sub_categories, $_GET['epcust_category_filter']);
+ foreach ($sub_categories AS $ckey => $category ) {
+ $categories_query_addition .= ' or ptoc.categories_id = ' . (int)$category . '';
+ }
+ $sql_filter .= ' and (' . $categories_query_addition . ')';
+ }
+ if ($_GET['epcust_manufacturer_filter']!='') {
+ $sql_filter .= ' and p.manufacturers_id = ' . (int)$_GET['epcust_manufacturer_filter'];
+ }
+ if ($_GET['epcust_status_filter']!='') {
+ $sql_filter .= ' and p.products_status = ' . (int)$_GET['epcust_status_filter'];
+ }
+
+ switch( $dltype ){
+ case 'full':
+ // The file layout is dynamically made depending on the number of languages
+ $iii = 0;
+ $filelayout = array(
+ 'v_products_model' => $iii++,
+ 'v_products_image' => $iii++,
+ );
+
+ foreach ($langcode as $key => $lang){
+ $l_id = $lang['id'];
+ // uncomment the head_title, head_desc, and head_keywords to use
+ // Linda's Header Tag Controller 2.0
+ // echo $langcode['id'] . $langcode['code'];
+ $filelayout = array_merge($filelayout , array(
+ 'v_products_name_' . $l_id => $iii++,
+ 'v_products_description_' . $l_id => $iii++,
+ 'v_products_url_' . $l_id => $iii++,
+ // 'v_products_head_title_tag_'.$l_id => $iii++,
+ // 'v_products_head_desc_tag_'.$l_id => $iii++,
+ // 'v_products_head_keywords_tag_'.$l_id => $iii++,
+ ));
+ }
+
+
+ // uncomment the customer_price and customer_group to support multi-price per product contrib
+
+ // VJ product attribs begin
+ $header_array = array(
+ 'v_products_price' => $iii++,
+ 'v_products_weight' => $iii++,
+ 'v_date_avail' => $iii++,
+ 'v_date_added' => $iii++,
+ 'v_products_quantity' => $iii++,
+ );
+
+ $languages = tep_get_languages();
+
+ $attribute_options_count = 1;
+ foreach ($attribute_options_array as $attribute_options_values) {
+ $key1 = 'v_attribute_options_id_' . $attribute_options_count;
+ $header_array[$key1] = $iii++;
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $l_id = $languages[$i]['id'];
+ $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id;
+ $header_array[$key2] = $iii++;
+ }
+
+ $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id";
+ $attribute_values_values = tep_db_query($attribute_values_query);
+
+ $attribute_values_count = 1;
+ while ($attribute_values = tep_db_fetch_array($attribute_values_values)) {
+ $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key3] = $iii++;
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $l_id = $languages[$i]['id'];
+ $key4 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id;
+ $header_array[$key4] = $iii++;
+ }
+
+ $key5 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key5] = $iii++;
+
+ //// attributes stock add start
+ if ( $products_attributes_stock == true ) {
+ $key6 = 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key6] = $iii++;
+ }
+ //// attributes stock add end
+
+ $attribute_values_count++;
+ }
+
+ $attribute_options_count++;
+ }
+ // VJ product attribs end
+
+ $header_array['v_manufacturers_name'] = $iii++;
+
+ $filelayout = array_merge($filelayout, $header_array);
+
+ // build the categories name section of the array based on the number of categores the user wants to have
+ for($i=1;$i<$max_categories+1;$i++){
+ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++));
+ }
+
+ $filelayout = array_merge($filelayout, array(
+ 'v_tax_class_title' => $iii++,
+ 'v_status' => $iii++,
+ ));
+
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ p.products_image as v_products_image,
+ p.products_price as v_products_price,
+ p.products_weight as v_products_weight,
+ p.products_date_available as v_date_avail,
+ p.products_date_added as v_date_added,
+ p.products_tax_class_id as v_tax_class_id,
+ p.products_quantity as v_products_quantity,
+ p.manufacturers_id as v_manufacturers_id,
+ subc.categories_id as v_categories_id,
+ p.products_status as v_status
+ FROM
+ ".TABLE_PRODUCTS." as p,
+ ".TABLE_CATEGORIES." as subc,
+ ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
+ WHERE
+ p.products_id = ptoc.products_id AND
+ ptoc.categories_id = subc.categories_id
+ " . $sql_filter;
+
+ break;
+ case 'priceqty':
+ $iii = 0;
+ // uncomment the customer_price and customer_group to support multi-price per product contrib
+ $filelayout = array(
+ 'v_products_model' => $iii++,
+ 'v_products_price' => $iii++,
+ 'v_products_quantity' => $iii++,
+ #'v_customer_price_1' => $iii++,
+ #'v_customer_group_id_1' => $iii++,
+ #'v_customer_price_2' => $iii++,
+ #'v_customer_group_id_2' => $iii++,
+ #'v_customer_price_3' => $iii++,
+ #'v_customer_group_id_3' => $iii++,
+ #'v_customer_price_4' => $iii++,
+ #'v_customer_group_id_4' => $iii++,
+ );
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ p.products_price as v_products_price,
+ p.products_tax_class_id as v_tax_class_id,
+ p.products_quantity as v_products_quantity
+ FROM
+ ".TABLE_PRODUCTS." as p
+ ";
+ break;
+
+ case 'custom':
+ $iii = 0;
+ $filelayout = array( 'v_products_model' => $iii++ );
+ if (!empty($_GET['epcust_upc'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_upc' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_status'])) {
+ $filelayout = array_merge($filelayout , array( 'v_status' => $iii++ ));
+ }
+
+ foreach ($langcode as $key => $lang){
+ $l_id = $lang['id'];
+ if (!empty($_GET['epcust_name'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_name_' . $l_id => $iii++ ));
+ }
+ if (!empty($_GET['epcust_description'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_description_' . $l_id => $iii++ ));
+ }
+ if (!empty($_GET['epcust_url'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_url_' . $l_id => $iii++ ));
+ }
+ }
+
+ if (!empty($_GET['epcust_image'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_image' => $iii++ ));
+ }
+
+ if (!empty($_GET['epcust_shopping_sites'])) {
+ foreach($shopping_sites as $skey => $shopping_site ) {
+ $filelayout = array_merge($filelayout , array(
+ 'v_shopping_sites_' . strtolower( str_replace(array(' ','.','/','_','-','\''), array('','','','','',''), $shopping_site['shopping_sites_title']) ) => $iii++
+ ));
+ }
+ }
+
+ if (!empty($_GET['epcust_attributes'])) {
+ // VJ product attribs begin
+ $languages = tep_get_languages();
+
+ $attribute_options_count = 1;
+ foreach ($attribute_options_array as $attribute_options_values) {
+ $filelayout = array_merge($filelayout , array( 'v_attribute_options_id_' . $attribute_options_count => $iii++ ));
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $filelayout = array_merge($filelayout , array( 'v_attribute_options_name_' . $attribute_options_count . '_' . $languages[$i]['id'] => $iii++ ));
+ }
+
+ $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id";
+ $attribute_values_values = tep_db_query($attribute_values_query);
+
+ $attribute_values_count = 1;
+ while ($attribute_values = tep_db_fetch_array($attribute_values_values)) {
+ $filelayout = array_merge($filelayout , array( 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ ));
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $filelayout = array_merge($filelayout , array( 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $languages[$i]['id'] => $iii++ ));
+ }
+ $filelayout = array_merge($filelayout , array( 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ ));
+ //// attributes stock add start
+ if ( $products_attributes_stock == true ) {
+ $filelayout = array_merge($filelayout , array( 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ ));
+ }
+ //// attributes stock add end
+ $attribute_values_count++;
+ }
+ $attribute_options_count++;
+ }
+ // VJ product attribs end
+ }
+ if (!empty($_GET['epcust_price'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_price' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_cost'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_cost' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_quantity'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_quantity' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_weight'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_weight' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_date_added'])) {
+ $filelayout = array_merge($filelayout , array( 'v_date_added' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_avail'])) {
+ $filelayout = array_merge($filelayout , array( 'v_date_avail' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_manufacturer'])) {
+ $filelayout = array_merge($filelayout , array( 'v_manufacturers_name' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_category'])) {
+ // build the categories name section of the array based on the number of categores the user wants to have
+ for($i=1;$i<$max_categories+1;$i++){
+ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++));
+ }
+ }
+ if (!empty($_GET['epcust_tax_class'])) {
+ $filelayout = array_merge($filelayout , array( 'v_tax_class_title' => $iii++ ));
+ }
+ if (!empty($_GET['epcust_comment'])) {
+ $filelayout = array_merge($filelayout , array( 'v_products_comment' => $iii++ ));
+ }
+
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ p.products_status as v_status,
+ p.products_price as v_products_price,
+ p.products_quantity as v_products_quantity,
+ p.products_weight as v_products_weight,
+ p.products_image as v_products_image,
+ p.manufacturers_id as v_manufacturers_id,
+ p.products_date_available as v_date_avail,
+ p.products_date_added as v_date_added,
+ p.products_tax_class_id as v_tax_class_id,
+ subc.categories_id as v_categories_id
+ FROM
+ ".TABLE_PRODUCTS." as p,
+ ".TABLE_CATEGORIES." as subc,
+ ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
+ WHERE
+ p.products_id = ptoc.products_id AND
+ ptoc.categories_id = subc.categories_id
+ " . $sql_filter;
+ break;
+
+ case 'category':
+ // The file layout is dynamically made depending on the number of languages
+ $iii = 0;
+ $filelayout = array(
+ 'v_products_model' => $iii++,
+ );
+
+ // build the categories name section of the array based on the number of categores the user wants to have
+ for($i=1;$i<$max_categories+1;$i++){
+ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++));
+ }
+
+
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ subc.categories_id as v_categories_id
+ FROM
+ ".TABLE_PRODUCTS." as p,
+ ".TABLE_CATEGORIES." as subc,
+ ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
+ WHERE
+ p.products_id = ptoc.products_id AND
+ ptoc.categories_id = subc.categories_id
+ ";
+ break;
+
+ case 'froogle':
+ // this is going to be a little interesting because we need
+ // a way to map from internal names to external names
+ //
+ // Before it didn't matter, but with froogle needing particular headers,
+ // The file layout is dynamically made depending on the number of languages
+ $iii = 0;
+ $filelayout = array(
+ 'v_froogle_products_url_1' => $iii++,
+ );
+ //
+ // here we need to get the default language and put
+ $l_id = 1; // dummy it in for now.
+// foreach ($langcode as $key => $lang){
+// $l_id = $lang['id'];
+ $filelayout = array_merge($filelayout , array(
+ 'v_froogle_products_name_' . $l_id => $iii++,
+ 'v_froogle_products_description_' . $l_id => $iii++,
+ ));
+// }
+ $filelayout = array_merge($filelayout , array(
+ 'v_products_price' => $iii++,
+ 'v_products_fullpath_image' => $iii++,
+ 'v_category_fullpath' => $iii++,
+ 'v_froogle_offer_id' => $iii++,
+ 'v_froogle_instock' => $iii++,
+ 'v_froogle_ shipping' => $iii++,
+ 'v_manufacturers_name' => $iii++,
+ 'v_froogle_ upc' => $iii++,
+ 'v_froogle_color' => $iii++,
+ 'v_froogle_size' => $iii++,
+ 'v_froogle_quantitylevel' => $iii++,
+ 'v_froogle_product_id' => $iii++,
+ 'v_froogle_manufacturer_id' => $iii++,
+ 'v_froogle_exp_date' => $iii++,
+ 'v_froogle_product_type' => $iii++,
+ 'v_froogle_delete' => $iii++,
+ 'v_froogle_currency' => $iii++,
+ ));
+ $iii=0;
+ $fileheaders = array(
+ 'product_url' => $iii++,
+ 'name' => $iii++,
+ 'description' => $iii++,
+ 'price' => $iii++,
+ 'image_url' => $iii++,
+ 'category' => $iii++,
+ 'offer_id' => $iii++,
+ 'instock' => $iii++,
+ 'shipping' => $iii++,
+ 'brand' => $iii++,
+ 'upc' => $iii++,
+ 'color' => $iii++,
+ 'size' => $iii++,
+ 'quantity' => $iii++,
+ 'product_id' => $iii++,
+ 'manufacturer_id' => $iii++,
+ 'exp_date' => $iii++,
+ 'product_type' => $iii++,
+ 'delete' => $iii++,
+ 'currency' => $iii++,
+ );
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ p.products_image as v_products_image,
+ p.products_price as v_products_price,
+ p.products_weight as v_products_weight,
+ p.products_date_added as v_date_avail,
+ p.products_tax_class_id as v_tax_class_id,
+ p.products_quantity as v_products_quantity,
+ p.manufacturers_id as v_manufacturers_id,
+ subc.categories_id as v_categories_id
+ FROM
+ ".TABLE_PRODUCTS." as p,
+ ".TABLE_CATEGORIES." as subc,
+ ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
+ WHERE
+ p.products_id = ptoc.products_id AND
+ ptoc.categories_id = subc.categories_id
+ " . $sql_filter;
+ break;
+
+// VJ product attributes begin
+ case 'attrib':
+ $iii = 0;
+ $filelayout = array(
+ 'v_products_model' => $iii++
+ );
+
+ $header_array = array();
+
+ $languages = tep_get_languages();
+
+ global $attribute_options_array;
+
+ $attribute_options_count = 1;
+ foreach ($attribute_options_array as $attribute_options_values) {
+ $key1 = 'v_attribute_options_id_' . $attribute_options_count;
+ $header_array[$key1] = $iii++;
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $l_id = $languages[$i]['id'];
+
+ $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id;
+ $header_array[$key2] = $iii++;
+ }
+
+ $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id";
+
+ $attribute_values_values = tep_db_query($attribute_values_query);
+
+ $attribute_values_count = 1;
+ while ($attribute_values = tep_db_fetch_array($attribute_values_values)) {
+ $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key3] = $iii++;
+
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $l_id = $languages[$i]['id'];
+
+ $key4 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id;
+ $header_array[$key4] = $iii++;
+ }
+
+ $key5 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key5] = $iii++;
+
+//// attributes stock add start
+ if ( $products_attributes_stock == true ) {
+ $key6 = 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count;
+ $header_array[$key6] = $iii++;
+ }
+//// attributes stock add end
+
+ $attribute_values_count++;
+ }
+
+ $attribute_options_count++;
+ }
+
+ $filelayout = array_merge($filelayout, $header_array);
+
+ $filelayout_sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model
+ FROM
+ ".TABLE_PRODUCTS." as p
+ ";
+
+ break;
+// VJ product attributes end
+ }
+ $filelayout_count = count($filelayout);
+
+}
+
+//////
+//////
+// walk()
+///////////////////////////////////////
+function walk( $item1 ) {
+ global $filelayout, $filelayout_count, $modelsize;
+ global $active, $inactive, $langcode, $default_these, $deleteit, $zero_qty_inactive;
+ global $epdlanguage_id, $price_with_tax, $replace_quotes;
+ global $default_images, $default_image_manufacturer, $default_image_product, $default_image_category;
+ global $separator, $max_categories;
+ global $excel_safe_output;
+ // first we clean up the row of data
+
+
+ if ($excel_safe_output == true) {
+ $items = $item1;
+ } else {
+ // chop blanks from each end
+ $item1 = ltrim(rtrim($item1));
+
+ // blow it into an array, splitting on the tabs
+ $items = explode($separator, $item1);
+ }
+
+ // make sure all non-set things are set to '';
+ // and strip the quotes from the start and end of the stings.
+ // escape any special chars for the database.
+ foreach( $filelayout as $key=> $value){
+ $i = $filelayout[$key];
+ if (isset($items[$i]) == false) {
+ $items[$i]='';
+ } else {
+ // Check to see if either of the magic_quotes are turned on or off;
+ // And apply filtering accordingly.
+ if (function_exists('ini_get')) {
+ //echo "Getting ready to check magic quotes ";
+ if (ini_get('magic_quotes_runtime') == 1){
+ // The magic_quotes_runtime are on, so lets account for them
+ // check if the last character is a quote;
+ // if it is, chop off the quotes.
+ if (substr($items[$i],-1) == '"'){
+ $items[$i] = substr($items[$i],2,strlen($items[$i])-4);
+ }
+ // now any remaining doubled double quotes should be converted to one doublequote
+ $items[$i] = str_replace('\"\"',""",$items[$i]);
+ if ($replace_quotes){
+ $items[$i] = str_replace('\"',""",$items[$i]);
+ $items[$i] = str_replace("\'","'",$items[$i]);
+ }
+ } else { // no magic_quotes are on
+ // check if the last character is a quote;
+ // if it is, chop off the 1st and last character of the string.
+ if (substr($items[$i],-1) == '"'){
+ $items[$i] = substr($items[$i],1,strlen($items[$i])-2);
+ }
+ // now any remaining doubled double quotes should be converted to one doublequote
+ $items[$i] = str_replace('""',""",$items[$i]);
+ if ($replace_quotes){
+ $items[$i] = str_replace('"',""",$items[$i]);
+ $items[$i] = str_replace("'","'",$items[$i]);
+ }
+ }
+ }
+ }
+ }
+/*
+ if ( $items['v_status'] == $deleteit ){
+ // they want to delete this product.
+ echo "Deleting product " . $items['v_products_model'] . " from the database ";
+ // Get the ID
+
+ // kill in the products_to_categories
+
+ // Kill in the products table
+
+ return; // we're done deleteing!
+ }
+*/
+ // now do a query to get the record's current contents
+ $sql = "SELECT
+ p.products_id as v_products_id,
+ p.products_model as v_products_model,
+ p.products_image as v_products_image,
+ p.products_price as v_products_price,
+ p.products_weight as v_products_weight,
+ p.products_date_added as v_date_avail,
+ p.products_tax_class_id as v_tax_class_id,
+ p.products_quantity as v_products_quantity,
+ p.manufacturers_id as v_manufacturers_id,
+ subc.categories_id as v_categories_id
+ FROM
+ ".TABLE_PRODUCTS." as p,
+ ".TABLE_CATEGORIES." as subc,
+ ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
+ WHERE
+ p.products_id = ptoc.products_id AND
+ p.products_model = '" . $items[$filelayout['v_products_model']] . "' AND
+ ptoc.categories_id = subc.categories_id
+ ";
+
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+
+
+ while ($row){
+ // OK, since we got a row, the item already exists.
+ // Let's get all the data we need and fill in all the fields that need to be defaulted to the current values
+ // for each language, get the description and set the vals
+ foreach ($langcode as $key => $lang){
+ //echo "Inside defaulting loop";
+ //echo "key is $key ";
+ //echo "langid is " . $lang['id'] . " ";
+// $sql2 = "SELECT products_name, products_description
+// FROM ".TABLE_PRODUCTS_DESCRIPTION."
+// WHERE
+// products_id = " . $row['v_products_id'] . " AND
+// language_id = '" . $lang['id'] . "'
+// ";
+ $sql2 = "SELECT *
+ FROM ".TABLE_PRODUCTS_DESCRIPTION."
+ WHERE
+ products_id = " . $row['v_products_id'] . " AND
+ language_id = '" . $lang['id'] . "'
+ ";
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+ // Need to report from ......_name_1 not ..._name_0
+ $row['v_products_name_' . $lang['id']] = $row2['products_name'];
+ $row['v_products_description_' . $lang['id']] = $row2['products_description'];
+ $row['v_products_url_' . $lang['id']] = $row2['products_url'];
+
+ // support for Linda's Header Controller 2.0 here
+ if(isset($filelayout['v_products_head_title_tag_' . $lang['id'] ])){
+ $row['v_products_head_title_tag_' . $lang['id']] = $row2['products_head_title_tag'];
+ $row['v_products_head_desc_tag_' . $lang['id']] = $row2['products_head_desc_tag'];
+ $row['v_products_head_keywords_tag_' . $lang['id']] = $row2['products_head_keywords_tag'];
+ }
+ // end support for Header Controller 2.0
+ }
+
+ // start with v_categories_id
+ // Get the category description
+ // set the appropriate variable name
+ // if parent_id is not null, then follow it up.
+ $thecategory_id = $row['v_categories_id'];
+
+ for( $categorylevel=1; $categorylevel<$max_categories+1; $categorylevel++){
+ if ($thecategory_id){
+ $sql2 = "SELECT categories_name
+ FROM ".TABLE_CATEGORIES_DESCRIPTION."
+ WHERE
+ categories_id = " . $thecategory_id . " AND
+ language_id = " . $epdlanguage_id ;
+
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+ // only set it if we found something
+ $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name'];
+ // now get the parent ID if there was one
+ $sql3 = "SELECT parent_id
+ FROM ".TABLE_CATEGORIES."
+ WHERE
+ categories_id = " . $thecategory_id;
+ $result3 = tep_db_query($sql3);
+ $row3 = tep_db_fetch_array($result3);
+ $theparent_id = $row3['parent_id'];
+ if ($theparent_id != ''){
+ // there was a parent ID, lets set thecategoryid to get the next level
+ $thecategory_id = $theparent_id;
+ } else {
+ // we have found the top level category for this item,
+ $thecategory_id = false;
+ }
+ } else {
+ $temprow['v_categories_name_' . $categorylevel] = '';
+ }
+ }
+ // temprow has the old style low to high level categories.
+ $newlevel = 1;
+ // let's turn them into high to low level categories
+ for( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel--){
+ if ($temprow['v_categories_name_' . $categorylevel] != ''){
+ $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel];
+ }
+ }
+
+ if ($row['v_manufacturers_id'] != ''){
+ $sql2 = "SELECT manufacturers_name
+ FROM ".TABLE_MANUFACTURERS."
+ WHERE
+ manufacturers_id = " . $row['v_manufacturers_id']
+ ;
+ $result2 = tep_db_query($sql2);
+ $row2 = tep_db_fetch_array($result2);
+ $row['v_manufacturers_name'] = $row2['manufacturers_name'];
+ }
+
+ //elari -
+ //We check the value of tax class and title instead of the id
+ //Then we add the tax to price if $price_with_tax is set to true
+ $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']);
+ $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']);
+ if ($price_with_tax){
+ $row['v_products_price'] = round($row['v_products_price'] + ($row['v_products_price'] * $row_tax_multiplier / 100),2);
+ }
+
+ // now create the internal variables that will be used
+ // the $$thisvar is on purpose: it creates a variable named what ever was in $thisvar and sets the value
+ foreach ($default_these as $thisvar){
+ $$thisvar = $row[$thisvar];
+ }
+
+ $row = tep_db_fetch_array($result);
+ }
+
+ // this is an important loop. What it does is go thru all the fields in the incoming file and set the internal vars.
+ // Internal vars not set here are either set in the loop above for existing records, or not set at all (null values)
+ // the array values are handled separatly, although they will set variables in this loop, we won't use them.
+ foreach( $filelayout as $key => $value ){
+ $$key = $items[ $value ];
+ }
+
+ // so how to handle these? we shouldn't built the array unless it's been giving to us.
+ // The assumption is that if you give us names and descriptions, then you give us name and description for all applicable languages
+ foreach ($langcode as $lang){
+ //echo "Langid is " . $lang['id'] . " ";
+ $l_id = $lang['id'];
+ if (isset($filelayout['v_products_name_' . $l_id ])){
+ //we set dynamically the language values
+ $v_products_name[$l_id] = $items[$filelayout['v_products_name_' . $l_id]];
+ $v_products_description[$l_id] = $items[$filelayout['v_products_description_' . $l_id ]];
+ $v_products_url[$l_id] = $items[$filelayout['v_products_url_' . $l_id ]];
+ // support for Linda's Header Controller 2.0 here
+ if(isset($filelayout['v_products_head_title_tag_' . $l_id])){
+ $v_products_head_title_tag[$l_id] = $items[$filelayout['v_products_head_title_tag_' . $l_id]];
+ $v_products_head_desc_tag[$l_id] = $items[$filelayout['v_products_head_desc_tag_' . $l_id]];
+ $v_products_head_keywords_tag[$l_id] = $items[$filelayout['v_products_head_keywords_tag_' . $l_id]];
+ }
+ // end support for Header Controller 2.0
+ }
+ }
+ //elari... we get the tax_clas_id from the tax_title
+ //on screen will still be displayed the tax_class_title instead of the id....
+ if ( isset( $v_tax_class_title) ){
+ $v_tax_class_id = tep_get_tax_title_class_id($v_tax_class_title);
+ }
+ //we check the tax rate of this tax_class_id
+ $row_tax_multiplier = tep_get_tax_class_rate($v_tax_class_id);
+
+ //And we recalculate price without the included tax...
+ //Since it seems display is made before, the displayed price will still include tax
+ //This is same problem for the tax_clas_id that display tax_class_title
+ if ($price_with_tax){
+ $v_products_price = round( $v_products_price / (1 + ( $row_tax_multiplier * $price_with_tax/100) ), 4);
+ }
+
+ // if they give us one category, they give us all 6 categories
+ unset ($v_categories_name); // default to not set.
+ if ( isset( $filelayout['v_categories_name_1'] ) ){
+ $newlevel = 1;
+ for( $categorylevel=6; $categorylevel>0; $categorylevel--){
+ if ( $items[$filelayout['v_categories_name_' . $categorylevel]] != ''){
+ $v_categories_name[$newlevel++] = $items[$filelayout['v_categories_name_' . $categorylevel]];
+ }
+ }
+ while( $newlevel < $max_categories+1){
+ $v_categories_name[$newlevel++] = ''; // default the remaining items to nothing
+ }
+ }
+
+ if (ltrim(rtrim($v_products_quantity)) == '') {
+ $v_products_quantity = 1;
+ }
+ if ($v_date_avail == '') {
+// $v_date_avail = "CURRENT_TIMESTAMP";
+ $v_date_avail = "NULL";
+ } else {
+ // we put the quotes around it here because we can't put them into the query, because sometimes
+ // we will use the "current_timestamp", which can't have quotes around it.
+ $v_date_avail = '"' . $v_date_avail . '"';
+ }
+
+ if ($v_date_added == '') {
+ $v_date_added = "CURRENT_TIMESTAMP";
+ } else {
+ // we put the quotes around it here because we can't put them into the query, because sometimes
+ // we will use the "current_timestamp", which can't have quotes around it.
+ $v_date_added = '"' . $v_date_added . '"';
+ }
+
+
+ // default the stock if they spec'd it or if it's blank
+ $v_db_status = '1'; // default to active
+ if ($v_status == $inactive){
+ // they told us to deactivate this item
+ $v_db_status = '0';
+ }
+ if ($zero_qty_inactive && $v_products_quantity == 0) {
+ // if they said that zero qty products should be deactivated, let's deactivate if the qty is zero
+ $v_db_status = '0';
+ }
+
+ if ($v_manufacturer_id==''){
+ $v_manufacturer_id="NULL";
+ }
+
+ if (trim($v_products_image)==''){
+ $v_products_image = $default_image_product;
+ }
+
+ if (strlen($v_products_model) > $modelsize ){
+ echo "" . strlen($v_products_model) . $v_products_model . "... ERROR! - Too many characters in the model number.
+ 12 is the maximum on a standard OSC install.
+ Your maximum product_model length is set to $modelsize
+ You can either shorten your model numbers or increase the size of the field in the database. ";
+ die();
+ }
+
+ // OK, we need to convert the manufacturer's name into id's for the database
+ if ( isset($v_manufacturers_name) && $v_manufacturers_name != '' ){
+ $sql = "SELECT man.manufacturers_id
+ FROM ".TABLE_MANUFACTURERS." as man
+ WHERE
+ man.manufacturers_name = '" . $v_manufacturers_name . "'";
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+ if ( $row != '' ){
+ foreach( $row as $item ){
+ $v_manufacturer_id = $item;
+ }
+ } else {
+ // to add, we need to put stuff in categories and categories_description
+ $sql = "SELECT MAX( manufacturers_id) max FROM ".TABLE_MANUFACTURERS;
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+ $max_mfg_id = $row['max']+1;
+ // default the id if there are no manufacturers yet
+ if (!is_numeric($max_mfg_id) ){
+ $max_mfg_id=1;
+ }
+
+ // Uncomment this query if you have an older 2.2 codebase
+ /*
+ $sql = "INSERT INTO ".TABLE_MANUFACTURERS."(
+ manufacturers_id,
+ manufacturers_name,
+ manufacturers_image
+ ) VALUES (
+ $max_mfg_id,
+ '$v_manufacturers_name',
+ '$default_image_manufacturer'
+ )";
+ */
+
+ // Comment this query out if you have an older 2.2 codebase
+ $sql = "INSERT INTO ".TABLE_MANUFACTURERS."(
+ manufacturers_id,
+ manufacturers_name,
+ manufacturers_image,
+ date_added,
+ last_modified
+ ) VALUES (
+ $max_mfg_id,
+ '$v_manufacturers_name',
+ '$default_image_manufacturer',
+ CURRENT_TIMESTAMP,
+ CURRENT_TIMESTAMP
+ )";
+ $result = tep_db_query($sql);
+ $v_manufacturer_id = $max_mfg_id;
+ }
+ }
+ // if the categories names are set then try to update them
+ if ( isset($v_categories_name_1)){
+ // start from the highest possible category and work our way down from the parent
+ $v_categories_id = 0;
+ $theparent_id = 0;
+ for ( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel-- ){
+ $thiscategoryname = $v_categories_name[$categorylevel];
+ if ( $thiscategoryname != ''){
+ // we found a category name in this field
+
+ // now the subcategory
+ $sql = "SELECT cat.categories_id
+ FROM ".TABLE_CATEGORIES." as cat,
+ ".TABLE_CATEGORIES_DESCRIPTION." as des
+ WHERE
+ cat.categories_id = des.categories_id AND
+ des.language_id = $epdlanguage_id AND
+ cat.parent_id = " . $theparent_id . " AND
+ des.categories_name = '" . $thiscategoryname . "'";
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+ if ( $row != '' ){
+ foreach( $row as $item ){
+ $thiscategoryid = $item;
+ }
+ } else {
+ // to add, we need to put stuff in categories and categories_description
+ $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES;
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+ $max_category_id = $row['max']+1;
+ if (!is_numeric($max_category_id) ){
+ $max_category_id=1;
+ }
+ $sql = "INSERT INTO ".TABLE_CATEGORIES."(
+ categories_id,
+ categories_image,
+ parent_id,
+ sort_order,
+ date_added,
+ last_modified
+ ) VALUES (
+ $max_category_id,
+ '$default_image_category',
+ $theparent_id,
+ 0,
+ CURRENT_TIMESTAMP
+ ,CURRENT_TIMESTAMP
+ )";
+ $result = tep_db_query($sql);
+ $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION."(
+ categories_id,
+ language_id,
+ categories_name
+ ) VALUES (
+ $max_category_id,
+ '$epdlanguage_id',
+ '$thiscategoryname'
+ )";
+ $result = tep_db_query($sql);
+ $thiscategoryid = $max_category_id;
+ }
+ // the current catid is the next level's parent
+ $theparent_id = $thiscategoryid;
+ $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later
+ }
+ }
+ }
+
+ if ($v_products_model != "") {
+ // products_model exists!
+ array_walk($items, 'print_el');
+
+ // First we check to see if this is a product in the current db.
+ $result = tep_db_query("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE (products_model = '". $v_products_model . "')");
+
+ if (tep_db_num_rows($result) == 0) {
+ // insert into products
+
+ $sql = "SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'";
+ $result = tep_db_query($sql);
+ $row = tep_db_fetch_array($result);
+ $max_product_id = $row['Auto_increment'];
+ if (!is_numeric($max_product_id) ){
+ $max_product_id=1;
+ }
+ $v_products_id = $max_product_id;
+ echo " !New Product! ";
+
+ $query = "INSERT INTO ".TABLE_PRODUCTS." (
+ products_image,
+ products_model,
+ products_price,
+ products_status,
+ products_last_modified,
+ products_date_added,
+ products_date_available,
+ products_tax_class_id,
+ products_weight,
+ products_quantity,
+ manufacturers_id)
+ VALUES (
+ '$v_products_image',";
+
+ // unmcomment these lines if you are running the image mods
+ /*
+ $query .= . $v_products_mimage . '", "'
+ . $v_products_bimage . '", "'
+ . $v_products_subimage1 . '", "'
+ . $v_products_bsubimage1 . '", "'
+ . $v_products_subimage2 . '", "'
+ . $v_products_bsubimage2 . '", "'
+ . $v_products_subimage3 . '", "'
+ . $v_products_bsubimage3 . '", "'
+ */
+
+ $query .=" '$v_products_model',
+ '$v_products_price',
+ '$v_db_status',
+ CURRENT_TIMESTAMP,
+ $v_date_added,
+ $v_date_avail,
+ '$v_tax_class_id',
+ '$v_products_weight',
+ '$v_products_quantity',
+ '$v_manufacturer_id')
+ ";
+ $result = tep_db_query($query);
+ } else {
+ // existing product, get the id from the query
+ // and update the product data
+ $row = tep_db_fetch_array($result);
+ $v_products_id = $row['products_id'];
+ echo " Updated ";
+ $row = tep_db_fetch_array($result);
+ $query = 'UPDATE '.TABLE_PRODUCTS.'
+ SET
+ products_price="'.$v_products_price.
+ '" ,products_image="'.$v_products_image;
+
+ // uncomment these lines if you are running the image mods
+/*
+ $query .=
+ '" ,products_mimage="'.$v_products_mimage.
+ '" ,products_bimage="'.$v_products_bimage.
+ '" ,products_subimage1="'.$v_products_subimage1.
+ '" ,products_bsubimage1="'.$v_products_bsubimage1.
+ '" ,products_subimage2="'.$v_products_subimage2.
+ '" ,products_bsubimage2="'.$v_products_bsubimage2.
+ '" ,products_subimage3="'.$v_products_subimage3.
+ '" ,products_bsubimage3="'.$v_products_bsubimage3;
+*/
+
+ $query .= '", products_weight="'.$v_products_weight .
+ '", products_tax_class_id="'.$v_tax_class_id .
+ '", products_date_available= ' . $v_date_avail .
+ ', products_date_added= ' . $v_date_added .
+ ', products_last_modified=CURRENT_TIMESTAMP
+ , products_quantity="' . $v_products_quantity .
+ '" ,manufacturers_id=' . $v_manufacturer_id .
+ ' , products_status=' . $v_db_status . '
+ WHERE
+ (products_id = "'. $v_products_id . '")';
+
+ $result = tep_db_query($query);
+ }
+
+ // the following is common in both the updating an existing product and creating a new product
+ if ( isset($v_products_name)){
+ foreach( $v_products_name as $key => $name){
+ if ($name!=''){
+ $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE
+ products_id = $v_products_id AND
+ language_id = " . $key;
+ $result = tep_db_query($sql);
+ if (tep_db_num_rows($result) == 0) {
+ // nope, this is a new product description
+ $result = tep_db_query($sql);
+ $sql =
+ "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."
+ (products_id,
+ language_id,
+ products_name,
+ products_description,
+ products_url)
+ VALUES (
+ '" . $v_products_id . "',
+ " . $key . ",
+ '". addslashes($name) . "',
+ '". addslashes($v_products_description[$key]) . "',
+ '". $v_products_url[$key] . "'
+ )";
+ // support for Linda's Header Controller 2.0
+ if (isset($v_products_head_title_tag)){
+ // override the sql if we're using Linda's contrib
+ $sql =
+ "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."
+ (products_id,
+ language_id,
+ products_name,
+ products_description,
+ products_url,
+ products_head_title_tag,
+ products_head_desc_tag,
+ products_head_keywords_tag)
+ VALUES (
+ '" . $v_products_id . "',
+ " . $key . ",
+ '". addslashes($name) . "',
+ '". addslashes($v_products_description[$key]) . "',
+ '". $v_products_url[$key] . "',
+ '". $v_products_head_title_tag[$key] . "',
+ '". $v_products_head_desc_tag[$key] . "',
+ '". $v_products_head_keywords_tag[$key] . "')";
+ }
+ // end support for Linda's Header Controller 2.0
+ $result = tep_db_query($sql);
+ } else {
+ // already in the description, let's just update it
+ $sql =
+ "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET
+ products_name='" . addslashes($name) . "',
+ products_description='" . addslashes($v_products_description[$key]) . "',
+ products_url='" . $v_products_url[$key] . "'
+ WHERE
+ products_id = '$v_products_id' AND
+ language_id = '$key'";
+ // support for Lindas Header Controller 2.0
+ if (isset($v_products_head_title_tag)){
+ // override the sql if we're using Linda's contrib
+ $sql =
+ "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET
+ products_name = '" . addslashes($name) . "',
+ products_description = '" . addslashes($v_products_description[$key]) . "',
+ products_url = '" . $v_products_url[$key] ."',
+ products_head_title_tag = '" . $v_products_head_title_tag[$key] ."',
+ products_head_desc_tag = '" . $v_products_head_desc_tag[$key] ."',
+ products_head_keywords_tag = '" . $v_products_head_keywords_tag[$key] ."'
+ WHERE
+ products_id = '$v_products_id' AND
+ language_id = '$key'";
+ }
+ // end support for Linda's Header Controller 2.0
+ $result = tep_db_query($sql);
+ }
+ }
+ }
+ }
+
+ if (isset($v_categories_id)){
+ //find out if this product is listed in the category given
+ $result_incategory = tep_db_query('SELECT
+ '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id,
+ '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id
+ FROM
+ '.TABLE_PRODUCTS_TO_CATEGORIES.'
+ WHERE
+ '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id='.$v_products_id.' AND
+ '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.$v_categories_id);
+
+ if (tep_db_num_rows($result_incategory) == 0) {
+ // nope, this is a new category for this product
+ $res1 = tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id)
+ VALUES ("' . $v_products_id . '", "' . $v_categories_id . '")');
+ } else {
+ // already in this category, nothing to do!
+ }
+ }
+
+ // for the separate prices per customer (SPPC) module
+ $ll=1;
+ if (isset($v_customer_price_1)){
+
+ if (($v_customer_group_id_1 == '') AND ($v_customer_price_1 != '')) {
+ echo "ERROR - v_customer_group_id and v_customer_price must occur in pairs ";
+ die();
+ }
+ // they spec'd some prices, so clear all existing entries
+ $result = tep_db_query('
+ DELETE
+ FROM
+ '.TABLE_PRODUCTS_GROUPS.'
+ WHERE
+ products_id = ' . $v_products_id
+ );
+ // and insert the new record
+ if ($v_customer_price_1 != ''){
+ $result = tep_db_query('
+ INSERT INTO
+ '.TABLE_PRODUCTS_GROUPS.'
+ VALUES
+ (
+ ' . $v_customer_group_id_1 . ',
+ ' . $v_customer_price_1 . ',
+ ' . $v_products_id . ',
+ ' . $v_products_price .'
+ )'
+ );
+ }
+ if ($v_customer_price_2 != ''){
+ $result = tep_db_query('
+ INSERT INTO
+ '.TABLE_PRODUCTS_GROUPS.'
+ VALUES
+ (
+ ' . $v_customer_group_id_2 . ',
+ ' . $v_customer_price_2 . ',
+ ' . $v_products_id . ',
+ ' . $v_products_price . '
+ )'
+ );
+ }
+ if ($v_customer_price_3 != ''){
+ $result = tep_db_query('
+ INSERT INTO
+ '.TABLE_PRODUCTS_GROUPS.'
+ VALUES
+ (
+ ' . $v_customer_group_id_3 . ',
+ ' . $v_customer_price_3 . ',
+ ' . $v_products_id . ',
+ ' . $v_products_price . '
+ )'
+ );
+ }
+ if ($v_customer_price_4 != ''){
+ $result = tep_db_query('
+ INSERT INTO
+ '.TABLE_PRODUCTS_GROUPS.'
+ VALUES
+ (
+ ' . $v_customer_group_id_4 . ',
+ ' . $v_customer_price_4 . ',
+ ' . $v_products_id . ',
+ ' . $v_products_price . '
+ )'
+ );
+ }
+
+ }
+ // end: separate prices per customer (SPPC) module
+
+ // VJ product attribs begin
+ if (isset($v_attribute_options_id_1)){
+ $attribute_rows = 1; // master row count
+
+ $languages = tep_get_languages();
+
+ // product options count
+ $attribute_options_count = 1;
+ $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count;
+
+ while (isset($$v_attribute_options_id_var) && !empty($$v_attribute_options_id_var)) {
+ // remove product attribute options linked to this product before proceeding further
+ // this is useful for removing attributes linked to a product
+ $attributes_clean_query = "delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "'";
+
+ tep_db_query($attributes_clean_query);
+
+ $attribute_options_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "'";
+
+ $attribute_options_values = tep_db_query($attribute_options_query);
+
+ // option table update begin
+ if ($attribute_rows == 1) {
+ // insert into options table if no option exists
+ if (tep_db_num_rows($attribute_options_values) <= 0) {
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid;
+
+ if (isset($$v_attribute_options_name_var)) {
+ $attribute_options_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')";
+
+ $attribute_options_insert = tep_db_query($attribute_options_insert_query);
+ }
+ }
+ } else { // update options table, if options already exists
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid;
+
+ if (isset($$v_attribute_options_name_var)) {
+ $attribute_options_update_lang_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "' and language_id ='" . (int)$lid . "'";
+
+ $attribute_options_update_lang_values = tep_db_query($attribute_options_update_lang_query);
+
+ // if option name doesn't exist for particular language, insert value
+ if (tep_db_num_rows($attribute_options_update_lang_values) <= 0) {
+ $attribute_options_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')";
+
+ $attribute_options_lang_insert = tep_db_query($attribute_options_lang_insert_query);
+ } else { // if option name exists for particular language, update table
+ $attribute_options_update_query = "update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . $$v_attribute_options_name_var . "' where products_options_id ='" . (int)$$v_attribute_options_id_var . "' and language_id = '" . (int)$lid . "'";
+
+ $attribute_options_update = tep_db_query($attribute_options_update_query);
+ }
+ }
+ }
+ }
+ }
+ // option table update end
+
+ // product option values count
+ $attribute_values_count = 1;
+ $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;
+
+ while (isset($$v_attribute_values_id_var) && !empty($$v_attribute_values_id_var)) {
+ $attribute_values_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "'";
+
+ $attribute_values_values = tep_db_query($attribute_values_query);
+
+ // options_values table update begin
+ if ($attribute_rows == 1) {
+ // insert into options_values table if no option exists
+ if (tep_db_num_rows($attribute_values_values) <= 0) {
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid;
+
+ if (isset($$v_attribute_values_name_var)) {
+ $attribute_values_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')";
+
+ $attribute_values_insert = tep_db_query($attribute_values_insert_query);
+ }
+ }
+
+
+ // insert values to pov2po table
+ $attribute_values_pov2po_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "')";
+
+ $attribute_values_pov2po = tep_db_query($attribute_values_pov2po_query);
+ } else { // update options table, if options already exists
+ for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
+ $lid = $languages[$i]['id'];
+
+ $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid;
+
+ if (isset($$v_attribute_values_name_var)) {
+ $attribute_values_update_lang_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "' and language_id ='" . (int)$lid . "'";
+
+ $attribute_values_update_lang_values = tep_db_query($attribute_values_update_lang_query);
+
+ // if options_values name doesn't exist for particular language, insert value
+ if (tep_db_num_rows($attribute_values_update_lang_values) <= 0) {
+ $attribute_values_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')";
+
+ $attribute_values_lang_insert = tep_db_query($attribute_values_lang_insert_query);
+ } else { // if options_values name exists for particular language, update table
+ $attribute_values_update_query = "update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . $$v_attribute_values_name_var . "' where products_options_values_id ='" . (int)$$v_attribute_values_id_var . "' and language_id = '" . (int)$lid . "'";
+
+ $attribute_values_update = tep_db_query($attribute_values_update_query);
+ }
+ }
+ }
+ }
+ }
+ // options_values table update end
+
+ // options_values price update begin
+ $v_attribute_values_price_var = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count;
+
+ if (isset($$v_attribute_values_price_var) && ($$v_attribute_values_price_var != '')) {
+ $attribute_prices_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id ='" . (int)$$v_attribute_options_id_var . "' and options_values_id = '" . (int)$$v_attribute_values_id_var . "'";
+
+ $attribute_prices_values = tep_db_query($attribute_prices_query);
+
+ $attribute_values_price_prefix = ($$v_attribute_values_price_var < 0) ? '-' : '+';
+
+ // options_values_prices table update begin
+ // insert into options_values_prices table if no price exists
+ if (tep_db_num_rows($attribute_prices_values) <= 0) {
+ $attribute_prices_insert_query = "insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$v_products_id . "', '" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "', '" . (float)$$v_attribute_values_price_var . "', '" . $attribute_values_price_prefix . "')";
+
+ $attribute_prices_insert = tep_db_query($attribute_prices_insert_query);
+ } else { // update options table, if options already exists
+ $attribute_prices_update_query = "update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $$v_attribute_values_price_var . "', price_prefix = '" . $attribute_values_price_prefix . "' where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "' and options_values_id ='" . (int)$$v_attribute_values_id_var . "'";
+
+ $attribute_prices_update = tep_db_query($attribute_prices_update_query);
+ }
+ }
+ // options_values price update end
+
+//////// attributes stock add start
+ $v_attribute_values_stock_var = 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count;
+
+ if (isset($$v_attribute_values_stock_var) && ($$v_attribute_values_stock_var != '')) {
+
+ $stock_attributes = $$v_attribute_options_id_var.'-'.$$v_attribute_values_id_var;
+
+ $attribute_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$v_products_id . "' and products_stock_attributes ='" . $stock_attributes . "'");
+
+ // insert into products_stock_quantity table if no stock exists
+ if (tep_db_num_rows($attribute_stock_query) <= 0) {
+ $attribute_stock_insert_query =tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . (int)$v_products_id . "', '" . $stock_attributes . "', '" . (int)$$v_attribute_values_stock_var . "')");
+
+ } else { // update options table, if options already exists
+ $attribute_stock_insert_query = tep_db_query("update " . TABLE_PRODUCTS_STOCK. " set products_stock_quantity = '" . (int)$$v_attribute_values_stock_var . "' where products_id = '" . (int)$v_products_id . "' and products_stock_attributes = '" . $stock_attributes . "'");
+
+ // turn on stock tracking on products_options table
+ $stock_tracking_query = tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_track_stock = '1' where products_options_id = '" . (int)$$v_attribute_options_id_var . "'");
+
+ }
+ }
+//////// attributes stock add end
+
+
+
+
+ $attribute_values_count++;
+ $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;
+ }
+
+ $attribute_options_count++;
+ $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count;
+ }
+
+ $attribute_rows++;
+ }
+ // VJ product attribs end
+
+ } else {
+ // this record was missing the product_model
+ array_walk($items, 'print_el');
+ echo "No products_model field in record. This line was not imported ";
+ echo " ";
+ }
+// end of row insertion code
+}
+
+require(DIR_WS_INCLUDES . 'application_bottom.php');
+?>
diff --git a/src/catalog/admin/easypopulate_functions.php b/src/catalog/admin/easypopulate_functions.php
new file mode 100644
index 0000000..1ef943d
--- /dev/null
+++ b/src/catalog/admin/easypopulate_functions.php
@@ -0,0 +1,61 @@
+ $_FILES[$filename]['name'],
+ 'type' => $_FILES[$filename]['type'],
+ 'size' => $_FILES[$filename]['size'],
+ 'tmp_name' => $_FILES[$filename]['tmp_name']);
+ } elseif (isset($GLOBALS['HTTP_POST_FILES'][$filename])) {
+ global $HTTP_POST_FILES;
+
+ $uploaded_file = array('name' => $HTTP_POST_FILES[$filename]['name'],
+ 'type' => $HTTP_POST_FILES[$filename]['type'],
+ 'size' => $HTTP_POST_FILES[$filename]['size'],
+ 'tmp_name' => $HTTP_POST_FILES[$filename]['tmp_name']);
+ } else {
+ $uploaded_file = array('name' => $GLOBALS[$filename . '_name'],
+ 'type' => $GLOBALS[$filename . '_type'],
+ 'size' => $GLOBALS[$filename . '_size'],
+ 'tmp_name' => $GLOBALS[$filename]);
+ }
+
+return $uploaded_file;
+}
+
+// the $filename parameter is an array with the following elements:
+// name, type, size, tmp_name
+function tep_copy_uploaded_file($filename, $target) {
+ if (substr($target, -1) != '/') $target .= '/';
+
+ $target .= $filename['name'];
+
+ move_uploaded_file($filename['tmp_name'], $target);
+}
+
+////
+// Recursively go through the categories and retreive all sub-categories IDs
+// TABLES: categories
+if (!function_exists(tep_get_sub_categories)) {
+ function tep_get_sub_categories(&$categories, $categories_id) {
+ $sub_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
+ while ($sub_categories = tep_db_fetch_array($sub_categories_query)) {
+ if ($sub_categories['categories_id'] == 0) return true;
+ $categories[sizeof($categories)] = $sub_categories['categories_id'];
+ if ($sub_categories['categories_id'] != $categories_id) {
+ tep_get_sub_categories($categories, $sub_categories['categories_id']);
+ }
+ }
+ }
+}
+?>
diff --git a/src/catalog/admin/edit_orders.php b/src/catalog/admin/edit_orders.php
new file mode 100644
index 0000000..d3fc1e4
--- /dev/null
+++ b/src/catalog/admin/edit_orders.php
@@ -0,0 +1,2300 @@
+ $orders_status['orders_status_id'],
+ 'text' => $orders_status['orders_status_name']);
+ $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
+ }
+
+ $action = (isset($_GET['action']) ? $_GET['action'] : 'edit');
+
+ // Update Inventory Quantity
+ if (tep_not_null($action)) {
+ switch ($action) {
+
+ // 1. UPDATE ORDER ###############################################################################################
+ case 'update_order':
+
+ $oID = tep_db_prepare_input($_GET['oID']);
+ $order = new oe_order($oID);
+ $status = tep_db_prepare_input($_POST['status']);
+
+ // Set this Session's variables
+ $_SESSION['billing_same_as_customer'] = $_POST['billing_same_as_customer'];
+ $_SESSION['shipping_same_as_billing'] = $_POST['shipping_same_as_billing'];
+
+ //tax business
+ $default_tax_name = tep_get_tax_description($default_tax_class, $_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id']);
+
+ //figure out the new currency value
+ $currency_value_query = tep_db_query("SELECT
+ value FROM " . TABLE_CURRENCIES . " WHERE code = '" . $_POST['update_info_payment_currency'] . "'");
+ $currency_value = tep_db_fetch_array($currency_value_query);
+
+ //figure out the country, state
+ $update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']);
+ $update_customer_country = tep_get_country_name($_POST['update_customer_country_id']);
+ $update_billing_state = tep_get_zone_name($_POST['update_billing_country_id'], $_POST['update_billing_zone_id'], $_POST['update_billing_state']);
+ $update_billing_country = tep_get_country_name($_POST['update_billing_country_id']);
+ $update_delivery_state = tep_get_zone_name($_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id'], $_POST['update_delivery_state']);
+ $update_delivery_country = tep_get_country_name($_POST['update_delivery_country_id']);
+
+
+ // 1.1 UPDATE ORDER INFO #####
+
+ $UpdateOrders = "UPDATE " . TABLE_ORDERS . " SET
+ customers_name = '" . tep_db_prepare_input($_POST['update_customer_name']) . "',
+ customers_company = '" . tep_db_prepare_input($_POST['update_customer_company']) . "',
+ customers_street_address = '" . tep_db_prepare_input($_POST['update_customer_street_address']) . "',
+ customers_suburb = '" . tep_db_prepare_input($_POST['update_customer_suburb']) . "',
+ customers_city = '" . tep_db_prepare_input($_POST['update_customer_city']) . "',
+ customers_state = '" . tep_db_prepare_input($update_customer_state) . "',
+ customers_postcode = '" . tep_db_prepare_input($_POST['update_customer_postcode']) . "',
+ customers_country = '" . tep_db_prepare_input($update_customer_country) . "',
+ customers_telephone = '" . tep_db_prepare_input($_POST['update_customer_telephone']) . "',
+ customers_email_address = '" . tep_db_prepare_input($_POST['update_customer_email_address']) . "',";
+
+ $UpdateOrders .= "
+ billing_name = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name'])) . "',
+ billing_company = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company'])) . "',
+ billing_street_address = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address'])) . "',
+ billing_suburb = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb'])) . "',
+ billing_city = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city'])) . "',
+ billing_state = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state)) . "',
+ billing_postcode = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode'])) . "',
+ billing_country = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country)) . "',";
+
+ $UpdateOrders .= "
+ delivery_name = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']) : $_POST['update_delivery_name'])) . "',
+ delivery_company = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']) : $_POST['update_delivery_company'])) . "',
+ delivery_street_address = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address']) : $_POST['update_delivery_street_address'])) . "',
+ delivery_suburb = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']) : $_POST['update_delivery_suburb'])) . "',
+ delivery_city = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']) : $_POST['update_delivery_city'])) . "',
+ delivery_state = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state) : $update_delivery_state)) . "',
+ delivery_postcode = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']) : $_POST['update_delivery_postcode'])) . "',
+ delivery_country = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country) : $update_delivery_country)) . "',";
+
+ $UpdateOrders .= "
+ payment_method = '" . tep_db_prepare_input($_POST['update_info_payment_method']) . "',
+ currency = '" . tep_db_prepare_input($_POST['update_info_payment_currency']) . "',
+ currency_value = '" . tep_db_prepare_input($currency_value['value']) . "',
+ cc_type = '" . tep_db_prepare_input($_POST['update_info_cc_type']) . "',
+ cc_owner = '" . tep_db_prepare_input($_POST['update_info_cc_owner']) . "',
+ cc_number = '" . tep_db_prepare_input($_POST['update_info_cc_number']) . "',
+ cc_expires = '" . tep_db_prepare_input($_POST['update_info_cc_expires']) . "',
+ shipping_tax = '" . tep_db_prepare_input($_POST['update_shipping_tax']) . "'";
+
+ $UpdateOrders .= " where orders_id = '" . tep_db_prepare_input($_GET['oID']) . "';";
+
+ tep_db_query($UpdateOrders);
+ $order_updated = true;
+
+ // 1.2 UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY #####
+
+ $check_status_query = tep_db_query("SELECT
+ customers_name, customers_email_address, orders_status, date_purchased
+ FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'");
+ $check_status = tep_db_fetch_array($check_status_query);
+
+ if (($check_status['orders_status'] != $_POST['status']) || (tep_not_null($_POST['comments']))) {
+
+ tep_db_query("UPDATE " . TABLE_ORDERS . " SET
+ orders_status = '" . tep_db_input($_POST['status']) . "',
+ last_modified = now()
+ WHERE orders_id = '" . (int)$oID . "'");
+
+ // Notify Customer ?
+ $customer_notified = '0';
+ if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) {
+ $notify_comments = '';
+ if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
+ $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comments']) . "\n\n";
+ }
+ $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]) . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE2);
+ tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
+ $customer_notified = '1';
+ }
+
+ tep_db_query("INSERT into " . TABLE_ORDERS_STATUS_HISTORY . "
+ (orders_id, orders_status_id, date_added, customer_notified, comments)
+ values ('" . tep_db_input($_GET['oID']) . "',
+ '" . tep_db_input($_POST['status']) . "',
+ now(),
+ " . tep_db_input($customer_notified) . ",
+ '" . tep_db_input($_POST['comments']) . "')");
+ }
+
+ // 1.3 UPDATE PRODUCTS #####
+ $RunningSubTotal = 0;
+ $RunningTax = array($default_tax_name => 0);
+
+ // Do pre-check for subtotal field existence
+ $ot_subtotal_found = false;
+ $ot_total_found = false;
+ if (is_array ($_POST['update_totals'])) {
+ foreach($_POST['update_totals'] as $total_details) {
+ extract($total_details,EXTR_PREFIX_ALL,"ot");
+ if($ot_class == "ot_subtotal") {
+ $ot_subtotal_found = true;
+ break;
+ }
+
+ if($ot_class == "ot_total"){
+ $ot_total_found = true;
+ break;
+ }
+ }//end foreach()
+ }//end if (is_array())
+
+ // 1.3.1 Update orders_products Table
+ if (is_array ($_POST['update_products'])){
+ foreach($_POST['update_products'] as $orders_products_id => $products_details) {
+ if (!tep_not_null($products_details["qty"])) $products_details["qty"] = 0;
+
+ // 1.3.1.1 Update Inventory Quantity
+ $order_query = tep_db_query("SELECT products_id, products_quantity
+ FROM " . TABLE_ORDERS_PRODUCTS . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_id = '$orders_products_id'");
+ $order = tep_db_fetch_array($order_query);
+
+ // First we do a stock check
+
+ if ($products_details["qty"] != $order['products_quantity']){
+ $quantity_difference = ($products_details["qty"] - $order['products_quantity']);
+ if (STOCK_LIMITED == 'true'){
+ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET
+ products_quantity = products_quantity - " . $quantity_difference . ",
+ products_ordered = products_ordered + " . $quantity_difference . "
+ WHERE products_id = '" . (int)$order['products_id'] . "'");
+ } else {
+ tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET
+ products_ordered = products_ordered + " . $quantity_difference . "
+ WHERE products_id = '" . (int)$order['products_id'] . "'");
+ }
+ }
+
+ //Then we check if the product should be deleted
+ if (isset($products_details['delete'])){
+ //update quantities first
+ if (STOCK_LIMITED == 'true'){
+ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET
+ products_quantity = products_quantity + " . $products_details["qty"] . ",
+ products_ordered = products_ordered - " . $products_details["qty"] . "
+ WHERE products_id = '" . (int)$order['products_id'] . "'");
+ } else {
+ tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET
+ products_ordered = products_ordered - " . $products_details["qty"] . "
+ WHERE products_id = '" . (int)$order['products_id'] . "'");
+ }
+
+ //then delete the little bugger
+ $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_id = '$orders_products_id';";
+ tep_db_query($Query);
+
+ // and all its attributes
+ if(isset($products_details[attributes]))
+ {
+ $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_id = '$orders_products_id';";
+ tep_db_query($Query);
+
+ $Query2 = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_id = '$orders_products_id';";
+ tep_db_query($Query2);
+ }
+
+
+
+ }// end of if (isset($products_details['delete']))
+
+ else { // if we don't delete, we update
+ $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET
+ products_model = '" . $products_details["model"] . "',
+ products_name = '" . tep_html_quotes($products_details["name"]) . "',
+ products_price = '" . $products_details["price"] . "',
+ final_price = '" . $products_details["final_price"] . "',
+ products_tax = '" . $products_details["tax"] . "',
+ products_quantity = '" . $products_details["qty"] . "'
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_id = '$orders_products_id';";
+ tep_db_query($Query);
+
+ //update subtotal and total during update function
+ if (DISPLAY_PRICE_WITH_TAX == 'true') {
+ $RunningSubTotal += (($products_details['tax']/100 + 1) * ($products_details['qty'] * $products_details['final_price']));
+ } else {
+ $RunningSubTotal += $products_details["qty"] * $products_details["final_price"];
+ }
+
+ $RunningTax[$products_details['tax_description']] += (($products_details['tax']/100) * ($products_details['qty'] * $products_details['final_price']));
+
+ // Update Any Attributes
+ if(isset($products_details[attributes]))
+ { foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details) {
+ $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
+ products_options = '" . $attributes_details["option"] . "',
+ products_options_values = '" . $attributes_details["value"] . "',
+ options_values_price ='" . $attributes_details["price"] . "',
+ price_prefix ='" . $attributes_details["prefix"] . "'
+ where orders_products_attributes_id = '$orders_products_attributes_id';";
+ tep_db_query($Query);
+ }//end of foreach($products_details["attributes"]
+ }// end of if(isset($products_details[attributes]))
+ }// end of if/else (isset($products_details['delete']))
+
+ }//end of foreach
+ }//end of if (is_array())
+
+ //1.3.5
+ //update any downloads that may exist
+ if (is_array($_POST['update_downloads'])) {
+ foreach($_POST['update_downloads'] as $orders_products_download_id => $download_details) {
+ $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET
+ orders_products_filename = '" . $download_details["filename"] . "',
+ download_maxdays = '" . $download_details["maxdays"] . "',
+ download_count = '" . $download_details["maxcount"] . "'
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_products_download_id = '$orders_products_download_id';";
+ tep_db_query($Query);
+ }
+ }
+
+ // 1.4 UPDATE SHIPPING, CUSTOM FEES, DISOUNTS, TAXES, AND TOTALS #####
+
+ // 1.4.0.1 Shipping Tax
+
+ if (is_array ($_POST['update_totals'])){
+ foreach($_POST['update_totals'] as $total_index => $total_details)
+ {
+ extract($total_details,EXTR_PREFIX_ALL,"ot");
+ if($ot_class == "ot_shipping")//a good place to add in custom total components
+ {
+ if (DISPLAY_PRICE_WITH_TAX == 'true') {//the shipping charge includes tax
+ $RunningTax[$default_tax_name] += ($ot_value * $_POST['update_shipping_tax']) / ($_POST['update_shipping_tax'] + 100);
+ } else { //shipping tax is in addition to the shipping charge
+ $RunningTax[$default_tax_name] += (($_POST['update_shipping_tax'] / 100) * $ot_value);
+ }
+ }
+ }
+ }
+
+ //1.4.1.0
+ $RunningTotal = 0;
+ $sort_order = 0;
+
+ // 1.4.1.1 If ot_tax doesn't exist, but $RunningTax has been calculated, create an appropriate entry in the db and add tax to the subtotal or total as appropriate
+ if (array_sum($RunningTax) != 0) {
+ foreach ($RunningTax as $key => $val) {
+
+ if (is_array ($_POST['update_totals'])){//1
+ foreach($_POST['update_totals'] as $total_details) {//2
+ extract($total_details,EXTR_PREFIX_ALL,"ot");
+ $ot_tax_found = 0;
+ if (($ot_class == "ot_tax") && (preg_replace("/:$/","",$ot_title) == $key))
+ {//3
+ $ot_tax_found = 1;
+ break;
+ }//end 3
+ }//end 2
+
+//bizzarro code needed to input text value into db properly
+//I still don't understand why
+//text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "',
+//isn't adequate. Maybe I never will
+ if ($ot_class == "ot_total" || $ot_class == "ot_tax" || $ot_class == "ot_subtotal" ||
+ $ot_class == "ot_shipping" || $ot_class == "ot_custom" || $ot_class == "ot_loworderfee") {
+ $order = new oe_order($oID);
+ // $RunningTax[$default_tax_name] += 0 * $products_details['tax'] / $order->info['currency_value'] / 100 ;
+ }//end bizarro code
+
+ }// end 1
+
+ if (($val > 0) && ($ot_tax_found != 1)) {
+ $sort_order++;
+ $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET
+ orders_id = '" . (int)$oID . "',
+ title ='" . $key . ":',
+ text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "',
+ value = '" . $val . "',
+ class = 'ot_tax',
+ sort_order = '2'";
+ tep_db_query($Query);
+ $ot_tax_found = 1;
+
+ if (DISPLAY_PRICE_WITH_TAX != 'true') {
+ $RunningTotal += $val;
+ } //end if (DISPLAY_PRICE_WITH_TAX != 'true')
+ } //end if (($val > 0) && ($ot_tax_found != 1)) {
+ } //end foreach ($RunningTax as $key => $val)
+ } //end if (array_sum($RunningTax) != 0)
+
+ ////////////////////OPTIONAL- create entries for subtotal and/or total if none exists
+ /*
+ //1.4.1.2
+ /////////////////////////Add in subtotal to db if it doesn't already exist
+ if (($RunningSubTotal >0) && ($ot_subtotal_found != true)) {
+ $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET
+ orders_id = "' . (int)$oID . '",
+ title ="' . ENTRY_SUB_TOTAL . '",
+ text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '",
+ value = "' . $RunningSubTotal . '",
+ class = "ot_subtotal",
+ sort_order = "1"';
+ tep_db_query($Query);
+ $ot_subtotal_found = true;
+ $RunningTotal += $RunningSubTotal;
+ }
+
+ //1.4.1.3
+ /////////////////////////Add in total to db if it doesn't already exist
+ if (($RunningTotal >0) && ($ot_total_found != true)) {
+ $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET
+ orders_id = "' . (int)$oID . '",
+ title ="' . ENTRY_TOTAL . '",
+ text = "' . $currencies->format($RunningTotal, true, $order->info['currency'], $order->info['currency_value']) . '",
+ value = "' . $RunningTotal . '",
+ class = "ot_total",
+ sort_order = "4"';
+ tep_db_query($Query);
+ $ot_total_found = true;
+ }
+ */
+ //////////////////////////end optional section
+
+ // 1.4.2. Summing up total
+ if (is_array ($_POST['update_totals'])) {
+ foreach($_POST['update_totals'] as $total_index => $total_details) {
+
+ extract($total_details,EXTR_PREFIX_ALL,"ot");
+ if (trim($ot_title)) {
+ $sort_order++;
+
+ if ($ot_class == "ot_subtotal") {
+ $ot_value = $RunningSubTotal;
+ }
+
+ if ($ot_class == "ot_tax") {
+ $ot_value = $RunningTax[preg_replace("/:$/","",$ot_title)];
+ }
+
+ if ($ot_class == "ot_total") {
+ $ot_value = $RunningTotal;
+
+ if ( !$ot_subtotal_found )
+ { // There was no subtotal on this order, lets add the running subtotal in.
+ $ot_value += $RunningSubTotal;
+ }
+ }
+
+ // Set $ot_text (display-formatted value)
+ $order = new oe_order($oID);
+ $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']);
+
+ if ($ot_class == "ot_total") {
+ $ot_text = "" . $ot_text . " ";
+ }
+
+ if($ot_total_id > 0) { // Already in database --> Update
+ $Query = "UPDATE " . TABLE_ORDERS_TOTAL . " SET
+ title = '" . $ot_title . "',
+ text = '" . $ot_text . "',
+ value = '" . $ot_value . "',
+ sort_order = '" . $sort_order . "'
+ WHERE orders_total_id = '". $ot_total_id . "'
+ AND orders_id = '" . (int)$oID . "'";
+ tep_db_query($Query);
+ } else { // New Insert (ie ot_custom)
+ $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET
+ orders_id = '" . (int)$oID . "',
+ title = '" . $ot_title . "',
+ text = '" . $ot_text . "',
+ value = '" . $ot_value . "',
+ class = '" . $ot_class . "',
+ sort_order = '" . $sort_order . "'";
+ tep_db_query($Query);
+ }
+
+ if ($ot_class == "ot_tax") {
+
+ if (DISPLAY_PRICE_WITH_TAX != 'true') {
+ //we don't add tax to the total here because it's already added to the subtotal
+ $RunningTotal += $ot_value;
+ }
+ } else {
+ $RunningTotal += $ot_value;
+ }
+ }
+
+ if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total")) { // value = 0 => Delete Total Piece
+
+ $Query = "DELETE from " . TABLE_ORDERS_TOTAL . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND orders_total_id = '$ot_total_id'";
+ tep_db_query($Query);
+ }
+
+ }
+}//end if (is_array())
+
+ // 1.5 SUCCESS MESSAGE #####
+
+ if ($order_updated) {
+ $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
+ }
+
+ tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit'));
+
+ break;
+
+ // 2. ADD A PRODUCT ###############################################################################################
+ case 'add_product':
+
+ if($_POST['step'] == 4)
+ {
+ // 2.1 GET ORDER INFO #####
+
+ $oID = tep_db_prepare_input($_GET['oID']);
+ $order = new oe_order($oID);
+ $AddedOptionsPrice = 0;
+
+ //tax business
+ $default_tax_name = tep_get_tax_description($default_tax_class, $order->delivery['country_id'], $order->delivery['zone_id']);
+
+ // 2.1.1 Get Product Attribute Info
+ if(is_array ($_POST['add_product_options']))
+ {
+ foreach($_POST['add_product_options'] as $option_id => $option_value_id)
+ {
+ $result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . "
+ pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po
+ ON po.products_options_id=pa.options_id
+ LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
+ ON pov.products_options_values_id=pa.options_values_id
+ WHERE products_id=" . $_POST['add_product_products_id'] . "
+ and options_id=" . $option_id . "
+ and options_values_id=" . $option_value_id . "
+ and po.language_id = '" . (int)$languages_id . "'
+ and pov.language_id = '" . (int)$languages_id . "'");
+
+ $row = tep_db_fetch_array($result);
+ if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "opt");
+ if ($opt_price_prefix == '-')
+ {$AddedOptionsPrice -= $opt_options_values_price;}
+ else //default to positive
+ {$AddedOptionsPrice += $opt_options_values_price;}
+ $option_value_details[$option_id][$option_value_id] = array (
+ "options_values_price" => $opt_options_values_price,
+ "price_prefix" => $opt_price_prefix);
+ $option_names[$option_id] = $opt_products_options_name;
+ $option_values_names[$option_value_id] = $opt_products_options_values_name;
+
+ //add on for downloads
+ if (DOWNLOAD_ENABLED == 'true') {
+ $download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount
+ from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
+ where products_attributes_id='" . $opt_products_attributes_id . "'";
+
+ $download_query = tep_db_query($download_query_raw);
+ if (tep_db_num_rows($download_query) > 0) {
+ $download = tep_db_fetch_array($download_query);
+ $filename[$option_id] = $download['products_attributes_filename'];
+ $maxdays[$option_id] = $download['products_attributes_maxdays'];
+ $maxcount[$option_id] = $download['products_attributes_maxcount'];
+ } //end if (tep_db_num_rows($download_query) > 0) {
+ } //end if (DOWNLOAD_ENABLED == 'true') {
+ //end downloads
+
+ } //end foreach($_POST['add_product_options'] as $option_id => $option_value_id)
+ } //end if(is_array ($_POST['add_product_options']))
+
+ // 2.1.2 Get Product Info
+ $InfoQuery = "SELECT
+ p.products_model, p.products_price, pd.products_name, p.products_tax_class_id
+ from " . TABLE_PRODUCTS . " p
+ LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
+ ON pd.products_id=p.products_id
+ WHERE p.products_id=" . $_POST['add_product_products_id'] . "
+ AND pd.language_id = '" . (int)$languages_id . "'";
+ $result = tep_db_query($InfoQuery);
+
+ $row = tep_db_fetch_array($result);
+ if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "p");
+
+ // 2.1.3 Pull specials price from db if there is an active offer
+ $special_price = tep_db_query("
+ SELECT specials_new_products_price
+ FROM " . TABLE_SPECIALS . "
+ WHERE products_id =". $_POST['add_product_products_id'] . "
+ AND status");
+ $new_price = tep_db_fetch_array($special_price);
+
+ if ($new_price)
+ { $p_products_price = $new_price['specials_new_products_price']; }
+
+ // 2.2 UPDATE ORDER ####
+ $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS . " SET
+ orders_id = '" . (int)$oID . "',
+ products_id = '" . $_POST['add_product_products_id'] . "',
+ products_model = '" . $p_products_model . "',
+ products_name = '" . tep_html_quotes($p_products_name) . "',
+ products_price = '". $p_products_price . "',
+ final_price = '" . ($p_products_price + $AddedOptionsPrice) . "',
+ products_tax = '" . tep_get_tax_rate($p_products_tax_class_id, $countryid, $zoneid) . "',
+ products_quantity = '" . $_POST['add_product_quantity'] . "'";
+ tep_db_query($Query);
+ $new_product_id = tep_db_insert_id();
+
+ // 2.2.1 Update inventory Quantity
+ //This is only done if store is set up to use stock
+ if (STOCK_LIMITED == 'true'){
+ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET
+ products_quantity = products_quantity - " . $_POST['add_product_quantity'] . "
+ WHERE products_id = '" . $_POST['add_product_products_id'] . "'");
+ }
+
+ //2.2.1.1 Update products_ordered info
+ tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET
+ products_ordered = products_ordered + " . $_POST['add_product_quantity'] . "
+ WHERE products_id = '" . $_POST['add_product_products_id'] . "'");
+
+ //2.2.1.2 keep a record of the products attributes
+ if (is_array ($_POST['add_product_options'])) {
+ foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
+ $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " SET
+ orders_id = '" . (int)$oID . "',
+ orders_products_id = '" . $new_product_id . "',
+ products_options = '" . $option_names[$option_id] . "',
+ products_options_values = '" .
+ tep_db_input($option_values_names[$option_value_id]) . "',
+
+ options_values_price = '" .
+ $option_value_details[$option_id][$option_value_id]['options_values_price'] . "',
+
+ price_prefix = '" .
+ $option_value_details[$option_id][$option_value_id]['price_prefix'] . "'";
+
+ tep_db_query($Query);
+
+ //add on for downloads
+ if (DOWNLOAD_ENABLED == 'true' && isset($filename[$option_id])) {
+
+ $Query2 = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET
+ orders_id = '" . (int)$oID . "',
+ orders_products_id = '" . $new_product_id . "',
+ orders_products_filename = '" . $filename[$option_id] . "',
+ download_maxdays = '" . $maxdays[$option_id] . "',
+ download_count = '" . $maxcount[$option_id] . "'";
+
+ tep_db_query($Query2);
+
+ } //end if (DOWNLOAD_ENABLED == 'true') {
+ //end downloads
+
+ }
+ }
+
+ // 2.2.2 Calculate Tax and Sub-Totals
+ $order = new oe_order($oID);
+ $RunningSubTotal = 0;
+ $RunningTax = array($default_tax_name => 0);
+
+ //just adding in shipping tax, don't mind me
+ $ot_shipping_query = tep_db_query("
+ SELECT value
+ FROM " . TABLE_ORDERS_TOTAL . "
+ WHERE orders_id = '" . (int)$oID . "'
+ AND class = 'ot_shipping'");
+
+ while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) {
+ $ot_shipping_value = $ot_shipping_info['value'];
+
+ if (DISPLAY_PRICE_WITH_TAX == 'true') {
+ $RunningTax[$default_tax_name] += ($ot_shipping_value * $order->info['shipping_tax'] / ($order->info['shipping_tax'] + 100));
+ } else {
+ $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value);
+
+ }// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
+ }// end while
+
+ // end shipping tax calcs
+
+ for ($i=0; $iproducts); $i++) {
+
+ // This calculatiion of Subtotal and Tax is part of the 'add a product' process
+ if (DISPLAY_PRICE_WITH_TAX == 'true') {
+ $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));
+ } else {
+ $RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']);
+ }
+
+ $RunningTax[$order->products[$i]['tax_description']] += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));
+
+ }// end of for ($i=0; $iproducts); $i++) {
+
+
+
+ // 2.2.2.1 Tax
+ foreach ($RunningTax as $key => $val) {
+ $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set
+ text = "' . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . '",
+ value = "' . $val . '"
+ WHERE class= "ot_tax"
+ AND (title = "' . $key . ':" OR title = "' . $key . '")
+ AND orders_id= "' . (int)$oID . '"';
+ tep_db_query($Query);
+ }
+
+
+ // 2.2.2.2 Sub-Total
+ $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET
+ text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '",
+ value = "' . $RunningSubTotal . '"
+ WHERE class="ot_subtotal"
+ AND orders_id= "' . (int)$oID . '"';
+ tep_db_query($Query);
+
+ // 2.2.2.3 Total
+ if (DISPLAY_PRICE_WITH_TAX == 'true') {
+ $Query = 'SELECT sum(value)
+ AS total_value from ' . TABLE_ORDERS_TOTAL . '
+ WHERE class != "ot_total"
+ AND class != "ot_tax"
+ AND orders_id= "' . (int)$oID . '"';
+ $result = tep_db_query($Query);
+ $row = tep_db_fetch_array($result);
+ $Total = $row['total_value'];
+ } else {
+ $Query = 'SELECT sum(value)
+ AS total_value from ' . TABLE_ORDERS_TOTAL . '
+ WHERE class != "ot_total"
+ AND orders_id= "' . (int)$oID . '"';
+ $result = tep_db_query($Query);
+ $row = tep_db_fetch_array($result);
+ $Total = $row['total_value'];
+ }
+
+ $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set
+ text = "' . $currencies->format($Total, true, $order->info['currency'], $order->info['currency_value']) . '",
+ value = "' . $Total . '"
+ WHERE class="ot_total" and orders_id= "' . (int)$oID . '"';
+ tep_db_query($Query);
+
+ // 2.3 REDIRECTION #####
+ tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit'));
+
+ }
+
+ break;
+
+ }
+}
+
+ if (($action == 'edit') && isset($_GET['oID'])) {
+ $oID = tep_db_prepare_input($_GET['oID']);
+
+ $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
+ $order_exists = true;
+ if (!tep_db_num_rows($orders_query)) {
+ $order_exists = false;
+ $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
+ }
+ }
+
+ //oh, and by the way....
+ if (($action == 'edit') && ($order_exists == true)) $order = new oe_order($oID);
+
+ //and, we're off....
+ ?>
+
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ read()) {
+ if (!is_dir( $module_directory . $file)) {
+ if (substr($file, strrpos($file, '.')) == $file_extension) {
+ $directory_array[] = $file;
+ }
+ }
+ }
+ sort($directory_array);
+ $dir->close();
+ }
+
+ // For each available payment module, check if enabled
+ for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
+ $file = $directory_array[$i];
+
+ include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/payment/' . $file);
+ include($module_directory . $file);
+
+ $class = substr($file, 0, strrpos($file, '.'));
+ if (tep_class_exists($class)) {
+ $module = new $class;
+ if ($module->check() > 0) {
+ // If module enabled create array of titles
+ $enabled_payment[] = array('id' => $module->title, 'text' => $module->title);
+
+ //if the payment method is the same as the payment module title then don't add it to dropdown menu
+ if ($module->title == $order->info['payment_method']) {
+ $paymentMatchExists='true';
+ }
+ }
+ }
+ }
+ //just in case the payment method found in db is not the same as the payment module title then make it part of the dropdown array or else it cannot be the selected default value
+ if ($paymentMatchExists !='true') {
+ $enabled_payment[] = array('id' => $order->info['payment_method'], 'text' => $order->info['payment_method']);
+ }
+ $enabled_payment[] = array('id' => 'Other', 'text' => 'Other');
+ //draw the dropdown menu for payment methods and default to the order value
+ echo tep_draw_pull_down_menu('update_info_payment_method', $enabled_payment, $order->info['payment_method'], 'id="update_info_payment_method" onChange="init()"');
+ }
+ else {
+ //draw the input field for payment methods and default to the order value
+?>
+
+
+
+
+ currencies);
+ $currencies_array = array();
+ while (list($key, $value) = each($currencies->currencies)) {
+ $currencies_array[] = array('id' => $key, 'text' => $value['title']);
+ }
+
+echo tep_draw_pull_down_menu('update_info_payment_currency', $currencies_array, $order->info['currency'], 'id="update_info_payment_currency" onChange="currency()"');
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ products); $i++) {
+ //calculate total weight
+ $products_weight = array($order->products[$i]['weight'] * $order->products[$i]['qty']);
+ foreach ($products_weight as $key => $value);
+ $total_weight += $value;
+ //end total weight
+ $orders_products_id = $order->products[$i]['orders_products_id'];
+ $RowStyle = "dataTableContent";
+ echo ' ' . "\n" .
+ ' ' . "
\n" .
+ ' ' . " products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-qty' />
\n" .
+ ' ' . " ";
+
+ // Has Attributes?
+ if (sizeof($order->products[$i]['attributes']) > 0) {
+ for ($j=0; $jproducts[$i]['attributes']); $j++) {
+ $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id'];
+ echo ' - ' . " " . ': ' . " " . ': ' . " products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\">" . ': ' . " products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>";
+ echo ' ';
+ } //end for ($j=0; $jproducts[$i]['attributes']); $j++) {
+
+ //Has downloads?
+
+ if (DOWNLOAD_ENABLED == 'true') {
+ $downloads_count = 1;
+ $d_index = 0;
+ $download_query_raw ="SELECT *
+ FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . "
+ WHERE orders_products_id='" . $orders_products_id . "'
+ AND orders_id='" . (int)$oID . "'
+ ORDER BY orders_products_download_id";
+
+ $download_query = tep_db_query($download_query_raw);
+
+ //
+ if (isset($downloads->products)) unset($downloads->products);
+ //
+
+ if (tep_db_num_rows($download_query) > 0) {
+ while ($download = tep_db_fetch_array($download_query)) {
+
+ $downloads->products[$d_index] = array(
+ 'id' => $download['orders_products_download_id'],
+ 'filename' => $download['orders_products_filename'],
+ 'maxdays' => $download['download_maxdays'],
+ 'maxcount' => $download['download_count']);
+
+ $d_index++;
+
+ }
+ }
+
+ for ($mm=0; $mmproducts); $mm++) {
+ $id = $downloads->products[$mm]['id'];
+ echo '';
+ echo '' . ENTRY_DOWNLOAD_COUNT . $downloads_count . "";
+ echo ' ' . "\n";
+ echo ' - ' . ENTRY_DOWNLOAD_FILENAME . ": ";
+ echo ' ' . "\n";
+ echo ' - ' . ENTRY_DOWNLOAD_MAXDAYS . ": ";
+ echo ' ' . "\n";
+ echo ' - ' . ENTRY_DOWNLOAD_MAXCOUNT . ": ";
+ echo ' ' . "\n";
+ echo ' ';
+ $downloads_count++;
+ } //end for ($mm=0; $mmproducts[$i]['attributes']) > 0) {
+
+ echo ' ' . "\n" .
+ ' ' . " " . ' ' . "\n" .
+ ' ' . tep_get_products_inventory_stock($order->products[$i]['magazzino']). ' ' .//MOD mag view ************************************************
+ ' ' . " products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-tax' />" .
+ " " .
+ " products[$i]['final_price'] / 100 * $order->products[$i]['qty']), 4, '.', '') . "'>" .
+ ' ' . "\n" .
+ ' ' . " products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price' />" . ' ' . "\n" .
+ ' ' . " products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-final_price' />" . ' ' . "\n" .
+ ' ' . " products[$i]['tax']/100) + 1)), 4, '.', '') . "' onKeyUp=\"updatePrices('price_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price_incl' />" . ' ' . "\n" .
+ ' ' . " products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_excl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_excl' />" . ' ' . "\n" .
+ ' ' . " products[$i]['tax']/100) + 1))) * $order->products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_incl' />" . ' ' . "\n" .
+ ' ' .
+ " products[$i]['qty']), 2, '.', '') . "' id='p" . $orders_products_id . "-total_weight' readonly='readonly'>" . " " . ' ' . "\n" .
+ ' ' . "\n" .
+ ' ' . tep_draw_separator('pixel_trans.gif', '1', '1') . ' ' . "\n";
+ }
+?>
+
+
+
+
+
+
+ ' . tep_image_button('button_add_article.gif', ADDING_TITLE) . ''; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ '; ?>
+
+
+
+
+
+
+
+
+
+
+ delivery["state"]);
+ $default_tax_name = tep_get_tax_description($default_tax_class, $countryid, $zoneid);
+ //default tax class is set at the top of the file
+ echo $default_tax_name; ?>')" value="info['shipping_tax']); ?>" id="shipping_tax_rate" />
+
+
+
+
+
+
+
+
+totals); $i++) {
+ $TotalsLengthArray[] = array("Name" => $order->totals[$i]['title']);
+ }
+ reset($TotalsLengthArray);
+ foreach($TotalsLengthArray as $TotalIndex => $TotalDetails) {
+ if (strlen($TotalDetails["Name"]) > $max_length) {
+ $max_length = strlen($TotalDetails["Name"]);
+ }
+ }
+// END OF MAKING ALL INPUT FIELDS THE SAME LENGTH
+
+ $TotalsArray = array();
+ for ($i=0; $itotals); $i++) {
+ $TotalsArray[] = array(
+ "Name" => $order->totals[$i]['title'],
+ "Price" => number_format($order->totals[$i]['value'], 2, '.', ''),
+ "Class" => $order->totals[$i]['class'],
+ "TotalID" => $order->totals[$i]['orders_total_id']);
+
+ $TotalsArray[] = array(
+ "Name" => "",
+ "Price" => "",
+ "Class" => "ot_custom",
+ "TotalID" => "0");
+ }
+
+ array_pop($TotalsArray);
+ foreach($TotalsArray as $TotalIndex => $TotalDetails)
+ {
+ $TotalStyle = "smallText";
+
+ if ($TotalDetails["Class"] == "ot_total" || $TotalDetails["Class"] == "ot_subtotal") {
+ $id = $TotalDetails["Class"];//subtotal and total should each only exist once
+
+ } elseif ($TotalDetails["Class"] == "ot_tax") {
+ $id = preg_replace("/:$/", "", $TotalDetails["Name"]) . '-total';
+
+ } elseif ($TotalDetails["Class"] == "ot_shipping") {
+ $id = $TotalDetails["Class"] . $TotalIndex;
+
+ } else {
+ $id = $TotalDetails["Class"] . $TotalIndex;
+ }
+
+ if(//tax, subtotal, and total are not editable, but have all the same format
+ $TotalDetails["Class"] == "ot_total" ||
+ $TotalDetails["Class"] == "ot_subtotal" ||
+ $TotalDetails["Class"] == "ot_tax")
+ {
+
+ echo ' ' . "\n" .
+ ' ' . $TotalDetails["Name"] . ' ' .
+ ' ' .
+ " " .
+ " " .
+ " " .
+ " \n" .
+ " " . ' ' .
+ ' ' . tep_draw_separator('pixel_trans.gif', '1', '17') . ' ' .
+ ' ' . "\n";
+ } else { //the other total components are editable
+ echo ' ' . "\n" .
+ ' ' . " " . ' ' . "\n" .
+ ' ' . " " .
+ " " .
+ " " .
+ ' ' . tep_draw_separator('pixel_trans.gif', '1', '17') . ' ' .
+ ' ' . "\n" .
+ ' ' . "\n";
+ }
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+' . "\n" .
+ ' ' . tep_datetime_short($orders_history['date_added']) . ' ' . "\n" .
+ ' ' . "\n" .
+ ' ';
+ if ($orders_history['customer_notified'] == '1') {
+ echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . " \n";
+ } else {
+ echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "\n";
+ }
+ echo ' ' . "\n" .
+ ' ' . $orders_status_array[$orders_history['orders_status_id']] . ' ' . "\n";
+ echo ' ' . "\n" .
+ ' ' . nl2br(tep_db_output($orders_history['comments'])) . ' ' . "\n";
+ echo ' ' . "\n";
+ }
+} else {
+ echo ' ' . "\n" .
+ ' ' . TEXT_NO_ORDER_HISTORY . ' ' . "\n" .
+ ' ' . "\n";
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ info['orders_status']); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+
+ ' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+
+
+
+
+
+' . "\n";
+
+ ?>
+
+
+
+ // Step 1: Choose Products
+ echo '' . tep_draw_form('quick_find', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n";
+ echo '' . ADDPRODUCT_TEXT_STEP . ' 1: ' . "\n";
+ echo '';
+ if (isset($_GET['add_product_products_id'])) {
+ $form_product_name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $_GET['add_product_products_id'] . "' and language_id = '" . (int)$languages_id . "'");
+ $form_product_name = tep_db_fetch_array($form_product_name_query);
+ echo ' ' . ' ';
+ }else{
+ echo ' ' . ' ';
+ }
+ echo ' ' . "\n";
+ echo ' ' . "\n";
+ echo '
' . "\n";
+ echo ' ' . "\n";
+ echo ' ' . "\n";
+
+ // Step 2: Choose Options
+ if( (($_GET['step'] > 1) && ($_GET['add_product_products_id'] > 0)) || (($_POST['step'] > 1) && ($_POST['add_product_products_id'] > 0)) )
+
+ {
+ // Get Options for Products
+ $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $_GET['add_product_products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
+ $products_attributes = tep_db_fetch_array($products_attributes_query);
+ if ($products_attributes['total'] == 0) {
+ echo '' . "\n";
+ echo '' . ADDPRODUCT_TEXT_STEP . ' 2: ' . "\n";
+ echo '' . ADDPRODUCT_TEXT_OPTIONS_NOTEXIST . ' ' . "\n";
+ echo ' ' . "\n";
+ $_POST['step'] = 3;
+ }
+ else //product options exist
+ {
+ echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action'] . '&add_product_products_id=' . $_GET['add_product_products_id']) . "\n";
+ echo '' . ADDPRODUCT_TEXT_STEP . ' 2: ';
+ $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $_GET['add_product_products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
+ while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
+ $products_options_array = array();
+ $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $_GET['add_product_products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
+ while ($products_options = tep_db_fetch_array($products_options_query)) {
+ $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
+ if ($products_options['options_values_price'] != '0') {
+ $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
+ }
+ }
+
+ if(isset($_POST['add_product_options'])) {
+ $selected_attribute = $_POST['add_product_options'][$products_options_name['products_options_id']];
+ } else {
+ $selected_attribute = false;
+ }
+
+ echo $products_options_name['products_options_name'] . ':' . "\n";
+ echo tep_draw_pull_down_menu('add_product_options[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . ' ' . "\n";
+ }
+
+ echo ' ';
+ echo ' ';
+ echo ' ';
+ echo ' ';
+ echo ' ' . "\n";
+ echo ' ' . "\n";
+ }
+ echo ' ' . "\n";
+ }
+
+ // Step 3: Confirm
+ if($_POST['step'] > 2)
+ {
+ echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n";
+ echo '' . ADDPRODUCT_TEXT_STEP . ' 3: ';
+ echo ' ';
+ echo ' ' . ADDPRODUCT_TEXT_CONFIRM_QUANTITY . ' ';
+ echo ' ';
+ if(is_array ($_POST['add_product_options']))
+ {
+ foreach($_POST['add_product_options'] as $option_id => $option_value_id)
+ {
+ echo ' ';
+ }
+ }
+ echo ' ';
+ echo ' ';
+ echo ' ' . "\n";
+ echo ' ' . "\n";
+ }
+ echo '
' . "\n";
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/catalog/admin/file_manager.php b/src/catalog/admin/file_manager.php
new file mode 100644
index 0000000..3504674
--- /dev/null
+++ b/src/catalog/admin/file_manager.php
@@ -0,0 +1,348 @@
+add(sprintf(ERROR_DIRECTORY_NOT_WRITEABLE, $current_path), 'error');
+ }
+ break;
+ case 'edit':
+ if (strstr($HTTP_GET_VARS['info'], '..')) tep_redirect(tep_href_link(FILENAME_FILE_MANAGER));
+
+ $file_writeable = true;
+ if (!is_writeable($current_path . '/' . $HTTP_GET_VARS['info'])) {
+ $file_writeable = false;
+ $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $current_path . '/' . $HTTP_GET_VARS['info']), 'error');
+ }
+ break;
+ case 'delete':
+ if (strstr($HTTP_GET_VARS['info'], '..')) tep_redirect(tep_href_link(FILENAME_FILE_MANAGER));
+ break;
+ }
+ }
+
+ $in_directory = substr(substr(DIR_FS_DOCUMENT_ROOT, strrpos(DIR_FS_DOCUMENT_ROOT, '/')), 1);
+ $current_path_array = explode('/', $current_path);
+ $document_root_array = explode('/', DIR_FS_DOCUMENT_ROOT);
+ $goto_array = array(array('id' => DIR_FS_DOCUMENT_ROOT, 'text' => $in_directory));
+ for ($i=0, $n=sizeof($current_path_array); $i<$n; $i++) {
+ if ((isset($document_root_array[$i]) && ($current_path_array[$i] != $document_root_array[$i])) || !isset($document_root_array[$i])) {
+ $goto_array[] = array('id' => implode('/', array_slice($current_path_array, 0, $i+1)), 'text' => $current_path_array[$i]);
+ }
+ }
+?>
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . $current_path . ' '; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+
+
+
+read()) {
+ if ( ($file != '.') && ($file != 'CVS') && ( ($file != '..') || ($current_path != DIR_FS_DOCUMENT_ROOT) ) ) {
+ $file_size = number_format(filesize($current_path . '/' . $file)) . ' bytes';
+
+ $permissions = tep_get_file_permissions(fileperms($current_path . '/' . $file));
+ if ($showuser) {
+ $user = @posix_getpwuid(fileowner($current_path . '/' . $file));
+ $group = @posix_getgrgid(filegroup($current_path . '/' . $file));
+ } else {
+ $user = $group = array();
+ }
+
+ $contents[] = array('name' => $file,
+ 'is_dir' => is_dir($current_path . '/' . $file),
+ 'last_modified' => strftime(DATE_TIME_FORMAT, filemtime($current_path . '/' . $file)),
+ 'size' => $file_size,
+ 'permissions' => $permissions,
+ 'user' => $user['name'],
+ 'group' => $group['name']);
+ }
+ }
+
+ function tep_cmp($a, $b) {
+ return strcmp( ($a['is_dir'] ? 'D' : 'F') . $a['name'], ($b['is_dir'] ? 'D' : 'F') . $b['name']);
+ }
+ usort($contents, 'tep_cmp');
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name)) {
+ if ($fInfo->is_dir) {
+ echo ' ' . "\n";
+ $onclick_link = 'goto=' . $goto_link;
+ } else {
+ echo ' ' . "\n";
+ $onclick_link = 'info=' . urlencode($fInfo->name) . '&action=edit';
+ }
+ } else {
+ echo ' ' . "\n";
+ $onclick_link = 'info=' . urlencode($contents[$i]['name']);
+ }
+
+ if ($contents[$i]['is_dir']) {
+ if ($contents[$i]['name'] == '..') {
+ $icon = tep_image(DIR_WS_ICONS . 'previous_level.gif', ICON_PREVIOUS_LEVEL);
+ } else {
+ $icon = (isset($fInfo) && is_object($fInfo) && ($contents[$i]['name'] == $fInfo->name) ? tep_image(DIR_WS_ICONS . 'current_folder.gif', ICON_CURRENT_FOLDER) : tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER));
+ }
+ $link = tep_href_link(FILENAME_FILE_MANAGER, 'goto=' . $goto_link);
+ } else {
+ $icon = tep_image(DIR_WS_ICONS . 'file_download.gif', ICON_FILE_DOWNLOAD);
+ $link = tep_href_link(FILENAME_FILE_MANAGER, 'action=download&filename=' . urlencode($contents[$i]['name']));
+ }
+?>
+ ' . $icon . ' ' . $contents[$i]['name']; ?>
+
+
+
+
+
+ ' . tep_image(DIR_WS_ICONS . 'delete.gif', ICON_DELETE) . ' '; if (isset($fInfo) && is_object($fInfo) && ($fInfo->name == $contents[$i]['name'])) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } ?>
+
+
+
+
+
+
+ '' . $fInfo->name . ' ');
+
+ $contents = array('form' => tep_draw_form('file', FILENAME_FILE_MANAGER, 'info=' . urlencode($fInfo->name) . '&action=deleteconfirm'));
+ $contents[] = array('text' => TEXT_DELETE_INTRO);
+ $contents[] = array('text' => '' . $fInfo->name . ' ');
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'new_folder':
+ $heading[] = array('text' => '' . TEXT_NEW_FOLDER . ' ');
+
+ $contents = array('form' => tep_draw_form('folder', FILENAME_FILE_MANAGER, 'action=insert'));
+ $contents[] = array('text' => TEXT_NEW_FOLDER_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_FILE_NAME . ' ' . tep_draw_input_field('folder_name'));
+ $contents[] = array('align' => 'center', 'text' => ' ' . (($directory_writeable == true) ? tep_image_submit('button_save.gif', IMAGE_SAVE) : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'upload':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_UPLOAD . ' ');
+
+ $contents = array('form' => tep_draw_form('file', FILENAME_FILE_MANAGER, 'action=processuploads', 'post', 'enctype="multipart/form-data"'));
+ $contents[] = array('text' => TEXT_UPLOAD_INTRO);
+
+ $file_upload = '';
+ for ($i=1; $i<6; $i++) $file_upload .= tep_draw_file_field('file_' . $i) . ' ';
+
+ $contents[] = array('text' => ' ' . $file_upload);
+ $contents[] = array('align' => 'center', 'text' => ' ' . (($directory_writeable == true) ? tep_image_submit('button_upload.gif', IMAGE_UPLOAD) : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ default:
+ if (isset($fInfo) && is_object($fInfo)) {
+ $heading[] = array('text' => '' . $fInfo->name . ' ');
+
+ if (!$fInfo->is_dir) $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' ');
+ $contents[] = array('text' => ' ' . TEXT_FILE_NAME . ' ' . $fInfo->name . ' ');
+ if (!$fInfo->is_dir) $contents[] = array('text' => ' ' . TEXT_FILE_SIZE . ' ' . $fInfo->size . ' ');
+ $contents[] = array('text' => ' ' . TEXT_LAST_MODIFIED . ' ' . $fInfo->last_modified);
+ }
+ }
+
+ if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
+ echo ' ' . "\n";
+
+ $box = new box;
+ echo $box->infoBox($heading, $contents);
+
+ echo ' ' . "\n";
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalog/admin/geo_zones.php b/src/catalog/admin/geo_zones.php
new file mode 100644
index 0000000..59104bf
--- /dev/null
+++ b/src/catalog/admin/geo_zones.php
@@ -0,0 +1,353 @@
+
+
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . tep_get_geo_zone_name($HTTP_GET_VARS['zone']) . ' '; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+association_id)) {
+ echo ' ' . "\n";
+ } else {
+ echo ' ' . "\n";
+ }
+?>
+
+
+ association_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } ?>
+
+
+
+
+
+ display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['spage'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?>
+ display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['spage'], 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list', 'spage'); ?>
+
+
+
+
+ ' . tep_image_button('button_back.gif', IMAGE_BACK) . ' ' . tep_image_button('button_insert.gif', IMAGE_INSERT) . ' '; ?>
+
+
+
+
+
+
+
+
+ 0) {
+ $zones['num_zones'] = $num_zones['num_zones'];
+ } else {
+ $zones['num_zones'] = 0;
+ }
+
+ $zInfo = new objectInfo($zones);
+ }
+ if (isset($zInfo) && is_object($zInfo) && ($zones['geo_zone_id'] == $zInfo->geo_zone_id)) {
+ echo ' ' . "\n";
+ } else {
+ echo ' ' . "\n";
+ }
+?>
+ ' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' ' . $zones['geo_zone_name']; ?>
+ geo_zone_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } ?>
+
+
+
+
+
+ display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['zpage'], TEXT_DISPLAY_NUMBER_OF_TAX_ZONES); ?>
+ display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['zpage'], '', 'zpage'); ?>
+
+
+
+
+ geo_zone_id . '&action=new_zone') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
+
+
+
+
+ '' . TEXT_INFO_HEADING_NEW_SUB_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&' . (isset($HTTP_GET_VARS['sID']) ? 'sID=' . $HTTP_GET_VARS['sID'] . '&' : '') . 'saction=insert_sub'));
+ $contents[] = array('text' => TEXT_INFO_NEW_SUB_ZONE_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_COUNTRY . ' ' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(TEXT_ALL_COUNTRIES), '', 'onChange="update_zone(this.form);"'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_COUNTRY_ZONE . ' ' . tep_draw_pull_down_menu('zone_id', tep_prepare_country_zones_pull_down()));
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'edit':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_SUB_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&sID=' . $sInfo->association_id . '&saction=save_sub'));
+ $contents[] = array('text' => TEXT_INFO_EDIT_SUB_ZONE_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_COUNTRY . ' ' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(TEXT_ALL_COUNTRIES), $sInfo->zone_country_id, 'onChange="update_zone(this.form);"'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_COUNTRY_ZONE . ' ' . tep_draw_pull_down_menu('zone_id', tep_prepare_country_zones_pull_down($sInfo->zone_country_id), $sInfo->zone_id));
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'delete':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_SUB_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&sID=' . $sInfo->association_id . '&saction=deleteconfirm_sub'));
+ $contents[] = array('text' => TEXT_INFO_DELETE_SUB_ZONE_INTRO);
+ $contents[] = array('text' => '' . $sInfo->countries_name . ' ');
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ default:
+ if (isset($sInfo) && is_object($sInfo)) {
+ $heading[] = array('text' => '' . $sInfo->countries_name . ' ');
+
+ $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ');
+ $contents[] = array('text' => ' ' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->date_added));
+ if (tep_not_null($sInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->last_modified));
+ }
+ break;
+ }
+ } else {
+ switch ($action) {
+ case 'new_zone':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_NEW_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=insert_zone'));
+ $contents[] = array('text' => TEXT_INFO_NEW_ZONE_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_ZONE_NAME . ' ' . tep_draw_input_field('geo_zone_name'));
+ $contents[] = array('text' => ' ' . TEXT_INFO_ZONE_DESCRIPTION . ' ' . tep_draw_input_field('geo_zone_description'));
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'edit_zone':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=save_zone'));
+ $contents[] = array('text' => TEXT_INFO_EDIT_ZONE_INTRO);
+ $contents[] = array('text' => ' ' . TEXT_INFO_ZONE_NAME . ' ' . tep_draw_input_field('geo_zone_name', $zInfo->geo_zone_name));
+ $contents[] = array('text' => ' ' . TEXT_INFO_ZONE_DESCRIPTION . ' ' . tep_draw_input_field('geo_zone_description', $zInfo->geo_zone_description));
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ case 'delete_zone':
+ $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_ZONE . ' ');
+
+ $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=deleteconfirm_zone'));
+ $contents[] = array('text' => TEXT_INFO_DELETE_ZONE_INTRO);
+ $contents[] = array('text' => '' . $zInfo->geo_zone_name . ' ');
+ $contents[] = array('align' => 'center', 'text' => ' ' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ' ');
+ break;
+ default:
+ if (isset($zInfo) && is_object($zInfo)) {
+ $heading[] = array('text' => '' . $zInfo->geo_zone_name . ' ');
+
+ $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ' . ' ' . tep_image_button('button_details.gif', IMAGE_DETAILS) . ' ');
+ $contents[] = array('text' => ' ' . TEXT_INFO_NUMBER_ZONES . ' ' . $zInfo->num_zones);
+ $contents[] = array('text' => ' ' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($zInfo->date_added));
+ if (tep_not_null($zInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($zInfo->last_modified));
+ $contents[] = array('text' => ' ' . TEXT_INFO_ZONE_DESCRIPTION . ' ' . $zInfo->geo_zone_description);
+ }
+ break;
+ }
+ }
+
+ if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
+ echo ' ' . "\n";
+
+ $box = new box;
+ echo $box->infoBox($heading, $contents);
+
+ echo ' ' . "\n";
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalog/admin/images/Thumbs.db b/src/catalog/admin/images/Thumbs.db
new file mode 100644
index 0000000..e117521
Binary files /dev/null and b/src/catalog/admin/images/Thumbs.db differ
diff --git a/src/catalog/admin/images/ani_send_email.gif b/src/catalog/admin/images/ani_send_email.gif
new file mode 100644
index 0000000..a61022b
Binary files /dev/null and b/src/catalog/admin/images/ani_send_email.gif differ
diff --git a/src/catalog/admin/images/cal_close_small.gif b/src/catalog/admin/images/cal_close_small.gif
new file mode 100644
index 0000000..e5994d2
Binary files /dev/null and b/src/catalog/admin/images/cal_close_small.gif differ
diff --git a/src/catalog/admin/images/cal_date_down.gif b/src/catalog/admin/images/cal_date_down.gif
new file mode 100644
index 0000000..4b4eed4
Binary files /dev/null and b/src/catalog/admin/images/cal_date_down.gif differ
diff --git a/src/catalog/admin/images/cal_date_over.gif b/src/catalog/admin/images/cal_date_over.gif
new file mode 100644
index 0000000..7e29a4f
Binary files /dev/null and b/src/catalog/admin/images/cal_date_over.gif differ
diff --git a/src/catalog/admin/images/cal_date_up.gif b/src/catalog/admin/images/cal_date_up.gif
new file mode 100644
index 0000000..b4b9084
Binary files /dev/null and b/src/catalog/admin/images/cal_date_up.gif differ
diff --git a/src/catalog/admin/images/cal_del_small.gif b/src/catalog/admin/images/cal_del_small.gif
new file mode 100644
index 0000000..48632c4
Binary files /dev/null and b/src/catalog/admin/images/cal_del_small.gif differ
diff --git a/src/catalog/admin/images/categories/Thumbs.db b/src/catalog/admin/images/categories/Thumbs.db
new file mode 100644
index 0000000..5897d2c
Binary files /dev/null and b/src/catalog/admin/images/categories/Thumbs.db differ
diff --git a/src/catalog/admin/images/categories/catalog.gif b/src/catalog/admin/images/categories/catalog.gif
new file mode 100644
index 0000000..e5f4b05
Binary files /dev/null and b/src/catalog/admin/images/categories/catalog.gif differ
diff --git a/src/catalog/admin/images/categories/configuration.gif b/src/catalog/admin/images/categories/configuration.gif
new file mode 100644
index 0000000..e50dcc2
Binary files /dev/null and b/src/catalog/admin/images/categories/configuration.gif differ
diff --git a/src/catalog/admin/images/categories/customers.gif b/src/catalog/admin/images/categories/customers.gif
new file mode 100644
index 0000000..bd1f334
Binary files /dev/null and b/src/catalog/admin/images/categories/customers.gif differ
diff --git a/src/catalog/admin/images/categories/localization.gif b/src/catalog/admin/images/categories/localization.gif
new file mode 100644
index 0000000..517d69e
Binary files /dev/null and b/src/catalog/admin/images/categories/localization.gif differ
diff --git a/src/catalog/admin/images/categories/location.gif b/src/catalog/admin/images/categories/location.gif
new file mode 100644
index 0000000..c29520a
Binary files /dev/null and b/src/catalog/admin/images/categories/location.gif differ
diff --git a/src/catalog/admin/images/categories/modules.gif b/src/catalog/admin/images/categories/modules.gif
new file mode 100644
index 0000000..e7e3f11
Binary files /dev/null and b/src/catalog/admin/images/categories/modules.gif differ
diff --git a/src/catalog/admin/images/categories/reports.gif b/src/catalog/admin/images/categories/reports.gif
new file mode 100644
index 0000000..f4a82c1
Binary files /dev/null and b/src/catalog/admin/images/categories/reports.gif differ
diff --git a/src/catalog/admin/images/categories/tools.gif b/src/catalog/admin/images/categories/tools.gif
new file mode 100644
index 0000000..bb55c3a
Binary files /dev/null and b/src/catalog/admin/images/categories/tools.gif differ
diff --git a/src/catalog/admin/images/graph_hbar_blue.gif b/src/catalog/admin/images/graph_hbar_blue.gif
new file mode 100644
index 0000000..3833bd7
Binary files /dev/null and b/src/catalog/admin/images/graph_hbar_blue.gif differ
diff --git a/src/catalog/admin/images/graph_hbar_red.gif b/src/catalog/admin/images/graph_hbar_red.gif
new file mode 100644
index 0000000..bef4a88
Binary files /dev/null and b/src/catalog/admin/images/graph_hbar_red.gif differ
diff --git a/src/catalog/admin/images/graphs/.cvsignore b/src/catalog/admin/images/graphs/.cvsignore
new file mode 100644
index 0000000..caa8b09
--- /dev/null
+++ b/src/catalog/admin/images/graphs/.cvsignore
@@ -0,0 +1,12 @@
+banner_infobox-*.png
+banner_daily-*.png
+banner_monthly-*.png
+banner_yearly-*.png
+banner_infobox-*.jpg
+banner_daily-*.jpg
+banner_monthly-*.jpg
+banner_yearly-*.jpg
+banner_infobox-*.gif
+banner_daily-*.gif
+banner_monthly-*.gif
+banner_yearly-*.gif
diff --git a/src/catalog/admin/images/graphs/Thumbs.db b/src/catalog/admin/images/graphs/Thumbs.db
new file mode 100644
index 0000000..7858aa7
Binary files /dev/null and b/src/catalog/admin/images/graphs/Thumbs.db differ
diff --git a/src/catalog/admin/images/graphs/banner_infobox-1.png b/src/catalog/admin/images/graphs/banner_infobox-1.png
new file mode 100644
index 0000000..50c3ed2
Binary files /dev/null and b/src/catalog/admin/images/graphs/banner_infobox-1.png differ
diff --git a/src/catalog/admin/images/graphs/dummy b/src/catalog/admin/images/graphs/dummy
new file mode 100644
index 0000000..e69de29
diff --git a/src/catalog/admin/images/header_administration.gif b/src/catalog/admin/images/header_administration.gif
new file mode 100644
index 0000000..3f08845
Binary files /dev/null and b/src/catalog/admin/images/header_administration.gif differ
diff --git a/src/catalog/admin/images/header_checkout.gif b/src/catalog/admin/images/header_checkout.gif
new file mode 100644
index 0000000..9b5bd81
Binary files /dev/null and b/src/catalog/admin/images/header_checkout.gif differ
diff --git a/src/catalog/admin/images/header_support.gif b/src/catalog/admin/images/header_support.gif
new file mode 100644
index 0000000..382c0f1
Binary files /dev/null and b/src/catalog/admin/images/header_support.gif differ
diff --git a/src/catalog/admin/images/icon_arrow_right.gif b/src/catalog/admin/images/icon_arrow_right.gif
new file mode 100644
index 0000000..9d8bc1d
Binary files /dev/null and b/src/catalog/admin/images/icon_arrow_right.gif differ
diff --git a/src/catalog/admin/images/icon_info.gif b/src/catalog/admin/images/icon_info.gif
new file mode 100644
index 0000000..7bfbc62
Binary files /dev/null and b/src/catalog/admin/images/icon_info.gif differ
diff --git a/src/catalog/admin/images/icon_popup.gif b/src/catalog/admin/images/icon_popup.gif
new file mode 100644
index 0000000..3d60f42
Binary files /dev/null and b/src/catalog/admin/images/icon_popup.gif differ
diff --git a/src/catalog/admin/images/icon_reset.gif b/src/catalog/admin/images/icon_reset.gif
new file mode 100644
index 0000000..bd1c0cb
Binary files /dev/null and b/src/catalog/admin/images/icon_reset.gif differ
diff --git a/src/catalog/admin/images/icon_save.gif b/src/catalog/admin/images/icon_save.gif
new file mode 100644
index 0000000..93f2afa
Binary files /dev/null and b/src/catalog/admin/images/icon_save.gif differ
diff --git a/src/catalog/admin/images/icon_status_green.gif b/src/catalog/admin/images/icon_status_green.gif
new file mode 100644
index 0000000..964a742
Binary files /dev/null and b/src/catalog/admin/images/icon_status_green.gif differ
diff --git a/src/catalog/admin/images/icon_status_green_light.gif b/src/catalog/admin/images/icon_status_green_light.gif
new file mode 100644
index 0000000..46e0a02
Binary files /dev/null and b/src/catalog/admin/images/icon_status_green_light.gif differ
diff --git a/src/catalog/admin/images/icon_status_red.gif b/src/catalog/admin/images/icon_status_red.gif
new file mode 100644
index 0000000..3f8c2fe
Binary files /dev/null and b/src/catalog/admin/images/icon_status_red.gif differ
diff --git a/src/catalog/admin/images/icon_status_red_light.gif b/src/catalog/admin/images/icon_status_red_light.gif
new file mode 100644
index 0000000..f264494
Binary files /dev/null and b/src/catalog/admin/images/icon_status_red_light.gif differ
diff --git a/src/catalog/admin/images/icon_status_yellow.gif b/src/catalog/admin/images/icon_status_yellow.gif
new file mode 100644
index 0000000..9cef3b8
Binary files /dev/null and b/src/catalog/admin/images/icon_status_yellow.gif differ
diff --git a/src/catalog/admin/images/icons/Thumbs.db b/src/catalog/admin/images/icons/Thumbs.db
new file mode 100644
index 0000000..0a4a17d
Binary files /dev/null and b/src/catalog/admin/images/icons/Thumbs.db differ
diff --git a/src/catalog/admin/images/icons/cross.gif b/src/catalog/admin/images/icons/cross.gif
new file mode 100644
index 0000000..76d55a2
Binary files /dev/null and b/src/catalog/admin/images/icons/cross.gif differ
diff --git a/src/catalog/admin/images/icons/current_folder.gif b/src/catalog/admin/images/icons/current_folder.gif
new file mode 100644
index 0000000..ba2d7b0
Binary files /dev/null and b/src/catalog/admin/images/icons/current_folder.gif differ
diff --git a/src/catalog/admin/images/icons/delete.gif b/src/catalog/admin/images/icons/delete.gif
new file mode 100644
index 0000000..100f1e7
Binary files /dev/null and b/src/catalog/admin/images/icons/delete.gif differ
diff --git a/src/catalog/admin/images/icons/error.gif b/src/catalog/admin/images/icons/error.gif
new file mode 100644
index 0000000..d0e4f43
Binary files /dev/null and b/src/catalog/admin/images/icons/error.gif differ
diff --git a/src/catalog/admin/images/icons/file.gif b/src/catalog/admin/images/icons/file.gif
new file mode 100644
index 0000000..3122567
Binary files /dev/null and b/src/catalog/admin/images/icons/file.gif differ
diff --git a/src/catalog/admin/images/icons/file_download.gif b/src/catalog/admin/images/icons/file_download.gif
new file mode 100644
index 0000000..83e5e95
Binary files /dev/null and b/src/catalog/admin/images/icons/file_download.gif differ
diff --git a/src/catalog/admin/images/icons/folder.gif b/src/catalog/admin/images/icons/folder.gif
new file mode 100644
index 0000000..b55d830
Binary files /dev/null and b/src/catalog/admin/images/icons/folder.gif differ
diff --git a/src/catalog/admin/images/icons/locked.gif b/src/catalog/admin/images/icons/locked.gif
new file mode 100644
index 0000000..d23d2a1
Binary files /dev/null and b/src/catalog/admin/images/icons/locked.gif differ
diff --git a/src/catalog/admin/images/icons/preview.gif b/src/catalog/admin/images/icons/preview.gif
new file mode 100644
index 0000000..7e01028
Binary files /dev/null and b/src/catalog/admin/images/icons/preview.gif differ
diff --git a/src/catalog/admin/images/icons/previous_level.gif b/src/catalog/admin/images/icons/previous_level.gif
new file mode 100644
index 0000000..1ff3913
Binary files /dev/null and b/src/catalog/admin/images/icons/previous_level.gif differ
diff --git a/src/catalog/admin/images/icons/statistics.gif b/src/catalog/admin/images/icons/statistics.gif
new file mode 100644
index 0000000..98c0c6c
Binary files /dev/null and b/src/catalog/admin/images/icons/statistics.gif differ
diff --git a/src/catalog/admin/images/icons/success.gif b/src/catalog/admin/images/icons/success.gif
new file mode 100644
index 0000000..daaebdf
Binary files /dev/null and b/src/catalog/admin/images/icons/success.gif differ
diff --git a/src/catalog/admin/images/icons/tick.gif b/src/catalog/admin/images/icons/tick.gif
new file mode 100644
index 0000000..3851940
Binary files /dev/null and b/src/catalog/admin/images/icons/tick.gif differ
diff --git a/src/catalog/admin/images/icons/unlocked.gif b/src/catalog/admin/images/icons/unlocked.gif
new file mode 100644
index 0000000..b767637
Binary files /dev/null and b/src/catalog/admin/images/icons/unlocked.gif differ
diff --git a/src/catalog/admin/images/icons/warning.gif b/src/catalog/admin/images/icons/warning.gif
new file mode 100644
index 0000000..904485c
Binary files /dev/null and b/src/catalog/admin/images/icons/warning.gif differ
diff --git a/src/catalog/admin/images/oscommerce.gif b/src/catalog/admin/images/oscommerce.gif
new file mode 100644
index 0000000..5a6a3c2
Binary files /dev/null and b/src/catalog/admin/images/oscommerce.gif differ
diff --git a/src/catalog/admin/images/pixel_black.gif b/src/catalog/admin/images/pixel_black.gif
new file mode 100644
index 0000000..f1d566b
Binary files /dev/null and b/src/catalog/admin/images/pixel_black.gif differ
diff --git a/src/catalog/admin/images/pixel_trans.gif b/src/catalog/admin/images/pixel_trans.gif
new file mode 100644
index 0000000..e7749f2
Binary files /dev/null and b/src/catalog/admin/images/pixel_trans.gif differ
diff --git a/src/catalog/admin/includes/application_bottom.php b/src/catalog/admin/includes/application_bottom.php
new file mode 100644
index 0000000..5a598cc
--- /dev/null
+++ b/src/catalog/admin/includes/application_bottom.php
@@ -0,0 +1,20 @@
+timer_stop(DISPLAY_PAGE_PARSE_TIME);
+ }
+?>
\ No newline at end of file
diff --git a/src/catalog/admin/includes/application_top.php b/src/catalog/admin/includes/application_top.php
new file mode 100644
index 0000000..27267f5
--- /dev/null
+++ b/src/catalog/admin/includes/application_top.php
@@ -0,0 +1,208 @@
+set_language($HTTP_GET_VARS['language']);
+ } else {
+ $lng->get_browser_language();
+ }
+
+ $language = $lng->language['directory'];
+ $languages_id = $lng->language['id'];
+ }
+
+// include the language translations
+ require(DIR_WS_LANGUAGES . $language . '.php');
+ $current_page = basename($PHP_SELF);
+ if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) {
+ include(DIR_WS_LANGUAGES . $language . '/' . $current_page);
+ }
+
+// define our localization functions
+ require(DIR_WS_FUNCTIONS . 'localization.php');
+
+// Include validation functions (right now only email address)
+ require(DIR_WS_FUNCTIONS . 'validations.php');
+
+// setup our boxes
+ require(DIR_WS_CLASSES . 'table_block.php');
+ require(DIR_WS_CLASSES . 'box.php');
+
+// initialize the message stack for output messages
+ require(DIR_WS_CLASSES . 'message_stack.php');
+ $messageStack = new messageStack;
+
+// split-page-results
+ require(DIR_WS_CLASSES . 'split_page_results.php');
+
+// entry/item info classes
+ require(DIR_WS_CLASSES . 'object_info.php');
+
+// email classes
+ require(DIR_WS_CLASSES . 'mime.php');
+ require(DIR_WS_CLASSES . 'email.php');
+
+// file uploading class
+ require(DIR_WS_CLASSES . 'upload.php');
+
+// calculate category path
+ if (isset($HTTP_GET_VARS['cPath'])) {
+ $cPath = $HTTP_GET_VARS['cPath'];
+ } else {
+ $cPath = '';
+ }
+
+ if (tep_not_null($cPath)) {
+ $cPath_array = tep_parse_category_path($cPath);
+ $cPath = implode('_', $cPath_array);
+ $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
+ } else {
+ $current_category_id = 0;
+ }
+
+// default open navigation box
+ if (!tep_session_is_registered('selected_box')) {
+ tep_session_register('selected_box');
+ $selected_box = 'configuration';
+ }
+
+ if (isset($HTTP_GET_VARS['selected_box'])) {
+ $selected_box = $HTTP_GET_VARS['selected_box'];
+ }
+
+// the following cache blocks are used in the Tools->Cache section
+// ('language' in the filename is automatically replaced by available languages)
+ $cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),
+ array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true),
+ array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)
+ );
+
+// check if a default currency is set
+ if (!defined('DEFAULT_CURRENCY')) {
+ $messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error');
+ }
+
+// check if a default language is set
+ if (!defined('DEFAULT_LANGUAGE')) {
+ $messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error');
+ }
+
+ if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) {
+ $messageStack->add(WARNING_FILE_UPLOADS_DISABLED, 'warning');
+ }
+?>
diff --git a/src/catalog/admin/includes/boxes/catalog.php b/src/catalog/admin/includes/boxes/catalog.php
new file mode 100644
index 0000000..6721fb4
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/catalog.php
@@ -0,0 +1,39 @@
+
+
+
+
+ BOX_HEADING_CATALOG,
+ 'link' => tep_href_link(FILENAME_CATEGORIES, 'selected_box=catalog'));
+
+ if ($selected_box == 'catalog') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+
+ ' '.
+ ' ' .
+ ' ' .
+ ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/configuration.php b/src/catalog/admin/includes/boxes/configuration.php
new file mode 100644
index 0000000..9467ed9
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/configuration.php
@@ -0,0 +1,38 @@
+
+
+
+
+ BOX_HEADING_CONFIGURATION,
+ 'link' => tep_href_link(FILENAME_CONFIGURATION, 'gID=1&selected_box=configuration'));
+
+ if ($selected_box == 'configuration') {
+ $cfg_groups = '';
+ $configuration_groups_query = tep_db_query("select configuration_group_id as cgID, configuration_group_title as cgTitle from " . TABLE_CONFIGURATION_GROUP . " where visible = '1' order by sort_order");
+ while ($configuration_groups = tep_db_fetch_array($configuration_groups_query)) {
+ $cfg_groups .= ' ';
+ }
+
+ $contents[] = array('text' => $cfg_groups);
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/customers.php b/src/catalog/admin/includes/boxes/customers.php
new file mode 100644
index 0000000..65c0f47
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/customers.php
@@ -0,0 +1,33 @@
+
+
+
+
+ BOX_HEADING_CUSTOMERS,
+ 'link' => tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers'));
+
+ if ($selected_box == 'customers') {
+ $contents[] = array('text' => ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/localization.php b/src/catalog/admin/includes/boxes/localization.php
new file mode 100644
index 0000000..68346f1
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/localization.php
@@ -0,0 +1,34 @@
+
+
+
+
+ BOX_HEADING_LOCALIZATION,
+ 'link' => tep_href_link(FILENAME_CURRENCIES, 'selected_box=localization'));
+
+ if ($selected_box == 'localization') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/modules.php b/src/catalog/admin/includes/boxes/modules.php
new file mode 100644
index 0000000..35ffc83
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/modules.php
@@ -0,0 +1,37 @@
+
+
+
+
+ BOX_HEADING_MODULES,
+ 'link' => tep_href_link(FILENAME_MODULES, 'set=payment&selected_box=modules'));
+
+ if ($selected_box == 'modules') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+ // START STS 4.1
+ ' ' .
+ // END STS 4.1
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/reports.php b/src/catalog/admin/includes/boxes/reports.php
new file mode 100644
index 0000000..d8fb6fd
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/reports.php
@@ -0,0 +1,34 @@
+
+
+
+
+ BOX_HEADING_REPORTS,
+ 'link' => tep_href_link(FILENAME_STATS_PRODUCTS_VIEWED, 'selected_box=reports'));
+
+ if ($selected_box == 'reports') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/taxes.php b/src/catalog/admin/includes/boxes/taxes.php
new file mode 100644
index 0000000..abb05b3
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/taxes.php
@@ -0,0 +1,36 @@
+
+
+
+
+ BOX_HEADING_LOCATION_AND_TAXES,
+ 'link' => tep_href_link(FILENAME_COUNTRIES, 'selected_box=taxes'));
+
+ if ($selected_box == 'taxes') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/boxes/tools.php b/src/catalog/admin/includes/boxes/tools.php
new file mode 100644
index 0000000..4b28f8d
--- /dev/null
+++ b/src/catalog/admin/includes/boxes/tools.php
@@ -0,0 +1,40 @@
+
+
+
+
+ BOX_HEADING_TOOLS,
+ 'link' => tep_href_link(FILENAME_BACKUP, 'selected_box=tools'));
+
+ if ($selected_box == 'tools') {
+ $contents[] = array('text' => ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ ' ' .
+ '');
+ }
+
+ $box = new box;
+ echo $box->menuBox($heading, $contents);
+?>
+
+
+
diff --git a/src/catalog/admin/includes/classes/box.php b/src/catalog/admin/includes/classes/box.php
new file mode 100644
index 0000000..4ff551c
--- /dev/null
+++ b/src/catalog/admin/includes/classes/box.php
@@ -0,0 +1,60 @@
+ 'class="menuBoxHeading"',
+ 'text' => BOX_HEADING_TOOLS,
+ 'link' => tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('selected_box')) . 'selected_box=tools'));
+
+ $contents = array();
+ $contents[] = array('text' => SOME_TEXT);
+
+ $box = new box;
+ echo $box->infoBox($heading, $contents);
+*/
+
+ class box extends tableBlock {
+ function box() {
+ $this->heading = array();
+ $this->contents = array();
+ }
+
+ function infoBox($heading, $contents) {
+ $this->table_row_parameters = 'class="infoBoxHeading"';
+ $this->table_data_parameters = 'class="infoBoxHeading"';
+ $this->heading = $this->tableBlock($heading);
+
+ $this->table_row_parameters = '';
+ $this->table_data_parameters = 'class="infoBoxContent"';
+ $this->contents = $this->tableBlock($contents);
+
+ return $this->heading . $this->contents;
+ }
+
+ function menuBox($heading, $contents) {
+ $this->table_data_parameters = 'class="menuBoxHeading"';
+ if (isset($heading[0]['link'])) {
+ $this->table_data_parameters .= ' onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . $heading[0]['link'] . '\'"';
+ $heading[0]['text'] = ' ';
+ } else {
+ $heading[0]['text'] = ' ' . $heading[0]['text'] . ' ';
+ }
+ $this->heading = $this->tableBlock($heading);
+
+ $this->table_data_parameters = 'class="menuBoxContent"';
+ $this->contents = $this->tableBlock($contents);
+
+ return $this->heading . $this->contents;
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/currencies.php b/src/catalog/admin/includes/classes/currencies.php
new file mode 100644
index 0000000..36cb904
--- /dev/null
+++ b/src/catalog/admin/includes/classes/currencies.php
@@ -0,0 +1,59 @@
+currencies = array();
+ $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
+ while ($currencies = tep_db_fetch_array($currencies_query)) {
+ $this->currencies[$currencies['code']] = array('title' => $currencies['title'],
+ 'symbol_left' => $currencies['symbol_left'],
+ 'symbol_right' => $currencies['symbol_right'],
+ 'decimal_point' => $currencies['decimal_point'],
+ 'thousands_point' => $currencies['thousands_point'],
+ 'decimal_places' => $currencies['decimal_places'],
+ 'value' => $currencies['value']);
+ }
+ }
+
+// class methods
+ function format($number, $calculate_currency_value = true, $currency_type = DEFAULT_CURRENCY, $currency_value = '') {
+ if ($calculate_currency_value) {
+ $rate = ($currency_value) ? $currency_value : $this->currencies[$currency_type]['value'];
+ $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number * $rate, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
+// if the selected currency is in the european euro-conversion and the default currency is euro,
+// the currency will displayed in the national currency and euro currency
+ if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) {
+ $format_string .= ' [' . $this->format($number, true, 'EUR') . '] ';
+ }
+ } else {
+ $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
+ }
+
+ return $format_string;
+ }
+
+ function get_value($code) {
+ return $this->currencies[$code]['value'];
+ }
+
+ function display_price($products_price, $products_tax, $quantity = 1) {
+ return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/email.php b/src/catalog/admin/includes/classes/email.php
new file mode 100644
index 0000000..a1e302e
--- /dev/null
+++ b/src/catalog/admin/includes/classes/email.php
@@ -0,0 +1,578 @@
+
+ and can be found here: http://www.phpguru.org
+
+ Renamed and Modified by Jan Wildeboer for osCommerce
+*/
+
+ class email {
+ var $html;
+ var $text;
+ var $output;
+ var $html_text;
+ var $html_images;
+ var $image_types;
+ var $build_params;
+ var $attachments;
+ var $headers;
+
+ function email($headers = '') {
+ if ($headers == '') $headers = array();
+
+ $this->html_images = array();
+ $this->headers = array();
+
+ if (EMAIL_LINEFEED == 'CRLF') {
+ $this->lf = "\r\n";
+ } else {
+ $this->lf = "\n";
+ }
+
+/**
+ * If you want the auto load functionality
+ * to find other mime-image/file types, add the
+ * extension and content type here.
+ */
+
+ $this->image_types = array('gif' => 'image/gif',
+ 'jpg' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'bmp' => 'image/bmp',
+ 'png' => 'image/png',
+ 'tif' => 'image/tiff',
+ 'tiff' => 'image/tiff',
+ 'swf' => 'application/x-shockwave-flash');
+
+ $this->build_params['html_encoding'] = 'quoted-printable';
+ $this->build_params['text_encoding'] = '7bit';
+ $this->build_params['html_charset'] = constant('CHARSET');
+ $this->build_params['text_charset'] = constant('CHARSET');
+ $this->build_params['text_wrap'] = 998;
+
+/**
+ * Make sure the MIME version header is first.
+ */
+
+ $this->headers[] = 'MIME-Version: 1.0';
+
+ reset($headers);
+ while (list(,$value) = each($headers)) {
+ if (tep_not_null($value)) {
+ $this->headers[] = $value;
+ }
+ }
+ }
+
+/**
+ * This function will read a file in
+ * from a supplied filename and return
+ * it. This can then be given as the first
+ * argument of the the functions
+ * add_html_image() or add_attachment().
+ */
+
+ function get_file($filename) {
+ $return = '';
+
+ if ($fp = fopen($filename, 'rb')) {
+ while (!feof($fp)) {
+ $return .= fread($fp, 1024);
+ }
+ fclose($fp);
+
+ return $return;
+ } else {
+ return false;
+ }
+ }
+
+/**
+ * Function for extracting images from
+ * html source. This function will look
+ * through the html code supplied by add_html()
+ * and find any file that ends in one of the
+ * extensions defined in $obj->image_types.
+ * If the file exists it will read it in and
+ * embed it, (not an attachment).
+ *
+ * Function contributed by Dan Allen
+ */
+
+ function find_html_images($images_dir) {
+// Build the list of image extensions
+ while (list($key, ) = each($this->image_types)) {
+ $extensions[] = $key;
+ }
+
+ preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
+
+ for ($i=0; $ihtml = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
+ }
+ }
+
+ if (tep_not_null($html_images)) {
+// If duplicate images are embedded, they may show up as attachments, so remove them.
+ $html_images = array_unique($html_images);
+ sort($html_images);
+
+ for ($i=0; $iget_file($images_dir . $html_images[$i])) {
+ $content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
+ $this->add_html_image($image, basename($html_images[$i]), $content_type);
+ }
+ }
+ }
+ }
+
+/**
+ * Adds plain text. Use this function
+ * when NOT sending html email
+ */
+
+ function add_text($text = '') {
+ $this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
+ }
+
+/**
+ * Adds a html part to the mail.
+ * Also replaces image names with
+ * content-id's.
+ */
+
+ function add_html($html, $text = NULL, $images_dir = NULL) {
+ $this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), ' ', $html);
+ $this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
+
+ if (isset($images_dir)) $this->find_html_images($images_dir);
+ }
+
+/**
+ * Adds an image to the list of embedded
+ * images.
+ */
+
+ function add_html_image($file, $name = '', $c_type='application/octet-stream') {
+ $this->html_images[] = array('body' => $file,
+ 'name' => $name,
+ 'c_type' => $c_type,
+ 'cid' => md5(uniqid(time())));
+ }
+
+/**
+ * Adds a file to the list of attachments.
+ */
+
+ function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') {
+ $this->attachments[] = array('body' => $file,
+ 'name' => $name,
+ 'c_type' => $c_type,
+ 'encoding' => $encoding);
+ }
+
+/**
+ * Adds a text subpart to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_text_part(&$obj, $text) {
+ function add_text_part(&$obj, $text) {
+ $params['content_type'] = 'text/plain';
+ $params['encoding'] = $this->build_params['text_encoding'];
+ $params['charset'] = $this->build_params['text_charset'];
+
+ if (is_object($obj)) {
+ return $obj->addSubpart($text, $params);
+ } else {
+ return new mime($text, $params);
+ }
+ }
+
+/**
+ * Adds a html subpart to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_html_part(&$obj) {
+ function add_html_part(&$obj) {
+ $params['content_type'] = 'text/html';
+ $params['encoding'] = $this->build_params['html_encoding'];
+ $params['charset'] = $this->build_params['html_charset'];
+
+ if (is_object($obj)) {
+ return $obj->addSubpart($this->html, $params);
+ } else {
+ return new mime($this->html, $params);
+ }
+ }
+
+/**
+ * Starts a message with a mixed part
+ */
+
+/* HPDL PHP3 */
+// function &add_mixed_part() {
+ function add_mixed_part() {
+ $params['content_type'] = 'multipart/mixed';
+
+ return new mime('', $params);
+ }
+
+/**
+ * Adds an alternative part to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_alternative_part(&$obj) {
+ function add_alternative_part(&$obj) {
+ $params['content_type'] = 'multipart/alternative';
+
+ if (is_object($obj)) {
+ return $obj->addSubpart('', $params);
+ } else {
+ return new mime('', $params);
+ }
+ }
+
+/**
+ * Adds a html subpart to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_related_part(&$obj) {
+ function add_related_part(&$obj) {
+ $params['content_type'] = 'multipart/related';
+
+ if (is_object($obj)) {
+ return $obj->addSubpart('', $params);
+ } else {
+ return new mime('', $params);
+ }
+ }
+
+/**
+ * Adds an html image subpart to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_html_image_part(&$obj, $value) {
+ function add_html_image_part(&$obj, $value) {
+ $params['content_type'] = $value['c_type'];
+ $params['encoding'] = 'base64';
+ $params['disposition'] = 'inline';
+ $params['dfilename'] = $value['name'];
+ $params['cid'] = $value['cid'];
+
+ $obj->addSubpart($value['body'], $params);
+ }
+
+/**
+ * Adds an attachment subpart to a mime_part object
+ */
+
+/* HPDL PHP3 */
+// function &add_attachment_part(&$obj, $value) {
+ function add_attachment_part(&$obj, $value) {
+ $params['content_type'] = $value['c_type'];
+ $params['encoding'] = $value['encoding'];
+ $params['disposition'] = 'attachment';
+ $params['dfilename'] = $value['name'];
+
+ $obj->addSubpart($value['body'], $params);
+ }
+
+/**
+ * Builds the multipart message from the
+ * list ($this->_parts). $params is an
+ * array of parameters that shape the building
+ * of the message. Currently supported are:
+ *
+ * $params['html_encoding'] - The type of encoding to use on html. Valid options are
+ * "7bit", "quoted-printable" or "base64" (all without quotes).
+ * 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable
+ * $params['text_encoding'] - The type of encoding to use on plain text Valid options are
+ * "7bit", "quoted-printable" or "base64" (all without quotes).
+ * Default is 7bit
+ * $params['text_wrap'] - The character count at which to wrap 7bit encoded data.
+ * Default this is 998.
+ * $params['html_charset'] - The character set to use for a html section.
+ * Default is iso-8859-1
+ * $params['text_charset'] - The character set to use for a text section.
+ * - Default is iso-8859-1
+ */
+
+/* HPDL PHP3 */
+// function build_message($params = array()) {
+ function build_message($params = '') {
+ if ($params == '') $params = array();
+
+ if (count($params) > 0) {
+ reset($params);
+ while(list($key, $value) = each($params)) {
+ $this->build_params[$key] = $value;
+ }
+ }
+
+ if (tep_not_null($this->html_images)) {
+ reset($this->html_images);
+ while (list(,$value) = each($this->html_images)) {
+ $this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
+ }
+ }
+
+ $null = NULL;
+ $attachments = ((tep_not_null($this->attachments)) ? true : false);
+ $html_images = ((tep_not_null($this->html_images)) ? true : false);
+ $html = ((tep_not_null($this->html)) ? true : false);
+ $text = ((tep_not_null($this->text)) ? true : false);
+
+ switch (true) {
+ case (($text == true) && ($attachments == false)):
+/* HPDL PHP3 */
+// $message =& $this->add_text_part($null, $this->text);
+ $message = $this->add_text_part($null, $this->text);
+ break;
+ case (($text == false) && ($attachments == true) && ($html == false)):
+/* HPDL PHP3 */
+// $message =& $this->add_mixed_part();
+ $message = $this->add_mixed_part();
+
+ for ($i=0; $iattachments); $i++) {
+ $this->add_attachment_part($message, $this->attachments[$i]);
+ }
+ break;
+ case (($text == true) && ($attachments == true)):
+/* HPDL PHP3 */
+// $message =& $this->add_mixed_part();
+ $message = $this->add_mixed_part();
+ $this->add_text_part($message, $this->text);
+
+ for ($i=0; $iattachments); $i++) {
+ $this->add_attachment_part($message, $this->attachments[$i]);
+ }
+ break;
+ case (($html == true) && ($attachments == false) && ($html_images == false)):
+ if (tep_not_null($this->html_text)) {
+/* HPDL PHP3 */
+// $message =& $this->add_alternative_part($null);
+ $message = $this->add_alternative_part($null);
+ $this->add_text_part($message, $this->html_text);
+ $this->add_html_part($message);
+ } else {
+/* HPDL PHP3 */
+// $message =& $this->add_html_part($null);
+ $message = $this->add_html_part($null);
+ }
+ break;
+ case (($html == true) && ($attachments == false) && ($html_images == true)):
+ if (tep_not_null($this->html_text)) {
+/* HPDL PHP3 */
+// $message =& $this->add_alternative_part($null);
+ $message = $this->add_alternative_part($null);
+ $this->add_text_part($message, $this->html_text);
+/* HPDL PHP3 */
+// $related =& $this->add_related_part($message);
+ $related = $this->add_related_part($message);
+ } else {
+/* HPDL PHP3 */
+// $message =& $this->add_related_part($null);
+// $related =& $message;
+ $message = $this->add_related_part($null);
+ $related = $message;
+ }
+ $this->add_html_part($related);
+
+ for ($i=0; $ihtml_images); $i++) {
+ $this->add_html_image_part($related, $this->html_images[$i]);
+ }
+ break;
+ case (($html == true) && ($attachments == true) && ($html_images == false)):
+/* HPDL PHP3 */
+// $message =& $this->add_mixed_part();
+ $message = $this->add_mixed_part();
+ if (tep_not_null($this->html_text)) {
+/* HPDL PHP3 */
+// $alt =& $this->add_alternative_part($message);
+ $alt = $this->add_alternative_part($message);
+ $this->add_text_part($alt, $this->html_text);
+ $this->add_html_part($alt);
+ } else {
+ $this->add_html_part($message);
+ }
+
+ for ($i=0; $iattachments); $i++) {
+ $this->add_attachment_part($message, $this->attachments[$i]);
+ }
+ break;
+ case (($html == true) && ($attachments == true) && ($html_images == true)):
+/* HPDL PHP3 */
+// $message =& $this->add_mixed_part();
+ $message = $this->add_mixed_part();
+
+ if (tep_not_null($this->html_text)) {
+/* HPDL PHP3 */
+// $alt =& $this->add_alternative_part($message);
+ $alt = $this->add_alternative_part($message);
+ $this->add_text_part($alt, $this->html_text);
+/* HPDL PHP3 */
+// $rel =& $this->add_related_part($alt);
+ $rel = $this->add_related_part($alt);
+ } else {
+/* HPDL PHP3 */
+// $rel =& $this->add_related_part($message);
+ $rel = $this->add_related_part($message);
+ }
+ $this->add_html_part($rel);
+
+ for ($i=0; $ihtml_images); $i++) {
+ $this->add_html_image_part($rel, $this->html_images[$i]);
+ }
+
+ for ($i=0; $iattachments); $i++) {
+ $this->add_attachment_part($message, $this->attachments[$i]);
+ }
+ break;
+ }
+
+ if ( (isset($message)) && (is_object($message)) ) {
+ $output = $message->encode();
+ $this->output = $output['body'];
+
+ reset($output['headers']);
+ while (list($key, $value) = each($output['headers'])) {
+ $headers[] = $key . ': ' . $value;
+ }
+
+ $this->headers = array_merge($this->headers, $headers);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+/**
+ * Sends the mail.
+ */
+
+ function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
+ if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
+ return false;
+ }
+
+ if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
+ return false;
+ }
+
+ if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
+ return false;
+ }
+
+ if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
+ return false;
+ }
+
+ if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
+ return false;
+ }
+
+ $to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
+ $from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
+
+ if (is_string($headers)) {
+ $headers = explode($this->lf, trim($headers));
+ }
+
+ for ($i=0; $ioutput, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
+ } else {
+ return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
+ }
+ }
+
+/**
+ * Use this method to return the email
+ * in message/rfc822 format. Useful for
+ * adding an email to another email as
+ * an attachment. there's a commented
+ * out example in example.php.
+ *
+ * string get_rfc822(string To name,
+ * string To email,
+ * string From name,
+ * string From email,
+ * [string Subject,
+ * string Extra headers])
+ */
+
+ function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
+// Make up the date header as according to RFC822
+ $date = 'Date: ' . date('D, d M y H:i:s');
+ $to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);
+ $from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);
+
+ if (is_string($subject)) {
+ $subject = 'Subject: ' . $subject;
+ }
+
+ if (is_string($headers)) {
+ $headers = explode($this->lf, trim($headers));
+ }
+
+ for ($i=0; $iheaders, $xtra_headers);
+
+ return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/language.php b/src/catalog/admin/includes/classes/language.php
new file mode 100644
index 0000000..9a3c7fa
--- /dev/null
+++ b/src/catalog/admin/includes/classes/language.php
@@ -0,0 +1,95 @@
+ (detect_language.php v0.1 04/02/2002)
+*/
+
+ class language {
+ var $languages, $catalog_languages, $browser_languages, $language;
+
+ function language($lng = '') {
+ $this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic',
+ 'bg' => 'bg|bulgarian',
+ 'br' => 'pt[-_]br|brazilian portuguese',
+ 'ca' => 'ca|catalan',
+ 'cs' => 'cs|czech',
+ 'da' => 'da|danish',
+ 'de' => 'de([-_][[:alpha:]]{2})?|german',
+ 'el' => 'el|greek',
+ 'en' => 'en([-_][[:alpha:]]{2})?|english',
+ 'es' => 'es([-_][[:alpha:]]{2})?|spanish',
+ 'et' => 'et|estonian',
+ 'fi' => 'fi|finnish',
+ 'fr' => 'fr([-_][[:alpha:]]{2})?|french',
+ 'gl' => 'gl|galician',
+ 'he' => 'he|hebrew',
+ 'hu' => 'hu|hungarian',
+ 'id' => 'id|indonesian',
+ 'it' => 'it|italian',
+ 'ja' => 'ja|japanese',
+ 'ko' => 'ko|korean',
+ 'ka' => 'ka|georgian',
+ 'lt' => 'lt|lithuanian',
+ 'lv' => 'lv|latvian',
+ 'nl' => 'nl([-_][[:alpha:]]{2})?|dutch',
+ 'no' => 'no|norwegian',
+ 'pl' => 'pl|polish',
+ 'pt' => 'pt([-_][[:alpha:]]{2})?|portuguese',
+ 'ro' => 'ro|romanian',
+ 'ru' => 'ru|russian',
+ 'sk' => 'sk|slovak',
+ 'sr' => 'sr|serbian',
+ 'sv' => 'sv|swedish',
+ 'th' => 'th|thai',
+ 'tr' => 'tr|turkish',
+ 'uk' => 'uk|ukrainian',
+ 'tw' => 'zh[-_]tw|chinese traditional',
+ 'zh' => 'zh|chinese simplified');
+
+ $this->catalog_languages = array();
+ $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
+ while ($languages = tep_db_fetch_array($languages_query)) {
+ $this->catalog_languages[$languages['code']] = array('id' => $languages['languages_id'],
+ 'name' => $languages['name'],
+ 'image' => $languages['image'],
+ 'directory' => $languages['directory']);
+ }
+
+ $this->browser_languages = '';
+ $this->language = '';
+
+ $this->set_language($lng);
+ }
+
+ function set_language($language) {
+ if ( (tep_not_null($language)) && (isset($this->catalog_languages[$language])) ) {
+ $this->language = $this->catalog_languages[$language];
+ } else {
+ $this->language = $this->catalog_languages[DEFAULT_LANGUAGE];
+ }
+ }
+
+ function get_browser_language() {
+ $this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));
+
+ for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {
+ reset($this->languages);
+ while (list($key, $value) = each($this->languages)) {
+ if (eregi('^(' . $value . ')(;q=[0-9]\\.[0-9])?$', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
+ $this->language = $this->catalog_languages[$key];
+ break 2;
+ }
+ }
+ }
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/logger.php b/src/catalog/admin/includes/classes/logger.php
new file mode 100644
index 0000000..7870407
--- /dev/null
+++ b/src/catalog/admin/includes/classes/logger.php
@@ -0,0 +1,52 @@
+timer_start();
+ }
+
+ function timer_start() {
+ if (defined("PAGE_PARSE_START_TIME")) {
+ $this->timer_start = PAGE_PARSE_START_TIME;
+ } else {
+ $this->timer_start = microtime();
+ }
+ }
+
+ function timer_stop($display = 'false') {
+ $this->timer_stop = microtime();
+
+ $time_start = explode(' ', $this->timer_start);
+ $time_end = explode(' ', $this->timer_stop);
+
+ $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
+
+ $this->write(getenv('REQUEST_URI'), $this->timer_total . 's');
+
+ if ($display == 'true') {
+ return $this->timer_display();
+ }
+ }
+
+ function timer_display() {
+ return 'Parse Time: ' . $this->timer_total . 's ';
+ }
+
+ function write($message, $type) {
+ error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/message_stack.php b/src/catalog/admin/includes/classes/message_stack.php
new file mode 100644
index 0000000..3fbfdca
--- /dev/null
+++ b/src/catalog/admin/includes/classes/message_stack.php
@@ -0,0 +1,71 @@
+add('Error: Error 1', 'error');
+ $messageStack->add('Error: Error 2', 'warning');
+ if ($messageStack->size > 0) echo $messageStack->output();
+*/
+
+ class messageStack extends tableBlock {
+ var $size = 0;
+
+ function messageStack() {
+ global $messageToStack;
+
+ $this->errors = array();
+
+ if (tep_session_is_registered('messageToStack')) {
+ for ($i = 0, $n = sizeof($messageToStack); $i < $n; $i++) {
+ $this->add($messageToStack[$i]['text'], $messageToStack[$i]['type']);
+ }
+ tep_session_unregister('messageToStack');
+ }
+ }
+
+ function add($message, $type = 'error') {
+ if ($type == 'error') {
+ $this->errors[] = array('params' => 'class="messageStackError"', 'text' => tep_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . ' ' . $message);
+ } elseif ($type == 'warning') {
+ $this->errors[] = array('params' => 'class="messageStackWarning"', 'text' => tep_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message);
+ } elseif ($type == 'success') {
+ $this->errors[] = array('params' => 'class="messageStackSuccess"', 'text' => tep_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . ' ' . $message);
+ } else {
+ $this->errors[] = array('params' => 'class="messageStackError"', 'text' => $message);
+ }
+
+ $this->size++;
+ }
+
+ function add_session($message, $type = 'error') {
+ global $messageToStack;
+
+ if (!tep_session_is_registered('messageToStack')) {
+ tep_session_register('messageToStack');
+ $messageToStack = array();
+ }
+
+ $messageToStack[] = array('text' => $message, 'type' => $type);
+ }
+
+ function reset() {
+ $this->errors = array();
+ $this->size = 0;
+ }
+
+ function output() {
+ $this->table_data_parameters = 'class="messageBox"';
+ return $this->tableBlock($this->errors);
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/mime.php b/src/catalog/admin/includes/classes/mime.php
new file mode 100644
index 0000000..d785b5d
--- /dev/null
+++ b/src/catalog/admin/includes/classes/mime.php
@@ -0,0 +1,250 @@
+
+ and can be found here: http://www.phpguru.org
+
+ Renamed and Modified by Jan Wildeboer for osCommerce
+*/
+
+ class mime {
+ var $_encoding;
+ var $_subparts;
+ var $_encoded;
+ var $_headers;
+ var $_body;
+
+/**
+ * Constructor.
+ *
+ * Sets up the object.
+ *
+ * @param $body - The body of the mime part if any.
+ * @param $params - An associative array of parameters:
+ * content_type - The content type for this part eg multipart/mixed
+ * encoding - The encoding to use, 7bit, base64, or quoted-printable
+ * cid - Content ID to apply
+ * disposition - Content disposition, inline or attachment
+ * dfilename - Optional filename parameter for content disposition
+ * description - Content description
+ * @access public
+ */
+
+ function mime($body, $params = '') {
+ if ($params == '') $params = array();
+
+// Make sure we use the correct linfeed sequence
+ if (EMAIL_LINEFEED == 'CRLF') {
+ $this->lf = "\r\n";
+ } else {
+ $this->lf = "\n";
+ }
+
+ reset($params);
+ while (list($key, $value) = each($params)) {
+ switch ($key) {
+ case 'content_type':
+ $headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
+ break;
+ case 'encoding':
+ $this->_encoding = $value;
+ $headers['Content-Transfer-Encoding'] = $value;
+ break;
+ case 'cid':
+ $headers['Content-ID'] = '<' . $value . '>';
+ break;
+ case 'disposition':
+ $headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : '');
+ break;
+ case 'dfilename':
+ if (isset($headers['Content-Disposition'])) {
+ $headers['Content-Disposition'] .= '; filename="' . $value . '"';
+ } else {
+ $dfilename = $value;
+ }
+ break;
+ case 'description':
+ $headers['Content-Description'] = $value;
+ break;
+ case 'charset':
+ if (isset($headers['Content-Type'])) {
+ $headers['Content-Type'] .= '; charset="' . $value . '"';
+ } else {
+ $charset = $value;
+ }
+ break;
+ }
+ }
+
+// Default content-type
+ if (!isset($_headers['Content-Type'])) {
+ $_headers['Content-Type'] = 'text/plain';
+ }
+
+// Assign stuff to member variables
+ $this->_encoded = array();
+/* HPDL PHP3 */
+// $this->_headers =& $headers;
+ $this->_headers = $headers;
+ $this->_body = $body;
+ }
+
+/**
+ * encode()
+ *
+ * Encodes and returns the email. Also stores
+ * it in the encoded member variable
+ *
+ * @return An associative array containing two elements,
+ * body and headers. The headers element is itself
+ * an indexed array.
+ * @access public
+ */
+
+ function encode() {
+/* HPDL PHP3 */
+// $encoded =& $this->_encoded;
+ $encoded = $this->_encoded;
+
+ if (tep_not_null($this->_subparts)) {
+ $boundary = '=_' . md5(uniqid(tep_rand()) . microtime());
+ $this->_headers['Content-Type'] .= ';' . $this->lf . chr(9) . 'boundary="' . $boundary . '"';
+
+// Add body parts to $subparts
+ for ($i=0; $i_subparts); $i++) {
+ $headers = array();
+/* HPDL PHP3 */
+// $tmp = $this->_subparts[$i]->encode();
+ $_subparts = $this->_subparts[$i];
+ $tmp = $_subparts->encode();
+
+ reset($tmp['headers']);
+ while (list($key, $value) = each($tmp['headers'])) {
+ $headers[] = $key . ': ' . $value;
+ }
+
+ $subparts[] = implode($this->lf, $headers) . $this->lf . $this->lf . $tmp['body'];
+ }
+
+ $encoded['body'] = '--' . $boundary . $this->lf . implode('--' . $boundary . $this->lf, $subparts) . '--' . $boundary.'--' . $this->lf;
+ } else {
+ $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . $this->lf;
+ }
+
+// Add headers to $encoded
+/* HPDL PHP3 */
+// $encoded['headers'] =& $this->_headers;
+ $encoded['headers'] = $this->_headers;
+
+ return $encoded;
+ }
+
+/**
+ * &addSubPart()
+ *
+ * Adds a subpart to current mime part and returns
+ * a reference to it
+ *
+ * @param $body The body of the subpart, if any.
+ * @param $params The parameters for the subpart, same
+ * as the $params argument for constructor.
+ * @return A reference to the part you just added. It is
+ * crucial if using multipart/* in your subparts that
+ * you use =& in your script when calling this function,
+ * otherwise you will not be able to add further subparts.
+ * @access public
+ */
+
+/* HPDL PHP3 */
+// function &addSubPart($body, $params) {
+ function addSubPart($body, $params) {
+ $this->_subparts[] = new mime($body, $params);
+
+ return $this->_subparts[count($this->_subparts) - 1];
+ }
+
+/**
+ * _getEncodedData()
+ *
+ * Returns encoded data based upon encoding passed to it
+ *
+ * @param $data The data to encode.
+ * @param $encoding The encoding type to use, 7bit, base64,
+ * or quoted-printable.
+ * @access private
+ */
+
+ function _getEncodedData($data, $encoding) {
+ switch ($encoding) {
+ case '7bit':
+ return $data;
+ break;
+ case 'quoted-printable':
+ return $this->_quotedPrintableEncode($data);
+ break;
+ case 'base64':
+ return rtrim(chunk_split(base64_encode($data), 76, $this->lf));
+ break;
+ }
+ }
+
+/**
+ * quoteadPrintableEncode()
+ *
+ * Encodes data to quoted-printable standard.
+ *
+ * @param $input The data to encode
+ * @param $line_max Optional max line length. Should
+ * not be more than 76 chars
+ *
+ * @access private
+ */
+
+ function _quotedPrintableEncode($input , $line_max = 76) {
+ $lines = preg_split("/\r\n|\r|\n/", $input);
+ $eol = $this->lf;
+ $escape = '=';
+ $output = '';
+
+ while (list(, $line) = each($lines)) {
+ $linlen = strlen($line);
+ $newline = '';
+
+ for ($i = 0; $i < $linlen; $i++) {
+ $char = substr($line, $i, 1);
+ $dec = ord($char);
+
+// convert space at eol only
+ if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
+ $char = '=20';
+ } elseif ($dec == 9) {
+// Do nothing if a tab.
+ } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
+ $char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
+ }
+
+// $this->lf is not counted
+ if ((strlen($newline) + strlen($char)) >= $line_max) {
+// soft line break; " =\r\n" is okay
+ $output .= $newline . $escape . $eol;
+ $newline = '';
+ }
+ $newline .= $char;
+ }
+ $output .= $newline . $eol;
+ }
+// Don't want last crlf
+ $output = substr($output, 0, -1 * strlen($eol));
+
+ return $output;
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/object_info.php b/src/catalog/admin/includes/classes/object_info.php
new file mode 100644
index 0000000..c54ce35
--- /dev/null
+++ b/src/catalog/admin/includes/classes/object_info.php
@@ -0,0 +1,23 @@
+$key = tep_db_prepare_input($value);
+ }
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/oe_order.php b/src/catalog/admin/includes/classes/oe_order.php
new file mode 100644
index 0000000..7e5f78f
--- /dev/null
+++ b/src/catalog/admin/includes/classes/oe_order.php
@@ -0,0 +1,148 @@
+info = array();
+ $this->totals = array();
+ $this->products = array();
+ $this->customer = array();
+ $this->delivery = array();
+
+ $this->query($order_id);
+ }
+//Begin Order Editor modifications
+ function query($order_id) {
+ $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
+ $order = tep_db_fetch_array($order_query);
+
+ $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
+ while ($totals = tep_db_fetch_array($totals_query)) {
+ $this->totals[] = array(
+ 'title' => $totals['title'],
+ 'text' => $totals['text'],
+ 'class' => $totals['class'],
+ 'value' => $totals['value'],
+ 'sort_order' => $totals['sort_order'],
+ 'orders_total_id' => $totals['orders_total_id']);
+ }
+
+ $this->info = array('currency' => $order['currency'],
+ 'currency_value' => $order['currency_value'],
+ 'payment_method' => $order['payment_method'],
+ 'cc_type' => $order['cc_type'],
+ 'cc_owner' => $order['cc_owner'],
+ 'cc_number' => $order['cc_number'],
+ 'cc_expires' => $order['cc_expires'],
+ 'shipping_tax' => $order['shipping_tax'],
+ 'date_purchased' => $order['date_purchased'],
+ 'orders_status' => $order['orders_status'],
+ 'last_modified' => $order['last_modified']);
+
+ $this->customer = array('name' => $order['customers_name'],
+ 'company' => $order['customers_company'],
+ 'street_address' => $order['customers_street_address'],
+ 'suburb' => $order['customers_suburb'],
+ 'city' => $order['customers_city'],
+ 'postcode' => $order['customers_postcode'],
+ 'state' => $order['customers_state'],
+ 'country' => $order['customers_country'],
+ 'country_id' => tep_get_country_id($order['customers_country']),
+ 'zone_id' => tep_get_zone_id(tep_get_country_id($order['customers_country']), $order['customers_state']),
+ 'format_id' => $order['customers_address_format_id'],
+ 'telephone' => $order['customers_telephone'],
+ 'email_address' => $order['customers_email_address']);
+
+ $this->delivery = array('name' => $order['delivery_name'],
+ 'company' => $order['delivery_company'],
+ 'street_address' => $order['delivery_street_address'],
+ 'suburb' => $order['delivery_suburb'],
+ 'city' => $order['delivery_city'],
+ 'postcode' => $order['delivery_postcode'],
+ 'state' => $order['delivery_state'],
+ 'country' => $order['delivery_country'],
+ 'country_id' => tep_get_country_id($order['delivery_country']),
+ 'zone_id' => tep_get_zone_id(tep_get_country_id($order['delivery_country']), $order['delivery_state']),
+ 'format_id' => $order['delivery_address_format_id']);
+
+ $this->billing = array('name' => $order['billing_name'],
+ 'company' => $order['billing_company'],
+ 'street_address' => $order['billing_street_address'],
+ 'suburb' => $order['billing_suburb'],
+ 'city' => $order['billing_city'],
+ 'postcode' => $order['billing_postcode'],
+ 'state' => $order['billing_state'],
+ 'country' => $order['billing_country'],
+ 'country_id' => tep_get_country_id($order['billing_country']),
+ 'zone_id' => tep_get_zone_id(tep_get_country_id($order['billing_country']), $order['billing_state']),
+ 'format_id' => $order['billing_address_format_id']);
+
+
+ $countryid = tep_get_country_id($this->delivery["country"]);
+ $zoneid = tep_get_zone_id($countryid, $this->delivery["state"]);
+
+ $index = 0;
+ $orders_products_query = tep_db_query("
+ SELECT
+ op.orders_products_id,
+ op.products_name,
+ op.products_model,
+ op.products_price,
+ op.products_tax,
+ op.products_quantity,
+ op.final_price,
+ p.products_tax_class_id,
+ p.products_weight,
+ p.products_id
+ FROM " . TABLE_ORDERS_PRODUCTS . " op
+ LEFT JOIN " . TABLE_PRODUCTS . " p
+ ON op.products_id = p.products_id
+ WHERE orders_id = '" . (int)$order_id . "'");
+
+ while ($orders_products = tep_db_fetch_array($orders_products_query)) {
+ $this->products[$index] = array(
+ 'qty' => $orders_products['products_quantity'],
+ 'name' => $orders_products['products_name'],
+ 'model' => $orders_products['products_model'],
+ 'tax' => $orders_products['products_tax'],
+ 'tax_description' => tep_get_tax_description($orders_products['products_tax_class_id'], $countryid, $zoneid),
+ 'price' => $orders_products['products_price'],
+ 'final_price' => $orders_products['final_price'],
+ 'weight' => $orders_products['products_weight'],
+ //START MOD per visualizzare le quantità dei prodotti disponibili nella riga di descrizione del prodotto
+ 'magazzino' => $orders_products['products_id'],
+ //END MOD per visualizzare le quantità dei prodotti disponibili nella riga di descrizione del prodotto
+ 'orders_products_id' => $orders_products['orders_products_id']);
+
+
+ $subindex = 0;
+ $attributes_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
+ if (tep_db_num_rows($attributes_query)) {
+ while ($attributes = tep_db_fetch_array($attributes_query)) {
+ $this->products[$index]['attributes'][$subindex] =
+ array('option' => $attributes['products_options'],
+ 'value' => $attributes['products_options_values'],
+ 'prefix' => $attributes['price_prefix'],
+ 'price' => $attributes['options_values_price'],
+ 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);
+
+ $subindex++;
+ }
+ }
+ $index++;
+ }
+ }
+ }
+ //end Order Editor
+?>
diff --git a/src/catalog/admin/includes/classes/order.php b/src/catalog/admin/includes/classes/order.php
new file mode 100644
index 0000000..25ea6e0
--- /dev/null
+++ b/src/catalog/admin/includes/classes/order.php
@@ -0,0 +1,106 @@
+info = array();
+ $this->totals = array();
+ $this->products = array();
+ $this->customer = array();
+ $this->delivery = array();
+
+ $this->query($order_id);
+ }
+
+ function query($order_id) {
+ $order_query = tep_db_query("select customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_telephone, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
+ $order = tep_db_fetch_array($order_query);
+
+ $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
+ while ($totals = tep_db_fetch_array($totals_query)) {
+ $this->totals[] = array('title' => $totals['title'],
+ 'text' => $totals['text']);
+ }
+
+ $this->info = array('currency' => $order['currency'],
+ 'currency_value' => $order['currency_value'],
+ 'payment_method' => $order['payment_method'],
+ 'cc_type' => $order['cc_type'],
+ 'cc_owner' => $order['cc_owner'],
+ 'cc_number' => $order['cc_number'],
+ 'cc_expires' => $order['cc_expires'],
+ 'date_purchased' => $order['date_purchased'],
+ 'orders_status' => $order['orders_status'],
+ 'last_modified' => $order['last_modified']);
+
+ $this->customer = array('name' => $order['customers_name'],
+ 'company' => $order['customers_company'],
+ 'street_address' => $order['customers_street_address'],
+ 'suburb' => $order['customers_suburb'],
+ 'city' => $order['customers_city'],
+ 'postcode' => $order['customers_postcode'],
+ 'state' => $order['customers_state'],
+ 'country' => $order['customers_country'],
+ 'format_id' => $order['customers_address_format_id'],
+ 'telephone' => $order['customers_telephone'],
+ 'email_address' => $order['customers_email_address']);
+
+ $this->delivery = array('name' => $order['delivery_name'],
+ 'company' => $order['delivery_company'],
+ 'street_address' => $order['delivery_street_address'],
+ 'suburb' => $order['delivery_suburb'],
+ 'city' => $order['delivery_city'],
+ 'postcode' => $order['delivery_postcode'],
+ 'state' => $order['delivery_state'],
+ 'country' => $order['delivery_country'],
+ 'telephone' => $order['delivery_telephone'], //Rodax Software
+ 'format_id' => $order['delivery_address_format_id']);
+
+ $this->billing = array('name' => $order['billing_name'],
+ 'company' => $order['billing_company'],
+ 'street_address' => $order['billing_street_address'],
+ 'suburb' => $order['billing_suburb'],
+ 'city' => $order['billing_city'],
+ 'postcode' => $order['billing_postcode'],
+ 'state' => $order['billing_state'],
+ 'country' => $order['billing_country'],
+ 'format_id' => $order['billing_address_format_id']);
+
+ $index = 0;
+ $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
+ while ($orders_products = tep_db_fetch_array($orders_products_query)) {
+ $this->products[$index] = array('qty' => $orders_products['products_quantity'],
+ 'name' => $orders_products['products_name'],
+ 'model' => $orders_products['products_model'],
+ 'tax' => $orders_products['products_tax'],
+ 'price' => $orders_products['products_price'],
+ 'final_price' => $orders_products['final_price']);
+
+ $subindex = 0;
+ $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
+ if (tep_db_num_rows($attributes_query)) {
+ while ($attributes = tep_db_fetch_array($attributes_query)) {
+ $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
+ 'value' => $attributes['products_options_values'],
+ 'prefix' => $attributes['price_prefix'],
+ 'price' => $attributes['options_values_price']);
+
+ $subindex++;
+ }
+ }
+ $index++;
+ }
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/payment_module_info.php b/src/catalog/admin/includes/classes/payment_module_info.php
new file mode 100644
index 0000000..177ac28
--- /dev/null
+++ b/src/catalog/admin/includes/classes/payment_module_info.php
@@ -0,0 +1,19 @@
+payment_code = $pmInfo_array['payment_code'];
+
+ for ($i = 0, $n = sizeof($pmInfo_array) - 1; $i < $n; $i++) {
+ $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description from " . TABLE_CONFIGURATION . " where configuration_key = '" . $pmInfo_array[$i] . "'");
+ $key_value = tep_db_fetch_array($key_value_query);
+
+ $this->keys[$pmInfo_array[$i]]['title'] = $key_value['configuration_title'];
+ $this->keys[$pmInfo_array[$i]]['value'] = $key_value['configuration_value'];
+ $this->keys[$pmInfo_array[$i]]['description'] = $key_value['configuration_description'];
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/src/catalog/admin/includes/classes/phplot.php b/src/catalog/admin/includes/classes/phplot.php
new file mode 100644
index 0000000..c5c1a41
--- /dev/null
+++ b/src/catalog/admin/includes/classes/phplot.php
@@ -0,0 +1,2639 @@
+ 0
+
+ var $point_size = 10;
+ var $point_shape = 'diamond'; //rect,circle,diamond,triangle,dot,line,halfline
+ var $error_bar_shape = 'tee'; //tee, line
+ var $error_bar_size = 5; //right left size of tee
+ var $error_bar_line_width = ''; //If set then use it, else use $line_width for thickness
+ var $error_bar_color = '';
+ var $data_values;
+
+ var $plot_border_type = 'full'; //left, none, full
+ var $plot_area_width = '';
+ var $number_x_points;
+ var $plot_min_x; // Max and min of the plot area
+ var $plot_max_x= ''; // Max and min of the plot area
+ var $plot_min_y= ''; // Max and min of the plot area
+ var $plot_max_y = ''; // Max and min of the plot area
+ var $min_y = '';
+ var $max_y = '';
+ var $max_x = 10; //Must not be = 0;
+ var $y_precision = '1';
+ var $x_precision = '1';
+ var $si_units = '';
+
+//Labels
+ var $draw_data_labels = '0';
+ var $legend = ''; //an array
+ var $legend_x_pos = '';
+ var $legend_y_pos = '';
+ var $title_txt = "";
+ var $y_label_txt = '';
+ var $x_label_txt = "";
+
+//DataAxis Labels (on each axis)
+ var $y_grid_label_type = 'data'; //data, none, time, other
+ var $y_grid_label_pos = 'plotleft'; //plotleft, plotright, yaxis, both
+ var $x_grid_label_type = 'data'; //data, title, none, time, other
+ var $draw_x_data_labels = ''; // 0=false, 1=true, ""=let program decide
+ var $x_time_format = "%H:%m:%s"; //See http://www.php.net/manual/html/function.strftime.html
+ var $x_datalabel_maxlength = 10;
+
+//Tick Formatting
+ var $tick_length = '10'; //pixels: tick length from axis left/downward
+ //tick_length2 to be implemented
+ //var $tick_length2 = ''; //pixels: tick length from axis line rightward/upward
+ var $draw_vert_ticks = 1; //1 = draw ticks, 0 = don't draw ticks
+ var $num_vert_ticks = '';
+ var $vert_tick_increment=''; //Set num_vert_ticks or vert_tick_increment, not both.
+ var $vert_tick_position = 'both'; //plotright=(right of plot only), plotleft=(left of plot only),
+ //both = (both left and right of plot), yaxis=(crosses y axis)
+ var $horiz_tick_increment=''; //Set num_horiz_ticks or horiz_tick_increment, not both.
+ var $num_horiz_ticks='';
+ var $skip_top_tick = '0';
+ var $skip_bottom_tick = '0';
+
+//Grid Formatting
+ var $draw_x_grid = 0;
+ var $draw_y_grid = 1;
+
+
+//BEGIN CODE
+//////////////////////////////////////////////////////
+ //Constructor: Setup Img pointer, Colors and Size of Image
+ function PHPlot($which_width=600,$which_height=400,$which_output_file="",$which_input_file="") {
+
+ $this->SetRGBArray('2');
+ $this->background_done = 0; //Set to 1 after background image first drawn
+
+ if ($which_output_file != "") { $this->SetOutputFile($which_output_file); };
+
+ if ($which_input_file != "") {
+ $this->SetInputFile($which_input_file) ;
+ } else {
+ $this->SetImageArea($which_width, $which_height);
+ $this->InitImage();
+ }
+
+ if ( ($this->session_set == 1) && ($this->img == "") ) { //For sessions
+ //Do nothing
+ } else {
+ $this->SetDefaultColors();
+ }
+
+ $this->SetIndexColors();
+
+ }
+
+ //Set up the image and colors
+ function InitImage() {
+ //if ($this->img) {
+ // ImageDestroy($this->img);
+ //}
+ $this->img = ImageCreate($this->image_width, $this->image_height);
+ return true;
+ }
+
+ function SetBrowserCache($which_browser_cache) { //Submitted by Thiemo Nagel
+ $this->browser_cache = $which_browser_cache;
+ return true;
+ }
+
+ function SetPrintImage($which_pi) {
+ $this->print_image = $which_pi;
+ return true;
+ }
+
+ function SetIsInline($which_ii) {
+ $this->is_inline = $which_ii;
+ return true;
+ }
+
+ function SetUseTTF($which_ttf) {
+ $this->use_ttf = $which_ttf;
+ return true;
+ }
+
+ function SetTitleFontSize($which_tfs) {
+ //TTF
+ $this->title_ttffont_size = $which_tfs; //pt size
+
+ //Non-TTF settings
+ if (($which_tfs > 5) && (!$this->use_ttf)) {
+ $this->DrawError('Non-TTF font size must be 1,2,3,4 or 5');
+ return false;
+ } else {
+ $this->title_font = $which_tfs;
+ //$this->title_font_height = ImageFontHeight($which_tfs) // height in pixels
+ //$this->title_font_width = ImageFontWidth($which_tfs); // width in pixels
+ }
+ return true;
+ }
+
+ function SetLineStyles($which_sls){
+ $this->line_style = $which_sls;
+ return true;
+ }
+
+ function SetLegend($which_leg){
+ if (is_array($which_leg)) {
+ $this->legend = $which_leg;
+ return true;
+ } else {
+ $this->DrawError('Error: SetLegend argument must be an array');
+ return false;
+ }
+ }
+
+ function SetLegendPixels($which_x,$which_y,$which_type) {
+ //which_type not yet used
+ $this->legend_x_pos = $which_x;
+ $this->legend_y_pos = $which_y;
+ return true;
+ }
+
+ function SetLegendWorld($which_x,$which_y,$which_type='') {
+ //which_type not yet used
+ //Must be called after scales are set up.
+ if ($this->scale_is_set != 1) { $this->SetTranslation(); };
+ $this->legend_x_pos = $this->xtr($which_x);
+ $this->legend_y_pos = $this->ytr($which_y);
+ return true;
+ }
+/* ***************************************
+ function SetFileFormat($which_file_format) { //Only works with PHP4
+ $asked = strtolower($which_file_format);
+ if( $asked =="jpg" || $asked =="png" || $asked =="gif" || $asked =="wbmp" ) {
+ if( $asked=="jpg" && !(imagetypes() & IMG_JPG) )
+ return false;
+ elseif( $asked=="png" && !(imagetypes() & IMG_PNG) )
+ return false;
+ elseif( $asked=="gif" && !(imagetypes() & IMG_GIF) )
+ return false;
+ elseif( $asked=="wbmp" && !(imagetypes() & IMG_WBMP) )
+ return false;
+ else {
+ $this->img_format=$asked;
+ return true;
+ }
+ }
+ else
+ return false;
+ }
+
+*************************************** */
+ function SetFileFormat($which_file_format) {
+ //eventually test to see if that is supported - if not then return false
+ $asked = strtolower(trim($which_file_format));
+ if( ($asked=='jpg') || ($asked=='png') || ($asked=='gif') || ($asked=='wbmp') ) {
+ $this->file_format = $asked;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function SetInputFile($which_input_file) {
+ //$this->SetFileFormat($which_frmt);
+ $size = GetImageSize($which_input_file);
+ $input_type = $size[2];
+
+ switch($input_type) { //After SetFileFormat is in lower case
+ case "1":
+ $im = @ImageCreateFromGIF ($which_input_file);
+ if (!$im) { // See if it failed
+ $this->PrintError("Unable to open $which_input_file as a GIF");
+ return false;
+ }
+ break;
+ case "3":
+ $im = @ImageCreateFromPNG ($which_input_file);
+ if (!$im) { // See if it failed
+ $this->PrintError("Unable to open $which_input_file as a PNG");
+ return false;
+ }
+ break;
+ case "2":
+ $im = @ImageCreateFromJPEG ($which_input_file);
+ if (!$im) { // See if it failed
+ $this->PrintError("Unable to open $which_input_file as a JPG");
+ return false;
+ }
+ break;
+ default:
+ $this->PrintError('Please select wbmp,gif,jpg, or png for image type!');
+ return false;
+ break;
+ }
+
+ //Get Width and Height of Image
+ $this->SetImageArea($size[0],$size[1]);
+
+ $this->img = $im;
+
+ return true;
+
+ }
+
+ function SetOutputFile($which_output_file) {
+ $this->output_file = $which_output_file;
+ return true;
+ }
+
+ function SetImageArea($which_iw,$which_ih) {
+ //Note this is now an Internal function - please set w/h via PHPlot()
+ $this->image_width = $which_iw;
+ $this->image_height = $which_ih;
+
+ return true;
+ }
+
+
+ function SetYAxisPosition($which_pos) {
+ $this->y_axis_position = $which_pos;
+ return true;
+ }
+ function SetXAxisPosition($which_pos) {
+ $this->x_axis_position = $which_pos;
+ return true;
+ }
+ function SetXTimeFormat($which_xtf) {
+ $this->x_time_format = $which_xtf;
+ return true;
+ }
+ function SetXDataLabelMaxlength($which_xdlm) {
+ if ($which_xdlm >0 ) {
+ $this->x_datalabel_maxlength = $which_xdlm;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function SetXDataLabelAngle($which_xdla) {
+ $this->x_datalabel_angle = $which_xdla;
+ return true;
+ }
+ function SetXScaleType($which_xst) {
+ $this->xscale_type = $which_xst;
+ return true;
+ }
+ function SetYScaleType($which_yst) {
+ $this->yscale_type = $which_yst;
+ if ($this->x_axis_position <= 0) {
+ $this->x_axis_position = 1;
+ }
+ return true;
+ }
+
+ function SetPrecisionX($which_prec) {
+ $this->x_precision = $which_prec;
+ return true;
+ }
+ function SetPrecisionY($which_prec) {
+ $this->y_precision = $which_prec;
+ return true;
+ }
+
+
+ function SetIndexColors() { //Internal Method called to set colors and preserve state
+ //These are the colors of the image that are used. They are initialized
+ //to work with sessions and PHP.
+
+ $this->ndx_i_light = $this->SetIndexColor($this->i_light);
+ $this->ndx_i_dark = $this->SetIndexColor($this->i_dark);
+ $this->ndx_bg_color= $this->SetIndexColor($this->bg_color);
+ $this->ndx_plot_bg_color= $this->SetIndexColor($this->plot_bg_color);
+
+ $this->ndx_title_color= $this->SetIndexColor($this->title_color);
+ $this->ndx_tick_color= $this->SetIndexColor($this->tick_color);
+ $this->ndx_label_color= $this->SetIndexColor($this->label_color);
+ $this->ndx_text_color= $this->SetIndexColor($this->text_color);
+ $this->ndx_light_grid_color= $this->SetIndexColor($this->light_grid_color);
+ $this->ndx_grid_color= $this->SetIndexColor($this->grid_color);
+
+ reset($this->error_bar_color);
+ unset($ndx_error_bar_color);
+ $i = 0;
+ while (list(, $col) = each($this->error_bar_color)) {
+ $this->ndx_error_bar_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+ //reset($this->data_border_color);
+ unset($ndx_data_border_color);
+ $i = 0;
+ while (list(, $col) = each($this->data_border_color)) {
+ $this->ndx_data_border_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+ //reset($this->data_color);
+ unset($ndx_data_color);
+ $i = 0;
+ while (list(, $col) = each($this->data_color)) {
+ $this->ndx_data_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+
+ return true;
+ }
+
+
+ function SetDefaultColors() {
+
+ $this->i_light = array(194,194,194);
+ $this->i_dark = array(100,100,100);
+ $this->SetPlotBgColor(array(222,222,222));
+ $this->SetBackgroundColor(array(200,222,222)); //can use rgb values or "name" values
+ $this->SetLabelColor('black');
+ $this->SetTextColor('black');
+ $this->SetGridColor('black');
+ $this->SetLightGridColor(array(175,175,175));
+ $this->SetTickColor('black');
+ $this->SetTitleColor(array(0,0,0)); // Can be array or name
+ $this->data_color = array('blue','green','yellow','red','orange');
+ $this->error_bar_color = array('blue','green','yellow','red','orange');
+ $this->data_border_color = array('black');
+
+ $this->session_set = 1; //Mark it down for PHP session() usage.
+ }
+
+ function PrintImage() {
+
+ if ( ($this->browser_cache == 0) && ($this->is_inline == 0)) { //Submitted by Thiemo Nagel
+ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+ header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT');
+ header('Cache-Control: no-cache, must-revalidate');
+ header('Pragma: no-cache');
+ }
+
+ switch($this->file_format) {
+ case "png":
+ if ($this->is_inline == 0) {
+ Header('Content-type: image/png');
+ }
+ if ($this->is_inline == 1 && $this->output_file != "") {
+ ImagePng($this->img,$this->output_file);
+ } else {
+ ImagePng($this->img);
+ }
+ break;
+ case "jpg":
+ if ($this->is_inline == 0) {
+ Header('Content-type: image/jpeg');
+ }
+ if ($this->is_inline == 1 && $this->output_file != "") {
+ ImageJPEG($this->img,$this->output_file);
+ } else {
+ ImageJPEG($this->img);
+ }
+ break;
+ case "gif":
+ if ($this->is_inline == 0) {
+ Header('Content-type: image/gif');
+ }
+ if ($this->is_inline == 1 && $this->output_file != "") {
+ ImageGIF($this->img,$this->output_file);
+ } else {
+ ImageGIF($this->img);
+ }
+
+ break;
+ case "wbmp":
+ if ($this->is_inline == 0) {
+ Header('Content-type: image/wbmp');
+ }
+ if ($this->is_inline == 1 && $this->output_file != "") {
+ ImageWBMP($this->img,$this->output_file);
+ } else {
+ ImageWBMP($this->img);
+ }
+
+ break;
+ default:
+ $this->PrintError('Please select an image type! ');
+ break;
+ }
+ ImageDestroy($this->img);
+ return true;
+ }
+
+
+ function DrawBackground() {
+ //if ($this->img == "") { $this->InitImage(); };
+ if ($this->background_done == 0) { //Don't draw it twice if drawing two plots on one image
+ ImageFilledRectangle($this->img, 0, 0,
+ $this->image_width, $this->image_height, $this->ndx_bg_color);
+ $this->background_done = 1;
+ }
+ return true;
+ }
+
+ function DrawImageBorder() {
+ switch ($this->image_border_type) {
+ case "raised":
+ ImageLine($this->img,0,0,$this->image_width-1,0,$this->ndx_i_light);
+ ImageLine($this->img,1,1,$this->image_width-2,1,$this->ndx_i_light);
+ ImageLine($this->img,0,0,0,$this->image_height-1,$this->ndx_i_light);
+ ImageLine($this->img,1,1,1,$this->image_height-2,$this->ndx_i_light);
+ ImageLine($this->img,$this->image_width-1,0,$this->image_width-1,$this->image_height-1,$this->ndx_i_dark);
+ ImageLine($this->img,0,$this->image_height-1,$this->image_width-1,$this->image_height-1,$this->ndx_i_dark);
+ ImageLine($this->img,$this->image_width-2,1,$this->image_width-2,$this->image_height-2,$this->ndx_i_dark);
+ ImageLine($this->img,1,$this->image_height-2,$this->image_width-2,$this->image_height-2,$this->ndx_i_dark);
+ break;
+ case "plain":
+ ImageLine($this->img,0,0,$this->image_width,0,$this->ndx_i_dark);
+ ImageLine($this->img,$this->image_width-1,0,$this->image_width-1,$this->image_height,$this->ndx_i_dark);
+ ImageLine($this->img,$this->image_width-1,$this->image_height-1,0,$this->image_height-1,$this->ndx_i_dark);
+ ImageLine($this->img,0,0,0,$this->image_height,$this->ndx_i_dark);
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
+ function SetPlotBorderType($which_pbt) {
+ $this->plot_border_type = $which_pbt; //left, none, anything else=full
+ }
+
+ function SetImageBorderType($which_sibt) {
+ $this->image_border_type = $which_sibt; //raised, plain
+ }
+
+ function SetDrawPlotAreaBackground($which_dpab) {
+ $this->draw_plot_area_background = $which_dpab; // 1=true or anything else=false
+ }
+
+ function SetDrawDataLabels($which_ddl) { //Draw next to datapoints
+ $this->draw_data_labels = $which_ddl; // 1=true or anything else=false
+ }
+
+ function SetDrawXDataLabels($which_dxdl) { //Draw on X Axis
+ $this->draw_x_data_labels = $which_dxdl; // 1=true or anything else=false
+ }
+
+ function SetDrawYGrid($which_dyg) {
+ $this->draw_y_grid = $which_dyg; // 1=true or anything else=false
+ }
+
+ function SetDrawXGrid($which_dxg) {
+ $this->draw_x_grid = $which_dxg; // 1=true or anything else=false
+ }
+
+ function SetYGridLabelType($which_yglt) {
+ $this->y_grid_label_type = $which_yglt;
+ return true;
+ }
+
+ function SetXGridLabelType($which_xglt) {
+ $this->x_grid_label_type = $which_xglt;
+ return true;
+ }
+
+ function SetXLabel($xlbl) {
+ $this->x_label_txt = $xlbl;
+ return true;
+ }
+ function SetYLabel($ylbl) {
+ $this->y_label_txt = $ylbl;
+ return true;
+ }
+ function SetTitle($title) {
+ $this->title_txt = $title;
+ return true;
+ }
+
+ //function SetLabels($xlbl,$ylbl,$title) {
+ // $this->title_txt = $title;
+ // $this->x_label_txt = $xlbl;
+ // $this->y_label_txt = $ylbl;
+ //}
+
+ function DrawLabels() {
+ $this->DrawTitle();
+ $this->DrawXLabel();
+ $this->DrawYLabel();
+ return true;
+ }
+
+ function DrawXLabel() {
+ if ($this->use_ttf == 1) {
+ $xpos = $this->xtr(($this->plot_max_x + $this->plot_min_x)/2.0) ;
+ $ypos = $this->ytr($this->plot_min_y) + $this->x_label_height/2.0;
+ $this->DrawText($this->x_label_ttffont, $this->x_label_angle,
+ $xpos, $ypos, $this->ndx_label_color, $this->x_label_ttffont_size, $this->x_label_txt,'center');
+ } else {
+ //$xpos = 0.0 - (ImageFontWidth($this->small_font)*strlen($this->x_label_txt)/2.0) + $this->xtr(($this->plot_max_x+$this->plot_min_x)/2.0) ;
+ $xpos = 0.0 + $this->xtr(($this->plot_max_x+$this->plot_min_x)/2.0) ;
+ $ypos = ($this->ytr($this->plot_min_y) + $this->x_label_height/2);
+
+ $this->DrawText($this->small_font, $this->x_label_angle,
+ $xpos, $ypos, $this->ndx_label_color, "", $this->x_label_txt, 'center');
+
+ }
+ return true;
+ }
+
+ function DrawYLabel() {
+ if ($this->use_ttf == 1) {
+ $size = $this->TTFBBoxSize($this->y_label_ttffont_size, 90, $this->y_label_ttffont, $this->y_label_txt);
+ $xpos = 8 + $size[0];
+ $ypos = ($size[1])/2 + $this->ytr(($this->plot_max_y + $this->plot_min_y)/2.0) ;
+ $this->DrawText($this->y_label_ttffont, 90,
+ $xpos, $ypos, $this->ndx_label_color, $this->y_label_ttffont_size, $this->y_label_txt);
+ } else {
+ $xpos = 8;
+ $ypos = (($this->small_font_width*strlen($this->y_label_txt)/2.0) +
+ $this->ytr(($this->plot_max_y + $this->plot_min_y)/2.0) );
+ $this->DrawText($this->small_font, 90,
+ $xpos, $ypos, $this->ndx_label_color, $this->y_label_ttffont_size, $this->y_label_txt);
+ }
+ return true;
+ }
+
+ function DrawText($which_font,$which_angle,$which_xpos,$which_ypos,$which_color,$which_size,$which_text,$which_halign='left',$which_valign='') {
+
+ if ($this->use_ttf == 1 ) {
+ $size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text);
+ if ($which_valign == 'bottom') {
+ $which_ypos = $which_ypos + ImageFontHeight($which_font);
+ }
+ if ($which_halign == 'center') {
+ $which_xpos = $which_xpos - $size[0]/2;
+ }
+ ImageTTFText($this->img, $which_size, $which_angle,
+ $which_xpos, $which_ypos, $which_color, $which_font, $which_text);
+ } else {
+ if ($which_valign == 'top') {
+ $which_ypos = $which_ypos - ImageFontHeight($which_font);
+ }
+ $which_text = ereg_replace("\r","",$which_text);
+ $str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
+ $height = ImageFontHeight($which_font);
+ $width = ImageFontWidth($which_font);
+ if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss
+ for($i=0;$iimg, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color);
+ }
+ } else {
+ for($i=0;$iimg, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
+ } else {
+ ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
+ }
+ }
+ }
+
+ }
+ return true;
+
+ }
+ function DrawTitle() {
+ if ($this->use_ttf == 1 ) {
+ $xpos = ($this->plot_area[0] + $this->plot_area_width / 2);
+ $ypos = $this->y_top_margin/2;
+ $this->DrawText($this->title_ttffont, $this->title_angle,
+ $xpos, $ypos, $this->ndx_title_color, $this->title_ttffont_size, $this->title_txt,'center');
+ } else {
+ $xpos = ($this->plot_area[0] + $this->plot_area_width / 2);
+ $ypos = ImageFontHeight($this->title_font);
+ $this->DrawText($this->title_font, $this->title_angle,
+ $xpos, $ypos, $this->ndx_title_color, '', $this->title_txt,'center');
+ }
+ return true;
+
+ }
+
+ function DrawPlotAreaBackground() {
+ ImageFilledRectangle($this->img,$this->plot_area[0],
+ $this->plot_area[1],$this->plot_area[2],$this->plot_area[3],
+ $this->ndx_plot_bg_color);
+ }
+
+ function SetBackgroundColor($which_color) {
+ $this->bg_color= $which_color;
+ $this->ndx_bg_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+ function SetPlotBgColor($which_color) {
+ $this->plot_bg_color= $which_color;
+ $this->ndx_plot_bg_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetShading($which_s) {
+ $this->shading = $which_s;
+ return true;
+ }
+
+ function SetTitleColor($which_color) {
+ $this->title_color= $which_color;
+ $this->ndx_title_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetTickColor ($which_color) {
+ $this->tick_color= $which_color;
+ $this->ndx_tick_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetLabelColor ($which_color) {
+ $this->label_color= $which_color;
+ $this->ndx_label_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetTextColor ($which_color) {
+ $this->text_color= $which_color;
+ $this->ndx_text_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetLightGridColor ($which_color) {
+ $this->light_grid_color= $which_color;
+ $this->ndx_light_grid_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetGridColor ($which_color) {
+ $this->grid_color = $which_color;
+ $this->ndx_grid_color= $this->SetIndexColor($which_color);
+ return true;
+ }
+
+ function SetCharacterHeight() {
+ //to be set
+ return true;
+ }
+
+ function SetPlotType($which_pt) {
+ $accepted = "bars,lines,linepoints,area,points,pie,thinbarline";
+ $asked = trim($which_pt);
+ if (eregi($asked, $accepted)) {
+ $this->plot_type = $which_pt;
+ return true;
+ } else {
+ $this->DrawError('$which_pt not an acceptable plot type');
+ return false;
+ }
+ }
+
+ function FindDataLimits() {
+ //Text-Data is different than data-data graphs. For them what
+ // we have, instead of X values, is # of records equally spaced on data.
+ //text-data is passed in as $data[] = (title,y1,y2,y3,y4,...)
+ //data-data is passed in as $data[] = (title,x,y1,y2,y3,y4,...)
+
+ $this->number_x_points = count($this->data_values);
+
+ switch ($this->data_type) {
+ case "text-data":
+ $minx = 0; //valid for BAR TYPE GRAPHS ONLY
+ $maxx = $this->number_x_points - 1 ; //valid for BAR TYPE GRAPHS ONLY
+ $miny = (double) $this->data_values[0][1];
+ $maxy = $miny;
+ if ($this->draw_x_data_labels == "") {
+ $this->draw_x_data_labels = 1; //labels_note1: prevent both data labels and x-axis labels being both drawn and overlapping
+ }
+ break;
+ default: //Everything else: data-data, etc.
+ $maxx = $this->data_values[0][1];
+ $minx = $maxx;
+ $miny = $this->data_values[0][2];
+ $maxy = $miny;
+ $maxy = $miny;
+ break;
+ }
+
+ $max_records_per_group = 0;
+ $total_records = 0;
+ $mine = 0; //Maximum value for the -error bar (assume error bars always > 0)
+ $maxe = 0; //Maximum value for the +error bar (assume error bars always > 0)
+
+ reset($this->data_values);
+ while (list($dat_key, $dat) = each($this->data_values)) { //for each X barchart setting
+ //foreach($this->data_values as $dat) //can use foreach only in php4
+
+ $tmp = 0;
+ $total_records += count($dat) - 1; // -1 for label
+
+ switch ($this->data_type) {
+ case "text-data":
+ //Find the relative Max and Min
+
+ while (list($key, $val) = each($dat)) {
+ if ($key != 0) { //$dat[0] = label
+ SetType($val,"double");
+ if ($val > $maxy) {
+ $maxy = $val ;
+ }
+ if ($val < $miny) {
+ $miny = (double) $val ;
+ }
+ }
+ $tmp++;
+ }
+ break;
+ case "data-data": //X-Y data is passed in as $data[] = (title,x,y,y2,y3,...) which you can use for multi-dimentional plots.
+
+ while (list($key, $val) = each($dat)) {
+ if ($key == 1) { //$dat[0] = label
+ SetType($val,"double");
+ if ($val > $maxx) {
+ $maxx = $val;
+ } elseif ($val < $minx) {
+ $minx = $val;
+ }
+ } elseif ($key > 1) {
+ SetType($val,"double");
+ if ($val > $maxy) {
+ $maxy = $val ;
+ } elseif ($val < $miny) {
+ $miny = $val ;
+ }
+ }
+ $tmp++;
+ }
+ $tmp = $tmp - 1; //# records per group
+ break;
+ case "data-data-error": //Assume 2-D for now, can go higher
+ //Regular X-Y data is passed in as $data[] = (title,x,y,error+,error-,y2,error2+,error2-)
+
+ while (list($key, $val) = each($dat)) {
+ if ($key == 1) { //$dat[0] = label
+ SetType($val,'double');
+ if ($val > $maxx) {
+ $maxx = $val;
+ } elseif ($val < $minx) {
+ $minx = $val;
+ }
+ } elseif ($key%3 == 2) {
+ SetType($val,'double');
+ if ($val > $maxy) {
+ $maxy = $val ;
+ } elseif ($val < $miny) {
+ $miny = $val ;
+ }
+ } elseif ($key%3 == 0) {
+ SetType($val,'double');
+ if ($val > $maxe) {
+ $maxe = $val ;
+ }
+ } elseif ($key%3 == 1) {
+ SetType($val,'double');
+ if ($val > $mine) {
+ $mine = $val ;
+ }
+ }
+ $tmp++;
+ }
+ $maxy = $maxy + $maxe;
+ $miny = $miny - $mine; //assume error bars are always > 0
+
+ break;
+ default:
+ $this->PrintError('ERROR: unknown chart type');
+ break;
+ }
+ if ($tmp > $max_records_per_group) {
+ $max_records_per_group = $tmp;
+ }
+ }
+
+
+ $this->min_x = $minx;
+ $this->max_x = $maxx;
+ $this->min_y = $miny;
+ $this->max_y = $maxy;
+
+
+ if ($max_records_per_group > 1) {
+ $this->records_per_group = $max_records_per_group - 1;
+ } else {
+ $this->records_per_group = 1;
+ }
+
+
+ //$this->data_count = $total_records ;
+ } // function FindDataLimits
+
+ function SetMargins() {
+ /////////////////////////////////////////////////////////////////
+ // When the image is first created - set the margins
+ // to be the standard viewport.
+ // The standard viewport is the full area of the view surface (or panel),
+ // less a margin of 4 character heights all round for labelling.
+ // It thus depends on the current character size, set by SetCharacterHeight().
+ /////////////////////////////////////////////////////////////////
+
+ $str = split("\n",$this->title_txt);
+ $nbLines = count($str);
+
+ if ($this->use_ttf == 1) {
+ $title_size = $this->TTFBBoxSize($this->title_ttffont_size, $this->title_angle, $this->title_ttffont, 'X'); //An array
+ if ($nbLines == 1) {
+ $this->y_top_margin = $title_size[1] * 4;
+ } else {
+ $this->y_top_margin = $title_size[1] * ($nbLines+3);
+ }
+
+ //ajo working here
+ //$x_label_size = $this->TTFBBoxSize($this->x_label_ttffont_size, 0, $this->axis_ttffont, $this->x_label_txt);
+
+ $this->y_bot_margin = $this->x_label_height ;
+ $this->x_left_margin = $this->y_label_width * 2 + $this->tick_length;
+ $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels
+ } else {
+ $title_size = array(ImageFontWidth($this->title_font) * strlen($this->title_txt),ImageFontHeight($this->title_font));
+ //$this->y_top_margin = ($title_size[1] * 4);
+ if ($nbLines == 1) {
+ $this->y_top_margin = $title_size[1] * 4;
+ } else {
+ $this->y_top_margin = $title_size[1] * ($nbLines+3);
+ }
+ if ($this->x_datalabel_angle == 90) {
+ $this->y_bot_margin = 76.0; // Must be integer
+ } else {
+ $this->y_bot_margin = 66.0; // Must be integer
+ }
+ $this->x_left_margin = 77.0; // distance between left and start of x axis in pixels
+ $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels
+ }
+
+//exit;
+ $this->x_tot_margin = $this->x_left_margin + $this->x_right_margin;
+ $this->y_tot_margin = $this->y_top_margin + $this->y_bot_margin;
+
+ if ($this->plot_max_x && $this->plot_max_y && $this->plot_area_width ) { //If data has already been analysed then set translation
+ $this->SetTranslation();
+ }
+ }
+
+ function SetMarginsPixels($which_lm,$which_rm,$which_tm,$which_bm) {
+ //Set the plot area using margins in pixels (left, right, top, bottom)
+ $this->SetNewPlotAreaPixels($which_lm,$which_tm,($this->image_width - $which_rm),($this->image_height - $which_bm));
+ return true;
+ }
+
+ function SetNewPlotAreaPixels($x1,$y1,$x2,$y2) {
+ //Like in GD 0,0 is upper left set via pixel Coordinates
+ $this->plot_area = array($x1,$y1,$x2,$y2);
+ $this->plot_area_width = $this->plot_area[2] - $this->plot_area[0];
+ $this->plot_area_height = $this->plot_area[3] - $this->plot_area[1];
+ $this->y_top_margin = $this->plot_area[1];
+ if ($this->plot_max_x) {
+ $this->SetTranslation();
+ }
+ return true;
+ }
+
+ function SetPlotAreaPixels($x1,$y1,$x2,$y2) {
+ //Like in GD 0,0 is upper left
+ if (!$this->x_tot_margin) {
+ $this->SetMargins();
+ }
+ if ($x2 && $y2) {
+ $this->plot_area = array($x1,$y1,$x2,$y2);
+ } else {
+ $this->plot_area = array($this->x_left_margin, $this->y_top_margin,
+ $this->image_width - $this->x_right_margin,
+ $this->image_height - $this->y_bot_margin
+ );
+ }
+ $this->plot_area_width = $this->plot_area[2] - $this->plot_area[0];
+ $this->plot_area_height = $this->plot_area[3] - $this->plot_area[1];
+
+ return true;
+
+ }
+
+ function SetPlotAreaWorld($xmin,$ymin,$xmax,$ymax) {
+ if (($xmin == "") && ($xmax == "")) {
+ //For automatic setting of data we need $this->max_x
+ if (!$this->max_y) {
+ $this->FindDataLimits() ;
+ }
+ if ($this->data_type == 'text-data') { //labels for text-data is done at data drawing time for speed.
+ $xmax = $this->max_x + 1 ; //valid for BAR CHART TYPE GRAPHS ONLY
+ $xmin = 0 ; //valid for BAR CHART TYPE GRAPHS ONLY
+ } else {
+ $xmax = $this->max_x * 1.02;
+ $xmin = $this->min_x;
+ }
+
+ $ymax = ceil($this->max_y * 1.2);
+ if ($this->min_y < 0) {
+ $ymin = floor($this->min_y * 1.2);
+ } else {
+ $ymin = 0;
+ }
+ }
+
+ $this->plot_min_x = $xmin;
+ $this->plot_max_x = $xmax;
+
+ if ($ymin == $ymax) {
+ $ymax += 1;
+ }
+ if ($this->yscale_type == "log") {
+ //extra error checking
+ if ($ymin <= 0) {
+ $ymin = 1;
+ }
+ if ($ymax <= 0) {
+ $this->PrintError('Log plots need data greater than 0');
+ }
+ }
+ $this->plot_min_y = $ymin;
+ $this->plot_max_y = $ymax;
+
+ if ($ymax <= $ymin) {
+ $this->DrawError('Error in Data - max not gt min');
+ }
+
+//Set the boundaries of the box for plotting in world coord
+// if (!$this->x_tot_margin) { //We need to know the margins before we can calculate scale
+// $this->SetMargins();
+// }
+ //For this we have to reset the scale
+ if ($this->plot_area_width) {
+ $this->SetTranslation();
+ }
+
+ return true;
+
+ } //function SetPlotAreaWorld
+
+
+ function PrintError($error_message) {
+ // prints the error message to stdout and die
+ echo "Fatal error : $error_message
";
+ die;
+ }
+
+ function DrawError($error_message) {
+ // prints the error message inline into
+ // the generated image
+
+ if (($this->img) == "") { $this->InitImage(); } ;
+
+ $ypos = $this->image_height/2;
+
+ if ($this->use_ttf == 1) {
+ ImageRectangle($this->img, 0,0,$this->image_width,$this->image_height,ImageColorAllocate($this->img,255,255,255));
+ ImageTTFText($this->img, $this->small_ttffont_size, 0, $xpos, $ypos, ImageColorAllocate($this->img,0,0,0), $this->axis_ttffont, $error_message);
+ } else {
+ ImageRectangle($this->img, 0,0,$this->image_width,$this->image_height,ImageColorAllocate($this->img,255,255,255));
+ ImageString($this->img, $this->small_font,1,$ypos,$error_message, ImageColorAllocate($this->img,0,0,0));
+ }
+
+ $this->PrintImage();
+ return true;
+ }
+
+ function TTFBBoxSize($size, $angle, $font, $string) {
+
+ //Assume angle < 90
+ $arr = ImageTTFBBox($size, 0, $font, $string);
+ $flat_width = $arr[0] - $arr[2];
+ $flat_height = abs($arr[3] - $arr[5]);
+
+ // for 90deg:
+ // $height = $arr[5] - $arr[7];
+ // $width = $arr[2] - $arr[4];
+
+ $angle = deg2rad($angle);
+ $width = ceil(abs($flat_width*cos($angle) + $flat_height*sin($angle))); //Must be integer
+ $height = ceil(abs($flat_width*sin($angle) + $flat_height*cos($angle))); //Must be integer
+
+ return array($width, $height);
+ }
+
+ function SetXLabelHeight() {
+
+ if ($this->use_ttf == 1) {
+ //Space for the X Label
+ $size = $this->TTFBBoxSize($this->x_label_ttffont_size, 0, $this->axis_ttffont, $this->x_label_txt);
+ $tmp = $size[1];
+
+ //$string = Str_Repeat('w', $this->x_datalabel_maxlength);
+ $i = 0;
+ $string = '';
+ while ($i < $this->x_datalabel_maxlength) {
+ $string .= 'w';
+ $i++;
+ }
+
+ //Space for the axis data labels
+ $size = $this->TTFBBoxSize($this->axis_ttffont_size, $this->x_datalabel_angle, $this->axis_ttffont, $string);
+
+ $this->x_label_height = 2*$tmp + $size[1] + 4;
+
+ } else {
+ //For Non-TTF fonts we can have only angles 0 or 90
+ if ($this->x_datalabel_angle == 90) {
+ $this->x_label_height = $this->x_datalabel_maxlength * ImageFontWidth($this->small_font) / 1.5;
+ } else {
+ $this->x_label_height = 5 * ImageFontHeight($this->small_font);
+ }
+ }
+
+ $this->SetMargins();
+
+ return true;
+ } //function SetXLabelHeight
+
+ function SetYLabelWidth() {
+ //$ylab = sprintf("%6.1f %s",$i,$si_units[0]); //use for PHP2 compatibility
+ //the "." is for space. It isn't actually printed
+ $ylab = number_format($this->max_y, $this->y_precision, ".", ",") . $this->si_units . ".";
+
+ if ($this->use_ttf == 1) {
+ $size = $this->TTFBBoxSize($this->axis_ttffont_size, 0, $this->axis_ttffont, $ylab);
+ } else {
+ $size[0] = StrLen($ylab) * $this->small_font_width * .6;
+ }
+
+ $this->y_label_width = $size[0] * 2;
+//echo "SYLW: $this->y_label_width ";
+//exit;
+
+ $this->SetMargins();
+ return true;
+ }
+
+ function SetEqualXCoord() {
+ //for plots that have equally spaced x variables and multiple bars per x-point.
+
+ $space = ($this->plot_area[2] - $this->plot_area[0]) / ($this->number_x_points * 2) * $this->group_frac_width;
+ $group_width = $space * 2;
+ $bar_width = $group_width / $this->records_per_group;
+ //I think that eventually this space variable will be replaced by just graphing x.
+ $this->data_group_space = $space;
+ $this->record_bar_width = $bar_width;
+ return true;
+ }
+
+ function SetLabelScalePosition($which_blp) {
+ //0 to 1
+ $this->label_scale_position = $which_blp;
+ return true;
+ }
+
+ function SetErrorBarSize($which_ebs) {
+ //in pixels
+ $this->error_bar_size = $which_ebs;
+ return true;
+ }
+
+ function SetErrorBarShape($which_ebs) {
+ //in pixels
+ $this->error_bar_shape = $which_ebs;
+ return true;
+ }
+
+ function SetPointShape($which_pt) {
+ //in pixels
+ $this->point_shape = $which_pt;
+ return true;
+ }
+
+ function SetPointSize($which_ps) {
+ //in pixels
+ SetType($which_ps,'integer');
+ $this->point_size = $which_ps;
+
+ if ($this->point_shape == "diamond" or $this->point_shape == "triangle") {
+ if ($this->point_size % 2 != 0) {
+ $this->point_size++;
+ }
+ }
+ return true;
+ }
+
+ function SetDataType($which_dt) {
+ //The next three lines are for past compatibility.
+ if ($which_dt == "text-linear") { $which_dt = "text-data"; };
+ if ($which_dt == "linear-linear") { $which_dt = "data-data"; };
+ if ($which_dt == "linear-linear-error") { $which_dt = "data-data-error"; };
+
+ $this->data_type = $which_dt; //text-data, data-data, data-data-error
+ return true;
+ }
+
+ function SetDataValues($which_dv) {
+ $this->data_values = $which_dv;
+//echo $this->data_values
+ return true;
+ }
+
+//////////////COLORS
+ function SetRGBArray ($which_color_array) {
+ if ( is_array($which_color_array) ) {
+ //User Defined Array
+ $this->rgb_array = $which_color_array;
+ return true;
+ } elseif ($which_color_array == 2) { //Use the small predefined color array
+ $this->rgb_array = array(
+ "white" => array(255, 255, 255),
+ "snow" => array(255, 250, 250),
+ "PeachPuff" => array(255, 218, 185),
+ "ivory" => array(255, 255, 240),
+ "lavender" => array(230, 230, 250),
+ "black" => array( 0, 0, 0),
+ "DimGrey" => array(105, 105, 105),
+ "gray" => array(190, 190, 190),
+ "grey" => array(190, 190, 190),
+ "navy" => array( 0, 0, 128),
+ "SlateBlue" => array(106, 90, 205),
+ "blue" => array( 0, 0, 255),
+ "SkyBlue" => array(135, 206, 235),
+ "cyan" => array( 0, 255, 255),
+ "DarkGreen" => array( 0, 100, 0),
+ "green" => array( 0, 255, 0),
+ "YellowGreen" => array(154, 205, 50),
+ "yellow" => array(255, 255, 0),
+ "orange" => array(255, 165, 0),
+ "gold" => array(255, 215, 0),
+ "peru" => array(205, 133, 63),
+ "beige" => array(245, 245, 220),
+ "wheat" => array(245, 222, 179),
+ "tan" => array(210, 180, 140),
+ "brown" => array(165, 42, 42),
+ "salmon" => array(250, 128, 114),
+ "red" => array(255, 0, 0),
+ "pink" => array(255, 192, 203),
+ "maroon" => array(176, 48, 96),
+ "magenta" => array(255, 0, 255),
+ "violet" => array(238, 130, 238),
+ "plum" => array(221, 160, 221),
+ "orchid" => array(218, 112, 214),
+ "purple" => array(160, 32, 240),
+ "azure1" => array(240, 255, 255),
+ "aquamarine1" => array(127, 255, 212)
+ );
+ return true;
+ } elseif ($which_color_array == 1) {
+ include("./rgb.inc.php"); //Get large $ColorArray
+ $this->rgb_array = $RGBArray;
+ } else {
+ $this->rgb_array = array("white" =>array(255,255,255), "black" => array(0,0,0));
+ exit;
+ }
+
+ return true;
+ }
+
+ function SetColor($which_color) {
+ //obsoleted by SetRGBColor
+ SetRgbColor($which_color);
+ return true;
+ }
+
+ function SetIndexColor($which_color) { //Color is passed in as anything
+ list ($r, $g, $b) = $this->SetRgbColor($which_color); //Translate to RGB
+ $index = ImageColorExact($this->img, $r, $g, $b);
+ if ($index == -1) {
+ //return ImageColorAllocate($this->img, $r, $g, $b);
+ //return ImageColorClosest($this->img, $r, $g, $b);
+ return ImageColorResolve($this->img, $r, $g, $b); //requires PHP 3.0.2 and later
+ } else {
+ return $index;
+ }
+ }
+
+ function SetTransparentColor($which_color) {
+ ImageColorTransparent($this->img,$this->SetIndexColor($which_color));
+ return true;
+ }
+
+ function SetRgbColor($color_asked) {
+ //Returns an array in R,G,B format 0-255
+ if ($color_asked == "") { $color_asked = array(0,0,0); };
+
+ if ( count($color_asked) == 3 ) { //already array of 3 rgb
+ $ret_val = $color_asked;
+ } else { // is asking for a color by string
+ if(substr($color_asked,0,1) == "#") { //asking in #FFFFFF format.
+ $ret_val = array(hexdec(substr($color_asked,1,2)), hexdec(substr($color_asked,3,2)), hexdec(substr($color,5,2)));
+ } else {
+ $ret_val = $this->rgb_array[$color_asked];
+ }
+ }
+ return $ret_val;
+ }
+
+ function SetDataColors($which_data,$which_border) {
+ //Set the data to be displayed in a particular color
+ if (!$which_data) {
+ $which_data = array(array(0,255,0),array(0,0,248),'yellow',array(255,0,0),'orange');
+ $which_border = array('black');
+ }
+
+ $this->data_color = $which_data; //an array
+ $this->data_border_color = $which_border; //an array
+
+ unset($this->ndx_data_color);
+ reset($this->data_color); //data_color can be an array of colors, one for each thing plotted
+ //while (list(, $col) = each($this->data_color))
+ $i = 0;
+ while (list(, $col) = each($which_data)) {
+ $this->ndx_data_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+
+ // border_color
+ //If we are also going to put a border on the data (bars, dots, area, ...)
+ // then lets also set a border color as well.
+ //foreach($this->data_border_color as $col)
+ unset($this->ndx_data_border_color);
+ reset($this->data_border_color);
+ $i = 0;
+ while (list(, $col) = each($this->data_border_color)) {
+ $this->ndx_data_border_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+
+ //Set color of the error bars to be that of data if not already set.
+ if (!$this->error_bar_color) {
+ reset($which_data);
+ $this->SetErrorBarColors($which_data);
+ }
+
+ return true;
+
+ } //function SetDataColors
+
+ function SetErrorBarColors($which_data) {
+
+ //Set the data to be displayed in a particular color
+
+ if ($which_data) {
+ $this->error_bar_color = $which_data; //an array
+ unset($this->ndx_error_bar_color);
+ reset($this->error_bar_color); //data_color can be an array of colors, one for each thing plotted
+ $i = 0;
+ while (list(, $col) = each($this->error_bar_color)) {
+ $this->ndx_error_bar_color[$i] = $this->SetIndexColor($col);
+ $i++;
+ }
+ return true;
+ }
+ return false;
+ } //function SetErrorBarColors
+
+
+ function DrawPlotBorder() {
+ switch ($this->plot_border_type) {
+ case "left" :
+ ImageLine($this->img, $this->plot_area[0],$this->ytr($this->plot_min_y),
+ $this->plot_area[0],$this->ytr($this->plot_max_y),$this->ndx_grid_color);
+ break;
+ case "none":
+ //Draw No Border
+ break;
+ default:
+ ImageRectangle($this->img, $this->plot_area[0],$this->ytr($this->plot_min_y),
+ $this->plot_area[2],$this->ytr($this->plot_max_y),$this->ndx_grid_color);
+ break;
+ }
+ $this->DrawYAxis();
+ $this->DrawXAxis();
+ return true;
+ }
+
+
+ function SetHorizTickIncrement($which_ti) {
+ //Use either this or NumHorizTicks to set where to place x tick marks
+ if ($which_ti) {
+ $this->horiz_tick_increment = $which_ti; //world coordinates
+ } else {
+ if (!$this->max_x) {
+ $this->FindDataLimits(); //Get maxima and minima for scaling
+ }
+ //$this->horiz_tick_increment = ( ceil($this->max_x * 1.2) - floor($this->min_x * 1.2) )/10;
+ $this->horiz_tick_increment = ($this->plot_max_x - $this->plot_min_x )/10;
+ }
+ $this->num_horiz_ticks = ''; //either use num_vert_ticks or vert_tick_increment, not both
+ return true;
+ }
+
+ function SetDrawVertTicks($which_dvt) {
+ $this->draw_vert_ticks = $which_dvt;
+ return true;
+ }
+
+ function SetVertTickIncrement($which_ti) {
+ //Use either this or NumVertTicks to set where to place y tick marks
+ if ($which_ti) {
+ $this->vert_tick_increment = $which_ti; //world coordinates
+ } else {
+ if (!$this->max_y) {
+ $this->FindDataLimits(); //Get maxima and minima for scaling
+ }
+ //$this->vert_tick_increment = ( ceil($this->max_y * 1.2) - floor($this->min_y * 1.2) )/10;
+ $this->vert_tick_increment = ($this->plot_max_y - $this->plot_min_y )/10;
+ }
+ $this->num_vert_ticks = ''; //either use num_vert_ticks or vert_tick_increment, not both
+ return true;
+ }
+
+ function SetNumHorizTicks($which_nt) {
+ $this->num_horiz_ticks = $which_nt;
+ $this->horiz_tick_increment = ''; //either use num_horiz_ticks or horiz_tick_increment, not both
+ return true;
+ }
+
+ function SetNumVertTicks($which_nt) {
+ $this->num_vert_ticks = $which_nt;
+ $this->vert_tick_increment = ''; //either use num_vert_ticks or vert_tick_increment, not both
+ return true;
+ }
+ function SetVertTickPosition($which_tp) {
+ $this->vert_tick_position = $which_tp; //plotleft, plotright, both, yaxis
+ return true;
+ }
+ function SetSkipBottomTick($which_sbt) {
+ $this->skip_bottom_tick = $which_sbt;
+ return true;
+ }
+
+ function SetTickLength($which_tl) {
+ $this->tick_length = $which_tl;
+ return true;
+ }
+
+ function DrawYAxis() {
+ //Draw Line at left side or at this->y_axis_position
+ if ($this->y_axis_position != "") {
+ $yaxis_x = $this->xtr($this->y_axis_position);
+ } else {
+ $yaxis_x = $this->plot_area[0];
+ }
+
+ ImageLine($this->img, $yaxis_x, $this->plot_area[1],
+ $yaxis_x, $this->plot_area[3], $this->ndx_grid_color);
+ //$yaxis_x, $this->plot_area[3], 9);
+
+ if ($this->draw_vert_ticks == 1) {
+ $this->DrawVerticalTicks();
+ }
+
+ } //function DrawYAxis
+
+ function DrawXAxis() {
+ //Draw Tick and Label for Y axis
+ $ylab =$this->FormatYTickLabel($this->x_axis_position);
+ if ($this->skip_bottom_tick != 1) {
+ $this->DrawVerticalTick($ylab,$this->x_axis_position);
+ }
+
+ //Draw X Axis at Y=$x_axis_postion
+ ImageLine($this->img,$this->plot_area[0]+1,$this->ytr($this->x_axis_position),
+ $this->xtr($this->plot_max_x)-1,$this->ytr($this->x_axis_position),$this->ndx_tick_color);
+
+ //X Ticks and Labels
+ if ($this->data_type != 'text-data') { //labels for text-data done at data drawing time for speed.
+ $this->DrawHorizontalTicks();
+ }
+ return true;
+ }
+
+ function DrawHorizontalTicks() {
+ //Ticks and lables are drawn on the left border of PlotArea.
+ //Left Bottom
+ ImageLine($this->img,$this->plot_area[0],
+ $this->plot_area[3]+$this->tick_length,
+ $this->plot_area[0],$this->plot_area[3],$this->ndx_tick_color);
+
+ switch ($this->x_grid_label_type) {
+ case "title":
+ $xlab = $this->data_values[0][0];
+ break;
+ case "data":
+ $xlab = number_format($this->plot_min_x,$this->x_precision,".",",") . "$this->si_units";
+ break;
+ case "none":
+ $xlab = '';
+ break;
+ case "time": //Time formatting suggested by Marlin Viss
+ $xlab = strftime($this->x_time_format,$this->plot_min_x);
+ break;
+ default:
+ //Unchanged from whatever format is passed in
+ $xlab = $this->plot_min_x;
+ break;
+ }
+
+ if ($this->x_datalabel_angle == 90) {
+ $xpos = $this->plot_area[0] - $this->small_font_height/2;
+ $ypos = ( $this->small_font_width*strlen($xlab) + $this->plot_area[3] + $this->small_font_height);
+ ImageStringUp($this->img, $this->small_font,$xpos, $ypos, $xlab, $this->ndx_text_color);
+ } else {
+ $xpos = $this->plot_area[0] - $this->small_font_width*strlen($xlab)/2 ;
+ $ypos = $this->plot_area[3] + $this->small_font_height;
+ ImageString($this->img, $this->small_font,$xpos, $ypos, $xlab, $this->ndx_text_color);
+ }
+
+ //Will be changed to allow for TTF fonts in data as well.
+ //$this->DrawText($this->small_font, $this->x_datalabel_angle, $xpos, $ypos, $this->ndx_title_color, '', $xlab);
+
+ //Top
+
+ if ($this->horiz_tick_increment) {
+ $delta_x = $this->horiz_tick_increment;
+ } elseif ($this->num_horiz_ticks) {
+ $delta_x = ($this->plot_max_x - $this->plot_min_x) / $this->num_horiz_ticks;
+ } else {
+ $delta_x =($this->plot_max_x - $this->plot_min_x) / 10 ;
+ }
+
+ $i = 0;
+ $x_tmp = $this->plot_min_x;
+ SetType($x_tmp,'double');
+
+ while ($x_tmp <= $this->plot_max_x){
+ //$xlab = sprintf("%6.1f %s",$min_x,$si_units[0]); //PHP2 past compatibility
+ switch ($this->x_grid_label_type) {
+ case "title":
+ $xlab = $this->data_values[$x_tmp][0];
+ break;
+ case "data":
+ $xlab = number_format($x_tmp,$this->x_precision,".",",") . "$this->si_units";
+ break;
+ case "none":
+ $xlab = '';
+ break;
+ case "time": //Time formatting suggested by Marlin Viss
+ $xlab = strftime($this->x_time_format,$x_tmp);
+ break;
+ default:
+ //Unchanged from whatever format is passed in
+ $xlab = $x_tmp;
+ break;
+ }
+
+ $x_pixels = $this->xtr($x_tmp);
+
+ //Bottom Tick
+ ImageLine($this->img,$x_pixels,$this->plot_area[3] + $this->tick_length,
+ $x_pixels,$this->plot_area[3], $this->ndx_tick_color);
+ //Top Tick
+ //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length),
+ // $y_pixels,$this->xtr($this->plot_max_x)-1,$y_pixels,$this->ndx_tick_color);
+
+ if ($this->draw_x_grid == 1) {
+ ImageLine($this->img,$x_pixels,$this->plot_area[1],
+ $x_pixels,$this->plot_area[3], $this->ndx_light_grid_color);
+ }
+
+ if ($this->x_datalabel_angle == 90) { //Vertical Code Submitted by Marlin Viss
+ ImageStringUp($this->img, $this->small_font,
+ ( $x_pixels - $this->small_font_height/2),
+ ( $this->small_font_width*strlen($xlab) + $this->plot_area[3] + $this->small_font_height),$xlab, $this->ndx_text_color);
+ } else {
+ ImageString($this->img, $this->small_font,
+ ( $x_pixels - $this->small_font_width*strlen($xlab)/2) ,
+ ( $this->small_font_height + $this->plot_area[3]),$xlab, $this->ndx_text_color);
+ }
+
+ $i++;
+ $x_tmp += $delta_x;
+ }
+
+ } // function DrawHorizontalTicks
+
+ function FormatYTickLabel($which_ylab) {
+ switch ($this->y_grid_label_type) {
+ case "data":
+ $ylab = number_format($which_ylab,$this->y_precision,".",",") . "$this->si_units";
+ break;
+ case "none":
+ $ylab = '';
+ break;
+ case "time":
+ $ylab = strftime($this->y_time_format,$which_ylab);
+ break;
+ case "right":
+ //Make it right aligned
+ //$ylab = str_pad($which_ylab,$this->y_label_width," ",STR_PAD_LEFT); //PHP4 only
+ $sstr = "%".strlen($this->plot_max_y)."s";
+ $ylab = sprintf($sstr,$which_ylab);
+ break;
+ default:
+ //Unchanged from whatever format is passed in
+ $ylab = $which_ylab;
+ break;
+ }
+
+ return($ylab);
+
+ } //function FormatYTickLabel
+
+ function DrawVerticalTick($which_ylab,$which_ypos) { //ylab in world coord.
+ //Draw Just one Tick, called from DrawVerticalTicks
+ //Ticks and datalables can be left of plot only, right of plot only,
+ // both on the left and right of plot, or crossing a user defined Y-axis
+ //
+ //Its faster to draw both left and right ticks at same time
+ // than first left and then right.
+
+ if ($this->y_axis_position != "") {
+ //Ticks and lables are drawn on the left border of yaxis
+ $yaxis_x = $this->xtr($this->y_axis_position);
+ } else {
+ //Ticks and lables are drawn on the left border of PlotArea.
+ $yaxis_x = $this->plot_area[0];
+ }
+
+ $y_pixels = $this->ytr($which_ypos);
+
+ //Lines Across the Plot Area
+ if ($this->draw_y_grid == 1) {
+ ImageLine($this->img,$this->plot_area[0]+1,$y_pixels,
+ $this->plot_area[2]-1,$y_pixels,$this->ndx_light_grid_color);
+ }
+
+ //Ticks to the Left of the Plot Area
+ if (($this->vert_tick_position == "plotleft") || ($this->vert_tick_position == "both") ) {
+ ImageLine($this->img,(-$this->tick_length+$yaxis_x),
+ $y_pixels,$yaxis_x,
+ $y_pixels, $this->ndx_tick_color);
+ }
+
+ //Ticks to the Right of the Plot Area
+ if (($this->vert_tick_position == "plotright") || ($this->vert_tick_position == "both") ) {
+ ImageLine($this->img,($this->plot_area[2]+$this->tick_length),
+ $y_pixels,$this->plot_area[2],
+ $y_pixels,$this->ndx_tick_color);
+ }
+
+ //Ticks on the Y Axis
+ if (($this->vert_tick_position == "yaxis") ) {
+ ImageLine($this->img,($yaxis_x - $this->tick_length),
+ $y_pixels,$yaxis_x,$y_pixels,$this->ndx_tick_color);
+ }
+
+ //DataLabel
+//ajo working
+ //$this->DrawText($this->y_label_ttffont, 0,($yaxis_x - $this->y_label_width - $this->tick_length/2),
+ // $y_pixels, $this->ndx_text_color, $this->axis_ttffont_size, $which_ylab);
+ ImageString($this->img, $this->small_font, ($yaxis_x - $this->y_label_width - $this->tick_length/2),
+ ( -($this->small_font_height/2.0) + $y_pixels),$which_ylab, $this->ndx_text_color);
+ }
+
+ function DrawVerticalTicks() {
+
+ if ($this->skip_top_tick != 1) { //If tick increment doesn't hit the top
+ //Left Top
+ //ImageLine($this->img,(-$this->tick_length+$this->xtr($this->plot_min_x)),
+ // $this->ytr($this->plot_max_y),$this->xtr($this->plot_min_x),$this->ytr($this->plot_max_y),$this->ndx_tick_color);
+ //$ylab = $this->FormatYTickLabel($plot_max_y);
+
+ //Right Top
+ //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length),
+ // $this->ytr($this->plot_max_y),$this->xtr($this->plot_max_x-1),$this->ytr($this->plot_max_y),$this->ndx_tick_color);
+
+ //Draw Grid Line at Top
+ ImageLine($this->img,$this->plot_area[0]+1,$this->ytr($this->plot_max_y),
+ $this->plot_area[2]-1,$this->ytr($this->plot_max_y),$this->ndx_light_grid_color);
+
+ }
+
+ if ($this->skip_bottom_tick != 1) {
+ //Right Bottom
+ //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length),
+ // $this->ytr($this->plot_min_y),$this->xtr($this->plot_max_x),
+ // $this->ytr($this->plot_min_y),$this->ndx_tick_color);
+
+ //Draw Grid Line at Bottom of Plot
+ ImageLine($this->img,$this->xtr($this->plot_min_x)+1,$this->ytr($this->plot_min_y),
+ $this->xtr($this->plot_max_x),$this->ytr($this->plot_min_y),$this->ndx_light_grid_color);
+ }
+
+ // maxy is always > miny so delta_y is always positive
+ if ($this->vert_tick_increment) {
+ $delta_y = $this->vert_tick_increment;
+ } elseif ($this->num_vert_ticks) {
+ $delta_y = ($this->plot_max_y - $this->plot_min_y) / $this->num_vert_ticks;
+ } else {
+ $delta_y =($this->plot_max_y - $this->plot_min_y) / 10 ;
+ }
+
+ $y_tmp = $this->plot_min_y;
+ SetType($y_tmp,'double');
+ if ($this->skip_bottom_tick == 1) {
+ $y_tmp += $delta_y;
+ }
+
+ while ($y_tmp <= $this->plot_max_y){
+ //For log plots:
+ if (($this->yscale_type == "log") && ($this->plot_min_y == 1) &&
+ ($delta_y%10 == 0) && ($y_tmp == $this->plot_min_y)) {
+ $y_tmp = $y_tmp - 1; //Set first increment to 9 to get: 1,10,20,30,...
+ }
+
+ $ylab = $this->FormatYTickLabel($y_tmp);
+
+ $this->DrawVerticalTick($ylab,$y_tmp);
+
+ $y_tmp += $delta_y;
+ }
+
+ return true;
+
+ } // function DrawVerticalTicks
+
+ function SetTranslation() {
+ if ($this->xscale_type == "log") {
+ $this->xscale = ($this->plot_area_width)/(log10($this->plot_max_x) - log10($this->plot_min_x));
+ } else {
+ $this->xscale = ($this->plot_area_width)/($this->plot_max_x - $this->plot_min_x);
+ }
+ if ($this->yscale_type == "log") {
+ $this->yscale = ($this->plot_area_height)/(log10($this->plot_max_y) - log10($this->plot_min_y));
+ } else {
+ $this->yscale = ($this->plot_area_height)/($this->plot_max_y - $this->plot_min_y);
+ }
+
+ // GD defines x=0 at left and y=0 at TOP so -/+ respectively
+ if ($this->xscale_type == "log") {
+ $this->plot_origin_x = $this->plot_area[0] - ($this->xscale * log10($this->plot_min_x) );
+ } else {
+ $this->plot_origin_x = $this->plot_area[0] - ($this->xscale * $this->plot_min_x);
+ }
+ if ($this->yscale_type == "log") {
+ $this->plot_origin_y = $this->plot_area[3] + ($this->yscale * log10($this->plot_min_y));
+ } else {
+ $this->plot_origin_y = $this->plot_area[3] + ($this->yscale * $this->plot_min_y);
+ }
+
+ $this->scale_is_set = 1;
+ } // function SetTranslation
+
+ function xtr($x_world) {
+ //Translate world coordinates into pixel coordinates
+ //The pixel coordinates are those of the ENTIRE image, not just the plot_area
+ //$x_pixels = $this->x_left_margin + ($this->image_width - $this->x_tot_margin)*(($x_world - $this->plot_min_x) / ($this->plot_max_x - $this->plot_min_x)) ;
+ //which with a little bit of math reduces to ...
+ if ($this->xscale_type == "log") {
+ $x_pixels = $this->plot_origin_x + log10($x_world) * $this->xscale ;
+ } else {
+ $x_pixels = $this->plot_origin_x + $x_world * $this->xscale ;
+ }
+ return($x_pixels);
+ }
+
+ function ytr($y_world) {
+ // translate y world coord into pixel coord
+ if ($this->yscale_type == "log") {
+ $y_pixels = $this->plot_origin_y - log10($y_world) * $this->yscale ; //minus because GD defines y=0 at top. doh!
+ } else {
+ $y_pixels = $this->plot_origin_y - $y_world * $this->yscale ;
+ }
+ return ($y_pixels);
+ }
+
+
+ function DrawDataLabel($lab,$x_world,$y_world) {
+ //Depreciated. Use DrawText Instead.
+ //Data comes in in WORLD coordinates
+ //Draw data label near actual data point
+ //$y = $this->ytr($y_world) ; //in pixels
+ //$x = $this->xtr($x_world) ;
+ //$this->DrawText($which_font,$which_angle,$which_xpos,$which_ypos,$which_color,$which_size,$which_text,$which_halign='left');
+ if ($this->use_ttf) {
+//ajjjo
+ $lab_size = $this->TTFBBoxSize($this->axis_ttffont_size, $this->x_datalabel_angle, $this->axis_ttffont, $lab); //An array
+ $y = $this->ytr($y_world) - $lab_size[1] ; //in pixels
+ $x = $this->xtr($x_world) - $lab_size[0]/2;
+ ImageTTFText($this->img, $this->axis_ttffont_size, $this->x_datalabel_angle, $x, $y, $this->ndx_text_color, $this->axis_ttffont, $lab);
+ } else {
+ $lab_size = array($this->small_font_width*StrLen($lab), $this->small_font_height*3);
+ if ($this->x_datalabel_angle == 90) {
+ $y = $this->ytr($y_world) - $this->small_font_width*StrLen($lab); //in pixels
+ $x = $this->xtr($x_world) - $this->small_font_height;
+ ImageStringUp($this->img, $this->small_font,$x, $y ,$lab, $this->ndx_text_color);
+ } else {
+ $y = $this->ytr($y_world) - $this->small_font_height; //in pixels
+ $x = $this->xtr($x_world) - ($this->small_font_width*StrLen($lab))/2;
+ ImageString($this->img, $this->small_font,$x, $y ,$lab, $this->ndx_text_color);
+ }
+ }
+
+ }
+
+ function DrawXDataLabel($xlab,$xpos) {
+ //xpos comes in in PIXELS not in world coordinates.
+ //Draw an x data label centered at xlab
+ if ($this->use_ttf) {
+ $xlab_size = $this->TTFBBoxSize($this->axis_ttffont_size,
+ $this->x_datalabel_angle, $this->axis_ttffont, $xlab); //An array
+ $y = $this->plot_area[3] + $xlab_size[1] + 4; //in pixels
+ $x = $xpos - $xlab_size[0]/2;
+ ImageTTFText($this->img, $this->axis_ttffont_size,
+ $this->x_datalabel_angle, $x, $y, $this->ndx_text_color, $this->axis_ttffont, $xlab);
+ } else {
+ $xlab_size = array(ImageFontWidth($this->axis_font)*StrLen($xlab), $this->small_font_height*3);
+ if ($this->x_datalabel_angle == 90) {
+ $y = $this->plot_area[3] + ImageFontWidth($this->axis_font)*StrLen($xlab); //in pixels
+ $x = $xpos - ($this->small_font_height);
+ ImageStringUp($this->img, $this->axis_font,$x, $y ,$xlab, $this->ndx_text_color);
+ } else {
+ $y = $this->plot_area[3] + ImageFontHeight($this->axis_font); //in pixels
+ $x = $xpos - (ImageFontWidth($this->axis_font)*StrLen($xlab))/2;
+ ImageString($this->img, $this->axis_font,$x, $y ,$xlab, $this->ndx_text_color);
+ }
+ }
+
+ }
+
+ function DrawPieChart() {
+ //$pi = '3.14159265358979323846';
+ $xpos = $this->plot_area[0] + $this->plot_area_width/2;
+ $ypos = $this->plot_area[1] + $this->plot_area_height/2;
+ $diameter = (min($this->plot_area_width, $this->plot_area_height)) ;
+ $radius = $diameter/2;
+
+ ImageArc($this->img, $xpos, $ypos, $diameter, $diameter, 0, 360, $this->ndx_grid_color);
+
+ $total = 0;
+ reset($this->data_values);
+ $tmp = $this->number_x_points - 1;
+ while (list($j, $row) = each($this->data_values)) {
+ //Get sum of each type
+ $color_index = 0;
+ $i = 0;
+ //foreach ($row as $v)
+ while (list($k, $v) = each($row)) {
+ if ($k != 0) {
+ if ($j == 0) {
+ $sumarr[$i] = $v;
+ } elseif ($j < $tmp) {
+ $sumarr[$i] += $v;
+ } else {
+ $sumarr[$i] += $v;
+ // NOTE! sum > 0 to make pie charts
+ $sumarr[$i] = abs($sumarr[$i]);
+ $total += $sumarr[$i];
+ }
+ }
+ $i++;
+ }
+ }
+
+ $color_index = 0;
+ $start_angle = 0;
+
+ reset($sumarr);
+ $end_angle = 0;
+ while (list(, $val) = each($sumarr)) {
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0; //data_color = array
+ $label_txt = number_format(($val / $total * 100), $this->y_precision, ".", ",") . "%";
+ $val = 360 * ($val / $total);
+
+ $end_angle += $val;
+ $mid_angle = $end_angle - ($val / 2);
+
+ $slicecol = $this->ndx_data_color[$color_index];
+
+//Need this again for FillToBorder
+ ImageArc($this->img, $xpos, $ypos, $diameter, $diameter, 0, 360, $this->ndx_grid_color);
+
+ $out_x = $radius * cos(deg2rad($end_angle));
+ $out_y = - $radius * sin(deg2rad($end_angle));
+
+ $mid_x = $xpos + ($radius/2 * cos(deg2rad($mid_angle))) ;
+ $mid_y = $ypos + (- $radius/2 * sin(deg2rad($mid_angle)));
+
+ $label_x = $xpos + ($radius * cos(deg2rad($mid_angle))) * $this->label_scale_position;
+ $label_y = $ypos + (- $radius * sin(deg2rad($mid_angle))) * $this->label_scale_position;
+
+ $out_x = $xpos + $out_x;
+ $out_y = $ypos + $out_y;
+
+ ImageLine($this->img, $xpos, $ypos, $out_x, $out_y, $this->ndx_grid_color);
+ //ImageLine($this->img, $xpos, $ypos, $label_x, $label_y, $this->ndx_grid_color);
+ ImageFillToBorder($this->img, $mid_x, $mid_y, $this->ndx_grid_color, $slicecol);
+
+ if ($this->use_ttf) {
+ ImageTTFText($this->img, $this->axis_ttffont_size, 0, $label_x, $label_y, $this->ndx_grid_color, $this->axis_ttffont, $label_txt);
+ } else {
+ ImageString($this->img, $this->small_font, $label_x, $label_y, $label_txt, $this->ndx_grid_color);
+ }
+
+ $start_angle = $val;
+
+ $color_index++;
+ }
+
+ }
+
+ function DrawLinesError() {
+ //Draw Lines with Error Bars - data comes in as array("title",x,y,error+,error-,y2,error2+,error2-,...);
+ $start_lines = 0;
+
+ reset($this->data_values);
+ while (list(, $row) = each($this->data_values)) {
+ $color_index = 0;
+ $i = 0;
+
+ while (list($key, $val) = each($row)) {
+//echo "$key, $i, $val ";
+ if ($key == 0) {
+ $lab = $val;
+ } elseif ($key == 1) {
+ $x_now = $val;
+ $x_now_pixels = $this->xtr($x_now); //Use a bit more memory to save 2N operations.
+ } elseif ($key%3 == 2) {
+ $y_now = $val;
+ $y_now_pixels = $this->ytr($y_now);
+
+ //Draw Data Label
+ if ( $this->draw_data_labels == 1) {
+ $this->DrawDataLabel($lab,$x_now,$y_now);
+ }
+
+ if ($color_index >= count($this->ndx_data_color)) { $color_index=0;};
+ $barcol = $this->ndx_data_color[$color_index];
+ $error_barcol = $this->ndx_error_bar_color[$color_index];
+
+//echo "start = $start_lines ";
+ if ($start_lines == 1) {
+ for ($width = 0; $width < $this->line_width; $width++) {
+ ImageLine($this->img, $x_now_pixels, $y_now_pixels + $width,
+ $lastx[$i], $lasty[$i] + $width, $barcol);
+ }
+ }
+
+ $lastx[$i] = $x_now_pixels;
+ $lasty[$i] = $y_now_pixels;
+ $color_index++;
+ $i++;
+ $start_lines = 1;
+ } elseif ($key%3 == 0) {
+ $this->DrawYErrorBar($x_now,$y_now,$val,$this->error_bar_shape,$error_barcol);
+ } elseif ($key%3 == 1) {
+ $this->DrawYErrorBar($x_now,$y_now,-$val,$this->error_bar_shape,$error_barcol);
+ }
+ }
+ }
+ }
+
+ function DrawDotsError() {
+ //Draw Dots - data comes in as array("title",x,y,error+,error-,y2,error2+,error2-,...);
+ reset($this->data_values);
+ while (list(, $row) = each($this->data_values)) {
+ $color_index = 0;
+ //foreach ($row as $v)
+ while (list($key, $val) = each($row)) {
+ if ($key == 0) {
+ } elseif ($key == 1) {
+ $xpos = $val;
+ } elseif ($key%3 == 2) {
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ $barcol = $this->ndx_data_color[$color_index];
+ $error_barcol = $this->ndx_error_bar_color[$color_index];
+ $ypos = $val;
+
+ $color_index++;
+ $this->DrawDot($xpos,$ypos,$this->point_shape,$barcol);
+ } elseif ($key%3 == 0) {
+ $this->DrawYErrorBar($xpos,$ypos,$val,$this->error_bar_shape,$error_barcol);
+ } elseif ($key%3 == 1) {
+ $mine = $val ;
+ $this->DrawYErrorBar($xpos,$ypos,-$val,$this->error_bar_shape,$error_barcol);
+ }
+ }
+ }
+
+ }
+
+ function DrawDots() {
+ //Draw Dots - data comes in as array("title",x,y1,y2,y3,...);
+ reset($this->data_values);
+ while (list($j, $row) = each($this->data_values)) {
+ $color_index = 0;
+ //foreach ($row as $v)
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ } elseif (($k == 1) && ($this->data_type == "data-data")) {
+ $xpos = $v;
+ } else {
+ if ($this->data_type == "text-data") {
+ $xpos = ($j+.5);
+ }
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ $barcol = $this->ndx_data_color[$color_index];
+
+ //if (is_numeric($v)) //PHP4 only
+ if ((strval($v) != "") ) { //Allow for missing Y data
+ $this->DrawDot($xpos,$v,$this->point_shape,$barcol);
+ }
+ $color_index++;
+ }
+ }
+ }
+
+ } //function DrawDots
+
+ function DrawDotSeries() {
+ //Depreciated: Use DrawDots
+ $this->DrawDots();
+ }
+
+ function DrawThinBarLines() {
+ //A clean,fast routine for when you just want charts like stock volume charts
+ //Data must be text-data since I didn't see a graphing need for equally spaced thin lines.
+ //If you want it - then write to afan@jeo.net and I might add it.
+
+ if ($this->data_type != "data-data") { $this->DrawError('Data Type for ThinBarLines must be data-data'); };
+ $y1 = $this->ytr($this->x_axis_position);
+
+ reset($this->data_values);
+ while (list(, $row) = each($this->data_values)) {
+ $color_index = 0;
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ $xlab = $v;
+ } elseif ($k == 1) {
+ $xpos = $this->xtr($v);
+ if ( ($this->draw_x_data_labels == 1) ) { //See "labels_note1 above.
+ $this->DrawXDataLabel($xlab,$xpos);
+ }
+ } else {
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ $barcol = $this->ndx_data_color[$color_index];
+
+ ImageLine($this->img,$xpos,$y1,$xpos,$this->ytr($v),$barcol);
+ $color_index++;
+ }
+ }
+ }
+
+ } //function DrawThinBarLines
+
+ function DrawYErrorBar($x_world,$y_world,$error_height,$error_bar_type,$color) {
+ $x1 = $this->xtr($x_world);
+ $y1 = $this->ytr($y_world);
+ $y2 = $this->ytr($y_world+$error_height) ;
+
+ for ($width = 0; $width < $this->error_bar_line_width; $width++) {
+ ImageLine($this->img, $x1+$width, $y1 , $x1+$width, $y2, $color);
+ ImageLine($this->img, $x1-$width, $y1 , $x1-$width, $y2, $color);
+ }
+ switch ($error_bar_type) {
+ case "line":
+ break;
+ case "tee":
+ ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color);
+ break;
+ default:
+ ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color);
+ break;
+ }
+ return true;
+ }
+
+ function DrawDot($x_world,$y_world,$dot_type,$color) {
+ $half_point = $this->point_size / 2;
+ $x1 = $this->xtr($x_world) - $half_point;
+ $x2 = $this->xtr($x_world) + $half_point;
+ $y1 = $this->ytr($y_world) - $half_point;
+ $y2 = $this->ytr($y_world) + $half_point;
+
+ switch ($dot_type) {
+ case "halfline":
+ ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $this->xtr($x_world), $this->ytr($y_world), $color);
+ break;
+ case "line":
+ ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $x2, $this->ytr($y_world), $color);
+ break;
+ case "rect":
+ ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color);
+ break;
+ case "circle":
+ ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color);
+ break;
+ case "dot":
+ ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color);
+ ImageFillToBorder($this->img, $x1 + $half_point, $y1 + $half_point, $color, $color);
+ break;
+ case "diamond":
+
+ $arrpoints = array(
+ $x1,$y1 + $half_point,
+ $x1 + $half_point, $y1,
+ $x2,$y1 + $half_point,
+ $x1 + $half_point, $y2
+ );
+
+ ImageFilledPolygon($this->img, $arrpoints, 4, $color);
+ break;
+ case "triangle":
+ $arrpoints = array( $x1, $y1 + $half_point,
+ $x2, $y1 + $half_point,
+ $x1 + $half_point, $y2
+ );
+ ImageFilledPolygon($this->img, $arrpoints, 3, $color);
+ break;
+ default:
+ ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color);
+ break;
+ }
+ return true;
+ }
+
+ function SetErrorBarLineWidth($which_seblw) {
+ $this->error_bar_line_width = $which_seblw;
+ return true;
+ }
+
+
+ function SetLineWidth($which_lw) {
+ $this->line_width = $which_lw;
+ if (!$this->error_bar_line_width) {
+ $this->error_bar_line_width = $which_lw;
+ }
+ return true;
+ }
+
+ function DrawArea() {
+ //Data comes in as $data[]=("title",x,y,...);
+ //Set first and last datapoints of area
+ $i = 0;
+ while ($i < $this->records_per_group) {
+ $posarr[$i][] = $this->xtr($this->min_x); //x initial
+ $posarr[$i][] = $this->ytr($this->x_axis_position); //y initial
+ $i++;
+ }
+
+ reset($this->data_values);
+ while (list($j, $row) = each($this->data_values)) {
+ $color_index = 0;
+ //foreach ($row as $v)
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ //Draw Data Labels
+ $xlab = SubStr($v,0,$this->x_datalabel_maxlength);
+ } elseif ($k == 1) {
+ $x = $this->xtr($v);
+ // DrawXDataLabel interferes with Numbers on x-axis
+ //$this->DrawXDataLabel($xlab,$x);
+ } else {
+ // Create Array of points for later
+
+ $y = $this->ytr($v);
+ $posarr[$color_index][] = $x;
+ $posarr[$color_index][] = $y;
+ $color_index++;
+ }
+ }
+ }
+
+ //Final_points
+ for ($i = 0; $i < $this->records_per_group; $i++) {
+ $posarr[$i][] = $this->xtr($this->max_x); //x final
+ $posarr[$i][] = $this->ytr($this->x_axis_position); //y final
+ }
+
+ $color_index=0;
+
+ //foreach($posarr as $row)
+ reset($posarr);
+ while (list(, $row) = each($posarr)) {
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ $barcol = $this->ndx_data_color[$color_index];
+//echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11],$row[12], $barcol ";
+ ImageFilledPolygon($this->img, $row, (count($row)) / 2, $barcol);
+ $color_index++;
+ }
+//exit;
+
+ }
+
+ function DrawAreaSeries() {
+
+ //Set first and last datapoints of area
+ $i = 0;
+ while ($i < $this->records_per_group) {
+ $posarr[$i][] = $this->xtr(.5); //x initial
+ $posarr[$i][] = $this->ytr($this->x_axis_position); //y initial
+ $i++;
+ }
+
+ reset($this->data_values);
+ while (list($j, $row) = each($this->data_values)) {
+ $color_index = 0;
+ //foreach ($row as $v)
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ //Draw Data Labels
+ $xlab = SubStr($v,0,$this->x_datalabel_maxlength);
+ $this->DrawXDataLabel($xlab,$this->xtr($j + .5));
+ } else {
+ // Create Array of points for later
+
+ $x = round($this->xtr($j + .5 ));
+ $y = round($this->ytr($v));
+ $posarr[$color_index][] = $x;
+ $posarr[$color_index][] = $y;
+ $color_index++;
+ }
+ }
+ }
+
+ //Final_points
+ for ($i = 0; $i < $this->records_per_group; $i++) {
+ $posarr[$i][] = round($this->xtr($this->max_x + .5)); //x final
+ $posarr[$i][] = $this->ytr($this->x_axis_position); //y final
+ }
+
+ $color_index=0;
+
+ //foreach($posarr as $row)
+ reset($posarr);
+ while (list(, $row) = each($posarr)) {
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ $barcol = $this->ndx_data_color[$color_index];
+//echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11],$row[12], $barcol ";
+ ImageFilledPolygon($this->img, $row, (count($row)) / 2, $barcol);
+ $color_index++;
+ }
+
+ }
+
+ function DrawLines() {
+ //Data comes in as $data[]=("title",x,y,...);
+ $start_lines = 0;
+ if ($this->data_type == "text-data") {
+ $lastx[0] = $this->xtr(0);
+ $lasty[0] = $this->xtr(0);
+ }
+
+ //foreach ($this->data_values as $row)
+ reset($this->data_values);
+ while (list($j, $row) = each($this->data_values)) {
+
+ $color_index = 0;
+ $i = 0;
+ //foreach ($row as $v)
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ $xlab = SubStr($v,0,$this->x_datalabel_maxlength);
+ } elseif (($k == 1) && ($this->data_type == "data-data")) {
+ $x_now = $this->xtr($v);
+ } else {
+ //(double) $v;
+ // Draw Lines
+ if ($this->data_type == "text-data") {
+ $x_now = $this->xtr($j+.5);
+ }
+
+ //if (is_numeric($v)) //PHP4 only
+ if ((strval($v) != "") ) { //Allow for missing Y data
+ $y_now = $this->ytr($v);
+ if ($color_index >= count($this->ndx_data_color)) { $color_index=0;} ;
+ $barcol = $this->ndx_data_color[$color_index];
+
+ if ($start_lines == 1) {
+ for ($width = 0; $width < $this->line_width; $width++) {
+ if ($this->line_style[$i] == "dashed") {
+ $this->DrawDashedLine($x_now, $y_now + $width, $lastx[$i], $lasty[$i] + $width, 4,4, $barcol);
+ } else {
+ ImageLine($this->img, $x_now, $y_now + $width, $lastx[$i], $lasty[$i] + $width, $barcol);
+ }
+ }
+ }
+ $lastx[$i] = $x_now;
+ } else {
+ $y_now = $lasty[$i];
+ //Don't increment lastx[$i]
+ }
+ //$bordercol = $this->ndx_data_border_color[$colbarcount];
+
+ $lasty[$i] = $y_now;
+ $color_index++;
+ $i++;
+ }
+ //Now we are assured an x_value
+ if ( ($this->draw_x_data_labels == 1) && ($k == 1) ) { //See "labels_note1 above.
+ $this->DrawXDataLabel($xlab,$x_now);
+ }
+ } //while rows of data
+ $start_lines = 1;
+ }
+ }
+
+ //Data comes in as $data[]=("title",x,y,e+,e-,y2,e2+,e2-,...);
+
+ function DrawLineSeries() {
+ //This function is replaced by DrawLines
+ //Tests have shown not much improvement in speed by having separate routines for DrawLineSeries and DrawLines
+ //For ease of programming I have combined them
+ return false;
+ } //function DrawLineSeries
+
+ function DrawDashedLine($x1pix,$y1pix,$x2pix,$y2pix,$dash_length,$dash_space,$color) {
+ //Code based on work by Ariel Garza and James Pine
+ //I've decided to have this be in pixels only as a replacement for ImageLine
+ //$x1pix = $this->xtr($x1);
+ //$y1pix = $this->ytr($y1);
+ //$x2pix = $this->xtr($x2);
+ //$y2pix = $this->ytr($y2);
+
+ // Get the length of the line in pixels
+ $line_length = ceil (sqrt(pow(($x2pix - $x1pix),2) + pow(($y2pix - $y1pix),2)) );
+
+ $dx = ($x2pix - $x1pix) / $line_length;
+ $dy = ($y2pix - $y1pix) / $line_length;
+ $lastx = $x1pix;
+ $lasty = $y1pix;
+
+ // Draw the dashed line
+ for ($i = 0; $i < $line_length; $i += ($dash_length + $dash_space)) {
+ $xpix = ($dash_length * $dx) + $lastx;
+ $ypix = ($dash_length * $dy) + $lasty;
+
+ ImageLine($this->img,$lastx,$lasty,$xpix,$ypix,$color);
+ $lastx = $xpix + ($dash_space * $dx);
+ $lasty = $ypix + ($dash_space * $dy);
+ }
+ } // function DrawDashedLine
+
+ function DrawBars() {
+
+ if ($this->data_type != "text-data") {
+ $this->DrawError('Bar plots must be text-data: use function SetDataType("text-data")');
+ }
+
+ $xadjust = ($this->records_per_group * $this->record_bar_width )/4;
+
+ reset($this->data_values);
+ while (list($j, $row) = each($this->data_values)) {
+
+ $color_index = 0;
+ $colbarcount = 0;
+ $x_now = $this->xtr($j+.5);
+
+ while (list($k, $v) = each($row)) {
+ if ($k == 0) {
+ //Draw Data Labels
+ $xlab = SubStr($v,0,$this->x_datalabel_maxlength);
+ $this->DrawXDataLabel($xlab,$x_now);
+ } else {
+ // Draw Bars ($v)
+ $x1 = $x_now - $this->data_group_space + ($k-1)*$this->record_bar_width;
+ $x2 = $x1 + $this->record_bar_width*$this->bar_width_adjust;
+
+ if ($v < $this->x_axis_position) {
+ $y1 = $this->ytr($this->x_axis_position);
+ $y2 = $this->ytr($v);
+ } else {
+ $y1 = $this->ytr($v);
+ $y2 = $this->ytr($this->x_axis_position);
+ }
+
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ if ($colbarcount >= count($this->ndx_data_border_color)) $colbarcount=0;
+ $barcol = $this->ndx_data_color[$color_index];
+ $bordercol = $this->ndx_data_border_color[$colbarcount];
+
+ if ((strval($v) != "") ) { //Allow for missing Y data
+ if ($this->shading > 0) {
+ for($i=0;$i<($this->shading);$i++) {
+ //Shading set in SetDefaultColors
+ ImageFilledRectangle($this->img, $x1+$i, $y1-$i, $x2+$i, $y2-$i, $this->ndx_i_light);
+ }
+ }
+
+ ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $barcol);
+ ImageRectangle($this->img, $x1, $y1, $x2, $y2, $bordercol);
+ if ($this->draw_data_labels == '1') { //ajo
+ $y1 = $this->ytr($this->label_scale_position * $v);
+ //$this->DrawDataLabel($v,$j + .5,$v*$this->label_scale_position);
+ $this->DrawText($this->x_label_ttffont, $this->x_label_angle,
+ $x1+$this->record_bar_width/2, $y1, $this->ndx_label_color, $this->x_label_ttffont_size, $v,'center','top');
+ }
+ }
+
+ $color_index++;
+ $colbarcount++;
+ }
+ }
+ }
+ } //function DrawBars
+
+ function DrawLegend($which_x1,$which_y1,$which_boxtype) {
+ //Base code submitted by Marlin Viss
+ $max_legend_length=0;
+ reset($this->legend);
+ while (list(,$leg) = each($this->legend)) {
+ $len = strlen($leg);
+ if ($max_legend_length < $len) {
+ $max_legend_length = $len;
+ }
+ }
+
+ $line_spacing = 1.25;
+ $vert_margin = $this->small_font_height/2 ;
+ $dot_height = $this->small_font_height*$line_spacing - 1;
+
+ //Upper Left
+ if ((!$which_x1) || (!$which_y1) ) {
+ $box_start_x = $this->plot_area[2] - $this->small_font_width*($max_legend_length+4);
+ $box_start_y = $this->plot_area[1] + 4;
+ } else {
+ $box_start_x = $which_x1;
+ $box_start_y = $which_y1;
+ }
+
+ //Lower Right
+ $box_end_y = $box_start_y + $this->small_font_height*(count($this->legend)+1) + 2*$vert_margin;
+ //$box_end_x = $this->plot_area[2] - 5;
+ $box_end_x = $box_start_x + $this->small_font_width*($max_legend_length+4) - 5;
+
+
+ // Draw box for legend
+ ImageFilledRectangle($this->img,
+ $box_start_x, $box_start_y,$box_end_x,
+ $box_end_y, $this->ndx_bg_color);
+ ImageRectangle($this->img,
+ $box_start_x, $box_start_y,$box_end_x,
+ $box_end_y, $this->ndx_grid_color);
+
+ $color_index=0;
+ $i = 0;
+
+
+ reset($this->legend);
+
+
+ while (list(,$leg) = each($this->legend)) {
+ $y_pos = $box_start_y + $this->small_font_height*($i)*($line_spacing) + $vert_margin;
+
+ ImageString($this->img, $this->small_font,
+ $box_start_x + $this->small_font_width*( $max_legend_length - strlen($leg) + 1 ) ,
+ $y_pos,
+ $leg, $this->ndx_text_color);
+
+ if ($color_index >= count($this->ndx_data_color)) $color_index=0;
+ // Draw a box in the data color
+ ImageFilledRectangle($this->img,
+ $box_end_x - $this->small_font_width*2,
+ $y_pos + 1, $box_end_x - $this->small_font_width,
+ $y_pos + $dot_height,
+ $this->ndx_data_color[$color_index]);
+
+ ImageRectangle($this->img,
+ $box_end_x - $this->small_font_width*2,
+ $y_pos + 1, $box_end_x - $this->small_font_width,
+ $y_pos + $dot_height,
+ $this->ndx_text_color);
+ $i++;
+ $color_index++;
+ }
+ } //function DrawLegend
+
+
+ function DrawGraph() {
+
+ if (($this->img) == "") {
+ $this->DrawError('No Image Defined: DrawGraph');
+ //$this->PHPlot();
+ }
+
+ if (! is_array($this->data_values)) {
+ $this->DrawBackground();
+ $this->DrawError("No array of data in \$data_values");
+ } else {
+ if (!$this->data_color) {
+ $this->SetDataColors(array('blue','green','yellow','red','orange','blue'),array('black'));
+ }
+
+ $this->FindDataLimits(); //Get maxima and minima for scaling
+
+ $this->SetXLabelHeight(); //Get data for bottom margin
+
+ $this->SetYLabelWidth(); //Get data for left margin
+
+ if (!$this->plot_area_width) {
+ $this->SetPlotAreaPixels('','','',''); //Set Margins
+ }
+
+ if (!$this->plot_max_y) { //If not set by user call SetPlotAreaWorld,
+ $this->SetPlotAreaWorld('','','','');
+ }
+
+ if ($this->data_type == "text-data") {
+ $this->SetEqualXCoord();
+ }
+
+ $this->SetPointSize($this->point_size);
+
+ $this->DrawBackground();
+ $this->DrawImageBorder();
+
+ $this->SetTranslation();
+
+ if ($this->draw_plot_area_background == 1) {
+ $this->DrawPlotAreaBackground();
+ }
+//$foo = "$this->max_y, $this->min_y, $new_miny, $new_maxy, $this->x_label_height";
+//ImageString($this->img, 4, 20, 20, $foo, $this->ndx_text_color);
+
+ switch ($this->plot_type) {
+ case "bars":
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ $this->DrawBars();
+ $this->DrawXAxis();
+ break;
+ case "thinbarline":
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ $this->DrawThinBarLines();
+ break;
+ case "lines":
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ if ( $this->data_type == "text-data") {
+ $this->DrawLines();
+ } elseif ( $this->data_type == "data-data-error") {
+ $this->DrawLinesError();
+ } else {
+ $this->DrawLines();
+ }
+ break;
+ case "area":
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ if ( $this->data_type == "text-data") {
+ $this->DrawAreaSeries();
+ } else {
+ $this->DrawArea();
+ }
+ break;
+ case "linepoints":
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ if ( $this->data_type == "text-data") {
+ $this->DrawLines();
+ $this->DrawDots();
+ } elseif ( $this->data_type == "data-data-error") {
+ $this->DrawLinesError();
+ $this->DrawDotsError();
+ } else {
+ $this->DrawLines();
+ $this->DrawDots();
+ }
+ break;
+ case "points";
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ if ( $this->data_type == "text-data") {
+ $this->DrawDots();
+ } elseif ( $this->data_type == "data-data-error") {
+ $this->DrawDotsError();
+ } else {
+ $this->DrawDots();
+ }
+ break;
+ case "pie":
+ $this->DrawPieChart();
+ $this->DrawLabels();
+ break;
+ default:
+ $this->DrawPlotBorder();
+ $this->DrawLabels();
+ $this->DrawBars();
+ break;
+ }
+
+ if ($this->legend) {
+ $this->DrawLegend($this->legend_x_pos,$this->legend_y_pos,'');
+ }
+
+ }
+ if ($this->print_image == 1) {
+ $this->PrintImage();
+ }
+ } //function DrawGraph
+
+ }
+
+// $graph = new PHPlot;
+
+// $graph->DrawGraph();
+
+?>
diff --git a/src/catalog/admin/includes/classes/sessions.php b/src/catalog/admin/includes/classes/sessions.php
new file mode 100644
index 0000000..fe35a3c
--- /dev/null
+++ b/src/catalog/admin/includes/classes/sessions.php
@@ -0,0 +1,512 @@
+mod_name = $this->save_handler;
+ }
+ }
+
+ class php3session_user {
+ var $open_func, $close_func, $read_func, $write_func, $destroy_func, $gc_func;
+
+ function open($save_path, $sess_name) {
+ $func = $this->open_func;
+ if (function_exists($func)) {
+ return $func($save_path, $sess_name);
+ }
+
+ return true;
+ }
+
+ function close($save_path, $sess_name) {
+ $func = $this->close_func;
+ if (function_exists($func)) {
+ return $func();
+ }
+
+ return true;
+ }
+
+ function read($sess_id) {
+ $func = $this->read_func;
+
+ return $func($sess_id);
+ }
+
+ function write($sess_id, $val) {
+ $func = $this->write_func;
+
+ return $func($sess_id, $val);
+ }
+
+ function destroy($sess_id) {
+ $func = $this->destroy_func;
+ if (function_exists($func)) {
+ return $func($sess_id);
+ }
+
+ return true;
+ }
+
+ function gc($max_lifetime) {
+ $func = $this->gc_func;
+ if (function_exists($func)) {
+ return $func($max_lifetime);
+ }
+
+ return true;
+ }
+ }
+
+ class php3session_files {
+ function open($save_path, $sess_name) {
+ return true;
+ }
+
+ function close() {
+ return true;
+ }
+
+ function read($sess_id) {
+ global $session;
+
+// Open, read in, close file with session data
+ $file = $session->save_path . '/sess_' . $sess_id;
+ if (!file_exists($file)) {
+// Create it
+ touch($file);
+ }
+ $fp = fopen($file, 'r') or die('Could not open session file (' . $file . ').');
+ $val = fread($fp, filesize($file));
+ fclose($fp);
+
+ return $val;
+ }
+
+ function write($sess_id, $val) {
+ global $session;
+
+// Open, write to, close file with session data
+ $file = $session->save_path . '/sess_' . $sess_id;
+ $fp = fopen($file, 'w') or die('Could not write session file (' . $file . ')');
+ $val = fputs($fp, $val);
+ fclose($fp);
+
+ return true;
+ }
+
+ function destroy($sess_id) {
+ global $session;
+
+ $file = $session->save_path . '/sess_' . $sess_id;
+ unlink($file);
+
+ return true;
+ }
+
+ function gc($max_lifetime) {
+// We return true, since all cleanup should be handled by
+// an external entity (i.e. find -ctime x | xargs rm)
+ return true;
+ }
+ }
+
+ function _session_create_id() {
+ return md5(uniqid(microtime()));
+ }
+
+ function _session_cache_limiter() {
+ global $session;
+
+ switch ($session->cache_limiter) {
+ case 'nocache':
+ header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ break;
+ case 'private':
+ header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
+ header(sprintf('Cache-Control: private, max-age=%s', $session->cache_expire * 60));
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(basename($GLOBALS['PHP_SELF']))) . ' GMT');
+ break;
+ case 'public':
+ $now = time();
+ $now += $session->cache_expire * 60;
+ $now = gmdate('D, d M Y H:i:s', $now) . ' GMT';
+ header('Expires: ' . $now);
+ header(sprintf('Cache-Control: public, max-age=%s', $session->cache_expire * 60));
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(basename($GLOBALS['PHP_SELF']))) . ' GMT');
+ break;
+ default:
+ die('Caching method ' . $session->cache_limiter . ' not implemented.');
+ }
+ }
+
+ function _php_encode() {
+ global $session;
+
+ $ret = '';
+// Create a string containing the serialized variables
+ for (reset($session->vars); list($i)=each($session->vars);) {
+ $ret .= $session->vars[$i] . $session->delimiter_value . serialize($GLOBALS[$session->vars[$i]]) . $session->delimiter;
+ }
+
+ return $ret;
+ }
+
+ function _php_decode($data) {
+ global $session;
+
+ $data = trim($data);
+ $vars = explode($session->delimiter, $data);
+
+// Add the variables to the global namespace
+ for (reset($vars); list($i)=each($vars);) {
+ $tmp = explode($session->delimiter_value, $vars[$i]);
+ $name = trim($tmp[0]);
+ $value = trim($tmp[1]);
+ $GLOBALS[$name] = unserialize($value);
+ $session->vars[] = trim($name);
+ }
+ }
+
+ function _wddx_encode($data) {
+ global $session;
+
+ $ret = wddx_serialize_vars($session->vars);
+
+ return $ret;
+ }
+
+ function _wddx_decode($data) {
+ return wddx_deserialize($data);
+ }
+
+ function session_name($name = '') {
+ global $session;
+
+ if (empty($name)) {
+ return $session->name;
+ }
+
+ $session->name = $name;
+ }
+
+ function session_set_save_handler($open, $close, $read, $write, $destroy, $gc) {
+ global $session, $php3session_user;
+
+ $php3session_user = new php3session_user;
+ $php3session_user->open_func = $open;
+ $php3session_user->close_func = $close;
+ $php3session_user->read_func = $read;
+ $php3session_user->write_func = $write;
+ $php3session_user->destroy_func = $destroy;
+ $php3session_user->gc_func = $gc;
+ $session->mod_name = 'php3session_user';
+ }
+
+ function session_module_name($name = '') {
+ global $session;
+
+ if (empty($name)) {
+ return $session->mod_name;
+ }
+
+ $session->mod_name = $name;
+ }
+
+ function session_save_path($path = '') {
+ global $session;
+
+ if(empty($path)) {
+ return $session->save_path;
+ }
+
+ $session->save_path = $path;
+ }
+
+ function session_id($id = '') {
+ global $session;
+
+ if(empty($id)) {
+ return $session->id;
+ }
+
+ $session->id = $id;
+ }
+
+ function session_register($var) {
+ global $session;
+
+ if ($session->nr_open_sessions == 0) {
+ session_start();
+ }
+
+ $session->vars[] = trim($var);
+ }
+
+ function session_unregister($var) {
+ global $session;
+
+ for (reset($session->vars); list($i)=each($session->vars);) {
+ if ($session->vars[$i] == trim($var)) {
+ unset($session->vars[$i]);
+ break;
+ }
+ }
+ }
+
+ function session_is_registered($var) {
+ global $session;
+
+ for (reset($session->vars); list($i)=each($session->vars);) {
+ if ($session->vars[$i] == trim($var)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function session_encode() {
+ global $session;
+
+ $serializer = '_' . $session->serialize_handler . '_encode';
+ $ret = $serializer();
+
+ return $ret;
+ }
+
+ function session_decode($data) {
+ global $session;
+
+ $serializer = '_' . $session->serialize_handler . '_decode';
+ $ret = $serializer($data);
+
+ return $ret;
+ }
+
+ function session_start() {
+ global $session, $SID, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
+
+// Define the global variable $SID?
+ $define_sid = true;
+
+// Send the session cookie?
+ $send_cookie = true;
+
+// Is track_vars enabled?
+ $track_vars = ( (isset($HTTP_COOKIE_VARS)) || (isset($HTTP_GET_VARS)) || (isset($HTTP_POST_VARS)) ) ? true : false;
+
+// Check if session_start() has been called once already
+ if ($session->nr_open_sessions != 0) {
+ return false;
+ }
+
+// If our only resource is the global symbol_table, then check it.
+// If track_vars are enabled, we prefer these, because they are more
+// reliable, and we always know whether the user has accepted the
+// cookie.
+ if ( (isset($GLOBALS[$session->name])) && (!empty($GLOBALS[$session->name])) && (!$track_vars) ) {
+ $session->id = $GLOBALS[$session->name];
+ $send_cookie = false;
+ }
+
+// Now check the track_vars. Cookies are preferred, because initially
+// cookie and get variables will be available.
+ if ( (empty($session->id)) && ($track_vars) ) {
+ if (isset($HTTP_COOKIE_VARS[$session->name])) {
+ $session->id = $HTTP_COOKIE_VARS[$session->name];
+ $define_sid = false;
+ $send_cookie = false;
+ }
+
+ if (isset($HTTP_GET_VARS[$session->name])) {
+ $session->id = $HTTP_GET_VARS[$session->name];
+ }
+
+ if (isset($HTTP_POST_VARS[$session->name])) {
+ $session->id = $HTTP_POST_VARS[$session->name];
+ }
+ }
+
+/*
+// Check the REQUEST_URI symbol for a string of the form
+// '=' to allow URLs of the form
+// http://yoursite/=/script.php
+ if (empty($session->id)) {
+ eregi($session->name . '=([^/]+)', $GLOBALS['REQUEST_URI'], $regs);
+ $regs[1] = trim($regs[1]);
+ if (!empty($regs[1])) {
+ $session->id = $regs[1];
+ }
+ }
+*/
+
+// Check whether the current request was referred to by
+// an external site which invalidates the previously found ID
+ if ( (!empty($session->id)) && ($session->referer_check) ) {
+ $url = parse_url($GLOBALS['HTTP_REFERER']);
+ if (trim($url['host']) != $GLOBALS['SERVER_NAME']) {
+ unset($session->id);
+ $send_cookie = true;
+ $define_sid = true;
+ }
+ }
+
+// Do we have an existing session ID?
+ if (empty($session->id)) {
+// Create new session ID
+ $session->id = _session_create_id();
+ }
+
+// Is use_cookies set to false?
+ if ( (!$session->use_cookies) && ($send_cookie) ) {
+ $define_sid = true;
+ $send_cookie = false;
+ }
+
+// Should we send a cookie?
+ if ($send_cookie) {
+ setcookie($session->name, $session->id, $session->cookie_lifetime, $session->cookie_path, $session->cookie_domain);
+ }
+
+// Should we define the SID?
+ if($define_sid) {
+ $SID = $session->name . '=' . $session->id;
+ }
+
+ $session->nr_open_sessions++;
+
+// Send caching headers
+
+// Start session
+ $mod = $GLOBALS[$session->mod_name];
+ if (!$mod->open($session->save_path, $session->name)) {
+ die('Failed to initialize session module.');
+ }
+
+// Read session data
+ if ($val = $mod->read($session->id)) {
+// Decode session data
+ session_decode($val);
+ }
+
+// Send HTTP cache headers
+ _session_cache_limiter();
+
+// Check if we should clean up (call the garbage collection routines)
+ if ($session->gc_probability > 0) {
+ $randmax = getrandmax();
+ $nrand = (int)(100 * tep_rand() / $randmax);
+ if ($nrand < $session->gc_probability) {
+ $mod->gc($session->gc_maxlifetime);
+ }
+ }
+
+ if ($define_sid) {
+ define('SID', $SID);
+ } else {
+ define('SID', '');
+ }
+
+ return true;
+ }
+
+ function session_destroy() {
+ global $session;
+
+ if ($session->nr_open_sessions == 0) {
+ return false;
+ }
+
+// Destroy session
+ $mod = $GLOBALS[$session->mod_name];
+ if (!$mod->destroy($session->id)) {
+ return false;
+ }
+ unset($session);
+ $session = new php3session;
+
+ return true;
+ }
+
+ function session_close() {
+ global $session, $SID;
+
+ if ($session->nr_open_sessions == 0) {
+ return false;
+ }
+// Encode session
+ $val = session_encode();
+ $len = strlen($val);
+
+// Save session
+ $mod = $GLOBALS[$session->mod_name];
+ if (!$mod->write($session->id, $val)) {
+ die('Session could not be saved.');
+ }
+// Close session
+ if ( (function_exists($session->mod_name . '->close')) && (!$mod->close()) ) {
+ die('Session could not be closed.');
+ }
+ $SID = '';
+ $session->nr_open_sessions--;
+
+ return true;
+ }
+
+ $session = new php3session;
+ $mod = $session->save_handler;
+ $$mod = new $mod;
+
+ if ($session->auto_start) {
+ $ret = session_start() or die('Session could not be started.');
+ }
+
+ register_shutdown_function('session_close');
+?>
diff --git a/src/catalog/admin/includes/classes/shopping_cart.php b/src/catalog/admin/includes/classes/shopping_cart.php
new file mode 100644
index 0000000..a7a027b
--- /dev/null
+++ b/src/catalog/admin/includes/classes/shopping_cart.php
@@ -0,0 +1,306 @@
+reset();
+ }
+
+ function restore_contents() {
+ global $customer_id;
+
+ if (!$customer_id) return 0;
+
+// insert current cart contents in database
+ if ($this->contents) {
+ reset($this->contents);
+ while (list($products_id, ) = each($this->contents)) {
+ $qty = $this->contents[$products_id]['qty'];
+ $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+ if (!tep_db_num_rows($product_query)) {
+ tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')");
+ if ($this->contents[$products_id]['attributes']) {
+ reset($this->contents[$products_id]['attributes']);
+ while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
+ tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
+ }
+ }
+ } else {
+ tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($qty) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+ }
+ }
+ }
+
+// reset per-session cart contents, but not the database contents
+ $this->reset(FALSE);
+
+ $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
+ while ($products = tep_db_fetch_array($products_query)) {
+ $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
+// attributes
+ $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
+ while ($attributes = tep_db_fetch_array($attributes_query)) {
+ $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
+ }
+ }
+
+ $this->cleanup();
+ }
+
+ function reset($reset_database = FALSE) {
+ global $customer_id;
+
+ $this->contents = array();
+ $this->total = 0;
+
+ if ($customer_id && $reset_database) {
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
+ }
+ }
+
+ function add_cart($products_id, $qty = '', $attributes = '') {
+ global $new_products_id_in_cart, $customer_id;
+
+ $products_id = tep_get_uprid($products_id, $attributes);
+
+ if ($this->in_cart($products_id)) {
+ $this->update_quantity($products_id, $qty, $attributes);
+ } else {
+ if ($qty == '') $qty = '1'; // if no quantity is supplied, then add '1' to the customers basket
+
+ $this->contents[] = array($products_id);
+ $this->contents[$products_id] = array('qty' => $qty);
+// insert into database
+ if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')");
+
+ if (is_array($attributes)) {
+ reset($attributes);
+ while (list($option, $value) = each($attributes)) {
+ $this->contents[$products_id]['attributes'][$option] = $value;
+// insert into database
+ if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
+ }
+ }
+ $new_products_id_in_cart = $products_id;
+ tep_session_register('new_products_id_in_cart');
+ }
+ $this->cleanup();
+ }
+
+ function update_quantity($products_id, $quantity = '', $attributes = '') {
+ global $customer_id;
+
+ if ($quantity == '') return true; // nothing needs to be updated if theres no quantity, so we return true..
+
+ $this->contents[$products_id] = array('qty' => $quantity);
+// update database
+ if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($quantity) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+
+ if (is_array($attributes)) {
+ reset($attributes);
+ while (list($option, $value) = each($attributes)) {
+ $this->contents[$products_id]['attributes'][$option] = $value;
+// update database
+ if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
+ }
+ }
+ }
+
+ function cleanup() {
+ global $customer_id;
+
+ reset($this->contents);
+ while (list($key,) = each($this->contents)) {
+ if ($this->contents[$key]['qty'] < 1) {
+ unset($this->contents[$key]);
+// remove from database
+ if ($customer_id) {
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
+ }
+ }
+ }
+ }
+
+ function count_contents() { // get total number of items in cart
+ $total_items = 0;
+ if (is_array($this->contents)) {
+ reset($this->contents);
+ while (list($products_id, ) = each($this->contents)) {
+ $total_items += $this->get_quantity($products_id);
+ }
+ }
+ return $total_items;
+ }
+
+ function get_quantity($products_id) {
+ if ($this->contents[$products_id]) {
+ return $this->contents[$products_id]['qty'];
+ } else {
+ return 0;
+ }
+ }
+
+ function in_cart($products_id) {
+ if ($this->contents[$products_id]) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function remove($products_id) {
+ global $customer_id;
+
+ unset($this->contents[$products_id]);
+// remove from database
+ if ($customer_id) {
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+ tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+ }
+ }
+
+ function remove_all() {
+ $this->reset();
+ }
+
+ function get_product_id_list() {
+ $product_id_list = '';
+ if (is_array($this->contents))
+ {
+ reset($this->contents);
+ while (list($products_id, ) = each($this->contents)) {
+ $product_id_list .= ', ' . $products_id;
+ }
+ }
+ return substr($product_id_list, 2);
+ }
+
+ function calculate() {
+ $this->total = 0;
+ $this->weight = 0;
+ if (!is_array($this->contents)) return 0;
+
+ reset($this->contents);
+ while (list($products_id, ) = each($this->contents)) {
+ $qty = $this->contents[$products_id]['qty'];
+
+// products price
+ $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . (int)tep_get_prid($products_id) . "'");
+ if ($product = tep_db_fetch_array($product_query)) {
+ $prid = $product['products_id'];
+ $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
+ $products_price = $product['products_price'];
+ $products_weight = $product['products_weight'];
+
+ $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
+ if (tep_db_num_rows ($specials_query)) {
+ $specials = tep_db_fetch_array($specials_query);
+ $products_price = $specials['specials_new_products_price'];
+ }
+
+ $this->total += tep_add_tax($products_price, $products_tax) * $qty;
+ $this->weight += ($qty * $products_weight);
+ }
+
+// attributes price
+ if (isset($this->contents[$products_id]['attributes'])) {
+ reset($this->contents[$products_id]['attributes']);
+ while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
+ $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
+ $attribute_price = tep_db_fetch_array($attribute_price_query);
+ if ($attribute_price['price_prefix'] == '+') {
+ $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
+ } else {
+ $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
+ }
+ }
+ }
+ }
+ }
+
+ function attributes_price($products_id) {
+ $attributes_price = 0;
+
+ if (isset($this->contents[$products_id]['attributes'])) {
+ reset($this->contents[$products_id]['attributes']);
+ while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
+ $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
+ $attribute_price = tep_db_fetch_array($attribute_price_query);
+ if ($attribute_price['price_prefix'] == '+') {
+ $attributes_price += $attribute_price['options_values_price'];
+ } else {
+ $attributes_price -= $attribute_price['options_values_price'];
+ }
+ }
+ }
+
+ return $attributes_price;
+ }
+
+ function get_products() {
+ global $languages_id;
+
+ if (!is_array($this->contents)) return 0;
+ $products_array = array();
+ reset($this->contents);
+ while (list($products_id, ) = each($this->contents)) {
+ $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . (int)tep_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
+ if ($products = tep_db_fetch_array($products_query)) {
+ $prid = $products['products_id'];
+ $products_price = $products['products_price'];
+
+ $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
+ if (tep_db_num_rows($specials_query)) {
+ $specials = tep_db_fetch_array($specials_query);
+ $products_price = $specials['specials_new_products_price'];
+ }
+
+ $products_array[] = array('id' => $products_id,
+ 'name' => $products['products_name'],
+ 'model' => $products['products_model'],
+ 'price' => $products_price,
+ 'quantity' => $this->contents[$products_id]['qty'],
+ 'weight' => $products['products_weight'],
+ 'final_price' => ($products_price + $this->attributes_price($products_id)),
+ 'tax_class_id' => $products['products_tax_class_id'],
+ 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
+ }
+ }
+ return $products_array;
+ }
+
+ function show_total() {
+ $this->calculate();
+
+ return $this->total;
+ }
+
+ function show_weight() {
+ $this->calculate();
+
+ return $this->weight;
+ }
+
+ function unserialize($broken) {
+ for(reset($broken);$kv=each($broken);) {
+ $key=$kv['key'];
+ if (gettype($this->$key)!="user function")
+ $this->$key=$kv['value'];
+ }
+ }
+
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/split_page_results.php b/src/catalog/admin/includes/classes/split_page_results.php
new file mode 100644
index 0000000..1c3823a
--- /dev/null
+++ b/src/catalog/admin/includes/classes/split_page_results.php
@@ -0,0 +1,103 @@
+ $num_pages) {
+ $current_page_number = $num_pages;
+ }
+ $offset = ($max_rows_per_page * ($current_page_number - 1));
+ $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
+ }
+
+ function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '', $page_name = 'page') {
+ global $PHP_SELF;
+
+ if ( tep_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&';
+
+// calculate number of pages needing links
+ $num_pages = ceil($query_numrows / $max_rows_per_page);
+
+ $pages_array = array();
+ for ($i=1; $i<=$num_pages; $i++) {
+ $pages_array[] = array('id' => $i, 'text' => $i);
+ }
+
+ if ($num_pages > 1) {
+ $display_links = tep_draw_form('pages', basename($PHP_SELF), '', 'get');
+
+ if ($current_page_number > 1) {
+ $display_links .= '' . PREVNEXT_BUTTON_PREV . ' ';
+ } else {
+ $display_links .= PREVNEXT_BUTTON_PREV . ' ';
+ }
+
+ $display_links .= sprintf(TEXT_RESULT_PAGE, tep_draw_pull_down_menu($page_name, $pages_array, $current_page_number, 'onChange="this.form.submit();"'), $num_pages);
+
+ if (($current_page_number < $num_pages) && ($num_pages != 1)) {
+ $display_links .= ' ' . PREVNEXT_BUTTON_NEXT . ' ';
+ } else {
+ $display_links .= ' ' . PREVNEXT_BUTTON_NEXT;
+ }
+
+ if ($parameters != '') {
+ if (substr($parameters, -1) == '&') $parameters = substr($parameters, 0, -1);
+ $pairs = explode('&', $parameters);
+ while (list(, $pair) = each($pairs)) {
+ list($key,$value) = explode('=', $pair);
+ $display_links .= tep_draw_hidden_field(rawurldecode($key), rawurldecode($value));
+ }
+ }
+
+ if (SID) $display_links .= tep_draw_hidden_field(tep_session_name(), tep_session_id());
+
+ $display_links .= '';
+ } else {
+ $display_links = sprintf(TEXT_RESULT_PAGE, $num_pages, $num_pages);
+ }
+
+ return $display_links;
+ }
+
+ function display_count($query_numrows, $max_rows_per_page, $current_page_number, $text_output) {
+ $to_num = ($max_rows_per_page * $current_page_number);
+ if ($to_num > $query_numrows) $to_num = $query_numrows;
+ $from_num = ($max_rows_per_page * ($current_page_number - 1));
+ if ($to_num == 0) {
+ $from_num = 0;
+ } else {
+ $from_num++;
+ }
+
+ return sprintf($text_output, $from_num, $to_num, $query_numrows);
+ }
+ }
+?>
diff --git a/src/catalog/admin/includes/classes/table_block.php b/src/catalog/admin/includes/classes/table_block.php
new file mode 100644
index 0000000..b13c8c6
--- /dev/null
+++ b/src/catalog/admin/includes/classes/table_block.php
@@ -0,0 +1,80 @@
+table_border . '" width="' . $this->table_width . '" cellspacing="' . $this->table_cellspacing . '" cellpadding="' . $this->table_cellpadding . '"';
+ if (tep_not_null($this->table_parameters)) $tableBox_string .= ' ' . $this->table_parameters;
+ $tableBox_string .= '>' . "\n";
+
+ for ($i=0, $n=sizeof($contents); $i<$n; $i++) {
+ $tableBox_string .= ' table_row_parameters)) $tableBox_string .= ' ' . $this->table_row_parameters;
+ if (isset($contents[$i]['params']) && tep_not_null($contents[$i]['params'])) $tableBox_string .= ' ' . $contents[$i]['params'];
+ $tableBox_string .= '>' . "\n";
+
+ if (isset($contents[$i][0]) && is_array($contents[$i][0])) {
+ for ($x=0, $y=sizeof($contents[$i]); $x<$y; $x++) {
+ if (isset($contents[$i][$x]['text']) && tep_not_null($contents[$i][$x]['text'])) {
+ $tableBox_string .= ' table_data_parameters)) {
+ $tableBox_string .= ' ' . $this->table_data_parameters;
+ }
+ $tableBox_string .= '>';
+ if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= $contents[$i][$x]['form'];
+ $tableBox_string .= $contents[$i][$x]['text'];
+ if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= '';
+ $tableBox_string .= ' ' . "\n";
+ }
+ }
+ } else {
+ $tableBox_string .= ' table_data_parameters)) {
+ $tableBox_string .= ' ' . $this->table_data_parameters;
+ }
+ $tableBox_string .= '>' . $contents[$i]['text'] . ' ' . "\n";
+ }
+
+ $tableBox_string .= ' ' . "\n";
+ }
+
+ $tableBox_string .= '