<?php
/**
 * Directory module
 * 
 * Delete given directory entry from back-office
 * 
 * @package linea21\modules\yellowpages
 * @author $Author$ - linea21 <info@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Inclusion de pages ////////////
if (!class_exists('auth')){
  include_once("../lib/lib_common.php");
  ReloadIndex('admin');
}
////////////

$link_det=$rub_link."&amp;todo=det&amp;id=";
$link_det2=$rub_link."&todo=det&id=";

if(!isset($_GET['id']) && !isset($_POST['id'])) {
  $id="1";
} else {
  if(isset($_POST['id']))	$id=$_POST['id'];
  if(isset($_GET['id']))	$id=$_GET['id'];
}

if(isset($_POST['valider'])) {
  $id_yp=$_POST['id_yp'];
  $yp_object= new yellowpages;
  $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  $result=$yp_object->DeleteYellowPages($id_yp, $sql_object);
  if($result) {
      header("Location: ".safe_redirect($link_confirm));
      exit;
  }
  else  system_error();
}

$req_det=SQL_getdetyp($id);
$data_yp=$sql_object->DBSelect($req_det, 'OBJECT');

// Do record exists?
if(!isset($data_yp[0]->yellowp_name)) redirect_to('@module_default');

$navtitle=_t('yp','sup')." : ".$data_yp[0]->yellowp_name;

$display_title=formatTitleh2($data_yp[0]->yellowp_name);

?>
<div id="chemin">
<ul>
	<li><a href="index.php" class="chemin_home"><?php echo _t('way','home') ?></a></li>
	<li><a href="<?php echo $rub_link; ?>" id="chemin_<?php echo $rub; ?>" class="chemin_rub"><?php echo _t('menu','yellowpages')?></a></li>
	<li><span><?php echo formatnavTitle($navtitle) ; ?></span></li>
</ul>
</div>
<!--end barre haute -->

<div class="contentcontainer"><?php
include_once(override($dir.'/menurub.php', THEME_ADMIN_PATH));
?>
<div id="content"><?php
if(isset($integrity) && is_string($integrity)) display_errors($integrity);
?>
<h2><?php echo $display_title; ?></h2>

<form id="supyp" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
	<div class="info">
		<i class="fa fa-trash"></i>
		<?php echo _t('yp','sup_yp_warning'); ?>
	</div>
	<div>
		<input name="id_yp" type="hidden" value="<?php echo $id; ?>" />
		<input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
		<input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
		<?php echo cancel_button($link_det2.$id); ?>
		<input name="valider" type="submit" value="<?php echo _t('btn','valid') ?>" class="button" id="valider" />
	</div>
</form>
<br />
</div> <!-- closing #content -->
</div> <!-- closing .contentcontainer -->