init
This commit is contained in:
45
modules/EcmProducts/checkCode.php
Normal file
45
modules/EcmProducts/checkCode.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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;
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user