Files
crm.twinpol.com/modules/EcmStockOperations/EcmStockOperation.php
2025-05-12 15:44:39 +00:00

667 lines
26 KiB
PHP
Executable File

<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/* * *******************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* ****************************************************************************** */
/* * *******************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
* ****************************************************************************** */
require_once('data/SugarBean.php');
require_once('include/utils.php');
class EcmStockOperation extends SugarBean {
var $field_name_map = array();
var $id;
var $date_entered;
var $date_modified;
var $modified_user_id;
var $assigned_user_id;
var $name;
var $product_name;
var $product_code;
var $product_id;
var $stock_name;
var $stock_id;
var $quantity;
var $price;
var $parent_type;
var $parent_name;
var $parent_id;
var $in_id;
var $documentitem_id;
var $type;
var $module_dir = 'EcmStockOperations';
var $table_name = "ecmstockoperations";
var $object_name = "EcmStockOperation";
var $new_schema = true;
var $additional_column_fields = array('assigned_user_name', 'assigned_user_id');
function EcmStockOperation() {
parent::SugarBean();
$this->setupCustomFields('EcmStockOperations');
foreach ($this->field_defs as $field) {
$this->field_name_map[$field['name']] = $field;
}
}
function get_summary_text() {
return $this->name;
}
function create_list_query($order_by, $where, $show_deleted = 0) {
$custom_join = $this->custom_fields->getJOIN();
$query = "SELECT ";
$query.="ecmstockoperations.*,users.user_name as assigned_user_name";
if ($custom_join)
$query.=$custom_join['select'];
$query.=" FROM ecmstockoperations ";
$query.="LEFT JOIN users ON ecmstockoperations.assigned_user_id=users.id";
$query.=" ";
if ($custom_join)
$query.=$custom_join['join'];
$where_auto = '1=1';
if ($show_deleted == 0)
$where_auto = " $this->table_name.deleted=0 ";
elseif ($show_deleted == 1)
$where_auto = " $this->table_name.deleted=1 ";
if ($where != "")
$query.="where $where AND " . $where_auto;
else
$query.="where " . $where_auto;
if (substr_count($order_by, '.') > 0)
$query .= " ORDER BY $order_by";
elseif ($order_by != "")
$query .= " ORDER BY $order_by";
else
$query .= " ORDER BY ecmstockoperations.name";
return $query;
}
function create_export_query($order_by, $where) {
$custom_join = $this->custom_fields->getJOIN();
$query = "SELECT ";
$query.="ecmstockoperations.*,users.user_name as assigned_user_name";
if ($custom_join)
$query.=$custom_join['select'];
$query.=" FROM ecmstockoperations ";
$query.="LEFT JOIN users ON ecmstockoperations.assigned_user_id=users.id";
$query.=" ";
if ($custom_join)
$query.=$custom_join['join'];
$where_auto = '1=1';
if ($show_deleted == 0)
$where_auto = " $this->table_name.deleted=0 ";
elseif ($show_deleted == 1)
$where_auto = " $this->table_name.deleted=1 ";
if ($where != "")
$query.="where $where AND " . $where_auto;
else
$query.="where " . $where_auto;
if (substr_count($order_by, '.') > 0)
$query .= " ORDER BY $order_by";
elseif ($order_by != "")
$query .= " ORDER BY $order_by";
else
$query .= " ORDER BY ecmstockoperations.name";
return $query;
}
function fill_in_additional_list_fields() {
}
function fill_in_additional_detail_fields() {
parent::fill_in_additional_detail_fields();
}
function get_list_view_data() {
$doc_name=array('EcmStockDocInsideIns'=>'PW','EcmStockDocMoves'=>'MM','EcmStockDocCorrects'=>'KS','EcmStockDocIns'=>'PZ','EcmStockDocOuts'=>'WZ','EcmStockDocInsideOuts'=>'RW','EcmInvoiceOuts'=>'FK');
global $current_language;
$db=$GLOBALS['db'];
$the_array = parent::get_list_view_data();
$app_list_strings = return_app_list_strings_language($current_language);
$mod_strings = return_module_language($current_language, 'EcmStockOperations');
$this->retrieve($this->id);
$mod_strings_doc = return_module_language($current_language, $this->parent_type);
$the_array['PARENT_TYPE'] = $this->parent_type;
$the_array['PARENT_TYPE_NAME'] = $mod_strings_doc['LBL_MODULE_NAME'];
$the_array['NAME'] = (($this->name == "") ? "<em>blank</em>" : $this->name);
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select parent_name,parent_id,parent_type,part_no,part_no2,part_no3,part_no4,part_no5,type from ecmstockoperations where id='" . $this->id . "'"));
$mod=substr($this->parent_type, 0, -1);
$nr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select counter from ecmstockoperations where id='".$this->id."'"));
$res=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("
select
sum(CASE
WHEN (type=0)
then @t :=+quantity
else @t :=-quantity
end) as tt
from ecmstockoperations where product_id='".$this->product_id."' and stock_id='".$this->stock_id."' and counter <= '".$nr['counter']."'"));
$n= new $mod();
$n->retrieve($this->parent_id);
$the_array['DOCUMENT_NAME'] = $doc_name[$this->parent_type].' '.$n->document_no;
$the_array['PREVIEW_PDF'] = '<img src="modules/EcmStockDocIns/images/pdf.gif" onclick="EcmPreviewPDF(\'index.php?module=' . $r['parent_type'] . '&action=previewPDF&method=I&record=' . $r['parent_id'] . '&to_pdf=1\',{zoom:75,toolbar:1});" style="cursor: pointer;" border="0">';
$the_array['COUNTER']=$this->date_modified;
$the_array['STOCK_NAME'] = '<a href="index.php?module=EcmStockOperations&action=&query=true&searchFormTab=basic_search&stock_id_basic=' . $this->stock_id . '&stock_name_basic=' . $this->stock_name . '">' . $this->stock_name . '</a>';
$the_array['ENCODED_NAME'] = $this->name;
$p = new EcmProduct ();
$p->retrieve ( $this->product_id );
$the_array ['QUANTITY'] = number_format($this->quantity,$app_list_strings['ecmproducts_unit_dom_precision'] [$p->unit_id],',','');
$the_array['STATE']= number_format($res['tt'],$app_list_strings['ecmproducts_unit_dom_precision'] [$p->unit_id],',','');
$the_array['TYPE']=$this->type==1 ? '<span style="color:red;">Wyjście</span>' : '<span style="color:green;">Wejście</span>';
return $the_array;
}
function build_generic_where_clause($the_query_string) {
$where_clauses = array();
$the_query_string = PearDatabase::quote(from_html($the_query_string));
array_push($where_clauses, "ecmstockoperations.name like '$the_query_string%'");
$the_where = "";
foreach ($where_clauses as $clause) {
if ($the_where != "")
$the_where.=" or ";
$the_where.=$clause;
}
return $the_where;
}
function set_notification_body($xtpl, $ecmstockoperation) {
global $mod_strings, $app_list_strings;
$xtpl->assign("ECMSTOCKOPERATION_SUBJECT", $ecmstockoperation->name);
return $xtpl;
}
function bean_implements($interface) {
switch ($interface) {
case 'ACL':return true;
}
return false;
}
function save($check_notify = FALSE) {
$id = parent::save($check_notify);
$class_name = substr($this->parent_type, 0, -1);
$obj = new $class_name;
$obj->retrieve($this->parent_id);
$queryupdate = 'UPDATE ecmstockoperations SET date_entered = "' . date("Y-m-d", strtotime($obj->register_date)) .' 00:00:03" WHERE id = "' . $this->id . '"';
$this->db->query($queryupdate);
return $id;
}
function deleteProducts($p, $id, $itemid, $stock_id, $date) {
$arr = array();
$w = $GLOBALS['db']->query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and used=0 and in_id IS NULL and stock_id='" . $stock_id . "' and product_id='" . $p['id'] . "'");
while ($rrr = $GLOBALS['db']->fetchByAssoc($w)) {
$ww = $GLOBALS['db']->query("select quantity from ecmstockoperations where in_id='" . $rrr['id'] . "' and type='1' and in_id IS NOT NULL and stock_id='" . $stock_id . "' and product_id='" . $p['id'] . "' and deleted='0'");
$rqty = 0;
while ($rrp = $GLOBALS['db']->fetchByAssoc($ww)) {
$rqty+=$rrp['quantity'];
}
$qty = $rrr['qty'] - $rqty;
if ($qty > 0) {
$arr[] = array("qty" => $qty, "id" => $rrr['id'], "price" => $rrr['price']);
}
}
$rr = array();
$used_qty = 0;
$stop = 0;
foreach ($arr as $value) {
if ($p['quantity'] - $used_qty <= $value['qty']) {
$rr[] = array("id" => $value['id'], "qty" => $p['quantity'] - $used_qty, "price" => $value['price']);
$stop = 1;
} else {
$rr[] = array("id" => $value['id'], "qty" => $value['qty'], "price" => $value['price']);
$used_qty+=$value['qty'];
}
if ($stop) {
$stop = 0;
break;
}
}
$qq = 0;
$pp = 0;
$avg_pq = 0;
$avg_q = 0;
foreach ($rr as $r) {
$this->addDeleteOperation($r['id'], $p['id'], $r['qty'], $r['price'], $date, $id, $stock_id, $itemid);
$avg_pq+=$r['qty'] * $r['price'];
$avg_q+=$r['qty'];
}
$GLOBALS['db']->query("update ecmstockdocoutitems set price='" . ($avg_pq / $avg_q) . "' where id='" . $itemid . "'");
}
function addDeleteOperation($stock_in_id, $product_id, $quantity, $price, $date, $wz_id, $stock_id, $itemid) {
require_once("modules/EcmStockOperations/EcmStockOperation.php");
$o = new EcmStockOperation();
$o->unformat_all_fields();
require_once("modules/EcmProducts/EcmProduct.php");
$o->product_id = $product_id;
$p = new EcmProduct();
$p->retrieve($product_id);
$o->product_code = $p->code;
$o->product_name = $p->name;
require_once("modules/EcmStocks/EcmStock.php");
$o->stock_id = $stock_id;
$s = new EcmStock();
$s->retrieve($stock_id);
$o->stock_name = $s->name;
$o->parent_id = $wz_id;
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_no from ecmstockdocouts where id='" . $wz_id . "'"));
$o->parent_name = $r['document_no'];
$o->parent_type = "EcmStockDocOuts";
$o->quantity = $quantity;
$o->price = $price;
$o->in_id = $stock_in_id;
$o->documentitem_id = $itemid;
$o->type = 1;
$o->save();
require_once("modules/EcmStockStates/EcmStockState.php");
$ss = new EcmStockState();
$ss->UpdateStockState($o->stock_id, $o->product_id);
}
static function saveProductReservation($product_id, $stock_id, $doc_id, $doc_type, $item_id, $quantity) {
global $current_user;
$db = $GLOBALS['db'];
//check params
if (strlen($stock_id)!='36' ||
strlen($product_id)!='36' ||
strlen($doc_id)!='36' ||
strlen($item_id)!='36' ||
$doc_id == "" ||
floatval($quantity) == 0) return false;
//save reservation
$query = "
INSERT INTO ecmreservations VALUES (
'".create_guid()."',
'$product_id',
'$stock_id',
'$doc_id',
'$doc_type',
'$item_id',
'".floatval($quantity)."',
'".$current_user->id."',
'".date("Y-m-d H:i:s")."')";
return $db->query($query);
}
static function deleteDocumentReservation($doc_id, $doc_type) {
return $GLOBALS['db']->query("DELETE FROM ecmreservations WHERE document_id='$doc_id' AND document_type='$doc_type'");
}
static function getDocumentItemReservation($doc_id, $doc_type, $item_id) {
$db = $GLOBALS['db'];
$res = $db->fetchByAssoc($db->query("SELECT quantity FROM ecmreservations WHERE document_id='$doc_id' AND document_type='$doc_type' AND document_item_id='$item_id'"));
return floatval($res['quantity']);
}
function saveParentReservation($stock_id, $product_id, $doc_id, $item_id, $quantity, $doc_type) {
global $db, $current_user;
session_start();
$q = "select count(*) as cnt from ecmreservations where item_id='$item_id' and doc_id='$doc_id'";
$r = $db->fetchByAssoc($db->query($q));
if ($r['cnt'] > 0) {
$updateQuery =
'
UPDATE
ecmreservations
SET
quantity = \'' . $quantity . '\'
WHERE
item_id = \'' . $item_id . '\'
;';
$result = $db->query($updateQuery);
} else {
$insertQuery = '
INSERT INTO
ecmreservations
SET
date_modified = \'' . date("Y-m-d H:i:s") . '\',
date_entered = \'' . date("Y-m-d H:i:s") . '\',
modified_user_id = \'' . $_SESSION['authenticated_user_id'] . '\',
created_by = \'' . $_SESSION['authenticated_user_id'] . '\',
id = \'' . create_guid() . '\',
doc_id = \'' . $doc_id . '\',
item_id = \'' . $item_id . '\',
product_id = \'' . $product_id . '\',
quantity = \'' . $quantity . '\',
stock_id = \'' . $stock_id . '\',
doc_type = \'' . $doc_type . '\'
;';
$result = $db->query($insertQuery);
}
return $result;
}
function updateReservation($doc_id, $item_id, $quantity) {
global $db;
if ($quantity < 0) {
$q = $db->fetchByAssoc($db->query("SELECT quantity FROM ecmreservations WHERE doc_id='$doc_id' and item_id='$item_id'"));
if (!$q || $q['quantity']=='') return;
if ($q['quantity'] + $quantity <= 0)
$db->query("DELETE from ecmreservations WHERE doc_id='$doc_id' AND item_id='$item_id'");
else
$db->query("UPDATE ecmreservations SET quantity=quantity+$quantity WHERE doc_id='$doc_id' AND item_id='$item_id'");
}
/*
else {
$q = $db->fetchByAssoc($db->query("SELECT quantity FROM ecmreservations WHERE doc_id='$doc_id' and item_id='$item_id'"));
if (!$q || $q['quantity']='') {
}
}
*/
}
/**
* Save document reservations.
*/
function saveDocumentReservations($temp_doc_id) {
global $db;
$query =
'
UPDATE
`ecmreservations` AS r
SET
r.`session_id` = NULL,
r.`doc_id` = r.`temp_doc_id`,
r.`item_id` = r.`temp_item_id`,
r.`temp_doc_id` = NULL,
r.`temp_item_id` = NULL
WHERE
r.`temp_doc_id` = \'' . $temp_doc_id . '\'
;';
echo $query;
$result = $db->query($query);
return $result;
}
function removeReservation($temp_item_id) {
global $db;
$db->query("DELETE FROM ecmreservations WHERE temp_item_id='" . $temp_item_id . "'");
}
function removeDocumentReservations($doc_id) {
global $db;
return $db->query("DELETE FROM ecmreservations WHERE doc_id='" . $doc_id . "'");
}
function removeTempDocumentReservations($temp_doc_id) {
global $db;
return $db->query("DELETE FROM ecmreservations WHERE temp_doc_id='" . $temp_doc_id . "'");
}
function removeSaleProductReservations($item_id) {
global $db;
$db->query("DELETE FROM ecmreservations WHERE item_id='" . $item_id . "'");
}
function getProductReservations($ecmsale_id, $item_id) {
global $db;
$res = $db->fetchByAssoc($db->query("SELECT quantity as res FROM ecmreservations WHERE doc_id='" . $ecmsale_id . "' AND item_id='" . $item_id . "'"));
return $res['res'];
}
function getStockR($product_id, $stock_id = "", $item_id = "") {
global $db;
if ($stock_id!='')
$stock = " and stock_id='" . $stock_id . "'";
else
$stock = "";
$z = "select sum(quantity) as q from ecmreservations where product_id='" . $product_id . "'" . $stock;
$q = $db->query($z);
$row = $db->fetchByAssoc($q);
return (int) $row['q'];
}
//stock without reservations
function getRealStock($product_id, $stock_id ="") {
global $db;
if ($stock_id!='')
$stock = " and stock_id='" . $stock_id . "'";
else
$stock = "";
$rquery = "SELECT sum(quantity) as quantity FROM ecmstockstates WHERE product_id='" . $product_id ."'". $stock;
//get stockstates quantity
$r = $db->fetchByAssoc($db->query($rquery));
if (!$r['quantity'])
$r['quantity'] = 0;
return $r['quantity'];
}
function getStock($product_id, $stock_id = "",$part_id="") {
global $db;
if ($stock_id!='')
$stock = " and stock_id='" . $stock_id . "'";
else
$stock = "";
if ($part_id!='')
$part = " and part_id='" . $part_id . "'";
else
$part = "and part_id is null";
$rquery = "SELECT quantity FROM ecmstockstates WHERE product_id='" . $product_id ."'". $stock." ".$part;
//get stockstates quantity
$r = $db->fetchByAssoc($db->query($rquery));
$rrquery = "SELECT sum(quantity) as res FROM ecmreservations WHERE product_id='" . $product_id . "'". $stock;
//get reservations
$rr = $db->fetchByAssoc($db->query($rrquery));
if (!is_array($rr))
$rr['res'] = 0;
return $r['quantity'] - $rr['res'];
}
function getStockArray($product_id) {
if (!$product_id) return '';
global $db;
$res = $db->query("SELECT id, name FROM ecmstocks WHERE deleted='0'");
$ret = array();
while ($row = $db->fetchByAssoc($res)) {
$qty = $this->getStock($product_id, $row['id']);
if ($qty> 0)
$ret[$row['name']] = $qty;
}
return $ret;
}
function getAllQuantity($product_id) {
global $db;
$r = $db->fetchByAssoc($db->query("
SELECT
CASE WHEN (SELECT sum(quantity) FROM ecmreservations WHERE ecmproduct_id='$product_id') IS NULL
THEN
(SELECT sum(quantity) FROM ecmstockstates WHERE product_id='$product_id')
ELSE
((SELECT sum(quantity) FROM ecmstockstates WHERE product_id='$product_id')-(SELECT sum(quantity) FROM ecmreservations WHERE ecmproduct_id='$product_id'))
END
as qty
"));
return $r['qty'];
}
function checkStock($p, $stock_id) {
global $db;
$p = base64_decode($p);
print_r($_REQUEST);
require_once('include/json_config.php');
$json_config = new json_config();
$json = getJSONobj();
$pll = array();
$exp = explode("||||", $p);
foreach ($exp as $ep) {
if ($ep) {
$pll[] = $json->decode(htmlspecialchars_decode($ep));
}
}
$p = $pll;
foreach ($p as $rr) {
$products[] = array("product_name" => $rr['name'], "product_id" => $rr['id'], "quantity" => $rr['quantity'], "item_id" => $rr['item_id']);
}
//print_r($products);echo "mmmmmmmmmm";
$str.='<div style="text-align:center">';
$str.='<span style="font-family:Geneva,Arial;font-size: 12px;font-weight:bold;">Sprawdzanie stanów magazynowych</span>';
$str.='<table align="center" style="padding:3px;border:1px solid #ccc"><tr><td style="background:#999;color:white;font-weight:bold;padding:3px;">Produkt</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">Ilość</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">Magazyn</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">&nbsp;</td></tr>';
if (count($products) > 0) {
foreach ($products as $p) {
if (!$p['product_id'])
continue;
$qty = self::getStock($p['product_id'], $stock_id, $p['item_id']);
$str.='<tr><td style="padding:3px;">' . $p['product_name'] . '</td><td style="padding:3px;">' . $p['quantity'] . '</td><td style="padding:3px;">' . $qty . '</td><td style="padding:3px;">';
if ($p['quantity'] > $qty) {
$no = true;
$str.='<span style="color:red">' . "błąd" . '</span>';
}
else
$str.='<span style="color:green">' . "ok" . '</span>';
$str.='</td></tr>';
}
}
$str.='</table><br>';
if ($no) {
$str.='<span style="font-family:Geneva,Arial;font-size: 12px;font-weight:bold;">' . "Brakuje produktów na magazynie" . '</span>';
$str.='&nbsp;<input type="button" class="button" onclick="document.getElementById(\'check_stock\').style.display=\'none\';" value="' . "Popraw" . '">';
} else {
$str.='<input type="submit" name="save" class="button" value="Zapisz" onclick="executingPostBack=1;saveItems(true);this.form.action.value=\'Save\';" />';
}
$str.='</div>';
return $str;
}
function checkStockSales($p, $stock_id) {
global $db;
require_once('include/json_config.php');
$json_config = new json_config();
$json = getJSONobj();
$pll = array();
$exp = explode("||||", $p);
foreach ($exp as $ep) {
if ($ep) {
$pll[] = $json->decode(htmlspecialchars_decode($ep));
}
}
$p = $pll;
foreach ($p as $rr) {
$products[] = array("product_name" => $rr['name'], "product_id" => $rr['id'], "quantity" => $rr['quantity'], "reservation" => $rr['reservation'], "rq" => $rr['rq']);
}
$str.='<div style="text-align:center">';
$str.='<span style="font-family:Geneva,Arial;font-size: 12px;font-weight:bold;">Sprawdzanie stanów magazynowych</span>';
$str.='<table align="center" style="padding:3px;border:1px solid #ccc"><tr><td style="background:#999;color:white;font-weight:bold;padding:3px;">Produkt</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">Ilość</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">Ilość do rezerwacji</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">Magazyn</td><td style="background:#999;color:white;font-weight:bold;padding:3px;">&nbsp;</td></tr>';
if (count($products) > 0) {
foreach ($products as $p) {
if (!$p['product_id'] || !$p['reservation'])
continue;
$qty = self::getStock($p['product_id'], $stock_id);
$str.='<tr><td style="padding:3px;">' . $p['product_name'] . '</td><td style="padding:3px;">' . $p['quantity'] . '</td><td style="padding:3px;">' . $p['rq'] . '</td><td style="padding:3px;">' . $qty . '</td><td style="padding:3px;">';
if ($p['rq'] > $qty || $p['rq'] > $p['quantity']) {
$no = true;
$str.='<span style="color:red">' . "błąd" . '</span>';
}
else
$str.='<span style="color:green">' . "ok" . '</span>';
$str.='</td></tr>';
}
}
$str.='</table><br>';
if ($no) {
$str.='<span style="font-family:Geneva,Arial;font-size: 12px;font-weight:bold;">' . "Brakuje produktów na magazynie lub wpisałeś za dużą ilość produktów do zarezerwowania" . '</span>';
$str.='&nbsp;<input type="button" class="button" onclick="document.getElementById(\'check_stock\').style.display=\'none\';" value="' . "Popraw" . '">';
} else {
$str.='<input type="submit" name="save" class="button" value="Zapisz" onclick="executingPostBack=1;saveItems(true);this.form.action.value=\'Save\';" />';
}
$str.='</div>';
return $str;
}
}
?>