<?php require_once('../Connections/telmanik_press.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "select_slider")) {
  $updateSQL = sprintf("UPDATE slider SET gallery_selected=%s, enable_disable=%s WHERE id=%s",
                       GetSQLValueString($_POST['select_gallery'], "text"),
                       GetSQLValueString(isset($_POST['enable_disable']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString($_POST['home_slider_id'], "int"));

  mysql_select_db($database_telmanik_press, $telmanik_press);
  $Result1 = mysql_query($updateSQL, $telmanik_press) or die(mysql_error());

  $updateGoTo = "success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_gallery_drop = "SELECT * FROM gallerys";
$gallery_drop = mysql_query($query_gallery_drop, $telmanik_press) or die(mysql_error());
$row_gallery_drop = mysql_fetch_assoc($gallery_drop);
$totalRows_gallery_drop = mysql_num_rows($gallery_drop);
?>
<?php require("assets/wrapper/header.php"); ?>

<div class="mainlayout"><div id="edithead"><div id="editload">


<p><?php echo $translate->__('Please select gallery for homepage slider.');?></p>


  <p>&nbsp;</p>
  
  <form action="<?php echo $editFormAction; ?>" method="POST" name="select_slider">
  <input type="hidden" name="home_slider_id" value="1" />
  <select name="select_gallery">
  
    <?php
do {  
?>
    <option value="<?php echo $row_gallery_drop['gallery_name']?>"><?php echo $row_gallery_drop['gallery_name']?></option>
    <?php
} while ($row_gallery_drop = mysql_fetch_assoc($gallery_drop));
  $rows = mysql_num_rows($gallery_drop);
  if($rows > 0) {
      mysql_data_seek($gallery_drop, 0);
	  $row_gallery_drop = mysql_fetch_assoc($gallery_drop);
  }
?>
  </select><BR /><BR />
  <?php echo $translate->__('Check to enable slider on homepage');?> <!-- if selected means enabled = 1 -->
  <input name="enable_disable" type="checkbox" value="1" checked /><BR /><BR />
 
  
  <input name="submit" type="submit" value="<?php echo $translate->__('Update');?>" />
  <input type="hidden" name="MM_update" value="select_slider" />
  </form>
  
  
  

  <p>&nbsp;</p>
</div>
</div></div>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($gallery_drop);
?>
