<?php
/*=======================================================================
 *
 * metafield_template.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/

include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");


$httpVars = array("f_act", "statusMessage", "deactivateMenu", "mtft_id", "mtft_content");

getSecHttpVars("1", $httpVars);                         

getLanguage(__FILE__);

$mtft_name = getFieldValueFromId("metafieldtemplate","mtft_id",$mtft_id,"mtft_name");
$pageTitel = getLngt("VORLAGE") . ": " . $mtft_name;

include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");

// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "0", "1");

if ($f_act == "mtft_save") :
   
   if ($mtft_id != "" && is_numeric($mtft_id)) :

      // Convert content according to html specification
      $mtft_content = my_str_check_http($mtft_content);

      updateStmt("metafieldtemplate","mtft_id",$mtft_id,array("mtft_content", $mtft_content));
      
      $statusMessage = "Die Vorlage wurde gespeichert!";

   else :
      $statusMessage = "Die Vorlage konnte nicht gespeichert werden!";
   endif;
endif;

// Get content of the current template ID
$mtft_content = getFieldValueFromId("metafieldtemplate","mtft_id",$mtft_id,"mtft_content");
$mtft_content = htmlspecialchars($mtft_content);
?>


<html>

<head>
<title><?php echo $pageTitel ?></title>

<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
  <?php include_once ("../css/navigation.css.php"); ?>
</style>

<?php include_once ("../include/js_framework.inc.php"); ?>

<script src="../include/checkFormTags.js" type="text/javascript"></script>
<script src="../include/searchLists.js" type="text/javascript"></script>

<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>

function finishPage2(f_act) {
  document.forms[0].f_act.value = f_act;
  document.forms[0].submit();
};
-->
</script>

</head>


<body class="menu_bgcol" onLoad="<?php echo $phpCurrentNavigationOnLoad ?>displayStatusMessage();">

<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>

<div class="maincontent2" name="maincontent" id="maincontent">

<form name="metafield_controller" action="../admin/metafield_template.php" method="post">
  <input type="hidden" name="f_act" value="">
  <input type="hidden" name="mtft_id" value="<?php echo ec($mtft_id) ?>">  

  <?php echo $phpCurrentNavigationInputHidden ?>
  <input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
  
 
  <center>
 
  <?php echo htmlDivLineSpacer("10px"); ?>
 
  <textarea name="mtft_content" cols="170" rows="50"><?php echo $mtft_content ?></textarea>
  
  <?php echo htmlDivLineSpacer("10px"); ?>
  
  <?php echo defineButtonType08("Speichern", "action_store", "finishPage2('mtft_save');", "100", ""); ?>
  
  <?php echo htmlDivLineSpacer("5px"); ?>
  
  </center>

</form>

</div>
</body>

</html>
