Files
votianng/html/stock/article_list.php
2026-03-29 10:34:57 +02:00

412 lines
21 KiB
PHP
Raw Permalink Blame History

<?php
/*=======================================================================
*
* article_list.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
include_once ("../include/inc_wording_wrapper.inc.php");
// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "f_mode", "orderClause", "statusMessage", "f_at_eid", "f_at_name", "f_at_match", "f_at_description",
"f_at_barcode", "f_at_authenticated", "f_searchmode", "f_show_invisible", "f_hq_id", "deactivateMenu", "objecttypemode"));
// Select user-type for mode of security check
$userType = getFieldValueFromId("user","usr_id",$usr_id,"usr_type");
$userTypeName = getUserTypeName($userType);
if ($userTypeName == "stk") :
$maskStkArticleAccess = getParameterValue($emp_id, "MASK_STK_ARTICLE_ACCESS");
if ($maskStkArticleAccess != "1") :
gotoReferer("1");
endif;
else :
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "14", "1");
endif;
getLanguage(__FILE__);
$pageTitel = getLngt(wrapPhrase("ARTIKELLISTE", $objecttypemode));
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
getCurrentScript(__FILE__);
$htmlClass01 = "class=\"smaller\""; // input,select
$htmlClass02 = "class=\"f7np1\""; // write
$numOfRows = 0;
$tableOfRows = "";
// Flag for "show invisible customers"
if ($f_show_invisible == "" || count($f_show_invisible) == 0) :
$f_show_invisible = "0";
else:
$f_show_invisible = "1";
endif;
// Mandator filter
if ($f_hq_id == "") : $f_hq_id = array(); endif;
if (count($f_hq_id) == 0) : array_push($f_hq_id, $hq_id); endif;
// Get the parameter to set the order of the columns to be displayed
$displayedListCols = getParameterValue($emp_id, "MASK_AT_LIST_COLS");
if ($displayedListCols == "") :
$displayedListCols = getParameterValue("0", "MASK_AT_LIST_COLS", $hqId);
if ($displayedListCols == "") :
// Default settings
$displayedListCols = "at_eid,at_name,at_serialno,at_mountable,at_match,at_barcode,at_createtime,at_id_history,at_id_edit,atg_data,at_description";
endif;
endif;
$displayedListColsArray = spliti(",",$displayedListCols);
$displayedListColsArrayLen = count($displayedListColsArray);
// OUTPUT: Table header search fields
$tableHeaderSearchFields = "";
if (TRUE) :
$dspColHeaderSearchFieldArray = array();
$dspColHeaderSearchFieldArray["at_eid"] = "<input type=\"text\" " . $htmlClass01 . " name=\"f_at_eid\" value=\"" . $f_at_eid . "\">";
$dspColHeaderSearchFieldArray["at_name"] = "<input type=\"text\" " . $htmlClass01 . " name=\"f_at_name\" value=\"" . $f_at_name . "\">";
$dspColHeaderSearchFieldArray["at_serialno"] = "";
$dspColHeaderSearchFieldArray["at_mountable"] = "";
$dspColHeaderSearchFieldArray["at_match"] = "<input type=\"text\" " . $htmlClass01 . " name=\"f_at_match\" value=\"" . $f_at_match . "\">";
$dspColHeaderSearchFieldArray["at_barcode"] = "<input type=\"text\" " . $htmlClass01 . " name=\"f_at_barcode\" value=\"" . $f_at_barcode . "\">";
$dspColHeaderSearchFieldArray["at_createtime"] = "";
$dspColHeaderSearchFieldArray["at_description"] = "<input type=\"text\" " . $htmlClass01 . " name=\"f_at_description\" value=\"" . $f_at_description . "\">";
$dspColHeaderSearchFieldArray["at_id_history"] = "&nbsp;";
// $dspColHeaderSearchFieldArray["at_id_report"] = "&nbsp;";
$dspColHeaderSearchFieldArray["at_id_edit"] = "&nbsp;";
$dspColHeaderSearchFieldArray["atg_data"] = "&nbsp;";
$tmpKeys = array_keys($dspColHeaderSearchFieldArray);
for ($i = 0; $i < $displayedListColsArrayLen; $i++) {
// Search for the value "$displayedListColsArray" in "$dspColArray" and get the key (index)
$j = array_search($displayedListColsArray[$i], $tmpKeys);
if (!($j === FALSE)) :
$cellColor = getListColor(1, 1);
$tableHeaderSearchFields .= "<td bgcolor=\"" . $cellColor . "\">" . $dspColHeaderSearchFieldArray[$tmpKeys[$j]] . "</td>";
endif;
}
endif;
// OUTPUT: Table header column links
$tableHeaderLinks = "";
if (TRUE) :
$dspColHeaderLinksArray = array();
$dspColHeaderLinksArray["at_eid"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_eid';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt(wrapPhrase("Artikelnr.", $objecttypemode)) . "&nbsp;</a>";
$dspColHeaderLinksArray["at_name"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_name';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Bezeichnung") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_serialno"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_serialno';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Seriennr.") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_mountable"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_mountable';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Montierbar") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_match"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_match';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Zusatz") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_barcode"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_barcode';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Barcode") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_createtime"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_createtime';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Neuanlagedatum") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_description"] = "<a href=\"javascript:document.forms[0].orderClause.value='at.at_description';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt("Beschreibung") . "&nbsp;</a>";
$dspColHeaderLinksArray["at_id_history"] = "&nbsp;" . getLngt("Historie");
// $dspColHeaderLinksArray["at_id_report"] = "&nbsp;" . getLngt("Berichte");
$dspColHeaderLinksArray["at_id_edit"] = "&nbsp;" . getLngt("Bearbeiten") . "&nbsp;";
$dspColHeaderLinksArray["atg_data"] = "<a href=\"javascript:document.forms[0].orderClause.value='atg_data';document.forms[0].f_act.value='search';document.forms[0].submit();\">&nbsp;" . getLngt(wrapPhrase("Warengruppe", $objecttypemode)) . "&nbsp;</a>";
$tmpKeys = array_keys($dspColHeaderLinksArray);
for ($i = 0; $i < $displayedListColsArrayLen; $i++) {
// Search for the value "$displayedListColsArray" in "$dspColArray" and get the key (index)
$j = array_search($displayedListColsArray[$i], $tmpKeys);
if (!($j === FALSE)) :
$cellColor = getListColor(0, 0);
$tableHeaderLinks .= "<td bgcolor=\"" . $cellColor . "\">" . $dspColHeaderLinksArray[$tmpKeys[$j]] . "</td>";
endif;
}
endif;
if ($f_searchmode == "") : $f_searchmode = "1"; endif;
// Generate search-resultset
if ($f_act == "search") :
$f_at_eid = trim($f_at_eid);
$f_at_name = trim($f_at_name);
$f_at_match = trim($f_at_match);
$f_at_barcode = trim($f_at_barcode);
$f_at_description = trim($f_at_description);
$doSearch = FALSE;
if (strlen($f_at_eid . $f_at_name . $f_at_match . $f_at_description . $f_at_barcode) == 0) :
if (getCountOfTable("article") <= MAX_CARDINALITY) :
$doSearch = TRUE;
endif;
endif;
if ($doSearch || strlen($f_at_eid) > 1 || strlen($f_at_name) > 1 || strlen($f_at_match) > 1 || strlen($f_at_description) > 1 || strlen($f_at_barcode) > 2) :
// *******************************************
// * Selection of the customers for the list *
// *******************************************
if ($f_searchmode == "1") : $prefix = "%"; else : $prefix = ""; endif;
$whereClause = "";
if ($f_at_eid != "") : $whereClause .= "at.at_eid LIKE '" . $prefix . $f_at_eid . "%'"; endif;
if ($whereClause != "" && $f_at_name != "") : $whereClause .= " AND "; endif;
if ($f_at_name != "") : $whereClause .= "at.at_name LIKE '" . $prefix . $f_at_name . "%'"; endif;
if ($whereClause != "" && $f_at_match != "") : $whereClause .= " AND "; endif;
if ($f_at_match != "") : $whereClause .= "at.at_match LIKE '" . $prefix . $f_at_match . "%'"; endif;
if ($whereClause != "" && $f_at_barcode != "") : $whereClause .= " AND "; endif;
if ($f_at_barcode != "") : $whereClause .= "at.at_barcode LIKE '" . $prefix . $f_at_barcode . "%'"; endif;
if ($whereClause != "" && $f_at_description != "") : $whereClause .= " AND "; endif;
if ($f_at_description != "") : $whereClause .= "at.at_description LIKE '" . $prefix . $f_at_description . "%'"; endif;
// if ($whereClause != "" && $f_cs_eid != "") : $whereClause .= " AND "; endif;
// if ($f_cs_eid != "") : $whereClause .= "cs.cs_eid LIKE '" . $prefix . $f_cs_eid . "%'"; endif;
// Check authentication
// if ($whereClause != "" && $f_at_authenticated == "1") : $whereClause .= " AND "; endif;
// if ($f_at_authenticated == "1") : $whereClause .= "at.at_authenticated LIKE '" . $f_at_authenticated . "%'"; endif;
// Check visibles
$whereClauseVisibility = " at.at_visible = '1' ";
if ($f_show_invisible == "1") : $whereClauseVisibility = ""; endif;
if ($whereClause != "" && $whereClauseVisibility != "") : $whereClauseVisibility = " AND " . $whereClauseVisibility; endif;
$whereClause .= $whereClauseVisibility;
if ($whereClause != "") : $whereClause .= " AND "; endif;
$whereClause .= " at.hq_id IN " . getSQLMandatorArray($f_hq_id);
if ($orderClause == "") : $orderClause = "at.at_eid"; endif;
$sqlquery = "SELECT at.at_id, at.hq_id, at.at_eid, at.at_name, at.at_match, at.at_description, at.at_barcode,"
. " at.at_serialno, at.at_mountable, at.at_authenticated, at.at_visible, at.at_createtime, CONCAT(atg.atg_key,' ',atg.atg_name) AS atg_data"
. " FROM article AS at LEFT JOIN articlegroupitem AS atgi ON atgi.md_id = '" . $md_id . "' AND atgi.hq_id IN ('0','" . $hq_id . "') AND atgi.at_id = at.at_id"
. " LEFT JOIN articlegroup AS atg ON atg.md_id = '" . $md_id . "' AND atg.atg_id = atgi.atg_id"
. " WHERE " . $whereClause
. " ORDER BY " . $orderClause;
// echo $sqlquery . "<br>";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
// Table with header
$rowCounter = 0;
$lineToggler = 0;
while ($row = $result->fetch_assoc()):
$numOfRows++;
$dspColArray = array();
// Only for focussing the first element (link) of the list
// Look in tag <body ... onLoad=...>
$elementName = "";
if ($numOfRows == "1") : $elementName = " name=\"at2focus\" "; endif;
$tableOfRows .= "<tr>";
// Link refers to customer details
// $dspColArray["at_eid"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;<a href=\"javascript:openArticleSpecial('" . ec($row["at_id"]) . "');\" " . $elementName . ">"
// . $row["at_eid"] . "</a>" . "</td>";
$dspColArray["at_eid"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;<a href=\"../stock/article_special.php?objecttypemode=" . ec($objecttypemode) . "&articleId=" . ec($row["at_id"]) . "\" " . $elementName . "target=\"_blank\">"
. $row["at_eid"] . "</a>" . "</td>";
$dspColArray["at_name"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["at_name"] . "</td>";
$dspColArray["at_serialno"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__>&nbsp;" . ($row["at_serialno"] == "1" ? "<img src=\"../images/circle_blue.png\" border=\"0\" height=\"8\" width=\"8\">" : "") . "</td>";
$dspColArray["at_mountable"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__>&nbsp;" . ($row["at_mountable"] == "1" ? "<img src=\"../images/circle_blue.png\" border=\"0\" height=\"8\" width=\"8\">" : "") . "</td>";
$dspColArray["at_match"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["at_match"] . "</td>";
$dspColArray["at_barcode"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["at_barcode"] . "</td>";
$dspColArray["at_createtime"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["at_createtime"] . "</td>";
$dspColArray["at_id_history"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__><a href=\"../admin/history.php?history_mode=" . ec(3) . "&at_id=" . ec($row["at_id"]) . "&op=0\" target=\"_blank\">"
. "<img src=\"../images/arrow_right.png\" border=\"0\" height=\"10\" width=\"25\">"
. "</a></td>";
// $dspColArray["at_id_report"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__><a href=\"../groupware/cs_report.php?g_cs_eid=" . ec($row["cs_eid"]) . "\" target=\"_blank\">"
// . "<img src=\"../images/arrow_right.png\" border=\"0\" height=\"10\" width=\"25\">"
// . "</a></td>";
// $dspColArray["at_id_remove"] = "<td__BGCOL__>&nbsp;" . "<a href=\"javascript:removeArticle(" . ec($row["at_id"]) . ");\">"
// . "<img src=\"../images/trash.jpg\" border=\"0\" height=\"13\" width=\"8\">"
// . "</a>" . "</td>";
$authImgName = "circle_red.png";
if ($row["at_authenticated"] == "1") : $authImgName = "circle_green.png"; endif;
$dspColArray["at_authenticated_img"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__><img src=\"../images/" . $authImgName . "\" border=\"0\" height=\"10\" width=\"25\"></td>";
// $dspColArray["at_id_edit"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__><a href=\"javascript:openArticleSpecial('" . ec($row["at_id"]) . "');\">"
// . "<img src=\"../images/arrow_right.png\" border=\"0\" height=\"10\" width=\"25\">"
// . "</a>" . "</td>";
$dspColArray["at_id_edit"] = "<td ".$htmlClass02." align=\"center\"__BGCOL__><a href=\"../stock/article_special.php?objecttypemode=" . ec($objecttypemode) . "&articleId=" . ec($row["at_id"]) . "\" target=\"_blank\">"
. "<img src=\"../images/arrow_right.png\" border=\"0\" height=\"10\" width=\"25\">"
. "</a>" . "</td>";
$dspColArray["atg_data"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["atg_data"] . "</td>";
$dspColArray["at_description"] = "<td ".$htmlClass02."__BGCOL__>&nbsp;" . $row["at_description"] . "</td>";
// Generate list
$rowCounter++;
$tmpKeys = array_keys($dspColArray);
for ($i = 0; $i < $displayedListColsArrayLen; $i++) {
// Search for the value "$displayedListColsArray" in "$dspColArray" and get the key (index)
$j = array_search($displayedListColsArray[$i], $tmpKeys);
if (!($j === FALSE)) :
if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif;
$cellColor = getListColor($rowCounter, $lineToggler);
$dspColArray[$tmpKeys[$j]] = str_replace("__BGCOL__", " bgcolor=\"" . $cellColor ."\"", $dspColArray[$tmpKeys[$j]]);
$tableOfRows .= $dspColArray[$tmpKeys[$j]];
endif;
}
$tableOfRows .= "</tr>";
endwhile;
$result->free();
else :
$statusMessage = getLngt("Bei Eingabe weniger als 2 Zeichen in mindestens einem Feld erfolgt keine Suche!");
endif;
endif;
// Link to enter a new article or to switch "visibility output"
$headerOps = "";
$headerOps .= "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;";
$headerOps .= "<a href=\"javascript:openArticleSpecial('');\">" . getLngt(wrapPhrase("Neuer Artikel", $objecttypemode)) . "</a>";
$headerOps .= "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;";
$headerOps .= getLngt("Ausgeblendete&nbsp;anzeigen") . "&nbsp;<input type=\"checkbox\" name=\"f_show_invisible[]\" value=\"1\" " . ($f_show_invisible == "1" ? "checked" : "") . " tabindex=\"\">";
?>
<html>
<head>
<title><?php echo $pageTitel ?></title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
<?php include_once ("../css/navigation.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
function setFocus() {
var numOfRows = <?php echo $numOfRows ?>;
if (numOfRows > 0) {
numOfLinks = document.links.length;
for (i=0; i<numOfLinks; ++i) {
if (document.links[i].name == 'at2focus') {
document.links[i].focus();
};
};
} else {
document.forms[0].f_at_eid.focus();
};
};
function removeArticle(at_id) {
if (confirm('<?php echo getLngt(wrapPhrase("Artikel", $objecttypemode) . " wirklich entfernen?"); ?>')) {
document.forms[0].f_act.value = '<?php echo ec("removeArticle") ?>';
document.forms[0].articleId.value = cmp_id;
document.forms[0].submit();
};
};
function finishPage(eid,name,match,description,barcode) {
document.forms[0].f_at_eid.value=eid;
document.forms[0].f_at_name.value=name;
document.forms[0].f_at_match.value=match;
document.forms[0].f_at_description.value=description;
document.forms[0].f_at_barcode.value=barcode;
document.forms[0].f_act.value='<?php echo ec("search") ?>';
document.forms[0].submit();
};
function clearFields() {
if (document.forms[0].f_at_eid) {document.forms[0].f_at_eid.value = ''};
if (document.forms[0].f_at_name) {document.forms[0].f_at_name.value = ''};
if (document.forms[0].f_at_match) {document.forms[0].f_at_match.value = ''};
if (document.forms[0].f_at_description) {document.forms[0].f_at_description.value = ''};
if (document.forms[0].f_at_barcode) {document.forms[0].f_at_barcode.value = ''};
};
function openArticleSpecial(atId) {
var widthPopupWin = 900;
var heightPopupWin = 700;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../stock/article_special.php?objecttypemode=<?php echo ec($objecttypemode) ?>&articleId=" + atId ,"","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};
-->
</script>
</head>
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?>displayStatusMessage();setFocus();">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="maincontent" name="maincontent" id="maincontent">
<form action="../stock/article_list.php" method="post" target="">
<input type="hidden" name="f_act" value="">
<input type="hidden" name="orderClause" value="<?php echo $orderClause ?>">
<?php echo $phpCurrentNavigationInputHidden ?>
<input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
<input type="hidden" name="objecttypemode" value="<?php echo ec($objecttypemode) ?>">
<?php echo htmlDivLineSpacer("10px"); ?>
<!-- Headquarters checkboxes -->
<?php if ($userTypeName == "hq" && authCheckEmployeeRights($emp_id, "10")) : ?>
<?php echo getHeadquartersCheckboxes($f_hq_id); ?>
<?php echo htmlDivLineSpacer("10px", "", "left"); ?>
<?php endif; ?>
<div>
<a href="javascript:document.forms[0].f_act.value='search';document.forms[0].submit();">&nbsp;<?php echo getLngt("Suchen") ?>&nbsp;</a>
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
<a href="javascript:clearFields();"><?php echo getLngt("Felder zur<75>cksetzen") ?></a>
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
Option:&nbsp;&nbsp;
<input type="radio" name="f_searchmode" value="0" <?php if ($f_searchmode == "0") : echo "checked"; endif; ?>> <?php echo getLngt("Pr<50>fix") ?>
<input type="radio" name="f_searchmode" value="1" <?php if ($f_searchmode == "1") : echo "checked"; endif; ?>> <?php echo getLngt("Teilwort") ?>
<?php echo $headerOps ?>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<table class="f8np1" border="0" cellpadding="0">
<tr>
<?php echo $tableHeaderSearchFields ?>
</tr>
<tr>
<?php echo $tableHeaderLinks ?>
</tr>
<?php echo $tableOfRows ?>
</table>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<?php echo getLngt("Anzahl Eintr<74>ge:") ?> <?php echo $numOfRows ?><?php if ($numOfRows == "0" && $f_act == "search" && $statusMessage == "") : echo " " . getLngt("(Keine Eintr<74>ge gefunden.)"); endif; ?>
</div>
</form>
</div>
</body>
</html>