<main id="maincontent" role="main">
<div class="container">
<div class="row text-pkb">
<h1>НАВИГАЦИЯ</h1>
</div>
<div class="row">
<div class="pnd-list">
<div class="table-list">
<table>
<tr>
<?php $lists = $wpdb->get_results( "SELECT * FROM list" );
$counter=0;
?>
<?php foreach($lists as $list){
$counter++;
?>
<td>
<a class="pnd-li nonhref" id="<?php echo $list->id ?>" href="?page_id=<?php echo $_GET['page_id'] ?>&pnd=<?php echo $list->id ?>"><p><?php echo $list->number ?></p><p><?php echo $list->addres ?></p></a></td>
</td>
<?php if($counter == 9){
echo "</tr><tr>";
$counter = 0;
} ?>
<?php } ?>
</tr>
</table>
</div>
</div>
</div>
<div class="row">
<div class="pnd-addres">
<div class="addres-left">
<ul>
<?php
function definition($pnd){
$ar_pnd=array();
foreach($pnd as $pndOtd){
array_push($ar_pnd, $pndOtd->branch);
}
$ar_pnd=array_unique($ar_pnd);
$arr_otd = $ar_pnd;
return $arr_otd;
}
$pndid = 'number_'. $_GET['pnd'];
$pnd = $wpdb->get_results( "SELECT * FROM $pndid" );
$arr_otd = definition($pnd);
foreach($arr_otd as $otd){
?>
<li><a href="page_id=<?php echo $_GET['page_id'] ?>&pnd=<?php echo $_GET['pnd'] ?>&otd=<?php echo $otd ?>" class="nonhref otd-but"><?php echo $otd ?></a></li>
<?php }?>
</ul>
</div>
<div class="addres-right">
<?php if($_GET['pnd'] == 1){ ?>
<h1>ДЛЯ УДОБНОГО ПОИСКА НАЖМИТЕ НА СТРОЕНИЕ</h1>
<div class="addres-info">
<img src="img/map.png" alt="">
</div>
<?php }else{ ?>
<div class="card">
<?php
$idPnd = $_GET['pnd'];
$addresPnd = $wpdb->get_results("SELECT * FROM list WHERE id LIKE $idPnd");
?>
<div class="card-left">
<div class="header-card">
<h2><?php echo $addresPnd[0]->number; ?></h2>
<p><?php echo $addresPnd[0]->addres; ?></p>
</div>
<div class="footer-card">
<p class="addresPnd"><?php echo $addresPnd[0]->addresFull; ?></p>
<p class="numberPnd"><?php echo $addresPnd[0]->contacts; ?></p>
</div>
</div>
<div class="card-right">
<img src="img/<?php echo $idPnd ?>.jpg" alt="<?php echo $idPnd ?>">
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="row">
<div class="pnd-tables">
<div class="table-name">
<table>
<?php
if($_GET['otd']){
$searchdb = $_GET['otd'];
$pnd = $wpdb->get_results( "SELECT * FROM $pndid WHERE branch LIKE '$searchdb'" );
}
function maxArr($pnd){
$maxArray = array();
foreach($pnd as $maxCount){
array_push($maxArray, $maxCount->floor);
}
$maxArray = array_map('intval',$maxArray);
$maxArray = max($maxArray);
return $maxArray;
}
$maxNumb = maxArr($pnd);
?>
<tr>
<td>Должность</td>
<td>ФИО</td>
<td>Адрес</td>
<td>Кабинет</td>
<td>Городской номер</td>
<td>Внутренний номер</td>
</tr>
<?php for($i=1;$i <= $maxNumb;$i++){ ?>
<tr><td colspan="6" class="separator"><?php echo $i ?> ЭТАЖ</td></tr>
<?php foreach($pnd as $tableName){
if($tableName->floor == $i){ ?>
<tr>
<td><?php echo $tableName->rank ?></td>
<td><?php echo $tableName->name ?></td>
<td><?php echo $tableName->addres ?></td>
<td><?php echo $tableName->cabinet ?></td>
<td><?php echo $tableName->cphone ?></td>
<td><?php echo $tableName->phone ?></td>
</tr>
<?php }
} ?>
<?php } ?>
</table>
<div class="time-z">
</div>
</div>
</div>
</div>
</div>
</main>
<script>
jQuery('.otd-but').click(function(event){
var href = jQuery(this).attr('href');
jQuery.ajax({
type: 'GET',
url: '/wp-content/themes/jewellery-lite-child/hand-funct.php',
data: href,
success: function(html){
jQuery('.time-z').html(html);
},
error: function(xhr, status, error){
jQuery('.time-z').html(error);
}
});
});
jQuery('.nonhref').click(function(){
return false;
});
</script>