@include('./admin/util/header')
| # |
Date added |
First / last name |
State / Company Name |
Phone # |
Groups [assmnts.] |
Email |
Edit |
@php
$i =0;
@endphp
@foreach ($rsDB as $row)
@php
$i++;
$ID = $row->ID;
$IDLink = "" . $ID . "";
$dateAdded = date('m/d/Y', strtotime($row->dateAdded));
// $addOrderIconLink = "
";
$editRecordIconLink = "
";
$firstName = $row->firstName;
$lastName = $row->lastName;
if (is_null($firstName) && is_null($lastName)) {
$firstName = "No name on file";
}
$fullName = $firstName . " " . $lastName;
if ($sortBy == "lastName") {
$fullName = $lastName . ", " . $firstName;
}
$sortName = $fullName;
if (strlen($fullName) > 38) {
$fullName = substr($fullName, 0, 37) . "..";
}
if ($row->activeRecord == 0) {
$fullName = "" . $fullName . "";
}
$fullNameLink = "" . $fullName . "";
$billCity = $row->billCity;
$cityState = $billCity;
$billState = $row->billState;
if (!is_null($billState)) {
$cityState = $billCity . ", " . substr($billState, 0, 2);
}
$col3html = $cityState;
if (!isNull($billState)) {
$col3html = $billState . ", ";
}
$col3html .= $row->companyName;
$col3htmlLink = "" . $col3html . "";
$phoneNum = $row->phoneNum; // ../ssi/functions_record_display -
$emailLinkIcon = $row->email; // ../ssi/functions_record_display -
if ($emailLinkIcon !== " ") {
$emailLinkIcon = "
";
}
// Find the number of log entries assigned to this leader (group count)
$logCount = DB::table('info')
->where('ID', $ID)
->count();
$logCountHtml = "" . $logCount . "";
if ($logCount === 0) {
$logCountHtml = "" . $logCount . "";
}
// Get assessment count
$totSQL = "select sum(IFNULL(asicount,0)) as asicnttot, sum(IFNULL(oasicount,0)) as oasicnttot, sum(IFNULL(asi360count,0)) as asi360cnttot, sum(IFNULL(aspasicount,0)) as aspasicnttot, sum(IFNULL(aspoasicount,0)) as aspoasicnttot, sum(IFNULL(aspasi360count,0)) as aspasi360cnttot, sum(IFNULL(assetcount,0)) as assetcnttot, sum(IFNULL(assettaskcount,0)) as assettaskcnttot, sum(IFNULL(assetposcount,0)) as assetposcnttot FROM info i INNER JOIN infoinfo ii on i.logid=ii.logid where id = " . $ID;
$rTotAssess = 0;
$rsDBTot = DB::select($totSQL);
if (count($rsDBTot) > 0) {
$rTotAssess = $rsDBTot[0]->asicnttot + $rsDBTot[0]->oasicnttot + $rsDBTot[0]->asi360cnttot + $rsDBTot[0]->aspasicnttot + $rsDBTot[0]->aspoasicnttot + $rsDBTot[0]->aspasi360cnttot + $rsDBTot[0]->assetcnttot + $rsDBTot[0]->assettaskcnttot + $rsDBTot[0]->assetposcnttot;
}
if ($rTotAssess === 0) {
$rTotAssessHtml = "" . $rTotAssess . "";
} else {
$rTotAssessHtml = $rTotAssess;
if ($logCount > 0) {
$rTotAssessHtml = "" . $rTotAssess . "";
}
}
$delLink = "
";
if (!session("adminAccess")) {
$delLink = " ";
}
if (!$row->activeRecord) {
$delLink = " ";
}
// Initialize variables
$glRow = "";
$rowFormat = "tableFont"; // Assuming this is initialized somewhere
$glRowLen = 0;
$glRowArray = [];
// Build group leader row
$glRow .= "" . PHP_EOL;
$glRow .= "| " . $i . " | " . PHP_EOL;
$glRow .= "" . $dateAdded . " | " . PHP_EOL;
$glRow .= "" . $fullNameLink . " | " . PHP_EOL;
$glRow .= "" . $col3htmlLink . " | " . PHP_EOL;
$glRow .= "" . $phoneNum . " | " . PHP_EOL;
$glRow .= "" . $logCountHtml . " [" . $rTotAssessHtml . "] | " . PHP_EOL;
$glRow .= "" . $emailLinkIcon . " | " . PHP_EOL;
$glRow .= "" . $editRecordIconLink . " | " . PHP_EOL;
// $glRow .= "" . $delLink . " | ";
$glRow .= "
" . PHP_EOL;
// Build group leader row sort array, which contains sort criteria and glRow
$glRowLen++;
$glRowArray[$glRowLen][0] = $logCount;
$glRowArray[$glRowLen][1] = $rTotAssess;
$glRowArray[$glRowLen][2] = $sortName;
$glRowArray[$glRowLen][3] = $glRow;
if ($rowFormat == "tableFont") {
$rowFormat = "tableFont2";
} else {
$rowFormat = "tableFont";
}
// Determine the range of rows to display based on pagination
if ($sortBy === "assmnts" || $sortBy === "groups") {
$glBegRow = $glRowPageLen;
$glEndRow = session("recordsPerPage") + $glRowPageLen - 1;
}
// Sort the rows based on the chosen criteria
switch ($sortBy) {
case "groups":
$glRowOutput = Sort3Way($glRowArray, 0, 1, 2, !$lowHigh, $glRowLen);
break;
case "assmnts":
$glRowOutput = Sort3Way($glRowArray, 1, 0, 2, !$lowHigh, $glRowLen);
break;
default:
$glRowOutput = $glRowArray;
}
// Display the sorted rows within the specified range
if ($sortBy === "assmnts" || $sortBy === "groups") {
for ($glr = $glBegRow; $glr <= $glEndRow; $glr++) {
echo $glRowOutput[$glr][3]; // Output each group leader table row
}
} else {
foreach ($glRowOutput as $row) {
echo $row[3]; // Output each group leader table row
}
}
@endphp
@endforeach
@include('../util/footer')