Portions created by the Initial Developer are Copyright (C) 2017-2018 the Initial Developer. All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('number_translation_add') || permission_exists('number_translation_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $number_translation_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (is_array($_POST)) { $number_translation_uuid = check_str($_POST["number_translation_uuid"]); $number_translation_name = check_str($_POST["number_translation_name"]); $number_translation_details = check_str($_POST["number_translation_details"]); $number_translation_enabled = check_str($_POST["number_translation_enabled"]); $number_translation_description = check_str($_POST["number_translation_description"]); } //process the user data and save it to the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //get the uuid from the POST if ($action == "update") { $number_translation_uuid = check_str($_POST["number_translation_uuid"]); } //check for all required data $msg = ''; if (strlen($number_translation_name) == 0) { $msg .= $text['message-required']." ".$text['label-number_translation_name']."
\n"; } //if (strlen($number_translation_details) == 0) { $msg .= $text['message-required']." ".$text['label-number_translation_details']."
\n"; } if (strlen($number_translation_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-number_translation_enabled']."
\n"; } //if (strlen($number_translation_description) == 0) { $msg .= $text['message-required']." ".$text['label-number_translation_description']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //cleanup the array $x = 0; foreach ($_POST["number_translation_details"] as $row) { //unset the empty row if (strlen($_POST["number_translation_details"][$x]["number_translation_detail_regex"]) == 0) { unset($_POST["number_translation_details"][$x]); } if (strlen($_POST["number_translation_details"][$x]["number_translation_detail_replace"]) == 0) { unset($_POST["number_translation_details"][$x]); } if (strlen($_POST["number_translation_details"][$x]["number_translation_detail_order"]) == 0) { unset($_POST["number_translation_details"][$x]); } //increment the row $x++; } //add the number_translation_uuid if (strlen($_POST["number_translation_uuid"]) == 0) { $number_translation_uuid = uuid(); $_POST["number_translation_uuid"] = $number_translation_uuid; } //prepare the array $array['number_translations'][0] = $_POST; //save to the data $database = new database; $database->app_name = 'number_translations'; $database->app_uuid = null; if (strlen($number_translation_uuid) > 0) { $database->uuid($number_translation_uuid); } $database->save($array); $message = $database->message; //debug info //echo "
";
			//print_r($message);
			//echo "
"; //exit; //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } header('Location: number_translation_edit.php?id='.escape($number_translation_uuid)); return; } } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $number_translation_uuid = check_str($_GET["id"]); $sql = "select * from v_number_translations "; $sql .= "where number_translation_uuid = '$number_translation_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $number_translation_name = $row["number_translation_name"]; $number_translation_details = $row["number_translation_details"]; $number_translation_enabled = $row["number_translation_enabled"]; $number_translation_description = $row["number_translation_description"]; } unset ($prep_statement); } //get the child data if (strlen($number_translation_uuid) > 0) { $sql = "select * from v_number_translation_details "; $sql .= "where number_translation_uuid = '".$number_translation_uuid."' "; $prep_statement = $db->prepare($sql); $prep_statement->execute(); $number_translation_details = $prep_statement->fetchAll(PDO::FETCH_NAMED); } //add the $number_translation_uuid if (strlen($number_translation_uuid) == 0) { $number_translation_uuid = uuid(); } //add an empty row if (is_array($number_translation_details)) { $x = count($number_translation_details); } else { $number_translation_details = []; $x = 0; } $number_translation_details[$x]['number_translation_uuid'] = $number_translation_uuid; $number_translation_details[$x]['number_translation_detail_uuid'] = uuid(); $number_translation_details[$x]['number_translation_detail_regex'] = ''; $number_translation_details[$x]['number_translation_detail_replace'] = ''; $number_translation_details[$x]['number_translation_detail_order'] = ''; //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['title-number_translation']."

\n"; echo " "; echo " "; echo "
\n"; echo " ".$text['label-number_translation_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-number_translation_name']."\n"; echo "
\n"; echo " ".$text['label-number_translation_details']."\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $x = 0; foreach($number_translation_details as $row) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $x++; } echo "
".$text['label-number_translation_detail_regex']."".$text['label-number_translation_detail_replace']."".$text['label-number_translation_detail_order']."
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo $text['description-number_translation_detail_order']."\n"; echo "
\n"; echo " ".$text['label-number_translation_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-number_translation_enabled']."\n"; echo "
\n"; echo " ".$text['label-number_translation_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-number_translation_description']."\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
"; echo "
"; echo "

"; //include the footer require_once "resources/footer.php"; ?>