09.05.2014 17:43
whitewizard
 
Встала задача на складе проверять товар на наличие в базе и разрешение приёмки.
На основе темы Альтернативный прайсчекер. сделал следующий файл:

Код:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<meta http-equiv="Content-Language" content="ru" />
<meta http-equiv="refresh" content="10;http://адрес_сервера/price.php" />
<title>Проверка товара</title>
<style type="text/css">
<!--
.text {
font-family: sans-serif;
font-weight: bold;
font-size: 36px;
color: #909;
}

.name {
font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: #F60;
}
.price {

font-family: sans-serif;
font-weight: bold;
font-size: 100px;
color: black;
}
.error {

font-family: sans-serif;
font-weight: bold;
font-size: 36px;
color: #F00;
}
.receiptok {

font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: green;
}
.receiptnotok {

font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: red;
text-decoration: line-through;
}
.ma {

font-family: sans-serif;
font-weight: bold;
font-size: 54px;
color: blue;
text-decoration: underline;
}


-->
</style>
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><td width="100%" ><table width="100%" cellspacing="0" cellpadding="0" align="center" valign="center" >
<tr><td width="100%" align="center" valign="center">
<img src="logo.png">

<p class="text">Чтобы узнать информацию о товаре, <br>поднесите его штрихкод к сканеру


<form onKeyPress="keychecker(event)" action='price.php' method=get>
<p>
<body onLoad="document.getElementById('id_barcode').focus()">

<script src=jquery.min.js></script>
<script>
$(document).ready(function() {
if (!("autofocus" in document.createElement("input"))) {
$("#id_barcode").focus();
}
});
</script>

<input name='barcode' id='id_barcode' autofocus>
<script>
if (!("autofocus" in document.createElement("input"))) {
document.getElementById("id_barcode").focus();
}
</script>

</p>
</form>
</td></tr></table></td></tr></table>


<script>
function keychecker( e )
{
if( e == null ) e = event;
if( e.keyCode == 13 )
{
var cod = document.getElementById('id_barcode').value.toString();
if( cod.substr(0,2) == "22" ) //Первые две цифры весового ШК
document.getElementById('id_barcode').value = cod.substr(0,cod.length-6);
document.forms[0].submit();
} 
}
</script>

<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><td width="100%" ><table width="100%" cellspacing="0" cellpadding="0" align="center" valign="center" >
<tr><td width="100%" align="center" valign="center">
<?php

header ("Content-type: text/html;charset=windows-1251");

if (isset ( $_GET ["barcode"] ) )
{
$database="TEST"; //Имя базы данных в переменную 
$username="supermag"; //Имя пользователя базы данных
$password="qqq"; //Пароль пользователя базы данных
$storeloc=58; //Место хранения
$pricetype=24; //Тип цены
 
$c = OCILogon("$username", "$password", "$database"); 
if ($c) {  
if (isset ( $_GET ["barcode"] ) )
  $b=$_GET["barcode"];
  // Производим выборку из базы данных 
  $s = OCIParse($c, "select * from supermag.smcard where article = (select article from supermag.smstoreunits where barcode='$b')"); 
  OCIExecute($s, OCI_DEFAULT); 

while (OCIFetch($s)) { 
$ARTICLE = ociresult($s, "ARTICLE");
$NAME = ociresult($s, "NAME");
$RECEIPTOK = ociresult($s, "RECEIPTOK");
} 

  $s = OCIParse($c, "select * from supermag.smprices where article = $ARTICLE and storeloc=$storeloc and pricetype=$pricetype"); 
  OCIExecute($s, OCI_DEFAULT); 

while (OCIFetch($s)) { 
$PRICE = number_format(ociresult($s, "PRICE"),2);
$SAVEDPRICE = ociresult($s, "SAVEDPRICE");
} 

if(empty($NAME)) //Проверка на пустой ввод
{
echo "<br><br><span class=error>Товар не найден, обратитесь к продавцу</span>";
}
else
{
if(empty($PRICE)) //Цена есть?
{
echo "<br><br><SPAN class=name>".$NAME."</SPAN><br><br>";
}
else
{
echo "<br><br><SPAN class=name>".$NAME."</SPAN><br><br><SPAN class=price>".$PRICE." руб.</SPAN>";
}

if(empty($RECEIPTOK)) //Приём разрешён?
{
echo "<br><br><SPAN class=receiptnotok>ПРИЁМ ЗАПРЕЩЁН</SPAN><br>";
}
else
{
echo "<br><br><SPAN class=receiptok>ПРИЁМ РАЗРЕШЁН</SPAN><br>";
}

if(empty($SAVEDPRICE)) //Действует маркетинговая акция?
{
}
else
{
echo "<br><br><SPAN class=ma>Действует маркетинговая акция</SPAN><br>";
}

}

// Отключаемся от базы данных 
  OCILogoff($c);
} 
else {  
  $err = OCIError();  
  echo "Oracle Connect Error " . $err[text];  
}  
exit();

}
?>
</td></tr></table></td></tr></table>

</body> 
</html>
Требуется наличии апача, PHP версии не ниже 5.2.4, клиента Oracle версии не ниже 10 (с более низкой версией PHP не работает).

Можно использовать для доработок под свои хитрые нужды
09.05.2014 19:09
whitewizard
 
В таком варианте при действующей маркетинговой акции будущая цена перечёркнута, а действующая показана

Код:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<meta http-equiv="Content-Language" content="ru" />
<meta http-equiv="refresh" content="10;http://192.168.200.254/ukm/price.php" />
<title>Проверка товара</title>
<style type="text/css">
<!--
.text {
font-family: sans-serif;
font-weight: bold;
font-size: 36px;
color: #909;
}

.name {
font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: #F60;
}
.price {

font-family: sans-serif;
font-weight: bold;
font-size: 100px;
color: black;
}
.error {

font-family: sans-serif;
font-weight: bold;
font-size: 36px;
color: #F00;
}
.receiptok {

font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: green;
}
.receiptnotok {

font-family: sans-serif;
font-weight: bold;
font-size: 72px;
color: red;
text-decoration: line-through;
}
.ma {

font-family: sans-serif;
font-weight: bold;
font-size: 36px;
color: blue;
text-decoration: line-through;
}


-->
</style>
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><td width="100%" ><table width="100%" cellspacing="0" cellpadding="0" align="center" valign="center" >
<tr><td width="100%" align="center" valign="center">
<img src="logo.png">

<p class="text">Чтобы узнать информацию о товаре, <br>поднесите его штрихкод к сканеру


<form onKeyPress="keychecker(event)" action='price.php' method=get>
<p>
<body onLoad="document.getElementById('id_barcode').focus()">

<script src=jquery.min.js></script>
<script>
$(document).ready(function() {
if (!("autofocus" in document.createElement("input"))) {
$("#id_barcode").focus();
}
});
</script>

<input name='barcode' id='id_barcode' autofocus>
<script>
if (!("autofocus" in document.createElement("input"))) {
document.getElementById("id_barcode").focus();
}
</script>

</p>
</form>
</td></tr></table></td></tr></table>


<script>
function keychecker( e )
{
if( e == null ) e = event;
if( e.keyCode == 13 )
{
var cod = document.getElementById('id_barcode').value.toString();
if( cod.substr(0,2) == "22" ) //Первые две цифры весового ШК
document.getElementById('id_barcode').value = cod.substr(0,cod.length-6);
document.forms[0].submit();
} 
}
</script>

<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><td width="100%" ><table width="100%" cellspacing="0" cellpadding="0" align="center" valign="center" >
<tr><td width="100%" align="center" valign="center">
<?php

header ("Content-type: text/html;charset=windows-1251");

if (isset ( $_GET ["barcode"] ) )
{
$database="KALIN20"; //Имя базы данных в переменную 
$username="supermag"; //Имя пользователя базы данных
$password="qqq"; //Пароль пользователя базы данных
$storeloc=58; //Место хранения
$pricetype=24; //Тип цены
$receiptok=0;
 
$c = OCILogon("$username", "$password", "$database"); 
if ($c) {  
if (isset ( $_GET ["barcode"] ) )
  $b=$_GET["barcode"];
  // Производим выборку из базы данных 
  $s = OCIParse($c, "select * from supermag.smcard where article = (select article from supermag.smstoreunits where barcode='$b')"); 
  OCIExecute($s, OCI_DEFAULT); 

while (OCIFetch($s)) { 
$ARTICLE = ociresult($s, "ARTICLE");
$NAME = ociresult($s, "NAME");
$RECEIPTOK = ociresult($s, "RECEIPTOK");
} 

  $s = OCIParse($c, "select * from supermag.smprices where article = $ARTICLE and storeloc=$storeloc and pricetype=$pricetype"); 
  OCIExecute($s, OCI_DEFAULT); 

while (OCIFetch($s)) { 
$PRICE = number_format(ociresult($s, "PRICE"),2);
$SAVEDPRICE = ociresult($s, "SAVEDPRICE");
} 

if(empty($NAME)) //Проверка на пустой ввод
{
echo "<br><br><span class=error>Товар не найден, обратитесь к продавцу</span>";
}
else
{
if(empty($PRICE)) //Цена есть?
{
echo "<br><br><SPAN class=name>".$NAME."</SPAN><br><br>";
}
else
  {
  echo "<br><br><SPAN class=name>".$NAME."</SPAN><br><br>";

  if(empty($SAVEDPRICE)) //Приём разрешён?
    {
    echo "<SPAN class=price>".$PRICE." руб.</SPAN>";
    }
  else
    {
    echo "<SPAN class=ma>".$SAVEDPRICE." руб.</SPAN><SPAN class=price>".$PRICE." руб.</SPAN>";
    echo "<br><SPAN class=text>действует маркетинговая акция</SPAN>";  
  }
}

if(empty($RECEIPTOK)) //Приём разрешён?
{
echo "<br><br><SPAN class=receiptnotok>ПРИЁМ ЗАПРЕЩЁН</SPAN><br>";
}
else
{
echo "<br><br><SPAN class=receiptok>ПРИЁМ РАЗРЕШЁН</SPAN><br>";
}

}

// Отключаемся от базы данных 
  OCILogoff($c);
} 
else {  
  $err = OCIError();  
  echo "Oracle Connect Error " . $err[text];  
}  
exit();

}
?>
</td></tr></table></td></tr></table>

</body> 
</html>
18.05.2014 14:19
whitewizard
 
Пару дней тупил по незнанию.
Захотел выводить последнего поставщика (есть у меня такая функция CLIENT=LASTCLIART(ARTICLE,STORELOC)).
Нишиша не работало в таком варианте:

Код:
$art = "'". $ARTICLE ."'";

$s = OCIParse($c, "select supermag.lastcliart($art, $storeloc) client from dual"); 
OCIExecute($s, OCI_DEFAULT); 

while (OCIFetch($s)) { 
$CLI = ociresult($s, "client");
}
Оказалось, что надо вот так делать:

Код:
$CLI = ociresult($s, "CLIENT");
Век живи, век учись.
Часовой пояс GMT +3, время: 11:03.

Форум на базе vBulletin®
Copyright © Jelsoft Enterprises Ltd.
В случае заимствования информации гипертекстовая индексируемая ссылка на Форум обязательна.