CODE STYLE

This commit is contained in:
Ralph Asendeteufrer
2012-10-17 11:20:15 -04:00
parent 0a1bb905d3
commit bb67ce3fcf

View File

@@ -1,155 +1,148 @@
<?php <?php
/** /**
* patterns_Ajax.php * patterns_Ajax.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* */
*/ G::LoadInclude( 'ajax' );
G::LoadInclude('ajax'); $oJSON = new Services_JSON();
$oJSON = new Services_JSON(); if (isset( $_POST['mode'] ) && $_POST['mode'] != '') {
if(isset($_POST['mode']) && $_POST['mode'] != '') $aData = $_POST;
$aData = $_POST; } else {
else $aData = $_POST['form'];
$aData = $_POST['form']; }
G::LoadClass('tasks'); G::LoadClass( 'tasks' );
$oTasks = new Tasks(); $oTasks = new Tasks();
$rou_id = 0; $rou_id = 0;
switch ($aData['action']) { switch ($aData['action']) {
case 'savePattern': case 'savePattern':
//if ($aData['ROU_TYPE'] != $aData['ROU_TYPE_OLD']) //if ($aData['ROU_TYPE'] != $aData['ROU_TYPE_OLD'])
//{ //{
$oTasks->deleteAllRoutesOfTask($aData['PROCESS'], $aData['TASK']); $oTasks->deleteAllRoutesOfTask( $aData['PROCESS'], $aData['TASK'] );
//} //}
require_once 'classes/model/Route.php'; require_once 'classes/model/Route.php';
$oRoute = new Route(); $oRoute = new Route();
switch ($aData['ROU_TYPE']) { switch ($aData['ROU_TYPE']) {
case 'SEQUENTIAL': case 'SEQUENTIAL':
case 'SEC-JOIN': case 'SEC-JOIN':
/*if ($aData['ROU_UID'] != '') /*if ($aData['ROU_UID'] != '')
{ {
$aFields['ROU_UID'] = $aData['ROU_UID']; $aFields['ROU_UID'] = $aData['ROU_UID'];
}*/ }*/
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aData['ROU_NEXT_TASK']; $aFields['ROU_NEXT_TASK'] = $aData['ROU_NEXT_TASK'];
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
//$aFields['ROU_TO_LAST_USER'] = $aData['ROU_TO_LAST_USER']; //$aFields['ROU_TO_LAST_USER'] = $aData['ROU_TO_LAST_USER'];
$rou_id = $oRoute->create($aFields); $rou_id = $oRoute->create( $aFields );
break; break;
case 'SELECT': case 'SELECT':
foreach ($aData['GRID_SELECT_TYPE'] as $iKey => $aRow) foreach ($aData['GRID_SELECT_TYPE'] as $iKey => $aRow) {
{ /*if ($aRow['ROU_UID'] != '')
/*if ($aRow['ROU_UID'] != '')
{ {
$aFields['ROU_UID'] = $aRow['ROU_UID']; $aFields['ROU_UID'] = $aRow['ROU_UID'];
}*/ }*/
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK']; $aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey; $aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION']; $aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
//$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER']; //$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER'];
$rou_id = $oRoute->create($aFields); $rou_id = $oRoute->create( $aFields );
unset($aFields); unset( $aFields );
} }
break; break;
case 'EVALUATE': case 'EVALUATE':
foreach ($aData['GRID_EVALUATE_TYPE'] as $iKey => $aRow) foreach ($aData['GRID_EVALUATE_TYPE'] as $iKey => $aRow) {
{ /*if ($aRow['ROU_UID'] != '')
/*if ($aRow['ROU_UID'] != '')
{ {
$aFields['ROU_UID'] = $aRow['ROU_UID']; $aFields['ROU_UID'] = $aRow['ROU_UID'];
}*/ }*/
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK']; $aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey; $aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION']; $aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
//$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER']; //$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER'];
$rou_id = $oRoute->create($aFields); $rou_id = $oRoute->create( $aFields );
unset($aFields); unset( $aFields );
} }
break; break;
case 'PARALLEL': case 'PARALLEL':
foreach ($aData['GRID_PARALLEL_TYPE'] as $iKey => $aRow) foreach ($aData['GRID_PARALLEL_TYPE'] as $iKey => $aRow) {
{ /*if ($aRow['ROU_UID'] != '')
/*if ($aRow['ROU_UID'] != '')
{ {
$aFields['ROU_UID'] = $aRow['ROU_UID']; $aFields['ROU_UID'] = $aRow['ROU_UID'];
}*/ }*/
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK']; $aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey; $aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$rou_id = $oRoute->create($aFields); $rou_id = $oRoute->create( $aFields );
unset($aFields); unset( $aFields );
} }
break; break;
case 'PARALLEL-BY-EVALUATION': case 'PARALLEL-BY-EVALUATION':
foreach ($aData['GRID_PARALLEL_EVALUATION_TYPE'] as $iKey => $aRow) foreach ($aData['GRID_PARALLEL_EVALUATION_TYPE'] as $iKey => $aRow) {
{ /*if ($aRow['ROU_UID'] != '')
/*if ($aRow['ROU_UID'] != '')
{ {
$aFields['ROU_UID'] = $aRow['ROU_UID']; $aFields['ROU_UID'] = $aRow['ROU_UID'];
}*/ }*/
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK']; $aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey; $aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION']; $aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
if(isset($aRow['ROU_OPTIONAL']) && trim($aRow['ROU_OPTIONAL'])!='' if (isset( $aRow['ROU_OPTIONAL'] ) && trim( $aRow['ROU_OPTIONAL'] ) != '' && ($aRow['ROU_OPTIONAL'] === 'TRUE' || $aRow['ROU_OPTIONAL'] === 'FALSE'))
&& ($aRow['ROU_OPTIONAL']==='TRUE' || $aRow['ROU_OPTIONAL']==='FALSE')) $aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL']; $rou_id = $oRoute->create( $aFields );
$rou_id = $oRoute->create($aFields); unset( $aFields );
unset($aFields); }
} break;
break; case 'DISCRIMINATOR': //Girish ->Added to save changes, while editing the route
case 'DISCRIMINATOR': //Girish ->Added to save changes, while editing the route foreach ($aData['GRID_DISCRIMINATOR_TYPE'] as $iKey => $aRow) {
foreach ($aData['GRID_DISCRIMINATOR_TYPE'] as $iKey => $aRow) $aFields['PRO_UID'] = $aData['PROCESS'];
{ $aFields['TAS_UID'] = $aData['TASK'];
$aFields['PRO_UID'] = $aData['PROCESS']; $aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['TAS_UID'] = $aData['TASK']; $aFields['ROU_CASE'] = $iKey;
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK']; $aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CASE'] = $iKey; $aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
$aFields['ROU_TYPE'] = $aData['ROU_TYPE']; $aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION']; $routeData = $oTasks->getRouteByType( $aData['PROCESS'], $aRow['ROU_NEXT_TASK'], $aData['ROU_TYPE'] );
$aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL']; foreach ($routeData as $route) {
$routeData = $oTasks->getRouteByType($aData['PROCESS'], $aRow['ROU_NEXT_TASK'], $aData['ROU_TYPE']); $sFields['ROU_UID'] = $route['ROU_UID'];
foreach($routeData as $route) $sFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
{ $sFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$sFields['ROU_UID'] = $route['ROU_UID']; $rou_id = $oRoute->update( $sFields );
$sFields['ROU_CONDITION'] = $aRow['ROU_CONDITION']; }
$sFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL']; $rou_id = $oRoute->create( $aFields );
$rou_id = $oRoute->update($sFields); unset( $aFields );
} }
$rou_id =$oRoute->create($aFields); break;
unset($aFields); }
} echo $rou_id;
break; }
}
echo $rou_id;
}
?> ?>