<?php
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
/**
 *----------------------------------------------------------------------------
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 网站地址: http://Www.HuCart.Com；
 * 作者: HuCart.COM
**/
class Ajax_exists_barcode extends HC_Controller
{
	//注意无须构造函数,使用了构造函数得重构父类 parent::__construct();
	function __construct()
	{
		parent::__construct();
		//$this->load_lang('adminsys/ajax_pro_type');
		//$this -> load('admin'); 
		//$this -> admin -> online_admin();
		$this -> load_db();
		/*
		$this -> load('helper'); //加载辅助类
		$this -> load_model('pro_sort'); //加载产品分类模型
		$this -> load_model('brand'); 	 //加载品牌模型
		$this -> load_model('pro_type'); 	 //加载类型模型
		*/
		//$this-> lang['txt_select'];
		
	}
	
	function get_barcode()
	{
		
		$pro_id_val = $this -> input -> req['pro_id'];
		//查询数据
		$barcode_val = $this -> input -> req['barcode_val'];

		if($barcode_val){
			
			if($pro_id_val!=''){
				$sql_pra 	= " SELECT count(*) as pronum  FROM ".$this -> db -> prefix."product WHERE pro_id <> ".$pro_id_val." AND pro_barcode = '$barcode_val' ";
			}else{
				$sql_pra 	= " SELECT count(*) as pronum  FROM ".$this -> db -> prefix."product WHERE pro_barcode = '$barcode_val' ";
			}
			$pra_detail = $this -> db -> select_one($sql_pra);
			if($pra_detail['pronum']>0){
				echo 'error';	
			}else{
				echo 'ok';
			}
		}else{
			echo 'error';
		}
		
	}


}


