⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inc_prod_arr.php

📁 自己实现一个实用的商店应用系统
💻 PHP
字号:
<?php
////////////////////////////////////////////////////////
// Author by Shuweich
// Date : 2007.07.27
// 建站支持: http://www.shuweich.org
// 作者: Shuweich
// QQ: 1502384
// ICQ: 190492112
// MSN: shuweich@hotmail.com
// E-mail: root@shuweich.org
// E-mail: shuweich@163.com
// CMS交流站点: http://www.cmscn.org
////////////////////////////////////////////////////////
// 模块管理 by lssppxb
// For 系统管理员(站长及经理)
////////////////////////////////////////////////////////
include_once '../../mainfile.php';
	if ( _SSP == 7 ) $_S_id = '696';
	elseif ( _SSP == 1 ) $_S_id = $s_id;
?>
<div name='m_code' id='m_code' style='position:absolute;top:64px;left:9px;height:20px;width:20px;display:none;'>
  <select id='MySelect' name='MySelect' size='1' onchange='javascript:mbarcode_sel();'></select>
</div>
<bgsound name='cmts' id='cmts' src='' />


<script type="text/javascript">
<!--
  var prodXml;
  var prod_info = new Array();
  function cre_prod_arr(barcode) {
    //如果没有把参数barcode传进来,则回传false
    if (typeof(barcode) == 'undefined') {
      return false;
    }
    prodXml = InitAjax();
    var pUr = "inc_get_prod_arr.php?pload="+pload+"&s_id0=<?php echo $s_id; ?>&barcode="+barcode+"&tS="+new Date().getTime();
    // alert(pUr);
    prodXml.open("GET", pUr, false);
    prodXml.send(null);
    // 求以下语句在MS-IE及Firefox等不同Browser上的争议
    // // prodXml.onreadystatechange = handleStateChange;
    if ( prodXml.readyState == 4 && prodXml.status == 200 ) {
      list_prod();
    }
  }

  function handleStateChange() {
    if ( prodXml.readyState == 4 && prodXml.status == 200 ) {
      list_prod();
    }
  }

  function list_prod() {
    var res = prodXml.responseXML;
    // var rest = prodXml.responseText;
    // alert(rest);
    var sku = null;	var barc = "";	var pname = "";		var price = "";		var uniqcode = "";
    var products = res.getElementsByTagName("sku");
    prod_info = new Array();
    for ( var i = 0; i < products.length; i++ ) {
      sku = products[i];
      barc = sku.getElementsByTagName("barcode")[0].firstChild.nodeValue;
      pname = sku.getElementsByTagName("pname")[0].firstChild.nodeValue;
      price = sku.getElementsByTagName("price")[0].firstChild.nodeValue;
      uniqcode = sku.getElementsByTagName("uniqcode")[0].firstChild.nodeValue;
      prod_info[i] = [barc,pname,price,uniqcode];
    }
  }

  function m_code_beep() {
    document.getElementById("cmts").loop = 1;
    // document.getElementById("cmts").src="images/cmts.mid";
    document.getElementById("cmts").src="images/cmts.wav";
  }
  function wrt_prod(curr_hs,info_iqu) {
    if ( info_iqu == -1 ) {
      document.getElementById('spmc0_'+curr_hs).value='';
      if ( _dj ) document.getElementById('spdj0_'+curr_hs).value='';
      document.getElementById('sp_code0_'+curr_hs).value='';
    } else {
      document.getElementById('spmc0_'+curr_hs).value=prod_info[info_iqu][1];
      if ( _dj ) document.getElementById('spdj0_'+curr_hs).value=prod_info[info_iqu][2];
      document.getElementById('sp_code0_'+curr_hs).value=prod_info[info_iqu][3];
    }
  }

  function mbarcode_sel() {
    if (document.getElementById("MySelect").selectedIndex == 0) {
      alert('商品条码重复,请选择所购商品!');
    } else {
      for ( var pro_i=0; pro_i<prod_info.length; pro_i++ ) {
        var temp_code = document.getElementById("MySelect")[document.getElementById("MySelect").selectedIndex].value;
        if ( prod_info[pro_i][3] == temp_code ) {
          wrt_prod(curr_hs9,pro_i);
	  sum_sj();
          document.getElementById("m_code").style.display='none';
        }
      }
      // alert(curr_hs9);
    }
  }

  var curr_hs9;
  function products_search(barcode,curr_hs) {
    // 激活条码重复显示选择框
    if ( prod_info.length > 0 ) {
      if ( prod_info.length > 1 ) {
        document.getElementById("m_code").style.display='';
        curr_hs9 = curr_hs;
	for ( ba=50; ba>0; ba-- ) {
          document.getElementById("MySelect").remove(document.getElementById("MySelect").ba);
	}
        var oOption=new Option('条码重复,请选择所购商品','01');
        document.getElementById("MySelect")[0]=oOption;
	for ( var ba=0; ba<prod_info.length; ba++ ) {
          if ( _dj ) var oOption=new Option(prod_info[ba][1]+"->¥"+prod_info[ba][2],prod_info[ba][3]);
	  else var oOption=new Option(prod_info[ba][1],prod_info[ba][3]);
          document.getElementById("MySelect")[ba+1]=oOption;
	}
        m_code_beep();
      } else {
        wrt_prod(curr_hs,0);
      }
    } else {
      alert('该商品条码不存在,请联系管理员!');
      wrt_prod(curr_hs,-1);
      return false;
    }
    return true;
  }

// -->
</script>

⌨️ 快捷键说明

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