<div class="submenu">
    <center><?php echo $this->element('menus/sessions/menu'); ?></center>
</div>

<div class="submenu">
    <center><?php echo $this->element('menus/menu/menu'); ?></center>
</div>
<div class="submenu">
    <center><?php echo $this->element('menus/menu/subsubmenu'); ?></center>
</div>
<div class="col-sm-12">
<h3 align="center"><?= $pageSubTitle?></h3>
</div>
<p align="center">
    <!-- </?php echo $this->Paginator->counter(array('format' => __('Page {{page}} of {{pages}}, showing {{current}} records out of {{count}} total, starting on record {{start}}, ending on {{end}}'))); ?> -->
</p>
<hr class="separate-title" />

<!-- <h4>
    <center><b>All Sub Sub Menus</b></center>
</h4> -->

<div class="row section-row">
    <div class="col-sm-12">
        <div style="float: left">
            <?php echo '<div class="search-text">Search Listing:&nbsp;&nbsp</div>'; ?>
        </div>
        <div style="float: left;margin-right: 20px">
            <?php
			 
				echo $this->Form->create(null, ['type'=>'get', 'url'=>['action'=>'categories']]);
				echo $this->Form->input('search',array('id' => 'search','class' => 'form-control search-box', 'label' => false));
			?>
        </div>
        <div style="float: left">
            <?php
				echo $this->Form->button('Search',['type' => 'submit', 'class'=>'btn btn-primary']);
				echo $this->Form->end();
			 ?>
        </div>
        <div class="pull-right">
            <?php  ?>
        </div>
    </div>
</div>
<center><?= $this->Flash->render() ?></center>

<div class="row">
    <div class="col-sm-12">
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                    <th>Name</th>
                    <th>Descriptions</th>
                    <th>Content</th>
                    <th>Home</th>
                    <th>Icon</th>
                    <th>Image</th>
                    <th>Actions</th>
                </thead>
                <tbody>
                    <?php
						$i = 0;
						foreach ($listings as $listing):  
							$img = Cake\Core\Configure::read('IMAGE_PREPATH') . $listing->image_path;
					?>
                    <tr>

                        <td><?php echo $listing->name; ?></td>
                        <td><?php echo $listing->description; ?></td>
                        <td><?= $this->Text->truncate(strip_tags($listing->content),200,['ellipsis' => '...','exact' => false])?>
                        </td>
                        <td><?= $listing->show_on_home == 1 ? 'Yes' : 'No' ?></td>
                        <td><span><i class="fa <?= $listing->fa_icon ?>"></i></span> <?= $listing->fa_icon ?></td>
                        <td>
                            <?= isset($listing->image_path) && trim($listing->image_path) != '' ? '<a href="' . $this->Url->image($img) . '">' . $this->Html->image($img, [  'height' => '70px']) . '</a>' : '' ?>
                        </td>
                        <td class="actions">
                            <?php
								
									echo $this->Html->link(__('Edit '), ['controller'=>$slug,'action' => 'edit'.$actiontitle,$listing->pmid, $listing->id],['class' => 'btn btn-sm btn-info', 'style' => 'margin-bottom: 5px;']); 
									echo '  ';
								
									// echo $this->Html->link(__('View'), ['controller'=>$slug,'action' =>$actiontitle.'s' , $listing->id],['class' => 'btn btn-sm btn-default', 'style' => 'margin-bottom: 5px;']); 
									echo "  ";
									if($listing->status==1){
									echo $this->Html->link(__('Disable '), ['controller'=>$slug,'action' => 'disableMenu', $listing->id],['class' => 'btn btn-sm btn-danger', 'style' => 'margin-bottom: 5px;']); 
								   }else{
								   	echo $this->Html->link(__('Enable '), ['controller'=>$slug,'action' => 'enableMenu', $listing->id],['class' => 'btn btn-sm btn-success', 'style' => 'margin-bottom: 5px;']); 
								   }
								
								  	if ($listing->show_on_home == 1) {
										echo "  " . $this->Html->link(__("Remove from home"), ['controller' => $slug, 'action' => 'removeMenuFromHome', $listing->id],['class' => 'btn btn-sm btn-warning', 'style' => 'margin-bottom: 5px;']) . " " ;
									}
									else {
										echo "  " . $this->Html->link(__("Show on home"), ['controller' => $slug, 'action' => 'showMenuOnHome', $listing->id],['class' => 'btn btn-sm btn-primary', 'style' => 'margin-bottom: 5px;']) . " " ;
									}

                                    if ($listing->show_on_footer == 1) {
										echo "  " . $this->Html->link(__("Remove from footer"), ['controller' => $slug, 'action' => 'removeMenuFromFooter', $listing->id],['class' => 'btn btn-sm ', 'style' => 'margin-bottom: 5px;background-color:#152a3b;color:#fff;']) . " " ;
									}
									else {
										echo "  " . $this->Html->link(__("Show on footer"), ['controller' => $slug, 'action' => 'showMenuOnFooter', $listing->id],['class' => 'btn btn-sm ', 'style' => 'margin-bottom: 5px; background-color:#f76a3f;color:#fff;']) . " " ;
									}
							?>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="paginator" style="text-align: center;">
            <ul class="pagination">
                <?= $this->Paginator->prev('< ' . __('prev')) ?>
                <?= $this->Paginator->numbers(['first' => 3, 'last' => 3, 'modulus' => 4]) ?>
                <?= $this->Paginator->next(__('next') . ' >') ?>
            </ul>
            <p><?= $this->Paginator->counter() ?></p>
        </div>
    </div>
</div>