2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* triggers_Save.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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
|
|
|
|
|
|
|
|
|
|
G::LoadClass('reportTables');
|
2011-01-03 10:29:07 +00:00
|
|
|
if(isset($_POST['form']))
|
|
|
|
|
$value= $_POST['form'];
|
|
|
|
|
else
|
|
|
|
|
$value=$_POST;
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
$oReportTable = new ReportTable();
|
2011-01-03 10:29:07 +00:00
|
|
|
if (!isset($value['REP_TAB_CONNECTION'])) {
|
|
|
|
|
$value['REP_TAB_CONNECTION'] = 'report';
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2011-01-03 10:29:07 +00:00
|
|
|
if ($value['REP_TAB_UID'] != '') {
|
|
|
|
|
$aReportTable = $oReportTable->load($value['REP_TAB_UID']);
|
2010-12-02 23:34:41 +00:00
|
|
|
$sOldTableName = $aReportTable['REP_TAB_NAME'];
|
|
|
|
|
$sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
|
|
|
|
|
}
|
|
|
|
|
else {
|
2011-01-03 10:29:07 +00:00
|
|
|
$sOldTableName = $value['REP_TAB_NAME'];
|
|
|
|
|
$sOldConnection = $value['REP_TAB_CONNECTION'];
|
|
|
|
|
$oReportTable->create($value);
|
|
|
|
|
$value['REP_TAB_UID'] = $oReportTable->getRepTabUid();
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-03 10:29:07 +00:00
|
|
|
$oReportTable->update($value);
|
2010-12-02 23:34:41 +00:00
|
|
|
$oReportVar = new ReportVar();
|
|
|
|
|
$oReportTables = new ReportTables();
|
2011-01-03 10:29:07 +00:00
|
|
|
$oReportTables->deleteAllReportVars($value['REP_TAB_UID']);
|
2010-12-02 23:34:41 +00:00
|
|
|
$aFields = array();
|
2011-01-03 10:29:07 +00:00
|
|
|
if ($value['REP_TAB_TYPE'] == 'GRID') {
|
|
|
|
|
$aAux = explode('-', $value['REP_TAB_GRID']);
|
2010-12-02 23:34:41 +00:00
|
|
|
global $G_FORM;
|
2011-01-03 10:29:07 +00:00
|
|
|
$G_FORM = new Form($value['PRO_UID'] . '/' . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
|
2010-12-02 23:34:41 +00:00
|
|
|
$aAux = $G_FORM->getVars(false);
|
|
|
|
|
foreach ($aAux as $aField) {
|
2011-01-03 10:29:07 +00:00
|
|
|
$value['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-01-03 10:29:07 +00:00
|
|
|
foreach ($value['FIELDS'] as $sField) {
|
2010-12-02 23:34:41 +00:00
|
|
|
$aField = explode('-', $sField);
|
|
|
|
|
switch ($aField[1]) {
|
|
|
|
|
case 'currency':
|
|
|
|
|
case 'percentage':
|
|
|
|
|
$sType = 'number';
|
|
|
|
|
break;
|
|
|
|
|
case 'text':
|
|
|
|
|
case 'password':
|
|
|
|
|
case 'dropdown':
|
|
|
|
|
case 'yesno':
|
|
|
|
|
case 'checkbox':
|
|
|
|
|
case 'radiogroup':
|
|
|
|
|
case 'hidden':
|
|
|
|
|
$sType = 'char';
|
|
|
|
|
break;
|
|
|
|
|
case 'textarea':
|
|
|
|
|
$sType = 'text';
|
|
|
|
|
break;
|
|
|
|
|
case 'date':
|
|
|
|
|
$sType = 'date';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$sType = 'char';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-01-03 10:29:07 +00:00
|
|
|
$oReportVar->create(array('REP_TAB_UID' => $value['REP_TAB_UID'],
|
|
|
|
|
'PRO_UID' => $value['PRO_UID'],
|
2010-12-02 23:34:41 +00:00
|
|
|
'REP_VAR_NAME' => $aField[0],
|
|
|
|
|
'REP_VAR_TYPE' => $sType));
|
|
|
|
|
$aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
|
|
|
|
|
}
|
|
|
|
|
$oReportTables->dropTable($sOldTableName, $sOldConnection);
|
2011-01-03 10:29:07 +00:00
|
|
|
$oReportTables->createTable($value['REP_TAB_NAME'], $value['REP_TAB_CONNECTION'], $value['REP_TAB_TYPE'], $aFields);
|
|
|
|
|
$oReportTables->populateTable($value['REP_TAB_NAME'], $value['REP_TAB_CONNECTION'], $value['REP_TAB_TYPE'], $aFields, $value['PRO_UID'], $value['REP_TAB_GRID']);
|
2010-12-02 23:34:41 +00:00
|
|
|
?>
|