$msgTxt = "An error ocurred when a new submission"
. " was added to the $doctype document type. Thi"
. "s new submission is the ${subToAdd}$doctype "
. "submission and was cloned from the $toClone "
. "document type.\n\nIt was not possible to add "
. "the " . $element["fidesc"] . " element which "
. "should appear in position "
. $element["fieldnb"] . " on page "
. $element["pagenb"] . " of this new submission."
. "\n\nThe cloning of the rest of this submission"
. " was however continued, which means that there"
. " may be problems with elements being out of or"
. "der on this page of the submission.\n\nYou sho"
. "uld examine this and correct any problems imme"
. "diately.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: Unable to Add "
. $element["fidesc"] . " Element "
. "to ${subToAdd}$doctype", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END while
# Now we also clone the functions used in this submission
$res = mysql_query("SELECT action,function,score,step FROM sbmFUNCTIONS WHERE action='$subToAdd' and doctype='$toClone'");
while ($row = mysql_fetch_array($res))
{
$res2 = mysql_query("SELECT 1 from sbmFUNCTIONS where action='".$row['action']."' and doctype='$doctype' and function='".$row['function']."' and score='".$row['score']."' and step='".$row['step']."'");
if (mysql_num_rows($res2) < 1)
mysql_query("INSERT INTO sbmFUNCTIONS (action,doctype,function,score,step) VALUES ('".$row['action']."','$doctype','".$row['function']."','".$row['score']."','".$row['step']."')");
}
#clone parameters
$res = mysql_query("select * from sbmPARAMETERS where doctype='$toClone'");
while ($row = mysql_fetch_array($res))
{
$res2 = mysql_query("select * from sbmPARAMETERS where doctype='$doctype' and name='".$row['name']."'");
if (mysql_num_rows($res2) < 1)
mysql_query("insert into sbmPARAMETERS(doctype, name, value) values ('$doctype','".$row['name']."','".$row['value']."')");
}
# Now that the submission has been cloned, it is
# possible to present the user with a message saying
# this, and redirect their browser to the
# "documentEDS.php" page so that they can look into the
# details of this new submission, and change anything
# that they might feel appropriate. A javascript alert
# should also be displayed however, advising them to
# check all of the values for their new submission and
# ensure that they are correct. We can then mail the
# administrator to let them know that a new submission
# has been created, and that it was cloned from another