$aData['APP_NUMBER'] = $Fields['APP_NUMBER']; $aData['APP_PROC_STATUS'] = $Fields['APP_PROC_STATUS']; $aData['APP_DATA'] = $Fields['APP_DATA']; $aData['DEL_INDEX'] = $_SESSION['INDEX']; $aData['TAS_UID'] = $_SESSION['TASK']; $aData['CURRENT_DYNAFORM'] = $_GET['UID']; $aData['USER_UID'] = $_SESSION['USER_LOGGED']; $aData['APP_STATUS'] = $Fields['APP_STATUS']; $aData['PRO_UID'] = $_SESSION['PROCESS']; $oCase->updateCase($_SESSION['APPLICATION'], $aData); // saving the data ina pm table in case that is a new record if (!empty($newValues)) { $id = key($newValues); if (!$oAdditionalTables->updateDataInTable($oForm->fields[$oForm->fields[$id]->pmconnection]->pmtable, $newValues)) { //<--This is to know if it is a new registry on the PM Table $oAdditionalTables->saveDataInTable($oForm->fields[$oForm->fields[$id]->pmconnection]->pmtable, $newValues); } } //Save files //require_once ("classes/model/AppDocument.php"); if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) { $arrayField = array(); $arrayFileName = array(); $arrayFileTmpName = array(); $arrayFileError = array(); $i = 0; foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) { if (is_array($fieldValue)) { foreach ($fieldValue as $index => $value) { if (is_array($value)) { foreach ($value as $grdFieldIndex => $grdFieldValue) {
/** * import a CSV to pm tables record * * @param string $httpData->id */ public function importCSV($httpData) { if (preg_match('/[\\x00-\\x08\\x0b-\\x0c\\x0e\\x1f]/', file_get_contents($_FILES['form']['tmp_name']['CSV_FILE'])) === 0) { $filename = $_FILES['form']['name']['CSV_FILE']; if ($oFile = fopen($_FILES['form']['tmp_name']['CSV_FILE'], 'r')) { require_once 'classes/model/AdditionalTables.php'; $oAdditionalTables = new AdditionalTables(); $aAdditionalTables = $oAdditionalTables->load($_POST['form']['ADD_TAB_UID'], true); $sErrorMessages = ''; $i = 1; $swHead = false; while (($aAux = fgetcsv($oFile, 4096, $_POST['form']['CSV_DELIMITER'])) !== false) { if (!is_null($aAux[0])) { if (count($aAdditionalTables['FIELDS']) > count($aAux)) { $this->success = false; $this->message = G::LoadTranslation('INVALID_FILE'); return 0; } if ($i == 1) { $j = 0; foreach ($aAdditionalTables['FIELDS'] as $aField) { if ($aField['FLD_NAME'] === $aAux[$j]) { $swHead = true; } $j++; } } if ($swHead == false) { $aData = array(); $j = 0; foreach ($aAdditionalTables['FIELDS'] as $aField) { $aData[$aField['FLD_NAME']] = isset($aAux[$j]) ? $aAux[$j] : ''; if ($aData[$aField['FLD_NAME']] == '') { switch ($aField['FLD_TYPE']) { case 'DATE': case 'TIMESTAMP': $aData[$aField['FLD_NAME']] = null; break; } } $j++; } try { if (!$oAdditionalTables->saveDataInTable($_POST['form']['ADD_TAB_UID'], $aData)) { $sErrorMessages .= G::LoadTranslation('ID_DUPLICATE_ENTRY_PRIMARY_KEY') . ', ' . G::LoadTranslation('ID_LINE') . ' ' . $i . '. '; } } catch (Exception $oError) { $sErrorMessages .= G::LoadTranslation('ID_ERROR_INSERT_LINE') . ': ' . G::LoadTranslation('ID_LINE') . ' ' . $i . '. '; } } else { $swHead = false; } $i++; } } fclose($oFile); } if ($sErrorMessages != '') { $this->success = false; $this->message = $sErrorMessages; } else { $this->success = true; $this->message = G::loadTranslation('ID_FILE_IMPORTED_SUCCESSFULLY', array($filename)); } } else { $sMessage = G::LoadTranslation('ID_UPLOAD_VALID_CSV_FILE'); $this->success = false; $this->message = $sMessage; } }
$id = key($newValues); $newValues[$id] = $aData['APP_DATA'][$id]; foreach ($aKeys as $key => $value) { if (!isset($newValues[$key]) || $newValues[$key] == '') { $G_PUBLISH = new Publisher(); $aMessage = array(); $aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS') . ' (' . $key . ') '; $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); G::RenderPage('publish', 'blank'); die; } } $idPmtable = isset($oForm->fields[$id]->pmconnection->pmtable) && $oForm->fields[$id]->pmconnection->pmtable != '' ? $oForm->fields[$id]->pmconnection->pmtable : $oForm->fields[$id]->owner->tree->children[0]->attributes['pmtable']; if (!$oAdditionalTables->updateDataInTable($idPmtable, $newValues)) { //<--This is to know if it is a new registry on the PM Table $oAdditionalTables->saveDataInTable($idPmtable, $newValues); } } //Save files //require_once ("classes/model/AppDocument.php"); if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) { $arrayField = array(); $arrayFileName = array(); $arrayFileTmpName = array(); $arrayFileError = array(); $i = 0; foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) { if (is_array($fieldValue)) { foreach ($fieldValue as $index => $value) { if (is_array($value)) { foreach ($value as $grdFieldIndex => $grdFieldValue) {