<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
             <?php
               echo isset($title) ? $title : NULL;
             ?>
          </h1>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-3 col-sm-6 col-xs-12">
                  <div class="info-box">
                    <span class="info-box-icon bg-aqua icons_edit_top"><i class="fa fa-dollar"></i></span>

                    <div class="info-box-content">
                      <span class="info-box-text">Offer Id</span>
                      <span class="info-box-number"><?php echo $offer['id'] ?></span>
                    </div>
                    <!-- /.info-box-content -->
                  </div>
                  <!-- /.info-box -->
                </div>
                <!-- /.col -->
                <div class="col-md-3 col-sm-6 col-xs-12">
                  <div class="info-box">
                    <span class="info-box-icon bg-green icons_edit_top"><i class="fa fa-money"></i></span>

                    <div class="info-box-content">
                      <span class="info-box-text">Price Per Item</span>
                      <span class="info-box-number"><?php echo (isset($offerDefaultPrice) && is_array($offerDefaultPrice))?$offerDefaultPrice['price_per_item'] : 0 ?> L.E</span>
                    </div>

                    <!-- /.info-box-content -->
                  </div>
                  <!-- /.info-box -->
                </div>
                <!-- /.col -->

              </div>
              <!-- /.row -->
            <div class="row">
                <form method="post">
                <div class="col-lg-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                          <h3 class="box-title">Show Offer Information</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->

                        <?php
                        if(isset($message))
                        {
                            echo $message;
                            echo $offer['id'];
                        }
                        ?>
                          <div class="box-body">
                              <table class="table table-bordered dt-responsive tablefordata">
                                    <tr>
                                        <td><strong>Offer Id</strong></td>
                                        <td><strong><?php echo $offer['id'] ?></strong></td>
                                    </tr>
	                              <tr>
                                        <td><strong>Price After Discount</strong></td>
                                        <td><strong><?php echo (isset($offerDefaultPrice) && is_array($offerDefaultPrice))?$offerDefaultPrice['price_after_discount'] : 0 ?> L.E</strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer En Title</strong></td>
                                        <td><strong><?php echo $offerEnData['title'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer Ar Title</strong></td>
                                        <td><strong><?php echo $offerArData['title'] ?></strong></td>
                                    </tr>
                                  <tr>
                                        <td><strong>Offer En Slug</strong></td>
                                        <td><strong><?php echo $offerEnData['slug'] ?></strong></td>
                                    </tr>
                                  <tr>
                                        <td><strong>Offer Ar Slug</strong></td>
                                        <td><strong><?php echo $offerArData['slug'] ?></strong></td>
                                    </tr>

                                    <tr>
                                        <td><strong>Offer En Description</strong></td>
                                        <td><strong><?php echo $offerEnData['description'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer Ar Description</strong></td>
                                        <td><strong><?php echo $offerArData['description'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer En keywords</strong></td>
                                        <td><strong><?php echo $offerEnData['keywords'] ?></strong></td>
                                    </tr>
                                  <tr>
                                        <td><strong>Offer Ar keywords</strong></td>
                                        <td><strong><?php echo $offerArData['keywords'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Main Category</strong></td>
                                        <td><strong><?php echo $offerEnCategory['name']." - ".$offerArCategory['name'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Sub Category</strong></td>
                                        <td>
                                            <strong>
                                                <?php
                                                if(is_array($offerEnSubCategory))
                                                {
                                                    echo $offerEnSubCategory['name'].' - '.$offerArSubCategory['name'];
                                                }else{
                                                    echo 'No Data';
                                                }
                                                ?>
                                            </strong>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer Attributes</strong></td>
                                        <td>
                                            <table  class="table table_for_data table-striped table-bordered dt-responsive nowrap tableData" cellspacing="0" width="100%">
                                                <tr>
                                                    <th class="text-center">Attribute</th>
                                                    <th class="text-center">Value En</th>
                                                    <th class="text-center">Value Ar</th>
                                                </tr>
                                            <?php
                                            if(isset($offerItems) && is_array($offerItems))
                                            {
                                                foreach($offerItems as $key=>$data)
                                                {
                                                  echo '
                                                            <tr>
                                                                <td>'.$itemEnData[$key]['name']." - ".$itemArData[$key]['name'].'</td>
                                                                <td>'.$data['value'].'</td>
                                                                <td>'.$data['value_ar'].'</td>
                                                            </tr>
                                                       ';
                                                }
                                            }else{
                                                echo '<tr><td colspan="3">No Data Found</td></tr>';
                                            }
                                            ?>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>Approved</strong></td>
                                        <td>
                                            <strong>
                                                <?php
                                                    if($offer['approved'] == 1)
                                                    {
                                                        echo '<span data-id="'.$offer['id'].'" title="update Status" data-target="on" class=" pointer status on update'.$offer['id'].'">Yes</span>';
                                                    }else{
                                                        echo '<span data-id="'.$offer['id'].'" title="update Status" data-target="off" class=" pointer status off update'.$offer['id'].'">No</span>';
                                                    }
                                                ?>
                                            </strong>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td><strong>Added By</strong></td>
                                        <td><strong><?php echo $addedBy['name'] ?></strong></td>
                                    </tr>
                                  <tr>
                                        <td><strong>Last Update By</strong></td>
                                        <td><strong><?php echo $lastUpdatedBy['name'] ?></strong></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Offer Created</strong></td>
                                        <td><strong><?php echo date("Y/m/d h:i:s A",$offer['created']); ?></strong></td>
                                    </tr>
                                  <tr>
                                      <td colspan="2">

                                          <a href="<?php echo BASE_URL."VendorProduct/showVendorOffer/".$offer['id']; ?>" class="btn btn-primary">
                                              <i class="fa fa-eye" aria-hidden="true"></i> Show Vindor Offer
                                          </a>
	                                      <a href="<?php echo BASE_URL."offer/showcomments/".$offer['id']; ?>" class="btn btn-primary">
		                                      <i class="fa fa-comments" aria-hidden="true"></i> Show Comments
	                                      </a>

                                      </td>
                                  </tr>

                              </table>
                          </div>
                          <!-- /.box-body -->
                      </div>
                      <!-- /.box -->
                </div>

                </form>
            </div>
      </section><!-- /.content -->
</div><!-- /.content-wrapper -->
<script>
$(document).ready(function(){
    	//start update  Product approved
        $(".tablefordata").on( 'click', '.status', function () {
             var myId = $(this).attr("data-id");
             var myaction = "updateApproved";
             var mystatus = $(this).attr("data-target");
             var allData = {"action":myaction,"id":myId,"status":mystatus};
            $.ajax({
                    url: "<?php echo BASE_URL.'Offer/updateApproved' ?>",
                    type:"POST",
                    data: allData,
                    beforeSend:function(){
                    },
                    statusCode: {
                     404: function() {
                       alert( "page not found" );
                        },
                    },
                    success:function(valdata) {
                        var da = JSON.parse(valdata);
                        if(da['status'] == "success")
                        {
                          if(mystatus == "on")
                          {
                             $(".update"+myId).removeClass("on") ;
                             $(".update"+myId).html("No");
                             $(".update"+myId).addClass("off");
                             $(".update"+myId).attr("data-target","off");
                          }else{
                              $(".update"+myId).removeClass("off") ;
                              $(".update"+myId).html("Yes");
                             $(".update"+myId).addClass("on");
                              $(".update"+myId).attr("data-target","on");
                          }
                        }else{
                            alert("faild");
                        }
                    }
                });
                return false;
        });

    	//end update  Product approved
});
</script>
