- Improvement for the query: SELECT APPLICATION.APP_UID, APPLICATION.APP_NUMBER, APPLICATION.APP_STATUS, APPLICATION.PRO_UID, APPLICATION.APP_CREATE_DATE, APPLICATION.APP_FINISH_DATE, APPLICATION.APP_UPDATE_DATE, APPLICATION.APP_DATA, ad.DEL_INDEX, ad.DEL_PREVIOUS, ad.TAS_UID, ad.USR_UID, ad.DEL_TYPE, ad.DEL_THREAD, ad.DEL_THREAD_STATUS, ad.DEL_PRIORITY, ad.DEL_DELEGATE_DATE, ad.DEL_INIT_DATE, ad.DEL_TASK_DUE_DATE, ad.DEL_FINISH_DATE, ad.DEL_DURATION, ad.DEL_QUEUE_DURATION, ad.DEL_DELAY_DURATION, ad.DEL_STARTED, ad.DEL_FINISHED, ad.DEL_DELAYED, ad.APP_OVERDUE_PERCENTAGE, at.APP_THREAD_INDEX, at.APP_THREAD_PARENT, at.APP_THREAD_STATUS, capp.CON_VALUE AS APP_TITLE, cpro.CON_VALUE AS PRO_TITLE FROM APPLICATION JOIN APP_DELEGATION ad ON (APPLICATION.APP_UID=ad.APP_UID) LEFT JOIN CONTENT capp ON (APPLICATION.APP_UID=capp.CON_ID AND capp.CON_CATEGORY='?' AND capp.CON_LANG='?') LEFT JOIN CONTENT cpro ON (APPLICATION.PRO_UID=cpro.CON_ID AND cpro.CON_CATEGORY='?' AND cpro.CON_LANG='?') JOIN APP_THREAD at ON (ad.APP_UID=at.APP_UID AND ad.DEL_THREAD=at.APP_THREAD_INDEX) WHERE APPLICATION.APP_UID='?'
98 lines
4.1 KiB
PHP
Executable File
98 lines
4.1 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* proxySaveReassignCasesList.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.
|
|
*
|
|
*/
|
|
$aData = G::json_decode($_POST['data']);
|
|
$appSelectedUids = array ();
|
|
$items = explode(",",$_POST['APP_UIDS']);
|
|
foreach ($items as $item) {
|
|
$dataUids = explode("|",$item);
|
|
$appSelectedUids[] = $dataUids[0];
|
|
}
|
|
|
|
// var_dump($aData);
|
|
//var_dump($appSelectedUids);
|
|
$casesReassignedCount = 0;
|
|
$serverResponse = array();
|
|
G::LoadClass ('case');
|
|
$oCases = new Cases();
|
|
require_once ('classes/model/Task.php');
|
|
require_once ('classes/model/AppCacheView.php');
|
|
$oAppCacheView = new AppCacheView();
|
|
$oCasesReassignList = $oAppCacheView->getToReassignListCriteria();
|
|
if (isset($_POST['selected'])&&$_POST['selected']=='true'){
|
|
$oCasesReassignList->add(AppCacheViewPeer::APP_UID,$appSelectedUids,Criteria::IN);
|
|
}
|
|
// if there are no records to save return -1
|
|
if (empty($aData)){
|
|
$serverResponse['TOTAL']=-1;
|
|
echo G::json_encode($serverResponse);
|
|
die();
|
|
}
|
|
// $params = array ();
|
|
// $sql = BasePeer::createSelectSql($oCasesReassignList, $params);
|
|
// var_dump($sql);
|
|
if ( is_array($aData) ) {
|
|
$currentCasesReassigned=0;
|
|
foreach ($aData as $data){
|
|
$oTmpReassignCriteria = $oCasesReassignList;
|
|
$oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID,$data->TAS_UID);
|
|
$rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria);
|
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
$rs->next();
|
|
$row = $rs->getRow();
|
|
$aCase = $oCases->loadCaseInCurrentDelegation($data->APP_UID);
|
|
$oCases->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], ($aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED']), $data->APP_REASSIGN_USER_UID);
|
|
$currentCasesReassigned++;
|
|
$casesReassignedCount++;
|
|
$serverResponse[] = array ('APP_REASSIGN_USER' => $data->APP_REASSIGN_USER,
|
|
'APP_TITLE' => $data->APP_TITLE,
|
|
'TAS_TITLE' => $data->APP_TAS_TITLE,
|
|
'REASSIGNED_CASES' => $currentCasesReassigned);
|
|
}
|
|
}
|
|
else {
|
|
$oTmpReassignCriteria = $oCasesReassignList;
|
|
$oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID,$aData->TAS_UID);
|
|
$rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria);
|
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
$rs->next();
|
|
$row = $rs->getRow();
|
|
$currentCasesReassigned=0;
|
|
while (is_array($row)) {
|
|
$APP_UID = $row['APP_UID'];
|
|
$aCase = $oCases->loadCaseInCurrentDelegation($APP_UID);
|
|
$oCases->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], ($aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED']), $aData->APP_REASSIGN_USER_UID);
|
|
$currentCasesReassigned++;
|
|
$casesReassignedCount++;
|
|
// var_dump($aCase);
|
|
// echo ("<br>");
|
|
$rs->next();
|
|
$row = $rs->getRow();
|
|
}
|
|
$serverResponse[] = array ('TAS_TITLE'=>$aData->APP_TAS_TITLE,'REASSIGNED_CASES'=>$currentCasesReassigned);
|
|
}
|
|
|
|
$serverResponse['TOTAL'] = $casesReassignedCount;
|
|
echo G::json_encode($serverResponse);
|