<?
$str_activ=$_SERVER['PHP_SELF'];

if($_REQUEST['del_magazin'])
	{
	$del_magazin=intval($_REQUEST['del_magazin']);
	$r_magazin=mysql_query("SELECT * FROM magazin WHERE id='".$del_magazin."'");
	$rr_magazin=mysql_fetch_array($r_magazin);
	}

if($_GET['del_magazin'])
	{
	echo '<table width=400 bordercolor=red border=3 cellSpacing=0 cellPadding=5><tr><td bgcolor=ffffff>
	<p>Вы действительно хотите удалить магазин: <b>'.$rr_magazin['zag'].'</b> ?</p>';
	if(!$rr_magazin['activ'])
	echo '<p><font color=red><b>Предупреждение! </b></font><br>Данный магазин является <font color=red><b>действующим</b></font></p>';
	?>
	<form action="<?=$str_activ?>" method="post" name="form_del" >
  	<input type="hidden" name="del_magazin" value="<?=$del_magazin?>">
  	<input class="submit" type="submit" name="del_yes" value="Да">
  	<input class="submit" type="submit" name="del_no" value="Нет">
	</form>
	<?
	echo '</td></tr></table><br>';
	}
	
if($_POST['del_yes'] && $_POST['del_magazin'])
	{
	$small = '../'.$rr_magazin['small'];
	if(file_exists($small) && is_file($small)) unlink($small);
	if(mysql_query("DELETE FROM magazin WHERE id='".$del_magazin."'"))
	echo '<p><font color=green>Магазин успешно удален</font></p>';
	}


$maxRows_Recordset1=$rru['ob_na_str'];
$pn = 0;
if (isset($_GET['pn'])) 
	{
	$pn = intval($_GET['pn']);
	}
 
$uri=$_SERVER['REQUEST_URI'];
$uri=str_replace("&pn=".$pn, "", $uri);
$uri=str_replace("param_pn=".$pn, "", $uri);
$uri=str_replace("%5B", "[", $uri);
$uri=str_replace("%5D", "]", $uri);

if($id_firm)
$zmm='/_'.$id_firm.'/';
else
$zmm='/magazin/';

$uri2=explode("param_", $uri);

$startRow_Recordset1 = $pn * $maxRows_Recordset1;
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_array($Recordset1);

	
	$all_Recordset1 = mysql_query($query_count_all);
	$arr_query_count = mysql_fetch_array($all_Recordset1);
	$totalRows_Recordset1 = $arr_query_count[0];

$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

echo '&nbsp;Найдено записей: '.intval($totalRows_Recordset1);

if($totalRows_Recordset1) 
	{
	echo '<br><br><TABLE width="100%"  cellpadding="0" cellspacing="0">';

	do 
		{ 
	  	if (isset ($row_Recordset1['id'])) 
			{
			
			if(strtotime($row_Recordset1['vip_data'])>time() && !$row_Recordset1['vip_spec']) $vip_fon='background="'.$bp.'icon/vip-fon.jpg"'; else $vip_fon=''; 
			
			if($row_Recordset1['id']==14 ) $vip_fon='background="'.$bp.'icon/vip-fon.jpg"'; else $vip_fon=''; /////////////////// VIP FON
			
			echo '<tr data-href="'.$bp.'_'.$row_Recordset1['zag_url'].'/"><td '.$vip_fon.'><table width="100%" cellpadding="5" cellspacing="5" >';
			
			echo '<tr valign=top height="100">';
			
			echo '<td width="120">';
			
			echo dat_rus($row_Recordset1['data'], 1).'&nbsp; '.date("Y", strtotime($row_Recordset1['data']));
			echo '<br><font color=blue>'.dat_rus($row_Recordset1['data1'], 1).'&nbsp; '.date("Y", strtotime($row_Recordset1['data1'])).'</font>';
			
			$ost = ceil((strtotime($row_Recordset1['data1'])-time())/(24*60*60));
			if($ost>0)
			echo '<br><font color=green>Осталось '.$ost.' дн.</font>';
			elseif($ost==0)
			echo '<br>Последний день';
			elseif($ost<0)
				{
				if($row_Recordset1['activ'])
				echo '<br><font color=red>Не активен</font>';
				else
				echo '<br><font color=orange>Просрочен</font>';
				}
			
			echo '<br><a target=_blank href="../blok/edit_magazin.php?id='.$row_Recordset1['id'].'">редактировать</a>';
			echo '<br><a href="?del_magazin='.$row_Recordset1['id'].'"><font color=red>удалить</font></a>';
			
			echo '<td align=center valign=top width="120">';
			if($row_Recordset1['small'])
			echo '<img src="'.$bp.$row_Recordset1['small'].'" border=0>';

			echo '<td width="400">';
			if($row_Recordset1['opis']) $tit='title="'.obrez(str_replace("\n"," ", $row_Recordset1['opis']), 200).'"'; else $tit='';
			echo '<a style="font-size:14px" '.$tit.' href="'.$bp.'_'.$row_Recordset1['zag_url'].'/" >'.$row_Recordset1['zag'].'</a>';

			echo '<br><span style="color:#858585">'.$row_Recordset1['gorod'].'</span>';

						
			echo '<td>';
			echo '<span style="color:#858585">'.$row_Recordset1['razdel'].'</span>';

			echo '</table>';
			}
		} while ($row_Recordset1 = mysql_fetch_array($Recordset1));
		echo '</table>';
	}

mysql_free_result($Recordset1);





$uris=explode("?",$uri);

if($uris[1]) //есть параметы кроме pn
	{
	$dop2="&pn=";
	}
else
	{
	$dop2="?pn=";
	}

pages(15, $totalPages_Recordset1, $pn, $uri, $dop2);

?>