HOR-1101: Batch reassignment
. validacion USR_UID correccion observacion soporte multiple plugins
This commit is contained in:
@@ -432,6 +432,23 @@ class PMPlugin
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* callBack File on reassign
|
||||||
|
*
|
||||||
|
* @param string $callBackFile
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerOpenReassignCallback($callBackFile = '')
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||||
|
$oPluginRegistry->registerOpenReassignCallback($callBackFile);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class menuDetail
|
class menuDetail
|
||||||
@@ -788,4 +805,20 @@ class importCallBack
|
|||||||
$this->namespace = $namespace;
|
$this->namespace = $namespace;
|
||||||
$this->callBackFile = $callBackFile;
|
$this->callBackFile = $callBackFile;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OpenReassignCallback
|
||||||
|
{
|
||||||
|
public $callBackFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is the constructor of the cronFile class
|
||||||
|
* param string $namespace
|
||||||
|
* param string $callBackFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($callBackFile)
|
||||||
|
{
|
||||||
|
$this->callBackFile = $callBackFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +104,7 @@ class PMPluginRegistry
|
|||||||
private $_arrayDesignerMenu = array();
|
private $_arrayDesignerMenu = array();
|
||||||
private $_aMenuOptionsToReplace = array ();
|
private $_aMenuOptionsToReplace = array ();
|
||||||
private $_aImportProcessCallbackFile = array ();
|
private $_aImportProcessCallbackFile = array ();
|
||||||
|
private $_aOpenReassignCallback = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry a plugin javascript to include with js core at same runtime
|
* Registry a plugin javascript to include with js core at same runtime
|
||||||
@@ -413,7 +414,10 @@ class PMPluginRegistry
|
|||||||
if(sizeof( $this->_aImportProcessCallbackFile )){
|
if(sizeof( $this->_aImportProcessCallbackFile )){
|
||||||
unset( $this->_aImportProcessCallbackFile );
|
unset( $this->_aImportProcessCallbackFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sizeof( $this->_aOpenReassignCallback )){
|
||||||
|
unset( $this->_aOpenReassignCallback );
|
||||||
|
}
|
||||||
//unregistering javascripts from this plugin
|
//unregistering javascripts from this plugin
|
||||||
$this->unregisterJavascripts( $sNamespace );
|
$this->unregisterJavascripts( $sNamespace );
|
||||||
//unregistering rest services from this plugin
|
//unregistering rest services from this plugin
|
||||||
@@ -1748,5 +1752,42 @@ class PMPluginRegistry
|
|||||||
{
|
{
|
||||||
return $this->_aImportProcessCallbackFile;
|
return $this->_aImportProcessCallbackFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callBackFile in the singleton
|
||||||
|
*
|
||||||
|
* @param string $callBackFile
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerOpenReassignCallback ($callBackFile)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$found = false;
|
||||||
|
foreach ($this->_aOpenReassignCallback as $row => $detail) {
|
||||||
|
if ($callBackFile == $detail->callBackFile) {
|
||||||
|
$detail->callBackFile = $callBackFile;
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
$callBackFile = new OpenReassignCallback( $callBackFile );
|
||||||
|
$this->_aOpenReassignCallback[] = $callBackFile;
|
||||||
|
}
|
||||||
|
} catch(Excepton $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all callBackFiles registered
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getOpenReassignCallback()
|
||||||
|
{
|
||||||
|
return $this->_aOpenReassignCallback;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,22 @@ $oHeadPublisher->assign('extJsViewState', $oHeadPublisher->getExtJsViewState());
|
|||||||
$oHeadPublisher->assign('isIE', Bootstrap::isIE());
|
$oHeadPublisher->assign('isIE', Bootstrap::isIE());
|
||||||
$oHeadPublisher->assign('__OPEN_APPLICATION_UID__', $openApplicationUid);
|
$oHeadPublisher->assign('__OPEN_APPLICATION_UID__', $openApplicationUid);
|
||||||
|
|
||||||
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||||
|
$fromPlugin = $oPluginRegistry->getOpenReassignCallback();
|
||||||
|
$jsFunction = false;
|
||||||
|
if(sizeof($fromPlugin)) {
|
||||||
|
foreach($fromPlugin as $key => $jsFile) {
|
||||||
|
$jsFile = $jsFile->callBackFile;
|
||||||
|
if(is_file($jsFile)) {
|
||||||
|
$jsFile = file_get_contents($jsFile);
|
||||||
|
if(!empty($jsFile)) {
|
||||||
|
$jsFunction[] = $jsFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$oHeadPublisher->assign( 'openReassignCallback', $jsFunction );
|
||||||
|
|
||||||
G::RenderPage( 'publish', 'extJs' );
|
G::RenderPage( 'publish', 'extJs' );
|
||||||
|
|
||||||
function getUserArray ($action, $userUid)
|
function getUserArray ($action, $userUid)
|
||||||
|
|||||||
@@ -2905,5 +2905,53 @@ class Cases
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch reassign
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* return json Return an json with the result of the reassigned cases.
|
||||||
|
*/
|
||||||
|
public function doPostReassign($data)
|
||||||
|
{
|
||||||
|
if(!is_array($data)) {
|
||||||
|
$isJson = is_string($data) && is_array(G::json_decode($data, true)) ? true : false;
|
||||||
|
if($isJson) {
|
||||||
|
$data = G::json_decode($data, true);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataResponse = $data;
|
||||||
|
|
||||||
|
G::LoadClass( 'case' );
|
||||||
|
$oCases = new \Cases();
|
||||||
|
$appDelegation = new \AppDelegation();
|
||||||
|
$casesToReassign = $data['cases'];
|
||||||
|
if(sizeof($casesToReassign)) {
|
||||||
|
foreach($casesToReassign as $key => $val) {
|
||||||
|
$usrUid = '';
|
||||||
|
if(array_key_exists('USR_UID', $val)) {
|
||||||
|
if($val['USR_UID'] != '') {
|
||||||
|
$usrUid = $val['USR_UID'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($usrUid == '') {
|
||||||
|
$fields = $appDelegation->load($val['APP_UID'], $val['DEL_INDEX']);
|
||||||
|
$usrUid = $fields['USR_UID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$reassigned = $oCases->reassignCase($val['APP_UID'], $val['DEL_INDEX'], $usrUid, $data['usr_uid_target']);
|
||||||
|
$result = $reassigned ? 1 : 0 ;
|
||||||
|
$dataResponse['cases'][$key]['result'] = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($dataResponse['usr_uid_target']);
|
||||||
|
|
||||||
|
return G::json_encode($dataResponse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1150,4 +1150,20 @@ class Cases extends Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch reassign
|
||||||
|
* @url POST /reassign
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function doPostReassign($request_data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$case = new \ProcessMaker\BusinessModel\Cases();
|
||||||
|
$response = $case->doPostReassign($request_data);
|
||||||
|
return $response;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1150,6 +1150,13 @@ Ext.onReady ( function() {
|
|||||||
// text: 'Reassign',
|
// text: 'Reassign',
|
||||||
// text: TRANSLATIONS.LABEL_UNSELECT_ALL,
|
// text: TRANSLATIONS.LABEL_UNSELECT_ALL,
|
||||||
handler: function(){
|
handler: function(){
|
||||||
|
if(openReassignCallback) {
|
||||||
|
for(var key in openReassignCallback){
|
||||||
|
var callbackFunction = new Function(openReassignCallback[key]);
|
||||||
|
callbackFunction.call();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
reassign();
|
reassign();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -2591,3 +2598,4 @@ Ext.EventManager.on(window, 'beforeunload', function () {
|
|||||||
casesNewTab.close();
|
casesNewTab.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
| ||||||