0 && $f_del_customer_id[0] != "") :
// Remove all associations according to the zipcode nested in array $f_del_zipcode_id
for ($i = 0; $i < $fieldsLength; $i++) :
deleteStmt("customercourier","cr_id = " . $courierId . " AND cs_id = " . $f_del_customer_id[$i]);
writeToLogDB("182",$hq_id,"0",$usr_id,$courierId,"",$f_del_customer_id[$i],"CR_ID=" . $courierId . "|CS_ID=" . $f_del_customer_id[$i],"0","0",$emp_id);
// Resort the sort value of the favoured couriers of the customer
$sqlquery = "SELECT cs_id, cr_id FROM customercourier WHERE cs_id = " . $f_del_customer_id[$i] . " AND cscr_relation = '1' ORDER BY cscr_sort";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
$sortCounter = 1;
while ($row = $result->fetch_assoc()):
$csId = $row["cs_id"];
$crId = $row["cr_id"];
updateStmt("customercourier", "cs_id", $csId, array("cscr_sort", $sortCounter),"cr_id = '" . $crId . "' AND cscr_relation = '1'");
$sortCounter++;
endwhile;
$result->free();
endfor;
else :
$statusMessage = getLngt("Bitte markieren Sie zu löschende Beziehungen durch anklicken der jeweiligen Checkbox hinter dem Eintrag!");
endif;
TA("C");
TA("E");
endif;
// ***************************************************************************
// * Get the courier-customer relations of a specified courier for selection *
// ***************************************************************************
$f_cmp_comp = array(); $f_cmp_comp2 = array(); $f_cs_id = array(); $f_cs_eid = array(); $f_cscr_relation = array(); $f_cscr_prov = array(); $f_cscr_description = array();
$count = 0;
if ($courierId != "") :
$sqlquery = "SELECT cmp.cmp_comp, cmp.cmp_comp2, cs.cs_id, cs.cs_eid, cscr.cscr_relation, cscr.cscr_prov, cscr.cscr_description"
. " FROM customercourier AS cscr, courier AS cr, customer AS cs, "
. " company AS cmp"
. " WHERE cscr.cr_id = $courierId AND"
. " cr.cr_id = cscr.cr_id AND"
. " cr.hq_id = $hq_id AND"
. " cs.cs_id = cscr.cs_id AND"
. " cs.hq_id = $hq_id AND"
. " cmp.cmp_id = cs.cmp_id";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
$f_cmp_comp[$count] = $row["cmp_comp"];
$f_cmp_comp2[$count] = $row["cmp_comp2"];
$f_cs_id[$count] = $row["cs_id"];
$f_cs_eid[$count] = $row["cs_eid"];
$f_cscr_relation[$count] = $row["cscr_relation"];
$f_cscr_prov[$count] = $row["cscr_prov"];
$f_cscr_description[$count] = $row["cscr_description"];
$count++;
endwhile;
$result->free();
endif;
// Only for output
// $tmp_usr_id = getFieldValueFromId("courier", "cr_id", $courierId, "usr_id");
$tmpFields2 = getFieldsValueFromId("courier", "cr_id", $courierId, array("usr_id","cr_eid","cr_sid"));
$tmp_usr_id = $tmpFields2[0];
$tmp_cr_eid = $tmpFields2[1];
$tmp_cr_sid = $tmpFields2[2];
$tmpFields = getFieldsValueFromId("user","usr_id",$tmp_usr_id,array("usr_name","usr_firstname"));
$tmp_usr_name = $tmpFields[0];
$tmp_usr_firstname = $tmpFields[1];
$title = getLngt("Kundenbeziehungen von:") . "
" . $tmp_usr_firstname . " " . $tmp_usr_name . " ";
if ($tmp_cr_eid != "" || $tmp_cr_sid != "") : $title .= "(" . getLngt("EID:") . " " . $tmp_cr_eid . " / " . getLngt("Akt. SID:") . " " . $tmp_cr_sid . ")"; endif;
// Output of the existing relations of the current selected area
$customerOutput = "";
for ($j = 0; $j < $count; $j++) :
$customerOutput .= $f_cmp_comp[$j] . "
";
if ($f_cmp_comp2[$j] != "") : $customerOutput .= $f_cmp_comp2[$j] . "
"; endif;
$customerOutput .= $f_cs_eid[$j] . " ";
$imgName = "circle_red.jpg";
if ($f_cscr_relation[$j] == "1") : $imgName = "circle_green.jpg"; endif;
$customerOutput .= " ";
$customerOutput .= " ";
if ($f_cscr_relation[$j] == "1") :
$f_cscr_prov[$j] = str_replace (".", ",", $f_cscr_prov[$j]);
if ($crvhRgtRule01) :
$customerOutput .= " [%]";
else :
$customerOutput .= "[" . $f_cscr_prov[$j] . " %]";
endif;
endif;
$customerOutput .= "";
$customerOutput .= $f_cscr_description[$j] . "";
$customerOutput .= "\n";
endfor;
// Button to remove associations between courier and customer(s). Only show if at least one customer is associated to the current area.
if ($count > 0) :
$customerOutput .= "
\n";
$customerOutput .= defineButtonType10(getLngt("Markierte Verknüpfungen entfernen"), "action_remove", "finishPage('removeCourierCustomer');", "240");
$customerOutput .= "
\n";
endif;
if ($customerOutput == "") :
$customerOutput = getLngt("Zur Zeit sind keine Beziehungen eingetragen!");
endif;
?>