//replace group id with local one $grp_id = $def_rectype[$idx_rt_grp]; $def_rectype[$idx_rt_grp] = $group_rt_ids[$grp_id]; //disambiguate name $def_rectype[$idx_name] = doDisambiguate($def_rectype[$idx_name], $trg_rectypes['names']); //assign canonical to title mask (since in DB we store only rty_TitleMask) $def_rectype[$idx_titlemask] = $def_rectype[$idx_titlemask_canonical]; //fill original ids if missed if ($def_rectype[$idx_ccode] && (!$def_rectype[$idx_origin_dbid] || !$def_rectype[$idx_origin_id])) { $codes = explode("-", $def_rectype[$idx_ccode]); if ($codes && count($codes) == 2) { $def_rectype[$idx_origin_dbid] = $codes[0]; $def_rectype[$idx_origin_id] = $codes[1]; } } $res = createRectypes($columnNames, array("0" => array("common" => $def_rectype)), false, false); if (is_numeric($res)) { $new_rtyID = abs($res); $rectypes_correspondence[$rtyID] = $new_rtyID; $trg_rectypes['names'][$new_rtyID] = $def_rectype[$idx_name]; copyRectypeIcon($rtyID, $new_rtyID); } else { error_exit("Cannot add record type for id#" . $recId . ". " . $res); } } // ------------------------------------------------------------------------------------------------ // IV. Add new field type groups $columnNames = array("dtg_Name", "dtg_Order", "dtg_Description"); $idx_dt_grp = $def_dts['fieldNamesToIndex']['dty_DetailTypeGroupID']; foreach ($imp_fieldtypes as $ftId) { $grp_id = $def_dts[$ftId]['commonFields'][$idx_dt_grp];
case 'saveRectype': case 'saveRT': // Record type if (!array_key_exists('rectype', $data) || !array_key_exists('colNames', $data['rectype']) || !array_key_exists('defs', $data['rectype'])) { error_exit("Invalid data structure sent with saveRectype method call to saveStructure.php"); } $commonNames = $data['rectype']['colNames']['common']; //$dtFieldNames = $rtData['rectype']['colNames']['dtFields']; $rv['result'] = array(); //result foreach ($data['rectype']['defs'] as $rtyID => $rt) { if ($rtyID == -1) { // new rectypes $definit = @$_REQUEST['definit']; //create set of default fields for new rectype $ret = createRectypes($commonNames, $rt, $definit == "1", true, @$_REQUEST['icon']); array_push($rv['result'], $ret); } else { array_push($rv['result'], updateRectype($commonNames, $rtyID, $rt)); } } $rv['rectypes'] = getAllRectypeStructures(false); break; case 'saveRTS': // Record type structure if (!array_key_exists('rectype', $data) || !array_key_exists('colNames', $data['rectype']) || !array_key_exists('defs', $data['rectype'])) { error_exit("Invalid data structure sent with updateRecStructure method call to saveStructure.php"); } //$commonNames = $rtData['rectype']['colNames']['common']; $dtFieldNames = $data['rectype']['colNames']['dtFields']; $rv['result'] = array();
case 'saveRectype': case 'saveRT': // Record type if (!array_key_exists('rectype', $data) || !array_key_exists('colNames', $data['rectype']) || !array_key_exists('defs', $data['rectype'])) { die("Error: invalid data structure sent with saveRectype method call to saveStructure.php"); } $commonNames = $data['rectype']['colNames']['common']; //$dtFieldNames = $rtData['rectype']['colNames']['dtFields']; $rv = array(); $rv['result'] = array(); //result $definit = @$_REQUEST['definit']; foreach ($data['rectype']['defs'] as $rtyID => $rt) { if ($rtyID == -1) { // new rectypes array_push($rv['result'], createRectypes($commonNames, $rt, $definit == "1")); } else { array_push($rv['result'], updateRectype($commonNames, $rtyID, $rt)); } } $rv['rectypes'] = getAllRectypeStructures(); break; case 'saveRTS': // Record type structure /*****DEBUG****/ //DEBUG error_log(">>>>>>>".print_r($data,true)); if (!array_key_exists('rectype', $data) || !array_key_exists('colNames', $data['rectype']) || !array_key_exists('defs', $data['rectype'])) { die("Error: invalid data structure sent with updateRecStructure method call to saveStructure.php"); } //$commonNames = $rtData['rectype']['colNames']['common']; $dtFieldNames = $data['rectype']['colNames']['dtFields'];