0 && $f_del_courier_id[0] != "") :
// Remove all associations
for ($i = 0; $i < $fieldsLength; $i++) :
deleteStmt("customercourier","cs_id = " . $customerId . " AND cr_id = " . $f_del_courier_id[$i]);
writeToLogDB("182",$hq_id,"0",$usr_id,$f_del_courier_id[$i],"",$customerId,"CR_ID=" . $f_del_courier_id[$i] . "|CS_ID=" . $customerId,"0","0",$emp_id);
endfor;
// Resort the sort value of the favoured couriers of the customer
$sqlquery = "SELECT cs_id, cr_id FROM customercourier WHERE cs_id = " . $customerId . " 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();
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 customer for selection *
// ****************************************************************************
$count = 0;
if ($customerId != "") :
$sqlquery = "SELECT usr.usr_firstname, usr.usr_name, usr.usr_phone, usr.usr_email, cr.cr_id, cr.cr_eid, cr.cr_sid, cscr.cscr_relation, cscr.cscr_description"
. " FROM customercourier AS cscr, courier AS cr, customer AS cs, "
. " user AS usr"
. " WHERE cscr.cs_id = $customerId 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"
. " usr.usr_id = cr.usr_id"
. " ORDER BY cr.cr_sid";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
$f_usr_firstname[$count] = $row["usr_firstname"];
$f_usr_name[$count] = $row["usr_name"];
$f_usr_phone[$count] = $row["usr_phone"];
$f_usr_email[$count] = $row["usr_email"];
$f_cr_id[$count] = $row["cr_id"];
$f_cr_eid[$count] = $row["cr_eid"];
$f_cr_sid[$count] = $row["cr_sid"];
$f_cscr_relation[$count] = $row["cscr_relation"];
$f_cscr_description[$count] = $row["cscr_description"];
$count++;
endwhile;
$result->free();
endif;
// Only for output
$tmp_cmp_id = getFieldValueFromId("customer", "cs_id", "$customerId", "cmp_id");
$tmpFields = getFieldsValueFromId("company","cmp_id",$tmp_cmp_id,array("cmp_comp","cmp_comp2"));
$pageHeadline = getLngt("Transporteursbeziehungen von:") . " " . $tmpFields[0] . " " . $tmpFields[1];
// Output of the existing relations of the current selected area
$courierOutput = "";
for ($j = 0; $j < $count; $j++) :
$courierOutput .= $f_usr_firstname[$j] . " " . $f_usr_name[$j] . "
";
$courierOutput .= getLngt("EID:") . " " . $f_cr_eid[$j] . " / " . getLngt("Akt. SID:") . " " . $f_cr_sid[$j] . " ";
$imgName = "circle_red.jpg";
if ($f_cscr_relation[$j] == "1") : $imgName = "circle_green.jpg"; endif;
$courierOutput .= " ";
$courierOutput .= "
";
$courierOutput .= $f_cscr_description[$j];
$courierOutput .= "
\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) :
$courierOutput .= "
\n";
$courierOutput .= defineButtonType10(getLngt("Markierte Verknüpfungen entfernen"), "action_remove", "finishPage('removeCustomerCourier');", "240");
$courierOutput .= "
\n";
endif;
if ($courierOutput == "") :
$courierOutput = getLngt("Zur Zeit sind keine Beziehungen eingetragen!");
endif;
?>