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

273 lines
10 KiB
PHP

<?php
/*=======================================================================
*
* groupmembers.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
// include_once ("../include/html.inc.php");
include_once ("../include/inc_filters.inc.php");
$httpVarsArray = array("f_act", "itemId", "itemType", "orderClause", "statusMessage", "f_group", "deactivateMenu");
getSecHttpVars("1", $httpVarsArray);
getLanguage(__FILE__);
$deactivateMenuStatic = "1";
$pageTitel = getLngt("GRUPPENZUGEHÖRIGKEIT");
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
getCurrentScript(__FILE__);
// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "1", "1");
// Only for output
$htmlClass01 = "class=\"smaller\""; // input,select
$html_td_01 = "valign=\"top\" align=\"left\""; // input
$html_td_02 = "valign=\"top\" align=\"right\""; // input
// Implode groups
$f_group2 = getImplodedFilterstring($f_group);
// Set group(s) of the item (courier, customer, article, prospect, vehicle, etc.)
if ($md_id != "" && $md_id > 0) :
if ($f_act == "setGroup" && $itemId != "") :
TA("B");
// Group (Groups can be associated to other groups)
if ($itemType == "grp") :
updateStmt("groups","grp_id",$itemId,array("grp_group", $f_group2));
writeToLogDB("83",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2);
endif;
// Courier
if ($itemType == "cr") :
updateStmt("courier","cr_id",$itemId,array("cr_group", $f_group2));
writeToLogDB("77",$hq_id,"",$usr_id,$itemId,"","","GROUPS=".$f_group2);
endif;
// Customer
if ($itemType == "cs") :
updateStmt("customer","cs_id",$itemId,array("cs_group", $f_group2));
writeToLogDB("78",$hq_id,"",$usr_id,"","",$itemId,"GROUPS=".$f_group2);
endif;
// Article
if ($itemType == "at") :
updateStmt("article","at_id",$itemId,array("at_group", $f_group2));
writeToLogDB("79",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,$itemId);
endif;
// Branch
if ($itemType == "br") :
updateStmt("branch","br_id",$itemId,array("br_group", $f_group2));
writeToLogDB("80",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"",$itemId);
endif;
// Vehicle
if ($itemType == "crvh") :
updateStmt("couriervehicle","crvh_id",$itemId,array("crvh_group", $f_group2));
writeToLogDB("81",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2);
endif;
// Employee
if ($itemType == "emp") :
updateStmt("employee","emp_id",$itemId,array("emp_group", $f_group2));
writeToLogDB("82",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"","",$itemId);
endif;
// Service
if ($itemType == "srv") :
updateStmt("service","srv_id",$itemId,array("srv_group", $f_group2));
// writeToLogDB("83",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"","",$itemId);
endif;
// Servicetype
if ($itemType == "srvt") :
updateStmt("servicetype","srvt_id",$itemId,array("srvt_group", $f_group2));
// writeToLogDB("84",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"","",$itemId);
endif;
// Metafieldcategory
if ($itemType == "mtfc") :
updateStmt("metafieldcategory","mtfc_id",$itemId,array("mtfc_group", $f_group2));
// writeToLogDB("xx",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"","",$itemId);
endif;
// Metafieldtemplate
if ($itemType == "mtft") :
updateStmt("metafieldtemplate","mtft_id",$itemId,array("mtft_group", $f_group2));
// writeToLogDB("xx",$hq_id,"",$usr_id,"","","","GROUPS=".$f_group2,"","",$itemId);
endif;
TA("C");
TA("E");
endif;
endif;
// Get group membership of the current item
$f_group = "";
$title = "";
if ($itemType == "grp") :
$f_group = getFieldValueFromId("groups", "grp_id", $itemId, "grp_group");
$tmp_grp_name = getFieldValueFromId("groups", "grp_id", $itemId, "grp_name");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Gruppe") . "</span> &nbsp;&nbsp;" . $tmp_grp_name;
endif;
if ($itemType == "cr") :
$f_group = getFieldValueFromId("courier", "cr_id", $itemId, "cr_group");
$tmp_usr_id = getFieldValueFromId("courier", "cr_id", $itemId, "usr_id");
$tmpFields = getFieldsValueFromId("user","usr_id",$tmp_usr_id,array("usr_name","usr_firstname"));
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Transporteur") . "</span> &nbsp;&nbsp;" . $tmpFields[1] . " " . $tmpFields[0];
endif;
if ($itemType == "cs") :
$f_group = getFieldValueFromId("customer", "cs_id", $itemId, "cs_group");
$tmp_cmp_id = getFieldValueFromId("customer", "cs_id", $itemId, "cmp_id");
$tmpFields = getFieldsValueFromId("company","cmp_id",$tmp_cmp_id,array("cmp_comp","cmp_comp2"));
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Kunde") . "</span> &nbsp;&nbsp;" . $tmpFields[0] . " " . $tmpFields[1];
endif;
if ($itemType == "at") :
$f_group = getFieldValueFromId("article", "at_id", $itemId, "at_group");
$tmp_at_name = getFieldValueFromId("article", "at_id", $itemId, "at_name");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Artikel") . "</span> &nbsp;&nbsp;" . $tmp_at_name;
endif;
if ($itemType == "br") :
$f_group = getFieldValueFromId("branch", "br_id", $itemId, "br_group");
$tmpFields = getFieldsValueFromId("branch","br_id",$itemId,array("br_key","br_name"));
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Branche") . "</span> &nbsp;&nbsp;" . $tmpFields[0] . " " . $tmpFields[1];
endif;
if ($itemType == "crvh") :
$f_group = getFieldValueFromId("couriervehicle", "crvh_id", $itemId, "crvh_group");
$tmp_crvh_sid = getFieldValueFromId("couriervehicle", "crvh_id", $itemId, "crvh_sid");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Fahrzeug") . "</span> &nbsp;&nbsp;" . $tmp_crvh_sid;
endif;
if ($itemType == "emp") :
$f_group = getFieldValueFromId("employee", "emp_id", $itemId, "emp_group");
$tmp_usr_id = getFieldValueFromId("employee", "emp_id", $itemId, "usr_id");
$tmpFields = getFieldsValueFromId("user","usr_id",$tmp_usr_id,array("usr_name","usr_firstname"));
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Mitarbeiter") . "</span> &nbsp;&nbsp;" . $tmpFields[1] . " " . $tmpFields[0];
endif;
if ($itemType == "srv") :
$f_group = getFieldValueFromId("service", "srv_id", $itemId, "srv_group");
$tmp_srv_name = getFieldValueFromId("service", "srv_id", $itemId, "srv_name");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Preistyp") . "</span> &nbsp;&nbsp;" . $tmp_srv_name;
endif;
if ($itemType == "srvt") :
$f_group = getFieldValueFromId("servicetype", "srvt_id", $itemId, "srvt_group");
$tmp_srvt_name = getFieldValueFromId("servicetype", "srvt_id", $itemId, "srvt_name");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Leistungstyp") . "</span> &nbsp;&nbsp;" . $tmp_srvt_name;
endif;
if ($itemType == "mtfc") :
$f_group = getFieldValueFromId("metafieldcategory", "mtfc_id", $itemId, "mtfc_group");
$tmp_mtfc_name = getFieldValueFromId("metafieldcategory", "mtfc_id", $itemId, "mtfc_description");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Kategorie") . "</span> &nbsp;&nbsp;" . $tmp_mtfc_name;
endif;
if ($itemType == "mtft") :
$f_group = getFieldValueFromId("metafieldtemplate", "mtft_id", $itemId, "mtft_group");
$tmp_mtft_name = getFieldValueFromId("metafieldtemplate", "mtft_id", $itemId, "mtft_name");
$title .= "<span class=\"f14bp1_blue\">" . getLngt("Template") . "</span> &nbsp;&nbsp;" . $tmp_mtft_name;
endif;
$f_group = substr($f_group, 1, (strlen($f_group) - 2) );
$f_group = spliti(",",$f_group);
$output = addCheckboxesFromTable("f_group", "groups", "grp_id", "grp_name", "grp_name", "md_id = '" . $md_id . "' AND (hq_id = '" . $hq_id . "' OR hq_id = '0')", $f_group, "<br><br>");
$pageHeadline = "<span class=\"f14bp1_blue\">" . strtoupper($pageTitel) . "</span>" . " &nbsp;&nbsp;&nbsp;&nbsp;" . $title;
?>
<html>
<head>
<title><?php echo $pageTitel ?></title>
<style type="text/css">
<?php include_once ("../css/phoenix.css.php"); ?>
<?php include_once ("../css/navigation.css.php"); ?>
<?php include_once ("../css/mc.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<script src="../include/checkFormTags.js" type="text/javascript"></script>
<script src="../include/searchLists.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
function finishPage(mode) {
var ok = true;
if (mode == 'save') {
if (ok) {
document.forms[0].f_act.value='setGroup';
document.forms[0].submit();
};
}
if (mode == 'reset') {
document.location.href = "groupmembers.php?itemType=<?php echo ec($itemType) ?>&itemId=<?php echo ec($itemId) ?>";
}
};
-->
</script>
</head>
<body class="menu_bgcol" onLoad="<?php echo $phpCurrentNavigationOnLoad ?>displayStatusMessage();">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="mc_page-header">
<?php echo $pageHeadline ?>
</div>
<?php // echo htmlDivLineSpacer("5px", "", "left"); ?>
<div>
<?php echo defineButtonType10(getLngt("Speichern"), "action_save", "finishPage('save');", "120", "left", "20"); ?>
<?php echo defineButtonType10(getLngt("Zurücksetzen"), "action_close", "finishPage('reset');", "120", "left", "0"); ?>
<?php echo defineButtonType10(getLngt("Schließen"), "action_close", "window.close();", "120", "left", "0"); ?>
</div>
<div class="maincontent mc_elem" name="maincontent" id="maincontent">
<form action="../admin/groupmembers.php" method="post">
<input type="hidden" name="f_act" value="">
<input type="hidden" name="itemId" value="<?php echo ec($itemId) ?>">
<input type="hidden" name="itemType" value="<?php echo ec($itemType) ?>">
<?php echo $phpCurrentNavigationInputHidden ?>
<input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
<?php echo htmlDivLineSpacer("20px"); ?>
<!-- Groups -->
<div>
<table>
<tr>
<td>
<?php echo $output ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>