2 //------------This file inserts your field data into the MySQL database
3 include_once("../../globals.php");
4 include_once("../../../library/api.inc");
5 include_once("../../../library/forms.inc");
6 include_once("content_parser.php");
8 $field_names = array('category' => formData("category"), 'subcategory' => formData("subcategory"), 'item' => formData("item"), 'content' => strip_escape_custom($_POST['content']));
9 $camos_array = array();
10 process_commands($field_names['content'], $camos_array);
12 $CAMOS_form_name = "CAMOS-".$field_names['category'].'-'.$field_names['subcategory'].'-'.$field_names['item'];
14 if ($encounter == "") {
15 $encounter = date("Ymd");
18 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/", $field_names['content']) == 0) { //make sure blanks do not get submitted
19 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
20 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
21 // before being submitted to the database. Will also continue to support placeholder conversion on report
22 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
24 $field_names['content'] = add_escape_custom(replace($pid, $encounter, $field_names['content']));
26 $newid = formSubmit("form_CAMOS", $field_names, $_GET["id"], $userauthorized);
27 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
30 //deal with embedded camos submissions here
31 foreach ($camos_array as $val) {
32 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/", $val['content']) == 0) { //make sure blanks not submitted
33 foreach ($val as $k => $v) {
34 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
35 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
36 // before being submitted to the database. Will also continue to support placeholder conversion on report
37 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
39 $val[$k] = trim(add_escape_custom(replace($pid, $encounter, $v)));
42 $CAMOS_form_name = "CAMOS-".$val['category'].'-'.$val['subcategory'].'-'.$val['item'];
44 $newid = formSubmit("form_CAMOS", $val, $_GET["id"], $userauthorized);
45 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
49 echo "<font color=red><b>" . xl('submitted') . ": " . time() . "</b></font>";