Home » RADICORE development » Workflow » How to redirect to another url in batch ?
Re: How to redirect to another url in batch ? [message #4222 is a reply to message #4221] |
Thu, 05 June 2014 05:57 ![Go to previous message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to previous message](/theme/default/images/down.png) |
rainfallwu
Messages: 8 Registered: May 2014
|
Junior Member |
|
|
We modified some code, thanks!
<?php
//*****************************************************************************
// Allow a new occurrence to be added to the PERSON table.
//*****************************************************************************
//DebugBreak();
$stdout = '../logs/test_x_person.html';
$csvout = '../logs/test_x_person.csv';
ini_set('include_path', '.');
require 'std.batch.inc';
batchInit(__FILE__);
$table_id = 'test_x_person'; // table name
$screen = 'test_person.detail.screen.inc'; // file identifying screen structure
require_once 'include.general.inc';
// identify mode for xsl file
$mode = 'insert';
// add by wushan 0603
//$uri="http://192.168.131.68/radicore/xample/person_add.php?";
// load session variables
initSession();
if (isset($_POST['quit'])) {
// cancel this screen, return to previous screen
scriptPrevious(null, null, 'quit');
} // if
// define action buttons
$act_buttons['submitBtn'] = 'submit'; // do not use name 'submit' as this conflicts with javascript 'submit()' function.
$act_buttons['submitstay'] = 'submitstay';
$act_buttons['copy'] = 'copy';
$act_buttons['quit'] = 'cancel';
// create a class instance for the main database table
require_once "classes/$table_id.class.inc";
if (isset($script_vars['dbobject'])) {
// use data from previous instance for this script
$dbobject = unserialize($script_vars['dbobject']);
if (!empty($return_from)) {
// see if any action is required when being restarted
$dbobject->restart($return_from, $return_action, $return_string);
} // if
// get data from previous instance
$fieldarray = $dbobject->getFieldArray();
} else {
// create new instance for initial activation of this script
$dbobject = new $table_id;
// indicate that this object was started from a page controller
$dbobject->initiated_from_controller = true;
$dbobject->setRowsPerPage(1); // scroll through one item at a time
// get initial data for a new record
$where = $dbobject->initialise($where, $selection);
if (empty($dbobject->errors)) {
$fieldarray = $dbobject->getInitialData($where);
} // if
if ($dbobject->errors) {
scriptPrevious($dbobject->getErrors(), $dbobject->getMessages());
} // if
} // if
$i =28;
//while(1)
//{
$i = $i +1 ;
$fieldarray=array("person_id"=>$i ,"nat_ins_no"=>$i ,"pers_type_id"=>$i ,"node_id"=>"2","star_sign"=>"Can");
$_POST=$fieldarray;
$fieldarray = $dbobject->updateFieldArray($fieldarray, $_POST);
if ($dbobject->errors) {
$errors = $dbobject->getErrors();
} // if
$dbobject->startTransaction();
$fieldarray = $dbobject->insertRecord($fieldarray); // add this data to the database
$messages = array_merge($messages, $dbobject->getMessages());
if ($dbobject->errors) {
$errors = $dbobject->getErrors();
} // if
if (empty($errors)) {
$errors = $dbobject->commit();
if (empty($errors)) {
$messages[] = getLanguageText('sys0080'); // 'Record inserted OK'
if (isset($_POST['submitstay'])) {
// re-initialise data for a new record
$fieldarray = $dbobject->getInitialData($where);
// get any extra data and merge with $fieldarray
$fieldarray = $dbobject->getExtraData($fieldarray, $where);
if (isset($_SESSION['script_sequence'])) {
$script_vars['dbobject'] = serialize($dbobject);
// do other tasks before returning to this one
scriptNext($task_id);
} // if
} else {
// update was OK - return to previous screen
$selection = array2where($fieldarray, $dbobject->getPkeyNamesAdjusted());
$prev_script = getPreviousScript();
$prev_task = getPreviousTask($prev_script);
$_SESSION['pages'][$prev_script][$prev_task]['selection'] = $selection;
$messages = array_merge($messages, $dbobject->getMessages());
scriptPrevious(null, $messages, 'insert', $dbobject->getInstruction(), $selection);
} // if
} // if
} else {
$dbobject->rollback();
} // if
//sleep(10);
//}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
// check if we are returning from a child form where something has been selected
if (!empty($return_from) AND isset($selection) ) {
// merge previous saved variables with selection from popup form
$fieldarray = $dbobject->popupReturn($fieldarray, basename($return_from), $selection);
if ($dbobject->errors) {
$errors = $dbobject->getErrors();
} // if
} // if
// get any extra data and merge with $fieldarray
$fieldarray = $dbobject->getExtraData($fieldarray);
} // if
if (isset($_SESSION['data'][$table_id])) {
// saved data exists, so allow a PASTE button
$prepend = array('paste' => 'paste');
$act_buttons = array_merge($prepend, $act_buttons);
} // if
$messages = array_merge($messages, $dbobject->getMessages());
// save these variables for later in the same session
$script_vars['where'] = $where;
$script_vars['dbobject'] = serialize($dbobject);
$script_vars = updateScriptVars ($script_vars);
$dbobject->fieldarray = $fieldarray; // replace data lost during serialization
if ($_SERVER['REQUEST_METHOD'] == 'POST' AND empty($errors) AND !$button) {
// repeat current task with GET instead of POST
scriptNext($GLOBALS['task_id'], $where);
} // if
if (!empty($errors)) {
// all errors are associated with this table
$errors2[$dbobject->getClassName()] = $errors;
$errors = $errors2;
} // if
//$url = person_addr_add.php
//Header("HTTP/1.1 303 See Other");
// header('HTTP/1.0 401 Authorized');
//Header("Location: $url");
//Header("Location: http://192.168.131.68/radicore/xample/person_addr_add.php?session_name=".session_name());
//http://localhost/radicore/xample/person_add.php?session_name=menu3
//require 'std.add1.inc'; // activate page controller
batchEnd();
?>
|
|
|
Goto Forum:
Current Time: Tue Jul 23 09:30:00 EDT 2024
Total time taken to generate the page: 0.01032 seconds
|