<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<?php

include ("../navigation/header.php");
$page_name = "AD-pre defined";
include ("../navigation/access.php");

  
$set = $_GET['set']; 
$text_name = "";
$text_id = "";
$text_content="";
 
if ($set==0) {
	$text_name = $_GET['text_select'];
	
	$table_name = $_SESSION['db_prefix']."_text_quotes";
    $text_query = "SELECT text_id, text_content FROM $table_name WHERE text_name = '".$text_name."' ";
    $text_result = mySQL_query($text_query);
    $text_num = mysql_num_rows($text_result);
	$text_id = mysql_result($text_result, 0, "text_id");
    $text_content = mysql_result($text_result, 0, "text_content");
	
}

if ($set==1) {
	$text_id = $_GET['text_id'];
	$text_content= $_GET['content_text'];
	$table_name = $_SESSION['db_prefix']."_text_quotes";
    $content_query = "UPDATE $table_name SET text_content = '". $text_content ."' WHERE text_id = '".$text_id."' ";
    $content_result = mySQL_query($content_query);
	
	$table_name = $_SESSION['db_prefix']."_text_quotes";
    $text_query = "SELECT text_name FROM $table_name WHERE text_id = '".$text_id."' ";
    $text_result = mySQL_query($text_query);
    $text_num = mysql_num_rows($text_result);
	$text_name = mysql_result($text_result, 0, "text_name");
    
}

if ($set==2) {

	
}
	
if ($set==5) {
$user_id = $_SESSION['username'];
date_default_timezone_set('Africa/Khartoum');
$entry_date = date("Y-m-d H:i:s",time()-3600);

$table_name = $_SESSION['db_prefix']."_tracking_admin";
$action_query = "INSERT INTO $table_name (entry_date, user, action, details) VALUES ('".$entry_date."' ,'".$user_id."','pre-defined page' ,'predefined page' )";
execsql($action_query);
}
	



?>



<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script type="text/javascript">
<!--
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>

<?php if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body  onload="<?php if ($set==5) {?> MM_showHideLayers('caption1','','hide');MM_showHideLayers('caption2','','hide'); <?php } ?> " >
<?php include ('../include/tooltip.php'); ?>

<div class="main_frame">
<table id="tableMain" > <!--begin of tableMain-->
    <tr>
      <td width="700" height="125" valign="top" >
<table width="690" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="52" colspan="4" align="left" valign="top"><div class="page_head_frame">
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Pre-defined text</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
        <br /><br /><br /><br /><br />
<div class="caption_frame"><form name="form1" id="form1" action="text_definitions.php" method="get"> <label class="label_std">Select a pre-defined text to edit: &nbsp;&nbsp;</label>
    <select name="text_select" class="select160" id="text_select" onfocus="MM_showHideLayers('caption1','','hide');MM_showHideLayers('caption2','','hide')" >
      <option value="Payment terms 1">Payment terms 1</option>
      <option value="Payment terms 2">Payment terms 2</option>
      <option value="Payment terms 3">Payment terms 3</option>
      <option value="Delivery 1">Delivery 1</option>
      <option value="Delivery 2">Delivery 2</option>
      <option value="Delivery 3">Delivery 3</option>
      <option value="Warranty 1">Warranty 1</option>
      <option value="Warranty 2">Warranty 2</option>
      <option value="Warranty 3">Warranty 3</option>
      <option value="Installation 1">Installation 1</option>
      <option value="Installation 2">Installation 2</option>
      <option value="Installation 3">Installation 3</option>
      
      
      <option value=" " selected="selected"></option>
    </select>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <input name="button" type="submit" class="std_button" id="button" onclick="MM_showHideLayers('caption1','','show');MM_showHideLayers('caption2','','show')" value="Select" />
           <input name="set" type="hidden" id="set" value="0" />
                   
</form>

<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("page_select","req","Please select page.");
</script></div>
<br />
<br />
<br />
<br />
<br /><br />
</td>
    </tr>
    <tr>
      <td width="493" colspan="4" valign="top"><table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div class="caption_frame" id="caption1">
        <label class="label_std">text for:&nbsp;&nbsp;&nbsp;<font size="3"><font size="3"><?php echo $text_name ?></font></font></label></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" align="left"><div class="standard_frame" id="caption2"><label class="label_std">Type the content of the text and click &quot;Save&quot; to save.</label><br />
      <br />
      
      <form action="text_definitions.php" name="set_form" method="get">
        &nbsp;&nbsp;
        <textarea name="content_text" cols="70" rows="5" class="text_box" id="content_text"><?php echo $text_content ?></textarea>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="button2" type="submit" class="std_button" id="button2" value="Save" />
        <input name="text_id" type="hidden" id="text_id" value="<?php echo $text_id ?>" />
        <input name="set" type="hidden" id="set" value="1" />
        </form>
      <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("set_form");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("page_select","req","Please select text to edit.");
</script></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>


        
          </td>
    </tr>
    </table>
  
</td>
</tr>
</table>  <!--end of tableMain-->  
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else { 
$_SESSION['denied_return'] = "admin_module/user_list.php";	
include ("../navigation/admin_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>
</html>