Skip to content

Commit

Permalink
Department search & browse
Browse files Browse the repository at this point in the history
  • Loading branch information
rockhopsoft committed Jun 13, 2020
1 parent 751b504 commit 76c57dd
Show file tree
Hide file tree
Showing 51 changed files with 1,405 additions and 561 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
],
"require": {
"rockhopsoft/survloop": "^0.2.16",
"rockhopsoft/survloop": "^0.2.17",
"flexyourrights/openpolice-departments": "^0.1.2",
"flexyourrights/openpolice-website": "^0.1.1"
},
Expand Down
10 changes: 10 additions & 0 deletions src/Controllers/DepartmentScores.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ public function loadDeptStuff($deptID = -3)
if ($deptID > 0 && !isset($GLOBALS["SL"]->x["depts"][$deptID])) {
$d = [ "id" => $deptID ];
$d["deptRow"] = OPDepartments::find($deptID);
$d["deptAbbr"] = '';
$d["iaRow"] = OPOversight::where('over_dept_id', $deptID)
->where('over_type', $GLOBALS["SL"]->x["defOverIA"])
->first();
Expand Down Expand Up @@ -491,6 +492,15 @@ public function loadDeptStuff($deptID = -3)
. ' ' . $d["civRow"]->over_address_zip;
}
}
$paren1 = strpos($d["deptRow"]->dept_name, '(');
if ($paren1 > 0) {
$paren2 = strpos($d["deptRow"]->dept_name, ')', $paren1);
$d["deptAbbr"] = substr(
$d["deptRow"]->dept_name,
($paren1+1),
($paren2-$paren1-1)
);
}
}

$d["whichOver"] = $which = 'iaRow';
Expand Down
408 changes: 341 additions & 67 deletions src/Controllers/OpenAjax.php

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions src/Controllers/OpenComplaintConditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ protected function checkNodeConditionsCustom($nID, $condition = '')
} elseif ($condition == '#CanEditUploads') {
return $this->complaintCanEditUploads();

} elseif ($condition == '#NotSureAboutDepartment') {
return $this->condNotSureAboutDepartment();

} elseif ($condition == '#PrintAnonOnly') {
return $this->condPrintAnonOnly($complaint);

Expand Down Expand Up @@ -537,10 +540,6 @@ protected function complaintCanEditUploads()
protected function condPrintAnonOnly($complaint)
{
$unPub = $this->getUnPublishedStatusList();
$unPub[] = $GLOBALS["SL"]->def->getID(
'Complaint Status',
'OK to Submit to Oversight'
);
$types = [ 'public', 'pdf' ];
if (isset($GLOBALS["SL"]->pageView)
&& in_array($GLOBALS["SL"]->pageView, $types)
Expand Down Expand Up @@ -796,5 +795,26 @@ protected function condPartnerActiveOrTestLink()
}
return 0;
}

/**
* Checks whether or not this complainant is unsure
* about one or more department involved in this incident.
*
* @return int
*/
protected function condNotSureAboutDepartment()
{
if (isset($this->sessData->dataSets["departments"])
&& sizeof($this->sessData->dataSets["departments"]) > 0) {
foreach ($this->sessData->dataSets["departments"] as $dept) {
if (isset($dept->dept_name)
&& strpos($dept->dept_name, 'Not sure') !== false) {
return 1;
}
}
}
return 0;
}


}
6 changes: 4 additions & 2 deletions src/Controllers/OpenComplaintEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID)
case '[{ Complaint URL XML }]':
case '[{ Complaint URL JSON }]':
$swap = '<a href="' . $url . '/complaint/read-' . $this->corePublicID
. '/xml" target="_blank">Download full complaint as a XML</a>';
. '/xml" target="_blank">Download full complaint as an XML</a>';
break;
case '[{ Complaint URL XML Link }]':
case '[{ Complaint URL JSON Link }]':
Expand Down Expand Up @@ -589,7 +589,7 @@ public function prepEmailComDataRow($deptRow, $cnt)
"deptRow" => $deptRow
];
$defTyp = 'Investigative Agency Types';
$iaDef = $GLOBALS["SL"]->def->getID($defTyp, 'Internal Affairs');
$iaDef = $GLOBALS["SL"]->def->getID($defTyp, 'Internal Affairs');
$civDef = $GLOBALS["SL"]->def->getID($defTyp, 'Civilian Oversight');
$this->v["comDepts"][$cnt]["iaRow"] = OPOversight::where('over_type', $iaDef)
->where('over_dept_id', $deptRow->dept_id)
Expand Down Expand Up @@ -634,6 +634,7 @@ public function prepEmailComDataRow($deptRow, $cnt)
'lnk_com_over_complaint_id', $this->coreID)
->where('lnk_com_over_dept_id', $deptRow->dept_id)
//->where('lnk_com_over_over_id', $this->v["comDepts"][0][$w]->over_id)
->orderBy('created_at', 'asc')
->first();
/* if (!$this->v["comDepts"][$cnt]["overDates"]
|| !isset($this->v["comDepts"][$cnt]["overDates"]->lnk_com_dept_id)) {
Expand Down Expand Up @@ -661,6 +662,7 @@ protected function getOversightLinksChk()
foreach ($deptIDs as $deptID) {
$chk = OPLinksComplaintOversight::where('lnk_com_over_complaint_id', $this->coreID)
->where('lnk_com_over_dept_id', $deptID)
->orderBy('created_at', 'asc')
->first();
if (!$chk && !isset($chk->lnk_com_over_over_id)) {
$lnk = new OPLinksComplaintOversight;
Expand Down
13 changes: 8 additions & 5 deletions src/Controllers/OpenComplaintPrints.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,18 @@ protected function getReportUploads($nID)
+$this->v["uploadPrintMap"]["vid"]
+$this->v["uploadPrintMap"]["fil"];
$GLOBALS["SL"]->pageAJAX .= ' setTimeout(function() { '
. 'document.getElementById("uploadDelayed").innerHTML="' . $GLOBALS["SL"]->addSlashLines($ret)
. '"; }, 1500); ';
return '<h3 class="mT0 slBlueDark">'
. (($cnt > 1) ? 'Uploads' : 'Upload') . '</h3>'
. 'document.getElementById("uploadDelayed").innerHTML="'
. $GLOBALS["SL"]->addSlashLines($ret) . '"; }, 1500); ';
return '<h4 class="mT0 slBlueDark">'
. (($cnt > 1) ? 'Uploads' : 'Upload') . '</h4>'
. '<div id="uploadDelayed" class="w100"><div class="w100 taC">'
. $GLOBALS["SL"]->sysOpts["spinner-code"] . '</div></div>';
}

/* Double-Checking [For Now] */
protected function canShowUpload($nID, $upDeets, $isAdmin = false, $isOwner = false)
{
if ($isAdmin || $isOwner) {
if ($isAdmin || $isOwner || $this->v["isAdmin"] || $this->v["isOwner"]) {
return true;
}
if (isset($this->sessData->dataSets["complaints"])) {
Expand All @@ -381,6 +381,9 @@ protected function canShowUpload($nID, $upDeets, $isAdmin = false, $isOwner = fa

protected function loadUpDeetPrivacy($upRow = NULL)
{
if ($this->v["isAdmin"] || $this->v["isOwner"]) {
return 'Public';
}
if ($upRow && isset($upRow->up_privacy)) {
if ($upRow->up_tree_id == 1) {
if ($upRow->up_privacy == 'Private') {
Expand Down
20 changes: 20 additions & 0 deletions src/Controllers/OpenComplaintSaves.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ protected function postNodePublicCustom(&$curr)
return $this->saveForceTypes($nID);
} elseif ($nID == 2824) {
return $this->saveForceTypeLnkOneVictim($nID);
} elseif ($nID == 388) {
return $this->saveArrestChargesDropped($nID);
} elseif ($nID == 976) {
return $this->saveStatusCompletion($nID);

Expand Down Expand Up @@ -319,6 +321,24 @@ protected function saveForceTypeLnkOneVictim($nID)
return true;
}

/**
* Check discreprency with previous answer.
*
* @param int $nID
* @return boolean
*/
protected function saveArrestChargesDropped($nID)
{
if ((!isset($this->sessData->dataSets["complaints"][0]->com_all_charges_resolved)
|| $this->sessData->dataSets["complaints"][0]->com_all_charges_resolved != 'Y')
&& $GLOBALS["SL"]->REQ->has('n388fld')
&& trim($GLOBALS["SL"]->REQ->n388fld) == 'Y') {
$this->sessData->dataSets["complaints"][0]->com_all_charges_resolved = 'Y';
$this->sessData->dataSets["complaints"][0]->save();
}
return false;
}

/**
* Update the complaint status to 'New', AKA complete.
*
Expand Down
54 changes: 26 additions & 28 deletions src/Controllers/OpenDashAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function printDashTopLevStats()
"betas" => 0,
"incomplete" => 0,
"complete" => 0,
"processed" => 0,
"attorney" => 0,
"published" => 0,
"submitted" => 0
];
$stats["betas"] = DB::table('op_tester_beta')
Expand All @@ -60,31 +61,28 @@ public function printDashTopLevStats()
if ($chk->isNotEmpty()) {
$defSet = 'Complaint Status';
foreach ($chk as $com) {
switch (intVal($com->com_status)) {
case $GLOBALS["SL"]->def->getID($defSet, 'Incomplete'):
$stats["incomplete"]++;
break;
case $GLOBALS["SL"]->def->getID($defSet, 'New'):
case $GLOBALS["SL"]->def->getID($defSet, 'Hold'):
case $GLOBALS["SL"]->def->getID($defSet, 'Reviewed'):
case $GLOBALS["SL"]->def->getID($defSet, 'Needs More Work'):
case $GLOBALS["SL"]->def->getID($defSet, 'Pending Attorney'):
$stats["complete"]++;
break;
case $GLOBALS["SL"]->def->getID($defSet, 'Attorney\'d'):
case $GLOBALS["SL"]->def->getID($defSet, 'OK to Submit to Oversight'):
$stats["processed"]++;
$stats["complete"]++;
break;
case $GLOBALS["SL"]->def->getID($defSet, 'Submitted to Oversight'):
case $GLOBALS["SL"]->def->getID($defSet, 'Received by Oversight'):
case $GLOBALS["SL"]->def->getID($defSet, 'Declined To Investigate (Closed)'):
case $GLOBALS["SL"]->def->getID($defSet, 'Investigated (Closed)'):
case $GLOBALS["SL"]->def->getID($defSet, 'Closed'):
if ($com->com_status == $GLOBALS["SL"]->def->getID($defSet, 'Incomplete')) {
$stats["incomplete"]++;
} else {
$stats["complete"]++;
}
if (in_array($com->com_status, [
$GLOBALS["SL"]->def->getID($defSet, 'Pending Attorney'),
$GLOBALS["SL"]->def->getID($defSet, 'Attorney\'d')])) {
$stats["attorney"]++;
}
if (in_array($com->com_status, [
$GLOBALS["SL"]->def->getID($defSet, 'OK to Submit to Oversight'),
$GLOBALS["SL"]->def->getID($defSet, 'Submitted to Oversight'),
$GLOBALS["SL"]->def->getID($defSet, 'Received by Oversight'),
$GLOBALS["SL"]->def->getID($defSet, 'Declined To Investigate (Closed)'),
$GLOBALS["SL"]->def->getID($defSet, 'Investigated (Closed)')])) {
$stats["published"]++;
if ($com->com_status
!= $GLOBALS["SL"]->def->getID($defSet, 'OK to Submit to Oversight')) {
$stats["submitted"]++;
$stats["processed"]++;
$stats["complete"]++;
break;
}

}
}
}
Expand Down Expand Up @@ -498,10 +496,10 @@ public function recalcVolunStats()
}
}

$edits = OPzEditOversight::where('op_z_edit_oversight.zed_over_over_type', 303)
->join('op_z_edit_departments', 'op_z_edit_departments.zed_dept_id', '=', 'op_z_edit_oversight.zed_over_zed_dept_id')
->where('op_z_edit_oversight.zed_over_over_verified',
$edits = OPzEditOversight::where('op_z_edit_oversight.zed_over_over_verified',
'>', date("Y-m-d", strtotime($startDate)).' 00:00:00')
//->where('op_z_edit_oversight.zed_over_over_type', 303)
->join('op_z_edit_departments', 'op_z_edit_departments.zed_dept_id', '=', 'op_z_edit_oversight.zed_over_zed_dept_id')
->select('op_z_edit_oversight.*', 'op_z_edit_departments.zed_dept_user_id')
->get();
if ($edits->isNotEmpty()) {
Expand Down
Loading

0 comments on commit 76c57dd

Please sign in to comment.