<div  style="color:red;font-size: 15px " ><?php echo  $this->message; ?></div>
<div class="comm_div">
    <div class="comm_content_block">
        <h3>Manage Pending Listing</h3>
        <div class="comm_content_block_items">
            <div class="btm-padding">
                <form name="frmsearch" method="post" action="<?php echo ConfigUrl::base(); ?>index/pendinglist">
                    <span class="label-stl">Search</span>
                    <input type="text" value="<?php echo ($_POST['txtSearch']) ? $_POST['txtSearch'] : $this->txtSearch ?>" class="txt_area_2 txt_bx" name="txtSearch" >&nbsp;<input class="btn_styles butnstl" type="submit" name="btnSearch" value="Search">
                </form>
                <div class="clear"></div>
            </div>
            <table width="100%" cellspacing="1" cellpadding="0" border="0" id="example" class="list_table">
                
                <tbody><tr>
                        <th width="3%" valign="top" align="center">#</th>
                        <th width="25%" valign="top" align="left"><a href="<?php echo ConfigUrl::base() ?>index/pendinglist/1/Title/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC' ?>">Ad Title</a></th>
                        <th width="20%" valign="top" align="left"><a href="<?php echo ConfigUrl::base()?>index/pendinglist/1/vFirstName/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Posted By</a></th>
                        <th width="10%" valign="top" align="center"><a href="<?php echo ConfigUrl::base() ?>index/pendinglist/1/dPostDate/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC' ?>">Date</a></th>
                        <th width="25%" valign="top" align="center">Action</th>
                    </tr>
                    <?php
                    if (sizeof($this->resRatings) > 0) {
                        $i = 0;
                        foreach ($this->resRatings as $row) {
                            $i++;
                            ?>
                        <div id="rateMsg<?php echo $row->nBusId; ?>" style="color: red"></div>
                        <div>
                            
                            <tr class="row_color1" id="rate<?php echo $row->nBusId; ?>">
                                <td valign="top" align="center" width="3%"><?php echo ($this->page - 1) * $this->pageMaxCount + $i ?></td>
                                <td valign="top" align="left" width="58%"  id="divCommVal" ><a href="<?php echo ConfigUrl::base() . 'index/viewlisting/' . stripslashes($row->nBusId) . '/'; ?>" target='_blank'><?php echo stripslashes($row->Title); ?></a></td>
                                <td valign="top" align="left"><?php echo stripslashes($row->vFirstName).' '.stripslashes($row->vLastName)?></td>
                                <td  valign="top" align="center" width="8%"><?php echo date("m/d/Y", strtotime(stripslashes($row->dPostDate))); ?></td>
                                <td  valign="top" align="center" id="divStatusVal" width="7%"> <?php echo ($row->nStatus == 0) ? "<span id=\"status$row->nBusId\"><a href='javascript:void(0)' id=\"$row->nBusId\"  class='approveratings1'>Approve</a></span>" : "Approved"; ?> &nbsp;|&nbsp; <a href="javascript:void(0);" id="<?php echo $row->nBusId ?>" class="delratings" >Delete</a></td>
                            </tr>
                        </div>
                        <?php
                    }
                }
                else
                    echo '<tr class="row_color1">
                                                <td colspan="6">No Record Found</td></tr>';
                ?>
                </tbody></table>
                    
            <div class="clear"></div>
        </div>
    </div>
</div>


       <!--  start paging..................................................... -->
         <?php if($this->pageCount > 1){  ?>

       <div class="pagination">
               <ul>
                   <?php if ($this->page != 1) { ?>
                       <li><a href="<?php echo ConfigUrl::base() ?>index/pendinglist/1/<?php echo $this->sortfield.'/'.$this->order .'/'.$this->txtSearch ?>" class="page_first" >First</a></li>
                       <li><a class="page_prev" href="<?php echo ConfigUrl::base() ?>index/pendinglist/<?php if ($this->page != 1) echo $this->page - 1; else echo $this->page; ?>/<?php echo  $this->sortfield.'/'.$this->order .'/'.$this->txtSearch ?>" >Previous</a></li>
                       <?php }
                   ?>
                   <li class="pageinfo"><div id="page-info">Page <strong><?php echo $this->page; ?></strong> / <?php echo $this->pageCount; ?></div></li>
                   <?php if ($this->pageCount != $this->page) { ?>
                       <li><a class="page_next" href="<?php echo ConfigUrl::base() ?>index/pendinglist/<?php if ($this->pageCount != $this->page) echo $this->page + 1; else echo $this->pageCount; ?>/<?php echo $this->sortfield.'/'.$this->order .'/'.$this->txtSearch ?>" >Next</a></li>
                       <li><a class="page_last" href="<?php echo ConfigUrl::base() ?>index/pendinglist/<?php echo $this->pageCount; ?>/<?php echo $this->sortfield.'/'.$this->order .'/'.$this->txtSearch ?>" >Last</a></li>
                       <?php }
                   ?>
               </ul>
               <div class="clear"></div>
           </div>
        <?php
        }
       ?>

        <div id="divComm" style="top: 100px;left: 300px;position: absolute;background-color: gray"></div>
        <script type="text/javascript">
            $(document).ready(function() {
                $('.delratings').click(function () {
                    id =  $(this).attr("id");
                    var answer = confirm("Are you sure want to delete the listing?")
                    if (answer){
			if (id=='') {
                            return false;
			}
                   	var data = 'id='+ id;
			$.ajax({
                            url: "<?php echo ConfigUrl::base(); ?>index/deleteListing/",
                            type: "POST",
                            data: data,
                            cache: false,
                            success: function (html) {
                                if (html==1) {
                                    $("#rateMsg"+id).html('<font color="green">Listing deleted successfully</font>');
                                    $("#rateMsg"+id).fadeIn("Slow");
                                    setTimeout(function() {$("#rateMsg"+id).fadeOut("slow");$("#rateMsg"+id).html('')},2000);
                                    $('#rate'+id).fadeOut(1000);
                                }
                                else alert('Sorry, unexpected error. Please try again later.');
                            }
			});
                    }
                    return false;
                });
                $('.approveratings1').click(function () {
                    id =  $(this).attr("id");
                    if (id=='') {
                        return false;
                    }
                    var data = 'id='+ id;
                    $.ajax({
                        url: "<?php echo ConfigUrl::base(); ?>index/approveListing/",
                        type: "POST",
                        data: data,
                        cache: false,
                        success: function (html) {//alert(html);
                            if (html==1) {
                                $("#rateMsg"+id).html('<font color="green">Listing Approved Successfully</font>');
                                $("#rateMsg"+id).fadeIn("Slow");
                                $("#status"+id).html("Approved");
                                setTimeout(function() {$("#rateMsg"+id).fadeOut("slow");$("#rateMsg"+id).html('')},2000);
                            }
                            else alert('Sorry, unexpected error. Please try again later.');
                        }
                    });
                    
                });
            });
      </script>
