45 lines
894 B
PHP
45 lines
894 B
PHP
<?php
|
|
$code = trim($_REQUEST['code']);
|
|
|
|
$db = $GLOBALS['db'];
|
|
|
|
if (strlen($code)<7) {
|
|
echo '0';
|
|
return;
|
|
}
|
|
|
|
$res = $db->fetchByAssoc($db->query("SELECT count(id) as c FROM ecmproducts WHERE UPPER(code)='".strtoupper($code)."'"));
|
|
if (intval($res['c'])!=0) {
|
|
echo '0';
|
|
return;
|
|
}
|
|
|
|
//pod podobny
|
|
$res = $db->fetchByAssoc($db->query("SELECT count(id) as c FROM ecmproducts WHERE UPPER(code) LIKE '".strtoupper($code)."%'"));
|
|
if (intval($res['c'])!=0) {
|
|
echo '2';
|
|
return;
|
|
}
|
|
|
|
|
|
$type = substr($code,0,2);
|
|
$res = $db->fetchByAssoc($db->query("
|
|
select code_number from ecmproducts where code like '$type%'
|
|
and deleted='0'
|
|
and product_active = '1'
|
|
order by code_number desc limit 0,1;
|
|
"));
|
|
|
|
$number = intval($res['code_number'])+1;
|
|
|
|
$c_number = intval(substr($code, -5));
|
|
|
|
if ($c_number > $number) {
|
|
echo '0';
|
|
return;
|
|
}
|
|
|
|
echo '1';
|
|
return;
|
|
|
|
?>
|