Update feature branch with develop
This commit is contained in:
@@ -1,87 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Model\OutputDocument as ModelOutputDocument;
|
||||
|
||||
class OutputDocument
|
||||
{
|
||||
/**
|
||||
* Return output documents of a project
|
||||
* @param string $sProcessUID
|
||||
* Return output documents of a project.
|
||||
* @param string $proUid
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getOutputDocuments($sProcessUID = '')
|
||||
public function getOutputDocuments($proUid = '')
|
||||
{
|
||||
try {
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_REPORT_GENERATOR);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LANDSCAPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_MEDIA);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LEFT_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_RIGHT_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TOP_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_BOTTOM_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_GENERATE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_CURRENT_REVISION);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FIELD_MAPPING);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_VERSIONING);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESTINATION_PATH);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TAGS);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_ENABLED);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OPEN_PASSWORD);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OWNER_PASSWORD);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_OPEN_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TITLE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESCRIPTION);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FILENAME);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TEMPLATE);
|
||||
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$outputDocArray = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (($aRow['OUT_DOC_TITLE'] == null) || ($aRow['OUT_DOC_TITLE'] == "")) {
|
||||
// There is no transaltion for this Document name, try to get/regenerate the label
|
||||
$outputDocument = new \OutputDocument();
|
||||
$outputDocumentObj = $outputDocument->load($aRow['OUT_DOC_UID']);
|
||||
$aRow['OUT_DOC_TITLE'] = $outputDocumentObj['OUT_DOC_TITLE'];
|
||||
$aRow['OUT_DOC_DESCRIPTION'] = $outputDocumentObj['OUT_DOC_DESCRIPTION'];
|
||||
} else {
|
||||
$outputDocArray[] = array('out_doc_uid' => $aRow['OUT_DOC_UID'],
|
||||
'out_doc_title' => $aRow['OUT_DOC_TITLE'],
|
||||
'out_doc_description' => $aRow['OUT_DOC_DESCRIPTION'],
|
||||
'out_doc_filename' => $aRow['OUT_DOC_FILENAME'],
|
||||
'out_doc_template' => $aRow['OUT_DOC_TEMPLATE'],
|
||||
'out_doc_report_generator' => $aRow['OUT_DOC_REPORT_GENERATOR'],
|
||||
'out_doc_landscape' => $aRow['OUT_DOC_LANDSCAPE'],
|
||||
'out_doc_media' => $aRow['OUT_DOC_MEDIA'],
|
||||
'out_doc_left_margin' => $aRow['OUT_DOC_LEFT_MARGIN'],
|
||||
'out_doc_right_margin' => $aRow['OUT_DOC_RIGHT_MARGIN'],
|
||||
'out_doc_top_margin' => $aRow['OUT_DOC_TOP_MARGIN'],
|
||||
'out_doc_bottom_margin' => $aRow['OUT_DOC_BOTTOM_MARGIN'],
|
||||
'out_doc_generate' => $aRow['OUT_DOC_GENERATE'],
|
||||
'out_doc_type' => $aRow['OUT_DOC_TYPE'],
|
||||
'out_doc_current_revision' => $aRow['OUT_DOC_CURRENT_REVISION'],
|
||||
'out_doc_field_mapping' => $aRow['OUT_DOC_FIELD_MAPPING'],
|
||||
'out_doc_versioning' => $aRow['OUT_DOC_VERSIONING'],
|
||||
'out_doc_destination_path' => $aRow['OUT_DOC_DESTINATION_PATH'],
|
||||
'out_doc_tags' => $aRow['OUT_DOC_TAGS'],
|
||||
'out_doc_pdf_security_enabled' => $aRow['OUT_DOC_PDF_SECURITY_ENABLED'],
|
||||
'out_doc_pdf_security_permissions' => $aRow['OUT_DOC_PDF_SECURITY_PERMISSIONS'],
|
||||
"out_doc_open_type" => $aRow["OUT_DOC_OPEN_TYPE"]);
|
||||
$result = [];
|
||||
$outputDocuments = ModelOutputDocument::select()
|
||||
->where('PRO_UID', '=', $proUid)
|
||||
->get();
|
||||
foreach ($outputDocuments as $value) {
|
||||
if (!empty($value->OUT_DOC_TITLE)) {
|
||||
$result[] = [
|
||||
'out_doc_uid' => $value->OUT_DOC_UID,
|
||||
'out_doc_title' => $value->OUT_DOC_TITLE,
|
||||
'out_doc_description' => $value->OUT_DOC_DESCRIPTION,
|
||||
'out_doc_filename' => $value->OUT_DOC_FILENAME,
|
||||
'out_doc_template' => $value->OUT_DOC_TEMPLATE,
|
||||
'out_doc_report_generator' => $value->OUT_DOC_REPORT_GENERATOR,
|
||||
'out_doc_landscape' => $value->OUT_DOC_LANDSCAPE,
|
||||
'out_doc_media' => $value->OUT_DOC_MEDIA,
|
||||
'out_doc_left_margin' => $value->OUT_DOC_LEFT_MARGIN,
|
||||
'out_doc_right_margin' => $value->OUT_DOC_RIGHT_MARGIN,
|
||||
'out_doc_top_margin' => $value->OUT_DOC_TOP_MARGIN,
|
||||
'out_doc_bottom_margin' => $value->OUT_DOC_BOTTOM_MARGIN,
|
||||
'out_doc_generate' => $value->OUT_DOC_GENERATE,
|
||||
'out_doc_type' => $value->OUT_DOC_TYPE,
|
||||
'out_doc_current_revision' => $value->OUT_DOC_CURRENT_REVISION,
|
||||
'out_doc_field_mapping' => $value->OUT_DOC_FIELD_MAPPING,
|
||||
'out_doc_versioning' => $value->OUT_DOC_VERSIONING,
|
||||
'out_doc_destination_path' => $value->OUT_DOC_DESTINATION_PATH,
|
||||
'out_doc_tags' => $value->OUT_DOC_TAGS,
|
||||
'out_doc_pdf_security_enabled' => $value->OUT_DOC_PDF_SECURITY_ENABLED,
|
||||
'out_doc_pdf_security_permissions' => $value->OUT_DOC_PDF_SECURITY_PERMISSIONS,
|
||||
'out_doc_open_type' => $value->OUT_DOC_OPEN_TYPE,
|
||||
'out_doc_header' => json_decode($value->OUT_DOC_HEADER),
|
||||
'out_doc_footer' => json_decode($value->OUT_DOC_FOOTER)
|
||||
];
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
return $outputDocArray;
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -89,83 +59,51 @@ class OutputDocument
|
||||
|
||||
/**
|
||||
* Return a single output document of a project
|
||||
* @param string $sProcessUID
|
||||
* @param string $sOutputDocumentUID
|
||||
* @param string $proUid
|
||||
* @param string $outDocUid
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getOutputDocument($sProcessUID = '', $sOutputDocumentUID = '')
|
||||
public function getOutputDocument($proUid = '', $outDocUid = '')
|
||||
{
|
||||
try {
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_REPORT_GENERATOR);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LANDSCAPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_MEDIA);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LEFT_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_RIGHT_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TOP_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_BOTTOM_MARGIN);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_GENERATE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_CURRENT_REVISION);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FIELD_MAPPING);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_VERSIONING);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESTINATION_PATH);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TAGS);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_ENABLED);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OPEN_PASSWORD);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OWNER_PASSWORD);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_OPEN_TYPE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TITLE);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESCRIPTION);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FILENAME);
|
||||
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TEMPLATE);
|
||||
$oCriteria->add(\OutputDocumentPeer::OUT_DOC_UID, $sOutputDocumentUID);
|
||||
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$outputDocArray = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (($aRow['OUT_DOC_TITLE'] == null) || ($aRow['OUT_DOC_TITLE'] == "")) {
|
||||
// There is no transaltion for this Document name, try to get/regenerate the label
|
||||
$outputDocument = new \OutputDocument();
|
||||
$outputDocumentObj = $outputDocument->load($aRow['OUT_DOC_UID']);
|
||||
$aRow['OUT_DOC_TITLE'] = $outputDocumentObj['OUT_DOC_TITLE'];
|
||||
$aRow['OUT_DOC_DESCRIPTION'] = $outputDocumentObj['OUT_DOC_DESCRIPTION'];
|
||||
} else {
|
||||
$outputDocArray = array('out_doc_uid' => $aRow['OUT_DOC_UID'],
|
||||
'out_doc_title' => $aRow['OUT_DOC_TITLE'],
|
||||
'out_doc_description' => $aRow['OUT_DOC_DESCRIPTION'],
|
||||
'out_doc_filename' => $aRow['OUT_DOC_FILENAME'],
|
||||
'out_doc_template' => $aRow['OUT_DOC_TEMPLATE'],
|
||||
'out_doc_report_generator' => $aRow['OUT_DOC_REPORT_GENERATOR'],
|
||||
'out_doc_landscape' => $aRow['OUT_DOC_LANDSCAPE'],
|
||||
'out_doc_media' => $aRow['OUT_DOC_MEDIA'],
|
||||
'out_doc_left_margin' => $aRow['OUT_DOC_LEFT_MARGIN'],
|
||||
'out_doc_right_margin' => $aRow['OUT_DOC_RIGHT_MARGIN'],
|
||||
'out_doc_top_margin' => $aRow['OUT_DOC_TOP_MARGIN'],
|
||||
'out_doc_bottom_margin' => $aRow['OUT_DOC_BOTTOM_MARGIN'],
|
||||
'out_doc_generate' => $aRow['OUT_DOC_GENERATE'],
|
||||
'out_doc_type' => $aRow['OUT_DOC_TYPE'],
|
||||
'out_doc_current_revision' => $aRow['OUT_DOC_CURRENT_REVISION'],
|
||||
'out_doc_field_mapping' => $aRow['OUT_DOC_FIELD_MAPPING'],
|
||||
'out_doc_versioning' => $aRow['OUT_DOC_VERSIONING'],
|
||||
'out_doc_destination_path' => $aRow['OUT_DOC_DESTINATION_PATH'],
|
||||
'out_doc_tags' => $aRow['OUT_DOC_TAGS'],
|
||||
'out_doc_pdf_security_enabled' => $aRow['OUT_DOC_PDF_SECURITY_ENABLED'],
|
||||
'out_doc_pdf_security_permissions' => $aRow['OUT_DOC_PDF_SECURITY_PERMISSIONS'],
|
||||
"out_doc_open_type" => $aRow["OUT_DOC_OPEN_TYPE"]);
|
||||
$result = [];
|
||||
$outputDocuments = ModelOutputDocument::select()
|
||||
->where('PRO_UID', '=', $proUid)
|
||||
->where('OUT_DOC_UID', '=', $outDocUid)
|
||||
->get();
|
||||
foreach ($outputDocuments as $value) {
|
||||
if (!empty($value->OUT_DOC_TITLE)) {
|
||||
$result = [
|
||||
'out_doc_uid' => $value->OUT_DOC_UID,
|
||||
'out_doc_title' => $value->OUT_DOC_TITLE,
|
||||
'out_doc_description' => $value->OUT_DOC_DESCRIPTION,
|
||||
'out_doc_filename' => $value->OUT_DOC_FILENAME,
|
||||
'out_doc_template' => $value->OUT_DOC_TEMPLATE,
|
||||
'out_doc_report_generator' => $value->OUT_DOC_REPORT_GENERATOR,
|
||||
'out_doc_landscape' => $value->OUT_DOC_LANDSCAPE,
|
||||
'out_doc_media' => $value->OUT_DOC_MEDIA,
|
||||
'out_doc_left_margin' => $value->OUT_DOC_LEFT_MARGIN,
|
||||
'out_doc_right_margin' => $value->OUT_DOC_RIGHT_MARGIN,
|
||||
'out_doc_top_margin' => $value->OUT_DOC_TOP_MARGIN,
|
||||
'out_doc_bottom_margin' => $value->OUT_DOC_BOTTOM_MARGIN,
|
||||
'out_doc_generate' => $value->OUT_DOC_GENERATE,
|
||||
'out_doc_type' => $value->OUT_DOC_TYPE,
|
||||
'out_doc_current_revision' => $value->OUT_DOC_CURRENT_REVISION,
|
||||
'out_doc_field_mapping' => $value->OUT_DOC_FIELD_MAPPING,
|
||||
'out_doc_versioning' => $value->OUT_DOC_VERSIONING,
|
||||
'out_doc_destination_path' => $value->OUT_DOC_DESTINATION_PATH,
|
||||
'out_doc_tags' => $value->OUT_DOC_TAGS,
|
||||
'out_doc_pdf_security_enabled' => $value->OUT_DOC_PDF_SECURITY_ENABLED,
|
||||
'out_doc_pdf_security_permissions' => $value->OUT_DOC_PDF_SECURITY_PERMISSIONS,
|
||||
'out_doc_open_type' => $value->OUT_DOC_OPEN_TYPE,
|
||||
'out_doc_header' => json_decode($value->OUT_DOC_HEADER),
|
||||
'out_doc_footer' => json_decode($value->OUT_DOC_FOOTER)
|
||||
];
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
return $outputDocArray;
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -181,6 +119,19 @@ class OutputDocument
|
||||
*/
|
||||
public function addOutputDocument($sProcessUID, $outputDocumentData)
|
||||
{
|
||||
if (empty($outputDocumentData['out_doc_header'])) {
|
||||
$outputDocumentData['out_doc_header'] = [];
|
||||
}
|
||||
if (isset($outputDocumentData['out_doc_header'])) {
|
||||
$outputDocumentData['out_doc_header'] = json_encode($outputDocumentData['out_doc_header']);
|
||||
}
|
||||
if (empty($outputDocumentData['out_doc_footer'])) {
|
||||
$outputDocumentData['out_doc_footer'] = [];
|
||||
}
|
||||
if (isset($outputDocumentData['out_doc_footer'])) {
|
||||
$outputDocumentData['out_doc_footer'] = json_encode($outputDocumentData['out_doc_footer']);
|
||||
}
|
||||
|
||||
$pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
|
||||
$pemission = explode("|", $pemission);
|
||||
foreach ($pemission as $row) {
|
||||
@@ -222,6 +173,9 @@ class OutputDocument
|
||||
}
|
||||
$outDocUid = $oOutputDocument->create($outputDocumentData);
|
||||
$outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
|
||||
$outputDocumentData['out_doc_header'] = json_decode($outputDocumentData['out_doc_header']);
|
||||
$outputDocumentData['out_doc_footer'] = json_decode($outputDocumentData['out_doc_footer']);
|
||||
|
||||
$this->updateOutputDocument($sProcessUID, $outputDocumentData, 1, $outDocUid);
|
||||
//Return
|
||||
unset($outputDocumentData["PRO_UID"]);
|
||||
@@ -244,6 +198,19 @@ class OutputDocument
|
||||
*/
|
||||
public function updateOutputDocument($sProcessUID, $outputDocumentData, $sFlag, $sOutputDocumentUID = '')
|
||||
{
|
||||
if (empty($outputDocumentData['out_doc_header'])) {
|
||||
$outputDocumentData['out_doc_header'] = [];
|
||||
}
|
||||
if (isset($outputDocumentData['out_doc_header'])) {
|
||||
$outputDocumentData['out_doc_header'] = json_encode($outputDocumentData['out_doc_header']);
|
||||
}
|
||||
if (empty($outputDocumentData['out_doc_footer'])) {
|
||||
$outputDocumentData['out_doc_footer'] = [];
|
||||
}
|
||||
if (isset($outputDocumentData['out_doc_footer'])) {
|
||||
$outputDocumentData['out_doc_footer'] = json_encode($outputDocumentData['out_doc_footer']);
|
||||
}
|
||||
|
||||
$oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME);
|
||||
$pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
|
||||
$pemission = explode("|", $pemission);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Bootstrap;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\TaskScheduler;
|
||||
|
||||
@@ -223,13 +225,14 @@ class TaskSchedulerBM
|
||||
]
|
||||
/*----------------------------------********---------------------------------*/
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the records in Schedule Table by category
|
||||
*/
|
||||
public static function getSchedule($category)
|
||||
{
|
||||
$tasks = TaskScheduler::all();
|
||||
$count = $tasks->count();
|
||||
$count = $tasks->count();
|
||||
if ($count == 0) {
|
||||
TaskSchedulerBM::generateInitialData();
|
||||
$tasks = TaskScheduler::all();
|
||||
@@ -244,6 +247,7 @@ class TaskSchedulerBM
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the record Schedule in Schedule Table
|
||||
*/
|
||||
@@ -251,55 +255,122 @@ class TaskSchedulerBM
|
||||
{
|
||||
$task = TaskScheduler::find($request['id']);
|
||||
if (isset($request['enable'])) {
|
||||
$task->enable = $request['enable'];
|
||||
$task->enable = $request['enable'];
|
||||
}
|
||||
if (isset($request['expression'])) {
|
||||
$task->expression = $request['expression'];
|
||||
$task->startingTime = $request['startingTime'];
|
||||
$task->endingTime = $request['endingTime'];
|
||||
$task->timezone = $request['timezone'];
|
||||
$task->everyOn = $request['everyOn'];
|
||||
$task->interval = $request['interval'];
|
||||
$task->startingTime = $request['startingTime'];
|
||||
$task->endingTime = $request['endingTime'];
|
||||
$task->timezone = $request['timezone'];
|
||||
$task->everyOn = $request['everyOn'];
|
||||
$task->interval = $request['interval'];
|
||||
}
|
||||
$task->save();
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial data for Schedule Table, with default values
|
||||
*/
|
||||
public static function generateInitialData()
|
||||
{
|
||||
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
$toSave = [];
|
||||
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
foreach (TaskSchedulerBM::$services as $service) {
|
||||
$task = new TaskScheduler;
|
||||
$task->title = $service["title"];
|
||||
$task->category = $service["category"];
|
||||
$task->description = $service["description"];
|
||||
$task->startingTime = $service["startingTime"];
|
||||
$task->endingTime = $service["endingTime"];
|
||||
if ($win) {
|
||||
$task->body = 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force +async';
|
||||
} else {
|
||||
$task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force +async"';
|
||||
}
|
||||
$task->expression = $service["expression"];
|
||||
$task->type = "shell";
|
||||
$task->system = 1;
|
||||
$task->enable = $service["enable"];
|
||||
$task->everyOn = $service["everyOn"];
|
||||
$task->interval = $service["interval"];
|
||||
$task->timezone = $service["timezone"] == "default" ? date_default_timezone_get() : null;
|
||||
$task->default_value = json_encode([
|
||||
"startingTime" => $service["startingTime"],
|
||||
"endingTime" => $service["endingTime"],
|
||||
"everyOn" => $service["everyOn"],
|
||||
"interval" => $service["interval"],
|
||||
"expression" => $service["expression"],
|
||||
"timezone" => $task->timezone
|
||||
]);
|
||||
$task->save();
|
||||
self::registerScheduledTask($service);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register scheduled task.
|
||||
* @param array $service
|
||||
* @return TaskScheduler
|
||||
*/
|
||||
private static function registerScheduledTask(array $service)
|
||||
{
|
||||
$task = new TaskScheduler;
|
||||
$task->title = $service["title"];
|
||||
$task->category = $service["category"];
|
||||
$task->description = $service["description"];
|
||||
$task->startingTime = $service["startingTime"];
|
||||
$task->endingTime = $service["endingTime"];
|
||||
$task->body = self::buildBody($service);
|
||||
$task->expression = $service["expression"];
|
||||
$task->type = "shell";
|
||||
$task->system = 1;
|
||||
$task->enable = $service["enable"];
|
||||
$task->everyOn = $service["everyOn"];
|
||||
$task->interval = $service["interval"];
|
||||
$task->timezone = $service["timezone"] == "default" ? date_default_timezone_get() : null;
|
||||
$task->default_value = json_encode([
|
||||
"startingTime" => $service["startingTime"],
|
||||
"endingTime" => $service["endingTime"],
|
||||
"everyOn" => $service["everyOn"],
|
||||
"interval" => $service["interval"],
|
||||
"expression" => $service["expression"],
|
||||
"timezone" => $task->timezone
|
||||
]);
|
||||
$task->save();
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build body parameter.
|
||||
* @param array $service
|
||||
* @return string
|
||||
*/
|
||||
private static function buildBody(array $service): string
|
||||
{
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
return 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force +async';
|
||||
} else {
|
||||
return 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force +async"';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check data integrity.
|
||||
* @return array
|
||||
*/
|
||||
public static function checkDataIntegrity(): array
|
||||
{
|
||||
$beforeChanges = TaskScheduler::select()->get();
|
||||
|
||||
//remove missing register
|
||||
$titleCondition = [];
|
||||
$descriptionCondition = [];
|
||||
foreach (self::$services as $service) {
|
||||
$titleCondition[] = $service['title'];
|
||||
$descriptionCondition[] = $service['description'];
|
||||
}
|
||||
TaskScheduler::whereNotIn('title', $titleCondition)
|
||||
->whereNotIn('description', $descriptionCondition)
|
||||
->delete();
|
||||
|
||||
//update register or create new register
|
||||
foreach (self::$services as $service) {
|
||||
$scheduler = TaskScheduler::select()
|
||||
->where('title', '=', $service['title'])
|
||||
->where('description', '=', $service['description'])
|
||||
->get()
|
||||
->first();
|
||||
if (is_null($scheduler)) {
|
||||
self::registerScheduledTask($service);
|
||||
} else {
|
||||
$scheduler->body = self::buildBody($service);
|
||||
$scheduler->type = 'shell';
|
||||
$scheduler->category = $service['category'];
|
||||
$scheduler->system = 1;
|
||||
$scheduler->update();
|
||||
}
|
||||
}
|
||||
|
||||
//log changes
|
||||
$afterChanges = TaskScheduler::select()->get();
|
||||
$result = [
|
||||
'beforeChanges' => $beforeChanges,
|
||||
'afterChanges' => $afterChanges
|
||||
];
|
||||
$message = 'Check SCHEDULER table integrity';
|
||||
Log::channel(':taskSchedulerCheckDataIntegrity')->info($message, Bootstrap::context($result));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
336
workflow/engine/src/ProcessMaker/PDF/BasicStruct.php
Normal file
336
workflow/engine/src/ProcessMaker/PDF/BasicStruct.php
Normal file
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
/**
|
||||
* Struct for header and footer configuration.
|
||||
*/
|
||||
trait BasicStruct
|
||||
{
|
||||
/**
|
||||
* Path to image file.
|
||||
* @var string
|
||||
*/
|
||||
private $logo = '';
|
||||
|
||||
/**
|
||||
* Width to image file, the height is calculated automatically proportional
|
||||
* to the original dimensions.
|
||||
* @var float
|
||||
*/
|
||||
private $logoWidth = 0;
|
||||
|
||||
/**
|
||||
* Position of the image with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $logoPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the image with respect to the ordinate Y since top margin.
|
||||
* @var float
|
||||
*/
|
||||
private $logoPositionY = 0;
|
||||
|
||||
/**
|
||||
* Title of the page.
|
||||
* @var string
|
||||
*/
|
||||
private $title = '';
|
||||
|
||||
/**
|
||||
* Font size of the title.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontSize = 0;
|
||||
|
||||
/**
|
||||
* Position of the title with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the title with respect to the ordinate Y since top margin.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontPositionY = 0;
|
||||
|
||||
/**
|
||||
* Indicates if the page number is displayed.
|
||||
* @var bool
|
||||
*/
|
||||
private $pageNumber = false;
|
||||
|
||||
/**
|
||||
* Alternative text to indicate the numbered page.
|
||||
* @var string
|
||||
*/
|
||||
private $pageNumberTitle = '';
|
||||
|
||||
/**
|
||||
* Indicates if the pages total is displayed.
|
||||
* @var bool
|
||||
*/
|
||||
private $pageNumberTotal = false;
|
||||
|
||||
/**
|
||||
* Position of the page number with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $pageNumberPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the page number with respect to the ordinate Y since bottom margin.
|
||||
* @var float
|
||||
*/
|
||||
private $pageNumberPositionY = 0;
|
||||
|
||||
/**
|
||||
* Get logo property.
|
||||
* @return string
|
||||
*/
|
||||
public function getLogo(): string
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoWidth property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoWidth(): float
|
||||
{
|
||||
return $this->logoWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoPositionX(): float
|
||||
{
|
||||
return $this->logoPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoPositionY(): float
|
||||
{
|
||||
return $this->logoPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title property.
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontSize property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontSize(): float
|
||||
{
|
||||
return $this->titleFontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontPositionX(): float
|
||||
{
|
||||
return $this->titleFontPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontPositionY(): float
|
||||
{
|
||||
return $this->titleFontPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumber property.
|
||||
* @return bool
|
||||
*/
|
||||
public function getPageNumber(): bool
|
||||
{
|
||||
return $this->pageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberTitle property.
|
||||
* @return string
|
||||
*/
|
||||
public function getPageNumberTitle(): string
|
||||
{
|
||||
return $this->pageNumberTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberTotal property.
|
||||
* @return bool
|
||||
*/
|
||||
public function getPageNumberTotal(): bool
|
||||
{
|
||||
return $this->pageNumberTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getPageNumberPositionX(): float
|
||||
{
|
||||
return $this->pageNumberPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getPageNumberPositionY(): float
|
||||
{
|
||||
return $this->pageNumberPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property title.
|
||||
* @param string $title
|
||||
* @return void
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontSize.
|
||||
* @param float $titleFontSize
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontSize(float $titleFontSize): void
|
||||
{
|
||||
$this->titleFontSize = $titleFontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontPositionX.
|
||||
* @param float $titleFontPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontPositionX(float $titleFontPositionX): void
|
||||
{
|
||||
$this->titleFontPositionX = $titleFontPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontPositionY.
|
||||
* @param float $titleFontPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontPositionY(float $titleFontPositionY): void
|
||||
{
|
||||
$this->titleFontPositionY = $titleFontPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logo.
|
||||
* @param string $logo
|
||||
* @return void
|
||||
*/
|
||||
public function setLogo(string $logo): void
|
||||
{
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoWidth.
|
||||
* @param float $logoWidth
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoWidth(float $logoWidth): void
|
||||
{
|
||||
$this->logoWidth = $logoWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoPositionX.
|
||||
* @param float $logoPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoPositionX(float $logoPositionX): void
|
||||
{
|
||||
$this->logoPositionX = $logoPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoPositionY.
|
||||
* @param float $logoPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoPositionY(float $logoPositionY): void
|
||||
{
|
||||
$this->logoPositionY = $logoPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumber.
|
||||
* @param bool $pageNumber
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumber(bool $pageNumber): void
|
||||
{
|
||||
$this->pageNumber = $pageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberTitle.
|
||||
* @param string $pageNumberTitle
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberTitle(string $pageNumberTitle): void
|
||||
{
|
||||
$this->pageNumberTitle = $pageNumberTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberTotal.
|
||||
* @param bool $pageNumberTotal
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberTotal(bool $pageNumberTotal): void
|
||||
{
|
||||
$this->pageNumberTotal = $pageNumberTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberPositionX.
|
||||
* @param float $pageNumberPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberPositionX(float $pageNumberPositionX): void
|
||||
{
|
||||
$this->pageNumberPositionX = $pageNumberPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberPositionY.
|
||||
* @param float $pageNumberPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberPositionY(float $pageNumberPositionY): void
|
||||
{
|
||||
$this->pageNumberPositionY = $pageNumberPositionY;
|
||||
}
|
||||
|
||||
}
|
||||
11
workflow/engine/src/ProcessMaker/PDF/FooterStruct.php
Normal file
11
workflow/engine/src/ProcessMaker/PDF/FooterStruct.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
class FooterStruct
|
||||
{
|
||||
/**
|
||||
* Using basic struct for footer properties.
|
||||
*/
|
||||
use BasicStruct;
|
||||
}
|
||||
11
workflow/engine/src/ProcessMaker/PDF/HeaderStruct.php
Normal file
11
workflow/engine/src/ProcessMaker/PDF/HeaderStruct.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
class HeaderStruct
|
||||
{
|
||||
/**
|
||||
* Using basic struct for header properties.
|
||||
*/
|
||||
use BasicStruct;
|
||||
}
|
||||
243
workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooter.php
Normal file
243
workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooter.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
use TCPDF;
|
||||
|
||||
class TCPDFHeaderFooter extends TCPDF
|
||||
{
|
||||
/**
|
||||
* Property for configure header element.
|
||||
* @var HeaderStruct
|
||||
*/
|
||||
private $headerStruct;
|
||||
|
||||
/**
|
||||
* Property for configure footer element.
|
||||
* @var FooterStruct
|
||||
*/
|
||||
private $footerStruct;
|
||||
|
||||
/**
|
||||
* Save the original margins configured in the page.
|
||||
* @var array
|
||||
*/
|
||||
private $originalMargins;
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
* @param string $orientation
|
||||
* @param string $unit
|
||||
* @param string $format
|
||||
* @param bool $unicode
|
||||
* @param string $encoding
|
||||
* @param bool $diskcache
|
||||
* @param bool $pdfa
|
||||
*/
|
||||
public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa = false)
|
||||
{
|
||||
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
|
||||
$this->headerStruct = new HeaderStruct();
|
||||
$this->footerStruct = new FooterStruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor of the class.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an object that contains the properties of the header.
|
||||
* @return HeaderStruct
|
||||
*/
|
||||
public function getHeaderStruct(): HeaderStruct
|
||||
{
|
||||
return $this->headerStruct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an object that contains the properties of the footer.
|
||||
* @return FooterStruct
|
||||
*/
|
||||
public function getFooterStruct(): FooterStruct
|
||||
{
|
||||
return $this->footerStruct;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to render the page header.
|
||||
* This method has been overwritten.
|
||||
*/
|
||||
public function Header()
|
||||
{
|
||||
$heights = [];
|
||||
$struct = $this->getHeaderStruct();
|
||||
|
||||
if (empty($this->originalMargins)) {
|
||||
$this->originalMargins = $this->getMargins();
|
||||
}
|
||||
$margins = $this->originalMargins;
|
||||
|
||||
$this->buildHeaderLogo($struct, $margins, $heights);
|
||||
$this->buildHeaderTitle($struct, $margins, $heights);
|
||||
$this->buildHeaderPageNumber($struct, $margins, $heights);
|
||||
|
||||
//page adjust
|
||||
$newHeight = max($heights);
|
||||
$this->SetTopMargin($newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header logo.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderLogo(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
$path = $struct->getLogo();
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageSize = getimagesize($path);
|
||||
$extension = $pathinfo['extension'];
|
||||
$x = $struct->getLogoPositionX() + $margins['left'];
|
||||
$y = $struct->getLogoPositionY() + $margins['top'];
|
||||
$width = $struct->getLogoWidth();
|
||||
$this->Image($path, $x, $y, $width, 0, $extension, '', '', false, 300, '', false, false, 0, false, false, false);
|
||||
$newImageHeight = ($width * $imageSize[1] / $imageSize[0]);
|
||||
$heights[] = $margins['top'] + $newImageHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header title.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderTitle(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
$string = $struct->getTitle();
|
||||
$x = $struct->getTitleFontPositionX() + $margins['left'];
|
||||
$y = $struct->getTitleFontPositionY() + $margins['top'];
|
||||
$fontSize = $struct->getTitleFontSize();
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'B', $fontSize);
|
||||
$this->MultiCell(0, 0, $string, 0, 'L', false, 1, '', '', true, 0, false, true, 0, 'T', false);
|
||||
$heights[] = $margins['top'] + ($this->getCellHeight($fontSize, false)) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header page number.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderPageNumber(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
if ($struct->getPageNumber() === true) {
|
||||
$pageString = empty($struct->getPageNumberTitle()) ? 'Page ' : $struct->getPageNumberTitle() . ' ';
|
||||
$pageNumberTotal = $struct->getPageNumberTotal() === true ? ' / ' . $this->getAliasNbPages() : '';
|
||||
$string = $pageString . $this->getAliasNumPage() . $pageNumberTotal;
|
||||
$x = $struct->getPageNumberPositionX() + $margins['left'];
|
||||
$y = $struct->getPageNumberPositionY() + $margins['top'];
|
||||
$fontSize = 8;
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'I', $fontSize);
|
||||
$this->Cell(0, 0, $string, 0, 0, '', false, '', 0, false, 'T', 'M');
|
||||
$heights[] = $margins['top'] + ($this->getCellHeight($fontSize, false)) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to render the page footer.
|
||||
* This method has been overwritten.
|
||||
*/
|
||||
public function Footer()
|
||||
{
|
||||
$struct = $this->getFooterStruct();
|
||||
|
||||
if (empty($this->originalMargins)) {
|
||||
$this->originalMargins = $this->getMargins();
|
||||
}
|
||||
$margins = $this->originalMargins;
|
||||
|
||||
//page adjust
|
||||
$bottom = $margins['bottom'] <= 0 ? 1 : $margins['bottom'];
|
||||
$this->SetY(-1 * $bottom);
|
||||
$currentY = $this->GetY();
|
||||
|
||||
$this->buildFooterLogo($margins, $currentY, $struct);
|
||||
$this->buildFooterTitle($margins, $currentY, $struct);
|
||||
$this->buildFooterPageNumber($margins, $currentY, $struct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer logo.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterLogo(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
$path = $struct->getLogo();
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
$pathinfo = pathinfo($path);
|
||||
$extension = $pathinfo['extension'];
|
||||
$x = $struct->getLogoPositionX() + $margins['left'];
|
||||
$y = $struct->getLogoPositionY() + $currentY;
|
||||
$width = $struct->getLogoWidth();
|
||||
$this->Image($path, $x, $y, $width, 0, $extension, '', '', false, 300, '', false, false, 0, false, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer title.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterTitle(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
$string = $struct->getTitle();
|
||||
$x = $struct->getTitleFontPositionX() + $margins['left'];
|
||||
$y = $struct->getTitleFontPositionY() + $currentY;
|
||||
$fontSize = $struct->getTitleFontSize();
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'B', $fontSize);
|
||||
$this->MultiCell(0, 0, $string, 0, 'L', false, 1, '', '', true, 0, false, true, 0, 'T', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer page number.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterPageNumber(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
if ($struct->getPageNumber() === true) {
|
||||
$pageString = empty($struct->getPageNumberTitle()) ? 'Page ' : $struct->getPageNumberTitle() . ' ';
|
||||
$pageNumberTotal = $struct->getPageNumberTotal() === true ? ' / ' . $this->getAliasNbPages() : '';
|
||||
$string = $pageString . $this->getAliasNumPage() . $pageNumberTotal;
|
||||
$x = $struct->getPageNumberPositionX() + $margins['left'];
|
||||
$y = $struct->getPageNumberPositionY() + $currentY;
|
||||
$fontSize = 8;
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'I', $fontSize);
|
||||
$this->Cell(0, 0, $string, 0, 0, '', false, '', 0, false, 'T', 'M');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
use G;
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Group as BmGroup;
|
||||
use ProcessMaker\BusinessModel\User;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
* Group Api Controller
|
||||
@@ -19,14 +23,13 @@ class Group extends Api
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$user = new \ProcessMaker\BusinessModel\User();
|
||||
|
||||
$user = new User();
|
||||
$usrUid = $this->getUserId();
|
||||
|
||||
if (!$user->checkPermission($usrUid, "PM_USERS")) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", array($usrUid)));
|
||||
// Review the permissions roles to access the API
|
||||
if (!$user->checkPermission($usrUid, "PM_USERS") && !$user->checkPermission($usrUid, "PM_FACTORY")) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", [$usrUid]));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -37,19 +40,17 @@ class Group extends Api
|
||||
public function index($filter = null, $lfilter = null, $rfilter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayFilterData = array(
|
||||
$arrayFilterData = [
|
||||
"filter" => (!is_null($filter))? $filter : ((!is_null($lfilter))? $lfilter : ((!is_null($rfilter))? $rfilter : null)),
|
||||
"filterOption" => (!is_null($filter))? "" : ((!is_null($lfilter))? "LEFT" : ((!is_null($rfilter))? "RIGHT" : ""))
|
||||
);
|
||||
|
||||
];
|
||||
$response = $group->getGroups($arrayFilterData, null, null, $start, $limit);
|
||||
|
||||
return $response["data"];
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +62,13 @@ class Group extends Api
|
||||
public function doGet($grp_uid)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = $group->getGroup($grp_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,16 +89,14 @@ class Group extends Api
|
||||
public function doPost($request_data)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayData = $group->create($request_data);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,12 +116,11 @@ class Group extends Api
|
||||
public function doPut($grp_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayData = $group->update($grp_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,12 +134,11 @@ class Group extends Api
|
||||
public function doDelete($grp_uid)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$group->delete($grp_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,14 +150,13 @@ class Group extends Api
|
||||
public function doGetUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = $group->getUsers("USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
||||
$response = $group->getUsers("USERS", $grp_uid, ["filter" => $filter], null, null, $start, $limit);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,14 +168,13 @@ class Group extends Api
|
||||
public function doGetAvailableUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = $group->getUsers("AVAILABLE-USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
||||
$response = $group->getUsers("AVAILABLE-USERS", $grp_uid, ["filter" => $filter], null, null, $start, $limit);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,14 +186,13 @@ class Group extends Api
|
||||
public function doGetSupervisorUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$group = new \ProcessMaker\BusinessModel\Group();
|
||||
$group = new BmGroup();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = $group->getUsers("SUPERVISOR", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
||||
$response = $group->getUsers("SUPERVISOR", $grp_uid, ["filter" => $filter], null, null, $start, $limit);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,5 +243,15 @@ class OutputDocumentStructure
|
||||
* @var int {@from body} {@choice 0,1}
|
||||
*/
|
||||
public $out_doc_open_type;
|
||||
|
||||
/**
|
||||
* @var array {@from body}
|
||||
*/
|
||||
public $out_doc_header;
|
||||
|
||||
/**
|
||||
* @var array {@from body}
|
||||
*/
|
||||
public $out_doc_footer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user