Skip to content

Commit

Permalink
Complaint Management Tool Upgrades
Browse files Browse the repository at this point in the history
And evolving the Department Management.
  • Loading branch information
rockhopsoft committed Jun 3, 2020
1 parent a63e289 commit 751b504
Show file tree
Hide file tree
Showing 46 changed files with 1,268 additions and 347 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ XML included an automatically generated schema, eg.<br />

* php: >=7.2.5
* <a href="https://packagist.org/packages/laravel/laravel" target="_blank">laravel/laravel</a>: 7.6.*
* <a href="https://packagist.org/packages/rockhopsoft/survloop" target="_blank">rockhopsoft/survloop</a>: >=0.2.15
* <a href="https://packagist.org/packages/rockhopsoft/survloop" target="_blank">rockhopsoft/survloop</a>: >=0.2.16
* <a href="https://packagist.org/packages/flexyourrights/openpolice-departments" target="_blank">flexyourrights/openpolice-departments</a>: 0.1.*
* <a href="https://packagist.org/packages/flexyourrights/openpolice-website" target="_blank">flexyourrights/openpolice-website</a>: 0.1.*

Expand All @@ -81,7 +81,7 @@ DB_USERNAME=homestead
DB_PASSWORD=secret
```

You could do things like install Laravel's out-of-the-box user authentication tools, and push the vendor file copies where they need to be:
Next, install Laravel's out-of-the-box user authentication tools, and push the vendor file copies where they need to be:
```
$ composer require laravel/ui
$ php artisan ui vue --auth
Expand All @@ -98,7 +98,7 @@ $ nano composer.json
...
"require": {
...
"rockhopsoft/survloop": "^0.2.16",
"rockhopsoft/survloop": "^0.2.4",
"flexyourrights/openpolice": "^0.2.16",
...
},
Expand Down
67 changes: 39 additions & 28 deletions src/Controllers/DepartmentScores.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use App\Models\OPDepartments;
use App\Models\OPOversight;
use App\Models\OPzComplaintReviews;
use App\Models\OPZeditDepartments;
use App\Models\OPZeditOversight;
use App\Models\OPzEditDepartments;
use App\Models\OPzEditOversight;
use App\Models\OPOversightModels;

class DepartmentScores
Expand Down Expand Up @@ -236,20 +236,14 @@ public function loadAllDepts($searchFilts = [])
$deptName = str_replace('Police Dept', '', trim($dept->dept_name));
$deptName = str_replace('Police Department', '', $deptName);
$deptName = trim(str_replace('Department', 'Dept', $deptName));
$this->deptNames[$dept->dept_id] = $deptName . ', ' . $dept->dept_address_state;
$this->deptOvers[$dept->dept_id] = OPOversight::where('over_dept_id', $dept->dept_id)
->whereNotNull('over_agnc_name')
->where('over_agnc_name', 'NOT LIKE', '')
->orderBy('over_type', 'asc')
$this->deptNames[$dept->dept_id] = $deptName
. ', ' . $dept->dept_address_state;
$this->deptOvers[$dept->dept_id]["ia"] = OPOversight::where('over_dept_id', $dept->dept_id)
->where('over_type', $GLOBALS["SL"]->x["defOverIA"])
->first();
$this->deptOvers[$dept->dept_id]["civ"] = OPOversight::where('over_dept_id', $dept->dept_id)
->where('over_type', $GLOBALS["SL"]->x["defOverCiv"])
->first();
if (isset($this->deptOvers[$dept->dept_id]->over_type)
&& $this->deptOvers[$dept->dept_id]->over_type == $GLOBALS["SL"]->x["defOverCiv"]) {
$this->deptScore[$dept->dept_id] = OPOversight::where('over_dept_id', $dept->dept_id)
->whereNotNull('over_agnc_name')
->where('over_agnc_name', 'NOT LIKE', '')
->where('over_type', $GLOBALS["SL"]->x["defOverIA"])
->first();
}
}
}
}
Expand All @@ -261,7 +255,7 @@ public function loadAllDepts($searchFilts = [])
protected function recheckVerified()
{
$verifList = $verifDates = $verifCnt = [];
$chk = OPZeditOversight::where(function ($query) {
$chk = OPzEditOversight::where(function ($query) {
$query->where('zed_over_online_research', 1)
->orWhere('zed_over_made_dept_call', 1)
->orWhere('zed_over_made_ia_call', 1);
Expand Down Expand Up @@ -302,7 +296,8 @@ protected function recheckVerified()
if (isset($verifDates[$deptID])) {
$dept = OPDepartments::find($deptID);
if ($dept && isset($dept->dept_id)) {
$dept->dept_verified = date("Y-m-d H:i:s", strtotime($verifDates[$deptID]));
$time = strtotime($verifDates[$deptID]);
$dept->dept_verified = date("Y-m-d H:i:s", $time);
$dept->save();
}
}
Expand All @@ -320,7 +315,8 @@ public function recalcAllDepts()
$this->loadAllDepts();
if ($this->scoreDepts->isNotEmpty()) {
foreach ($this->scoreDepts as $i => $dept) {
if ($this->deptOvers[$dept->dept_id]) {
$id = $dept->dept_id;
if ($this->deptOvers[$id]["ia"]) {
$this->scoreDepts[$i]->dept_score_openness = 0;
foreach ($this->vals as $type => $specs) {
$score = $this->checkRecFld($specs, $dept->dept_id);
Expand All @@ -329,12 +325,20 @@ public function recalcAllDepts()
$this->stats[$type]++;
}
}
if (isset($this->deptOvers[$dept->dept_id]->over_email)
&& trim($this->deptOvers[$dept->dept_id]->over_email) != ''
&& isset($this->deptOvers[$dept->dept_id]->over_way_sub_email)
&& intVal($this->deptOvers[$dept->dept_id]->over_way_sub_email) == 1
&& isset($this->deptOvers[$dept->dept_id]->over_official_form_not_req)
&& intVal($this->deptOvers[$dept->dept_id]->over_official_form_not_req) == 1) {
$hasEmail = false;
if ((isset($dept->dept_email) && trim($dept->dept_email) != '')
|| (isset($this->deptOvers[$id]["ia"]->over_email)
&& trim($this->deptOvers[$id]["ia"]->over_email) != '')
|| ($this->deptOvers[$id]["civ"]
&& isset($this->deptOvers[$id]["civ"]->over_email)
&& trim($this->deptOvers[$id]["civ"]->over_email) != '')) {
$hasEmail = true;
}
if ($hasEmail
&& isset($this->deptOvers[$id]["ia"]->over_way_sub_email)
&& intVal($this->deptOvers[$id]["ia"]->over_way_sub_email) == 1
&& isset($this->deptOvers[$id]["ia"]->over_official_form_not_req)
&& intVal($this->deptOvers[$id]["ia"]->over_official_form_not_req) == 1) {
$this->scoreDepts[$i]->dept_op_compliant = 1;
} else {
$this->scoreDepts[$i]->dept_op_compliant = 0;
Expand All @@ -357,7 +361,7 @@ public function checkRecFld($specs, $deptID, $overrow = null)
if ($deptID <= 0) {
return 0;
}
$overrow = $this->deptOvers[$deptID];
$overrow = $this->deptOvers[$deptID]["ia"];
if (isset($this->deptScore[$deptID])) {
$overrow = $this->deptScore[$deptID];
}
Expand Down Expand Up @@ -446,8 +450,10 @@ public function loadDeptStuff($deptID = -3)
}
$d["iaRow"]->save();
}
if (isset($d["deptRow"]->dept_name) && trim($d["deptRow"]->dept_name) != '') {
if (!isset($d["iaRow"]->over_agnc_name) || trim($d["iaRow"]->over_agnc_name) == '') {
if (isset($d["deptRow"]->dept_name)
&& trim($d["deptRow"]->dept_name) != '') {
if (!isset($d["iaRow"]->over_agnc_name)
|| trim($d["iaRow"]->over_agnc_name) == '') {
$d["iaRow"]->over_agnc_name = $d["deptRow"]->dept_name;
$d["iaRow"]->save();
}
Expand All @@ -458,7 +464,8 @@ public function loadDeptStuff($deptID = -3)
$d["deptAddy"] .= $d["deptRow"]->dept_address2 . ', ';
}
$d["deptAddy"] .= $d["deptRow"]->dept_address_city . ', '
. $d["deptRow"]->dept_address_state . ' ' . $d["deptRow"]->dept_address_zip;
. $d["deptRow"]->dept_address_state . ' '
. $d["deptRow"]->dept_address_zip;
$d["iaAddy"] = '';
if (isset($d["iaRow"]->over_address)
&& trim($d["iaRow"]->over_address) != '') {
Expand Down Expand Up @@ -508,6 +515,10 @@ public function loadDeptStuff($deptID = -3)
];
}
}
$chk = OPzEditDepartments::where('zed_dept_dept_id', $deptID)
->select('zed_dept_dept_id')
->get();
$d["editCnt"] = $chk->count();
$GLOBALS["SL"]->x["depts"][$deptID] = $d;
}
return true;
Expand Down
21 changes: 17 additions & 4 deletions src/Controllers/OpenComplaintConditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,22 @@ protected function condPrintAnonOnly($complaint)
return 0;
}

/**
* Checks whether or not the incident record indicates
* that the location should be printed.
*
* @return int
*/
protected function canPrintIncidentLocation()
{
return (isset($this->sessData->dataSets["incidents"])
&& isset($this->sessData->dataSets["incidents"][0])
&& isset($this->sessData->dataSets["incidents"][0]->inc_public)
&& intVal($this->sessData->dataSets["incidents"][0]->inc_public) == 1
&& in_array($this->sessData->dataSets["complaints"][0]->com_status,
[200, 201, 202, 203, 204]));
}

/**
* Checks whether or not the incident location
* should be printed for the current page load.
Expand All @@ -564,10 +580,7 @@ protected function condPrintAnonOnly($complaint)
*/
protected function condPrintIncidentLocation()
{
if (isset($this->sessData->dataSets["incidents"])
&& isset($this->sessData->dataSets["incidents"][0])
&& isset($this->sessData->dataSets["incidents"][0]->inc_public)
&& intVal($this->sessData->dataSets["incidents"][0]->inc_public) == 1) {
if ($this->canPrintIncidentLocation()) {
return 1;
}
if ((isset($this->v["isAdmin"]) && $this->v["isAdmin"])
Expand Down
14 changes: 7 additions & 7 deletions src/Controllers/OpenComplaintEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class OpenComplaintEmails extends OpenPoliceEvents
protected function postContactEmail($nID)
{
$this->postNodeLoadEmail($nID);
if ($GLOBALS["SL"]->REQ->has('n831fld') && trim($GLOBALS["SL"]->REQ->n831fld) != '') {
if ($GLOBALS["SL"]->REQ->has('n831fld')
&& trim($GLOBALS["SL"]->REQ->n831fld) != '') {
return true;
}
$emaSubject = $this->postDumpFormEmailSubject();
Expand Down Expand Up @@ -85,7 +86,8 @@ protected function postDumpFormEmailSubject()
}
return $ret;
}
return $GLOBALS["SL"]->sysOpts["site-name"] . ': ' . $GLOBALS["SL"]->treeRow->tree_name;
return $GLOBALS["SL"]->sysOpts["site-name"] . ': '
. $GLOBALS["SL"]->treeRow->tree_name;
}

protected function processTokenAccessRedirExtra()
Expand Down Expand Up @@ -633,17 +635,15 @@ public function prepEmailComDataRow($deptRow, $cnt)
->where('lnk_com_over_dept_id', $deptRow->dept_id)
//->where('lnk_com_over_over_id', $this->v["comDepts"][0][$w]->over_id)
->first();
/*
if (!$this->v["comDepts"][$cnt]["overDates"]
/* if (!$this->v["comDepts"][$cnt]["overDates"]
|| !isset($this->v["comDepts"][$cnt]["overDates"]->lnk_com_dept_id)) {
$lnk = new OPLinksComplaintOversight;
$lnk->lnk_com_over_complaint_id = $this->coreID;
$lnk->lnk_com_over_dept_id = $deptRow->dept_id;
$lnk->lnk_com_over_over_id = $this->v["comDepts"][0][$w]->over_id;
$lnk->save();
$this->v["comDepts"][$cnt]["overDates"] = $lnk;
$this->v["comDepts"][$cnt]["overDates"]->save();
}
*/
} */
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/OpenComplaintPrints.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function printEndOfComplaintRedirect($nID)
. $this->sessData->dataSets["compliments"][0]->compli_public_id;
}
$spin = $GLOBALS["SL"]->sysOpts["spinner-code"];
$this->restartSess($GLOBALS["SL"]->REQ);
//$this->restartSess($GLOBALS["SL"]->REQ);
return '<br /><br /><center><h1>All Done!<br />'
. 'Taking you to <a href="' . $url . '">your finished '
. (($nID == 270) ? 'complaint' : 'compliment')
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/OpenComplaintSaves.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function saveStartTime($curr)
$date = '0000-00-00';
}
$time = $this->postFormTimeStr($curr->nID);
if ($time === null) {
if ($time === null || strlen($time) != 8) {
$date .= ' 00:00:00';
} else {
$date .= ' ' . $time;
Expand Down
16 changes: 8 additions & 8 deletions src/Controllers/OpenDashAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use App\Models\OPzComplaintReviews;
use App\Models\OPLinksComplaintOversight;
use App\Models\OPDepartments;
use App\Models\OPZeditDepartments;
use App\Models\OPZeditOversight;
use App\Models\OPzEditDepartments;
use App\Models\OPzEditOversight;
use App\Models\OPzVolunStatDays;
use App\Models\OPTesterBeta;
use SurvLoop\Controllers\Stats\SurvTrends;
Expand Down Expand Up @@ -340,10 +340,10 @@ public function volunDeptsRecent()
];
foreach ($statRanges as $i => $stat) {
$this->v["statTots"][$i] = [ $stat[0] ];
$this->v["statTots"][$i][] = OPZeditDepartments::distinct('zed_dept_user_id')
$this->v["statTots"][$i][] = OPzEditDepartments::distinct('zed_dept_user_id')
->where('zed_dept_dept_verified', '>', $stat[1])
->count();
$this->v["statTots"][$i][] = OPZeditDepartments::select('zed_dept_id')
$this->v["statTots"][$i][] = OPzEditDepartments::select('zed_dept_id')
->where('zed_dept_dept_verified', '>', $stat[1])
->count();
$overType = " `zed_over_over_type` LIKE '303'";
Expand Down Expand Up @@ -376,15 +376,15 @@ public function volunDepts()
{
$this->volunDeptsRecent();
$deptEdits = [];
$recentEdits = OPZeditDepartments::take(100)
$recentEdits = OPzEditDepartments::take(100)
->orderBy('zed_dept_dept_verified', 'desc')
->get();
if ($recentEdits->isNotEmpty()) {
foreach ($recentEdits as $i => $edit) {
$iaEdit = OPZeditOversight::where('zed_over_zed_dept_id', $edit->zed_dept_id)
$iaEdit = OPzEditOversight::where('zed_over_zed_dept_id', $edit->zed_dept_id)
->where('zed_over_over_type', 303)
->first();
$civEdit = OPZeditOversight::where('zed_over_zed_dept_id', $edit->zed_dept_id)
$civEdit = OPzEditOversight::where('zed_over_zed_dept_id', $edit->zed_dept_id)
->where('zed_over_over_type', 302)
->first();
$userObj = User::find($edit->zed_dept_user_id);
Expand Down Expand Up @@ -498,7 +498,7 @@ public function recalcVolunStats()
}
}

$edits = OPZeditOversight::where('op_z_edit_oversight.zed_over_over_type', 303)
$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',
'>', date("Y-m-d", strtotime($startDate)).' 00:00:00')
Expand Down
Loading

0 comments on commit 751b504

Please sign in to comment.