query($sqlStmt); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $csc_id = $row["csc_id"]; $csc_path = str_replace("//$cscNameActual//","//$nameCostcenter//",strWrapJs($row["csc_path"])); updateStmt("costcenter","csc_id",$csc_id,array("csc_path",$csc_path)); endwhile; $result->free(); updateStmt("costcenter","csc_id",$cscIdActual,array("csc_name",$nameCostcenter)); // Write logdata into log database writeToLogDB("47",$hq_id,"",$usr_id,"","",$customerId,"CSC_ID=".$cscIdActual."|CSC_NAME=".$nameCostcenter); TA("C"); TA("E"); else : $statusMessage = getLngt("Eine Kostenstelle mit demselben Namen") . " " . $nameCostcenter . " " . getLngt("existiert schon. Bitte umbenennen!"); endif; endif; // Set status of visibility of the costcenter if ($f_act == "setVisibility") : // Check for existence $tmpFields = array("cs_id",$customerId,"csc_id",$cscIdActual); if (existsEntry("costcenter",$tmpFields)) : // Update authentication-status updateStmt("costcenter","csc_id",$cscIdActual,array("csc_visible",$cscVisibleActual)); // Write logdata into log database writeToLogDB("51",$hq_id,"",$usr_id,"","",$customerId,"STATUS_VISIBILITY=".$cscVisibleActual); else : $statusMessage = getLngt("Die Kostenstelle wurde nicht geändert!"); endif; endif; $cscNameRoot = getFieldValueFromId("costcenter","csc_id",$cscIdRoot,"csc_name"); $tmpFields = getFieldsValueFromId("costcenter","csc_id",$cscIdActual,array("csc_path","csc_name","csc_visible")); $cscPathActual = $tmpFields[0]; $cscNameActual = $tmpFields[1]; $cscVisibleActual = $tmpFields[2]; $cscVisibleActual2 = 0; if ($cscVisibleActual != "1") : $cscVisibleActual = 0; $cscVisibleActual2 = 1; endif; // Selection of all CHILDREN of the actual costcenter $whereClauseVisibility = " AND csc_visible = '1' "; if ($f_show_invisible == "1") : $whereClauseVisibility = ""; endif; $sqlquery = "SELECT csc_id, csc_name, csc_path FROM costcenter" . " WHERE cs_id = '" . $customerId . "' AND csc_pre_id = '" . $cscIdActual . "'" . $whereClauseVisibility . " ORDER BY csc_name"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $listOfChildren = ""; while ($row = $result->fetch_assoc()): $csc_id = $row["csc_id"]; $csc_name = $row["csc_name"]; $csc_path = $row["csc_path"]; // $listOfChildren .= (" " // . "" // . $csc_name . " | \n"); if (strtoupper($csc_name) != "EXTERN") : $listOfChildren .= "\n"; endif; endwhile; if ($listOfChildren != "") : $listOfChildren = "\n" . $listOfChildren; endif; $result->free(); // Output of the path-links for navigation in the costcenter-tree $cscPathActualOut = ""; $fields = spliti("//",$cscPathActual); $len = count($fields); $pathDelimiter = ""; $rootFlag = FALSE; $maxPathLength = 4; $pathPrefix = ""; $pathPrefixFlag = FALSE; for ($i = 0; $i < $len; $i++) : if ($fields[$i] != "") : // Only show the subpath from the "actual root" of the employee if ($fields[$i] == $cscNameRoot) : $rootFlag = TRUE; endif; if ($rootFlag) : // Only output of the last elements if ($i > $len - $maxPathLength) : $csc_id = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $customerId . "' AND csc_name = '" . strWrapJs($fields[$i]) . "'"); $cscPathActualOut .= "" . $fields[$i] . ""; $cscPathActualOut .= $pathDelimiter; else : if (!$pathPrefixFlag && ($i > $len - $maxPathLength - 1)) : $csc_id = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $customerId . "' AND csc_name = '" . strWrapJs($fields[$i]) . "'"); $pathPrefix = "" . $pathDelimiter; $pathPrefixFlag = TRUE; endif; endif; endif; endif; endfor; $cscPathActualOut = $pathPrefix . $cscPathActualOut . $cscNameActual; // Check for costcenter being an external costcenter, because an external one // has only access to addresses. Therefore the "empRights"-String has to be set // according to the following scheme if (strtoupper($cscNameActual) == "EXTERN" || !(strpos(strtoupper($cscPathActual), "//EXTERN//") === FALSE)) : $empRights = "100100000000000"; endif; // Check for the right to administrate the costcenters, only for output $cscAdminDisabled = ""; $maskCostcenterCompanyFieldsEditDisabled = ""; if ($userTypeName == "cs") : if (substr($empRights,1,1) != "1") : $cscAdminDisabled = "disabled"; endif; $maskCostcenterCompanyFieldsEditDisabled = getParameterValue("0", "MASK_CSC_CMP_FIELDS_EDIT_DISABLED", "0"); if ($maskCostcenterCompanyFieldsEditDisabled != "") : $maskCostcenterCompanyFieldsEditDisabled = "readonly"; endif; else : if (substr($empRights,0,1) != "1") : $cscAdminDisabled = "disabled"; endif; endif; // Definition of the select-fields, only for output $selectFieldSelectCostcenter = ""; $selectFieldDeleteCostcenter = ""; if ($listOfChildren != "") : // Check for the right to navigate in the subtree if (substr($empRights,0,1) == "1") : $selectFieldSelectCostcenter = "\n" . "\n" . "\n"; endif; $selectFieldDeleteCostcenter = "
" . "
\n" . "\n" . "  
\n" . defineButtonType10(getLngt("Löschen"), "action_remove", "cscFinishPage('" . ec("deleteCostcenter") . "');", "120", "left", "2"); endif; // Check the status of the visibility of the current costcenter $buttonVisibility = ""; $displayTextVisibility = ""; $confirmTextVisibility = ""; if ($cscIdRoot != $cscIdActual) : // NOT for the root costcenter !!! (Check $userTypeName == "hq" ???) $buttonVisibility = defineButtonType10(getLngt("Ausblenden"), "action_invisible", "visibilityFinishPage();", "120", "left", "2"); $confirmTextVisibility = getLngt("Soll die aktuelle Kostenstelle wirklich ausgeblendet werden?"); if ($cscVisibleActual != "1") : $buttonVisibility = defineButtonType10(getLngt("Einblenden"), "action_visible", "visibilityFinishPage();", "120", "left", "2"); $displayTextVisibility = getLngt("(ausgeblendet)"); $confirmTextVisibility = getLngt("Soll die aktuelle Kostenstelle wirklich eingeblendet werden?"); endif; endif; // Checkbox for displaying all costcenters $showInvisibles = getLngt("Alle anz.") . " "; // Check for the right to make the costcenters (in)visible, only for output if (($userTypeName == "cs" && substr($empRights,1,1) != "1") || ($userTypeName == "hq" && substr($empRights,0,1) != "1")) : $buttonVisibility = ""; $showInvisibles = ""; endif; // ************ // * SETTINGS * // ************ // Currently ONLY for headquarters if ($userTypeName == "hq" && substr($empRights,0,1) == "1") : // Secure-check of the association between customer, costcenter and employee $tmpFields = array("cs_id",$customerId,"csc_id",$cscIdActual); if (existsEntry("costcenter",$tmpFields)) : // Get the name of the current costcenter $cscNameActual = getFieldValueFromId("costcenter","csc_id",$cscIdActual,"csc_name"); // *** Save the settings (Begin) *** // Actually one addresstype is represented only one time per costcenter in costcenteraddress if ($f_act == "saveSettings") : // Update costcenter updateStmt("costcenter", "csc_id", $cscIdActual, array("csc_inv_interval", $f_csc_inv_interval, "csc_inv_type", $f_csc_inv_type)); // Check existence of parameter for costcenter invoice mode if ($f_csc_inv_mode != "" || ($f_csc_inv_mode == "" && existsEntry("parameter",array("par_key","COSTCENTER_INV_MODE_" . $cscIdActual)))) : setParameterValue("COSTCENTER_INV_MODE_" . $cscIdActual, $f_csc_inv_mode); endif; // Write logdata into log database writeToLogDB("49",$hq_id,"",$usr_id,"","",$customerId,"CSC_ID=".$cscIdActual."|CSC_NAME=".$cscNameActual."|INTERVAL=".$f_csc_inv_interval."|INVMODE=".$f_csc_inv_mode); // Set modification status of the current customer if values of the ROOT-costcenter(!) are changed if ($cscIdActual == $cscIdRoot) : setModificationStatus($customerId); endif; endif; // *** Save the settings (End) *** // ****************************************************** // * Selection of the settings of the actual costcenter * // ****************************************************** $sqlquery = "SELECT csc.csc_inv_interval,csc.csc_inv_type" . " FROM costcenter AS csc" . " WHERE csc.csc_id = '$cscIdActual'"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $f_csc_inv_interval = $row["csc_inv_interval"]; $f_csc_inv_type = $row["csc_inv_type"]; endwhile; $result->free(); // Get special costcenter invoice mode $f_csc_inv_mode = getParameterValue("0", "COSTCENTER_INV_MODE_" . $cscIdActual, "0"); endif; endif; // ************* // * ADDRESSES * // ************* // Set the default addresstype on "Abhol-/Lieferadresse" if ($v_adt_id == "") : $v_adt_id = "4"; endif; // Check for validation of the address assigned to the customer $noValidationOfAddress = FALSE; if ($f_noaddressvalidation != "") : if ($f_noaddressvalidation[0] == '1') : $noValidationOfAddress = TRUE; endif; endif; $addressValidationErr = ""; // Secure-check of the association between customer and costcenter $tmpFields = array("cs_id",$customerId,"csc_id",$cscIdActual); if (existsEntry("costcenter",$tmpFields)) : $cscNameActual = getFieldValueFromId("costcenter","csc_id",$cscIdActual,"csc_name"); // *** Save the adress (Begin) *** // Actually one addresstype is represented only one time per costcenter in costcenteraddress if ($f_act == "saveAddress") : $f_cscad_comp = trim($f_cscad_comp); $f_cscad_comp2 = trim($f_cscad_comp2); $f_cscad_comp3 = trim($f_cscad_comp3); $f_cscad_comp4 = trim($f_cscad_comp4); $f_ad_street = trim($f_ad_street); $f_ad_zipcode = trim($f_ad_zipcode); $f_ad_city = trim($f_ad_city); $f_ad_country = trim($f_ad_country); $f_cscad_hsno = trim($f_cscad_hsno); // Check for empty entry in the company-field if ($f_cscad_comp != "") : // Check for empty entries in address-fields if ($f_ad_street != "" && $f_ad_zipcode != "" && $f_ad_city != "" && $f_ad_country != "") : // Check validity according to the address-server $addressValid = getGeoCoordinates($f_ad_street, $f_ad_zipcode, $f_ad_city, $f_cscad_hsno, $f_ad_country, ""); if ($addressValid != "") : // Check zipcode and city $addressValidityArray = checkCityZipcode($f_ad_zipcode, $f_ad_city, $f_ad_street); if ($noValidationOfAddress || $addressValidityArray[0] >= 1) : TA("B"); // Check for existing entry in address (because of redundance) if ($f_ad_country == "") : $f_ad_country = "DE"; endif; $tmpArray = insertAddress($f_ad_street, $f_ad_zipcode, $f_ad_city, "", $f_ad_country, $noValidationOfAddress); $ad_id = $tmpArray[0]; // Check for addresstype-entry(!) in costcenteraddress $cscadFields = array("csc_id",$cscIdActual,"adt_id",$v_adt_id); if (existsEntry("costcenteraddress",$cscadFields)) : // Update costcenteraddress $sqlStmt = "UPDATE costcenteraddress SET ad_id = $ad_id, cscad_hsno = '$f_cscad_hsno', " . "cscad_remark = '$f_cscad_remark', cscad_person = '$f_cscad_person', cscad_phone = '$f_cscad_phone', cscad_email = '$f_cscad_email', cscad_gln = '$f_cscad_gln', " . "cscad_comp = '$f_cscad_comp', cscad_comp2 = '$f_cscad_comp2', cscad_comp3 = '$f_cscad_comp3', cscad_comp4 = '$f_cscad_comp4' " . "WHERE csc_id = $cscIdActual AND adt_id = $v_adt_id"; // writeDbLog($sqlStmt); $res = $db->query($sqlStmt); else : // Insert costcenteraddress $sqlStmt = "INSERT INTO costcenteraddress (csc_id,adt_id,ad_id,cscad_hsno,cscad_remark,cscad_person,cscad_phone,cscad_comp,cscad_comp2,cscad_comp3,cscad_comp4,cscad_email,cscad_gln) " . " VALUES ($cscIdActual,$v_adt_id,$ad_id,'$f_cscad_hsno','$f_cscad_remark','$f_cscad_person','$f_cscad_phone','$f_cscad_comp','$f_cscad_comp2','$f_cscad_comp3','$f_cscad_comp4','$f_cscad_email','$f_cscad_gln')"; // writeDbLog($sqlStmt); $res = $db->query($sqlStmt); endif; // Write logdata into log database writeToLogDB("48",$hq_id,"",$usr_id,"","",$customerId,"CSC_ID=".$cscIdActual."|AD_ID=".$ad_id."|ADT_ID=".$v_adt_id."|ADDRESS=".$f_cscad_comp.";".$f_cscad_comp2.";".$f_cscad_comp3.";".$f_cscad_comp4.";".$f_ad_street.";".$f_ad_zipcode.";".$f_ad_city.";".$f_ad_country.";".$f_cscad_hsno.";".$f_cscad_remark.";".$f_cscad_person.";".$f_cscad_phone.";".$f_cscad_email.";".$f_cscad_gln); // Set modification status of the current customer if values of the ROOT-costcenter(!) are changed if ($cscIdActual == $cscIdRoot) : setModificationStatus($customerId); endif; TA("C"); TA("E"); else : $statusMessage = getLngt("Die Postleitzahl passt nicht zu dem angegebenen Ort!"); $addressValidationErr = "1"; endif; else : $statusMessage = getLngt("Der Adress-Server kennt die eingebene Adresse nicht! Bitte korrekt erfassen!"); endif; else : $statusMessage = getLngt("Bitte geben Sie mindestens Straße, Hausnummer, Stadt und Land an!"); endif; else : $statusMessage = getLngt("Bitte geben Sie den Firmennamen oder übernehmen Sie den aus der übergeordneten Kostenstelle!"); endif; endif; // *** Save the adress (End) *** // *************************************************************************************** // * Selection of the address of the actual costcenter based on the selected addresstype * // *************************************************************************************** $sqlquery = "SELECT cscad.ad_id,cscad.cscad_comp,cscad.cscad_comp2,cscad.cscad_comp3,cscad.cscad_comp4,cscad.cscad_hsno,cscad.cscad_remark,cscad.cscad_person,cscad.cscad_phone,cscad.cscad_email,cscad.cscad_gln,ad.ad_street,ad.ad_zipcode,ad.ad_city,ad.ad_country" . " FROM costcenteraddress AS cscad, address AS ad" . " WHERE cscad.csc_id = '$cscIdActual' AND" . " cscad.adt_id = '$v_adt_id' AND" . " cscad.ad_id = ad.ad_id "; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $v_ad_id = $row["ad_id"]; $v_ad_street = $row["ad_street"]; $v_ad_zipcode = $row["ad_zipcode"]; $v_ad_city = $row["ad_city"]; $v_ad_country = $row["ad_country"]; $v_cscad_comp = $row["cscad_comp"]; $v_cscad_comp2 = $row["cscad_comp2"]; $v_cscad_comp3 = $row["cscad_comp3"]; $v_cscad_comp4 = $row["cscad_comp4"]; $v_cscad_hsno = $row["cscad_hsno"]; $v_cscad_remark = $row["cscad_remark"]; $v_cscad_person = $row["cscad_person"]; $v_cscad_phone = $row["cscad_phone"]; $v_cscad_email = $row["cscad_email"]; $v_cscad_gln = $row["cscad_gln"]; endwhile; $result->free(); endif; // If company-name ("f_cscad_comp" and "f_cscad_comp2") in "costcenteraddress" empty, // take the name from the parent-costcenter if ($v_cscad_comp == "") : $sqlquery = "SELECT cscad.cscad_comp,cscad.cscad_comp2,cscad.cscad_comp3,cscad.cscad_comp4" . " FROM costcenteraddress AS cscad,costcenter AS csc, costcenter AS csc2" . " WHERE csc.csc_id = '$cscIdActual' AND" . " csc2.csc_id = csc.csc_pre_id AND" . " csc2.csc_id = cscad.csc_id AND" . " cscad.adt_id = '$v_adt_id'"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $v_cscad_comp = $row["cscad_comp"]; $v_cscad_comp2 = $row["cscad_comp2"]; $v_cscad_comp3 = $row["cscad_comp3"]; $v_cscad_comp4 = $row["cscad_comp4"]; endwhile; $result->free(); endif; $v_cscad_comp = strWrapHtml($v_cscad_comp); $v_cscad_comp2 = strWrapHtml($v_cscad_comp2); $v_cscad_comp3 = strWrapHtml($v_cscad_comp3); $v_cscad_comp4 = strWrapHtml($v_cscad_comp4); $pageHeadline = ($deactivateMenu == "1" ? "" . strtoupper($pageTitel) . "" . "     " : "" ) . $cmpComp . ($cmpComp2 != "" ? " :: " . $cmpComp2 : ""); ?> <?php echo $pageTitel ?>
         
"; echo "  "; echo "
"; echo defineButtonType10(getLngt("Anlegen"), "action_new", "cscFinishPage('" . ec("newCostcenter") . "');", "120", "left", "2"); echo defineButtonType10(getLngt("Umbenennen"), "action_rename", "cscFinishPage('" . ec("renameCostcenter") . "');", "120", "left", "2"); endif; ?>       
Einstellungen für:
       
       
:
>:
>:
>
>
>
>
>:
>:
 
>:
  
>:
>:
>:
>:
>:
>: