<?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"] == "company_info")) {
  $updateSQL = sprintf("UPDATE info SET address=%s, address2=%s, city=%s, state_provence=%s, zipcode=%s, country=%s, open_hours=%s, other_info_footer=%s, company=%s WHERE id=%s",
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['address2'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['country'], "text"),
                       GetSQLValueString($_POST['open_hours'], "text"),
                       GetSQLValueString($_POST['other_info'], "text"),
                       GetSQLValueString($_POST['company'], "text"),
                       GetSQLValueString($_POST['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_company_info = "SELECT * FROM info";
$company_info = mysql_query($query_company_info, $telmanik_press) or die(mysql_error());
$row_company_info = mysql_fetch_assoc($company_info);
$totalRows_company_info = mysql_num_rows($company_info);
?>
<?php require("assets/wrapper/header.php"); ?>
<div align="center"><div class="mainlayout">
  <p>&nbsp;</p>
 <p><?php echo $translate->__('Company Info - Please note if you do not want anything to show please leave box blank.');?></p><form action="<?php echo $editFormAction; ?>" method="POST" name="company_info">
 
 
 <input type="hidden" name="id" id="name" value="<?php echo $row_company_info['id']; ?>"/>
 <?php echo $translate->__('Company:');?> <BR /><input name="company" type="text" value="<?php echo $row_company_info['company']; ?>" size="100" maxlength="255" /><BR />
  <?php echo $translate->__('Address:');?> <BR /><input name="address" type="text" value="<?php echo $row_company_info['address']; ?>" size="100" maxlength="255" /><BR />
  <?php echo $translate->__('Address 2:');?> <BR /><input name="address2" type="text" value="<?php echo $row_company_info['address2']; ?>" size="100" maxlength="255"/><BR />
  <?php echo $translate->__('City:');?> <BR /><input name="city" type="text" value="<?php echo $row_company_info['city']; ?>" size="100" maxlength="255"/><BR />
    <?php echo $translate->__('State or Provence:');?> <BR /><input name="state" type="text" value="<?php echo $row_company_info['state_provence']; ?>" size="100" maxlength="255"/><BR />
    <?php echo $translate->__('Zip:');?> <BR /><input name="zip" type="text" value="<?php echo $row_company_info['zipcode']; ?>" size="100" maxlength="255"/><BR />
    
    <?php echo $translate->__('Country:');?> <BR /><input name="country" type="text" value="<?php echo $row_company_info['country']; ?>" size="100" maxlength="255"/><BR />
    <?php echo $translate->__('Hours Open:');?> <BR /><input name="open_hours" type="text" value="<?php echo $row_company_info['open_hours']; ?>" size="100" maxlength="255"/><BR />
    
    <?php echo $translate->__('Other Info:');?> <BR /><textarea name="other_info" cols="80" rows="10"><?php echo $row_company_info['other_info_footer']; ?></textarea>
    
     <p>&nbsp;</p>
    <input name="submit" type="submit" value="<?php echo $translate->__('Update');?>" />
    <input type="hidden" name="MM_update" value="company_info" />
 </form>
 

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