Merged in feature/PMCORE-2559 (pull request #7627)
PMCORE-2559 Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
@@ -2110,8 +2110,8 @@ class Cases
|
||||
}
|
||||
|
||||
$note_content = addslashes($note_content);
|
||||
$appNote = new \AppNotes();
|
||||
$appNote->addCaseNote($app_uid, $usr_uid, $note_content, intval($send_mail));
|
||||
// Define the Case for register a case note
|
||||
$response = $this->addNote($app_uid, $usr_uid, $note_content, intval($send_mail));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3869,14 +3869,28 @@ class Cases
|
||||
* @param string $note
|
||||
* @param bool $sendMail
|
||||
* @param array $files
|
||||
* @param int $appNUmber
|
||||
*
|
||||
* @see Ajax::cancelCase()
|
||||
* @see Ajax::pauseCase()
|
||||
* @see Ajax::reassignCase()
|
||||
* @see AppProxy::postNote()
|
||||
* @see WsBase::addCaseNote()
|
||||
* @see Cases::saveCaseNote()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function addNote($appUid, $userUid, $note, $sendMail = false, $files = [])
|
||||
public function addNote($appUid, $userUid, $note, $sendMail = false, $files = [], $appNumber = 0)
|
||||
{
|
||||
// Get the appNumber if was not send
|
||||
if ($appNumber === 0) {
|
||||
$appNumber = ModelApplication::getCaseNumber($appUid);
|
||||
}
|
||||
|
||||
// Register the note
|
||||
$attributes = [
|
||||
"APP_UID" => $appUid,
|
||||
"APP_NUMBER" => $appNumber,
|
||||
"USR_UID" => $userUid,
|
||||
"NOTE_DATE" => date("Y-m-d H:i:s"),
|
||||
"NOTE_CONTENT" => $note,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppNotes;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Task;
|
||||
|
||||
@@ -164,8 +165,8 @@ class Participated extends AbstractCases
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// todo: we will to complete the real count with other ticket
|
||||
$item['CASE_NOTES_COUNT'] = 0;
|
||||
// Get total case notes
|
||||
$item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']);
|
||||
// Define data according to the filters
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
@@ -178,8 +179,8 @@ class Participated extends AbstractCases
|
||||
$result[$i]['tas_title'] = $thread['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $thread['USR_ID'];
|
||||
$result[$i]['due_date'] = $thread['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$i++;
|
||||
}
|
||||
$item['PENDING'] = $result;
|
||||
@@ -187,8 +188,8 @@ class Participated extends AbstractCases
|
||||
$result[$i]['tas_title'] = $item['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $item['USR_ID'];
|
||||
$result[$i]['due_date'] = $item['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$item['PENDING'] = $result;
|
||||
}
|
||||
break;
|
||||
@@ -205,8 +206,8 @@ class Participated extends AbstractCases
|
||||
$result[$i]['tas_title'] = $item['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $item['USR_ID'];
|
||||
$result[$i]['due_date'] = $item['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$item['PENDING'] = $result;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppNotes;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
@@ -177,8 +178,8 @@ class Search extends AbstractCases
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// todo: we will to complete the real count with other ticket
|
||||
$item['CASE_NOTES_COUNT'] = 0;
|
||||
// Get total case notes
|
||||
$item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']);
|
||||
// Get the detail related to the open thread
|
||||
if (!empty($item['THREADS'])) {
|
||||
$result = $this->prepareTaskPending($item['THREADS'], false);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\AppNotes;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\ProcessUser;
|
||||
|
||||
@@ -154,8 +155,8 @@ class Supervising extends AbstractCases
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// todo: we will to complete the real count with other ticket
|
||||
$item['CASE_NOTES_COUNT'] = 0;
|
||||
// Get total case notes
|
||||
$item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']);
|
||||
// Get the detail related to the open thread
|
||||
if (!empty($item['PENDING'])) {
|
||||
$result = $this->prepareTaskPending($item['PENDING']);
|
||||
|
||||
@@ -34,6 +34,7 @@ class AppNotes extends Model
|
||||
*/
|
||||
protected $fillable = [
|
||||
'APP_UID',
|
||||
'APP_NUMBER',
|
||||
'USR_UID',
|
||||
'NOTE_DATE',
|
||||
'NOTE_CONTENT',
|
||||
@@ -57,6 +58,18 @@ class AppNotes extends Model
|
||||
return $query->where('APP_UID', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific case id
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appNumber
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAppNumber($query, int $appNumber)
|
||||
{
|
||||
return $query->where('APP_NUMBER', $appNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the documents related to the case
|
||||
*
|
||||
@@ -72,6 +85,7 @@ class AppNotes extends Model
|
||||
$query = AppNotes::query()->select([
|
||||
'NOTE_ID',
|
||||
'APP_UID',
|
||||
'APP_NUMBER',
|
||||
'NOTE_DATE',
|
||||
'NOTE_CONTENT',
|
||||
'NOTE_TYPE',
|
||||
@@ -106,7 +120,7 @@ class AppNotes extends Model
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return array
|
||||
* @return int
|
||||
*/
|
||||
public static function getTotal(string $appUid)
|
||||
{
|
||||
@@ -116,4 +130,19 @@ class AppNotes extends Model
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total notes by case
|
||||
*
|
||||
* @param int $appNumber
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function total(int $appNumber)
|
||||
{
|
||||
$query = AppNotes::query()->select(['NOTE_ID']);
|
||||
$query->appNumber($appNumber);
|
||||
|
||||
return $query->get()->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,27 @@ class Application extends Model
|
||||
return $firstElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app number
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getCaseNumber($appUid)
|
||||
{
|
||||
$query = Application::query()->select(['APP_NUMBER'])
|
||||
->appUid($appUid)
|
||||
->limit(1);
|
||||
$results = $query->get();
|
||||
$caseNumber = 0;
|
||||
$results->each(function ($item) use (&$caseNumber) {
|
||||
$caseNumber = $item->APP_NUMBER;
|
||||
});
|
||||
|
||||
return $caseNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties
|
||||
*
|
||||
@@ -164,6 +185,6 @@ class Application extends Model
|
||||
->statusId($status)
|
||||
->positivesCases();
|
||||
|
||||
return $query->get()->count();
|
||||
return $query->get()->count(['APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user