PMCORE-4084 Supervisor > multiple step > Previous and Next step buttons are not displayed

This commit is contained in:
Roly Gutierrez
2022-12-15 12:47:29 -04:00
parent 6e80a9e2f5
commit afb94f2234
9 changed files with 267 additions and 57 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use App\Factories\Factory;
class StepSupervisorFactory extends Factory
{
public function definition()
{
return [
'STEP_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"),
'PRO_UID' => function () {
return \ProcessMaker\Model\Process::factory()->create()->PRO_UID;
},
'STEP_TYPE_OBJ' => 'DYNAFORM',
'STEP_UID_OBJ' => function () {
return \ProcessMaker\Model\Dynaform::factory()->create()->DYN_UID;
},
'STEP_POSITION' => 1
];
}
}

View File

@@ -1,8 +1,11 @@
<?php <?php
use Faker\Factory; use Faker\Factory;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Dynaform; use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\InputDocument;
use ProcessMaker\Model\Process; use ProcessMaker\Model\Process;
use ProcessMaker\Model\StepSupervisor;
use Tests\TestCase; use Tests\TestCase;
/** /**
@@ -1203,6 +1206,39 @@ class PmDynaformTest extends TestCase
// Session variable for "USER_LOGGED" should be empty // Session variable for "USER_LOGGED" should be empty
$this->assertTrue(empty($_SESSION['USER_LOGGED'])); $this->assertTrue(empty($_SESSION['USER_LOGGED']));
} }
/**
* @test
* @covers PmDynaform::navigationBarForStepsToRevise
*/
public function it_should_test_navigationBarForStepsToRevise()
{
//definition data
$dynaform = Dynaform::factory()->create();
$inputDocument = InputDocument::factory()->create();
$application = Application::factory()->create([
'PRO_UID' => $dynaform->PRO_UID
]);
StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'DYNAFORM',
'STEP_UID_OBJ' => $dynaform->DYN_UID
]);
StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'DYNAFORM',
'STEP_UID_OBJ' => $dynaform->DYN_UID
]);
StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT',
'STEP_UID_OBJ' => $inputDocument->INP_DOC_UID
]);
//assertion
$result = PmDynaform::navigationBarForStepsToRevise($application->APP_UID, $dynaform->DYN_UID, 2);
$this->assertNotEmpty($result);
}
} }
// Dummy function used for the coverture // Dummy function used for the coverture

View File

@@ -8,13 +8,16 @@ use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\AppDelay; use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Documents; use ProcessMaker\Model\Documents;
use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf; use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\InputDocument;
use ProcessMaker\Model\ListUnassigned; use ProcessMaker\Model\ListUnassigned;
use ProcessMaker\Model\Process; use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessUser; use ProcessMaker\Model\ProcessUser;
use ProcessMaker\Model\Step; use ProcessMaker\Model\Step;
use ProcessMaker\Model\StepSupervisor;
use ProcessMaker\Model\Task; use ProcessMaker\Model\Task;
use ProcessMaker\Model\Triggers; use ProcessMaker\Model\Triggers;
use ProcessMaker\Model\User; use ProcessMaker\Model\User;
@@ -534,4 +537,59 @@ class CasesTest extends TestCase
// Asserts // Asserts
$this->assertCount(3, $result['data']); $this->assertCount(3, $result['data']);
} }
/**
* This test the method getStepsToRevise.
* @test
* @covers ProcessMaker\BusinessModel\Cases::getStepsToRevise
*/
public function it_should_test_getStepsToRevise()
{
//definition data
$dynaform = Dynaform::factory()->create();
$application = Application::factory()->create([
'PRO_UID' => $dynaform->PRO_UID
]);
$stepSupervisor = StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'DYNAFORM',
'STEP_UID_OBJ' => $dynaform->DYN_UID
]);
//assertion
$cases = new Cases();
$result = $cases->getStepsToRevise($application->APP_UID, 'DYNAFORM');
$this->assertEquals($stepSupervisor->PRO_UID, $result[0]['PRO_UID']);
}
/**
* This test the method getAllUrlStepsToRevise.
* @test
* @covers ProcessMaker\BusinessModel\Cases::getAllUrlStepsToRevise
*/
public function it_should_test_getAllUrlStepsToRevise()
{
//definition data
$dynaform = Dynaform::factory()->create();
$inputDocument = InputDocument::factory()->create();
$application = Application::factory()->create([
'PRO_UID' => $dynaform->PRO_UID
]);
$stepSupervisor = StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'DYNAFORM',
'STEP_UID_OBJ' => $dynaform->DYN_UID
]);
$stepSupervisor = StepSupervisor::factory()->create([
'PRO_UID' => $application->PRO_UID,
'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT',
'STEP_UID_OBJ' => $inputDocument->INP_DOC_UID
]);
//assertion
$cases = new Cases();
$result = $cases->getAllUrlStepsToRevise($application->APP_UID, 2);
$this->assertEquals($dynaform->DYN_UID, $result[0]['uid']);
$this->assertEquals($inputDocument->INP_DOC_UID, $result[1]['uid']);
}
} }

View File

@@ -1377,8 +1377,16 @@ class PmDynaform
exit(); exit();
} }
public function printEditSupervisor() /**
* Print edit supervisor forms.
* @param array $param
*/
public function printEditSupervisor(array $param = [])
{ {
$navbar = '';
if (isset($param['DEL_INDEX'])) {
$navbar = self::navigationBarForStepsToRevise($this->fields["APP_UID"], $this->fields["CURRENT_DYNAFORM"], $param['DEL_INDEX']);
}
ob_clean(); ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]); $json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json); $this->jsonr($json);
@@ -1405,6 +1413,7 @@ class PmDynaform
" . $this->getTheStringVariableForGoogleMaps() . " " . $this->getTheStringVariableForGoogleMaps() . "
</script> </script>
<script type=\"text/javascript\" src=\"/jscore/cases/core/pmDynaform.js\"></script> <script type=\"text/javascript\" src=\"/jscore/cases/core/pmDynaform.js\"></script>
{$navbar}
<div> <div>
" . $this->getSessionMessageForSupervisor() . " " . $this->getSessionMessageForSupervisor() . "
<div style=\"display: none;\"> <div style=\"display: none;\">
@@ -2629,4 +2638,46 @@ class PmDynaform
} }
}; };
} }
/**
* Get html navigation bar for steps to revise.
* @param string $appUid
* @param string $dynUid
* @param int $delIndex
* @return string
*/
public static function navigationBarForStepsToRevise(string $appUid, string $dynUid, int $delIndex): string
{
$navbar = '';
$cases = new Cases();
$steps = $cases->getAllUrlStepsToRevise($appUid, $delIndex);
$n = count($steps);
foreach ($steps as $key => $step) {
if ($step['uid'] === $dynUid) {
$previousLabel = '';
$previousUrl = '';
$nextLabel = '';
$nextUrl = '';
if ($key - 1 >= 0) {
$previousLabel = G::LoadTranslation('ID_PREVIOUS');
$previousUrl = $steps[$key - 1]['url'];
}
if ($key + 1 < $n) {
$nextLabel = G::LoadTranslation('ID_NEXT');
$nextUrl = $steps[$key + 1]['url'];
}
$navbar = "<div style='width:100%;padding:0px 10px 0px 10px;margin:15px 0px 0px 0px;'>" .
" <img src='/images/bulletButtonLeft.gif' style='float:left;'>&nbsp;" .
" <a href='{$previousUrl}' style='float:left;font-size:12px;line-height:1;margin:0px 0px 1px 5px;text-decoration:none;!important;'>" .
" {$previousLabel}" .
" </a>" .
" <img src='/images/bulletButton.gif' style='float:right;'>&nbsp;" .
" <a href='{$nextUrl}' style='float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;text-decoration:none;!important;'>" .
" {$nextLabel}" .
" </a>" .
"</div>";
}
}
return $navbar;
}
} }

View File

@@ -1,28 +1,4 @@
<?php <?php
/**
* cases_Step.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
// die("first");
/* Permissions */
$filter = new InputFilter(); $filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET, "url"); $_GET = $filter->xssFilterHard($_GET, "url");
@@ -151,7 +127,7 @@ if ($_GET['DYN_UID'] != '') {
$FieldsPmDynaform["CURRENT_DYNAFORM"] = $_GET['DYN_UID']; $FieldsPmDynaform["CURRENT_DYNAFORM"] = $_GET['DYN_UID'];
$a = new PmDynaform($FieldsPmDynaform); $a = new PmDynaform($FieldsPmDynaform);
if ($a->isResponsive()) { if ($a->isResponsive()) {
$a->printEditSupervisor(); $a->printEditSupervisor(['DEL_INDEX' => $_GET['DEL_INDEX']]);
} else { } else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_GET['DYN_UID'], '', $Fields['APP_DATA'], 'cases_SaveDataSupervisor?UID=' . $_GET['DYN_UID'] . '&ex=' . $_GET['ex']); $G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_GET['DYN_UID'], '', $Fields['APP_DATA'], 'cases_SaveDataSupervisor?UID=' . $_GET['DYN_UID'] . '&ex=' . $_GET['ex']);
} }

View File

@@ -1,28 +1,4 @@
<?php <?php
/**
* cases_Step.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
//die("second");
/* Permissions */
$filter = new InputFilter(); $filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET, "url"); $_GET = $filter->xssFilterHard($_GET, "url");
@@ -119,13 +95,8 @@ if (! isset($_GET['INP_DOC_UID'])) {
$Fields['MESSAGE2'] = G::LoadTranslation('ID_PLEASE_SELECT_FILE'); $Fields['MESSAGE2'] = G::LoadTranslation('ID_PLEASE_SELECT_FILE');
$docName = $Fields['INP_DOC_TITLE']; $docName = $Fields['INP_DOC_TITLE'];
$oHeadPublisher->addScriptCode('var documentName=\'Reviewing Input Document<br>' . $docName . '\';'); $oHeadPublisher->addScriptCode('var documentName=\'Reviewing Input Document<br>' . $docName . '\';');
// $G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', $Fields, 'cases_SupervisorSaveDocument?UID=' . $G_PUBLISH->AddContent('view','cases/paged-table-inputDocumentsToReviseNavBar');
//$_GET['INP_DOC_UID'] . '&APP_UID=' . $_GET['APP_UID'] . '&position=' . $_GET['position']); $G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocumentsToRevise', 'cases/cases_ToReviseInputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['INP_DOC_UID']), array_merge(['DOC_UID' => $_GET['INP_DOC_UID']], $Fields));
$G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocumentsToRevise', 'cases/cases_ToReviseInputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['INP_DOC_UID']), array_merge(array('DOC_UID' => $_GET['INP_DOC_UID']
), $Fields));
//$aFields
// $G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList',
//$oCase->getInputDocumentsCriteria($_SESSION['APPLICATION']));//$aFields
} }
G::RenderPage('publish', 'blank'); G::RenderPage('publish', 'blank');

View File

@@ -58,6 +58,7 @@ use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\ListUnassigned; use ProcessMaker\Model\ListUnassigned;
use ProcessMaker\Model\Triggers; use ProcessMaker\Model\Triggers;
use ProcessMaker\Model\ProcessUser; use ProcessMaker\Model\ProcessUser;
use ProcessMaker\Model\StepSupervisor;
use ProcessMaker\Model\Task; use ProcessMaker\Model\Task;
use ProcessMaker\Model\User; use ProcessMaker\Model\User;
use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Plugins\PluginRegistry;
@@ -4388,4 +4389,70 @@ class Cases
// Return results // Return results
return $dynaForms; return $dynaForms;
} }
/**
* Get objects that they have send it.
* @param string $appUid
* @param string $typeObject
* @return array
*/
public function getStepsToRevise(string $appUid, string $typeObject): array
{
$application = ModelApplication::where('APP_UID', '=', $appUid)
->first();
$result = StepSupervisor::where('PRO_UID', '=', $application['PRO_UID'])->
where('STEP_TYPE_OBJ', '=', $typeObject)->
orderBy('STEP_POSITION', 'ASC')->
get()->
toArray();
return $result;
}
/**
* Get all url steps to revise.
* @param string $appUid
* @param int $delIndex
* @return array
*/
public function getAllUrlStepsToRevise(string $appUid, int $delIndex): array
{
$result = [];
$dynaformStep = $this->getStepsToRevise($appUid, 'DYNAFORM');
$i = 0;
foreach ($dynaformStep as $step) {
$url = "cases_StepToRevise?"
. "type=DYNAFORM&"
. "ex={$i}&"
. "PRO_UID={$step["PRO_UID"]}&"
. "DYN_UID={$step['STEP_UID_OBJ']}&"
. "APP_UID={$appUid}&"
. "position={$step['STEP_POSITION']}&"
. "DEL_INDEX={$delIndex}";
$result[] = [
'uid' => $step['STEP_UID_OBJ'],
'url' => $url
];
$i++;
}
$inputDocumentStep = $this->getStepsToRevise($appUid, 'INPUT_DOCUMENT');
$i = 0;
foreach ($inputDocumentStep as $step) {
$url = "cases_StepToReviseInputs?"
. "type=INPUT_DOCUMENT&"
. "ex={$i}&"
. "PRO_UID={$step["PRO_UID"]}&"
. "INP_DOC_UID={$step['STEP_UID_OBJ']}&"
. "APP_UID={$appUid}&"
. "position={$step['STEP_POSITION']}&"
. "DEL_INDEX={$delIndex}";
$result[] = [
'uid' => $step['STEP_UID_OBJ'],
'url' => $url
];
$i++;
}
return $result;
}
} }

View File

@@ -0,0 +1,17 @@
<?php
namespace ProcessMaker\Model;
use App\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StepSupervisor extends Model
{
use HasFactory;
protected $table = 'STEP_SUPERVISOR';
protected $primaryKey = 'STEP_UID';
public $incrementing = false;
public $timestamps = false;
}

View File

@@ -0,0 +1,11 @@
<?php
$navbar = PmDynaform::navigationBarForStepsToRevise($_GET['APP_UID'], $_GET['INP_DOC_UID'], $_GET['DEL_INDEX']);
echo '<div class="pagedTableDefault" style="border:none;margin:0px;padding:0px;margin-right:20px;margin-top:-3px;">'
. '<div class="headerContent" style="border:none;margin:0px;padding:0px;">'
. '<div class="tableOption" style="border:none;margin:0px;padding:0px;">'
. $navbar
. '</div>'
. '</div>'
. '</div>';