sales_report.js.php

来自「Zen Cart是真正的电子商务艺术」· PHP 代码 · 共 584 行 · 第 1/2 页

PHP
584
字号
      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_SHIPPING; ?>', 'shipping');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_DISCOUNTS; ?>', 'discount');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_GC_SOLD; ?>', 'gc_sold');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_GC_USED; ?>', 'gc_used');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_ORDER_TOTAL; ?>', 'grand');    }    else if (view == 'product') {      // define text above first sort box      sort_title.innerHTML = '<?php echo SEARCH_SORT_PRODUCT; ?>';      sort_box.options[sort_box.options.length] = new Option('<?php echo SELECT_PRODUCT_ID; ?>', 'pID');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_PRODUCT_NAME; ?>', 'name');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_MANUFACTURER; ?>', 'manufacturer');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_MODEL; ?>', 'model');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_BASE_PRICE; ?>', 'base_price');      sort_box.options[sort_box.options.length] = new Option('<?php echo SELECT_QUANTITY; ?>', 'quantity');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_ONETIME_CHARGES; ?>', 'onetime_charges');      sort_box.options[sort_box.options.length] = new Option('<?php echo TABLE_HEADING_PRODUCT_TOTAL; ?>', 'grand');    }  }////////////// Function    : auto_select_input// Arguments   : string "default_option", element "input_obj", string "input_type"// Description : general function used to select an option from a drop down or radio group///////////////  function auto_select_input(default_option, input_obj, input_type) {    var option_found = false;    switch (input_type) {      case 'option':        var option = document.getElementsByName(input_obj);        for(var i = 0; i < option.length; i++) {          if (option[i].value == default_option) {            option[i].checked = true;            option_found = true;            break;          }        }        if (!option_found) option[0].checked = true;      break;      case 'select':        var select = document.getElementById(input_obj);        for(var i = 0; i < select.options.length; i++) {          if (select.options[i].value == default_option) {            select.selectedIndex = i;            option_found = true;            break;          }        }        if (!option_found) select.selectedIndex = 0;      break;    }  }////////////// Function    : clearDefault// Arguments   : element "el"// Description : clears default text from a text field when given cursor attention///////////////  function clearDefault(el) {    if (el.defaultValue == el.value) el.value = "";  }////////////// Function    : format_checkbox// Arguments   : string "current_output"// Description : sets visibilty of checkboxes that appear depending//               on the output format selected.///////////////  function format_checkbox(current_output) {    switch (current_output) {      case 'print':        show('span_auto_print');        hide('span_csv_header');      break;      case 'csv':        hide('span_auto_print');        show('span_csv_header');      break;      default:        document.search.auto_print.checked = false;        document.search.csv_header.checked = false;        hide('span_auto_print');        hide('span_csv_header');      break;    }  }////////////// Function    : form_check// Arguments   : none// Description : Checks the sales report search parameters; submits the search//               if valid, alerts the user if there are problems///////////////  function form_check() {    var ready_date = false;    var date_valid = false;    var compatible_csv = false;    // check for a preset date selection    var date_preset_set = false;    var date_preset = document.getElementsByName('date_preset');    for (var i = 0; i < date_preset.length; i++) {      if (date_preset[i].checked) {        date_preset_set = true;        break;      }    }    var start_date = document.search.start_date;    var end_date = document.search.end_date;    // check for a preset date range selection    if (date_preset_set) {      ready_date = true;      date_valid = true;    }    // check for a custom date range    else if (start_date.value != "" && end_date.value != "") {      ready_date = true;      // if there's a custom date range, we need to make sure both dates are valid      var sd_string = start_date.value.toString();      var ed_string = end_date.value.toString();      var date_delim = sd_string.charAt(2);      var sd_array = sd_string.split( date_delim );      var ed_array = ed_string.split( date_delim );      if (isDate(sd_array[1], sd_array[0], sd_array[2]) &&          isDate(ed_array[1], ed_array[0], ed_array[2]) ) {          // the array is in mm-dd-yyyy format, but isDate needs it in dd-mm-yyyy        date_valid = true;      }      else {        date_valid = false;      }      // in order to prevent timeouts and server overloads, we      // should also make sure the date range isn't too big    }    else {      ready_date = false;      date_valid = true;  // 1 date-related error is enough    }    // make sure CSV output is not selected with the matrix detail level    var detail_level = document.getElementById('detail_level');    var output_format = document.getElementById('output_format');    if (detail_level.options[detail_level.selectedIndex].value == 'matrix' &&        output_format.options[output_format.selectedIndex].value == 'csv') {      var compatible_csv = false;    }    else {      var compatible_csv = true;    }    // if everything checks out, submit the search    if (ready_date && date_valid && compatible_csv) {      document.search.btn_submit.disabled = true;      show('td_wait_text');      setTimeout('submit_timeout()', 5000);      // check to see if we should open in a new window      if (document.search.new_window.checked) {        window.open('', 'sr_popup', '');        document.search.target = 'sr_popup';      }      document.search.submit();    }    // otherwise alert the user and highlight the problem(s)    else {      var alert_start = "";      var alert_date_invalid = "";      var alert_date_missing = "";      var alert_csv_conflict = "";      var alert_finish = "";      var error_count = 0;      alert_start = "<?php echo ALERT_MSG_START; ?>"  + "\n \n";      if (!date_valid) {        alert_date_invalid = "<?php echo ALERT_DATE_INVALID; ?>" + "\n";        start_date.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        end_date.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        error_count++;      }      if (!ready_date) {        alert_date_missing = "<?php echo ALERT_DATE_MISSING; ?>" + "\n";        var td_yesterday  = document.getElementById('td_yesterday');        td_yesterday.style.color = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        td_yesterday.style.fontWeight = 'bold';        var td_last_month = document.getElementById('td_last_month');        td_last_month.style.color = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        td_last_month.style.fontWeight = 'bold';        var td_this_month = document.getElementById('td_this_month');        td_this_month.style.color = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        td_this_month.style.fontWeight = 'bold';        start_date.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        end_date.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        error_count++;      }      if (!compatible_csv) {        alert_csv_conflict = "<?php echo ALERT_CSV_CONFLICT; ?>" + "\n";        detail_level.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        output_format.style.backgroundColor = "<?php echo ALERT_JS_HIGHLIGHT; ?>";        error_count++;      }      alert_finish = "\n" + "<?php echo ALERT_MSG_FINISH; ?>";      var msg = alert_start +                alert_date_invalid +                alert_date_missing +                alert_csv_conflict +                alert_finish;      alert(msg);    }  }////////////// Function    : submit_timeout// Arguments   : none// Description : re-enables the submit button when CSV or new window options//               are selected.  Prevents "breaking" the submit button.///////////////  function submit_timeout() {    var format = document.search.output_format.options[document.search.output_format.selectedIndex].value;    if (format == 'csv' || document.search.new_window.checked) {      hide('td_wait_text');      document.search.btn_submit.disabled = false;    }  }////////////// Function    : img_over// Arguments   : element "img_name", string "img_src"// Description : replaces source of img_name with image identified in img_src///////////////  function img_over(img_name, img_src) {    var img = document.getElementById(img_name);    img.src = img_src;  }////////////// Function    : isDate// Arguments   : string "day", string "month", string "year"// Description : checks if passed date is valid//               (e.g. returns false for Feb. 29 or Sept. 31)///////////////  function isDate(day, month, year) {    var today = new Date();    year = ((!year) ? today.getFullYear() : year);    month = ((!month) ? today.getMonth() : month - 1);    // subtract 1 because date.getMonth() numbers months 0 - 11    if (!day) {      return false;    }    var test = new Date(year, month, day);    if ( (year == test.getFullYear()) &&         (month == test.getMonth()) &&         (day == test.getDate()) ) {      return true;    }    else {      return false;    }  }--></script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?