<?php $this->load->view('site/templates/header.php');
$this->load->model('order_model');
?>
<?php #echo "<pre>"; print_r($ViewList); die; ?>

<div style="background:none repeat scroll 0 0 #FFFFFF;border-bottom:1px solid #DDDDDD;border-top:1px solid #DDDDDD;padding: 20px 0;" class="add_shop">
  <div class="main">
    <table class="tab_form_list_table" style="padding:none;">
      <thead>
        <tr class="table-header">
          <th class="date-wid" style="width:80px;"><?php if($this->lang->line('discussion_bag_items') != '') { echo stripslashes($this->lang->line('discussion_bag_items')); } else echo 'Bag Items'; ?></th>
          <th align="center"><?php if($this->lang->line('discussion_product_name') != '') { echo stripslashes($this->lang->line('discussion_product_name')); } else echo 'Product Name'; ?>
            <span class="sort-arrow"></span></th>
          <th class="price-wid"><span>
            <?php if($this->lang->line('discussion_qty') != '') { echo stripslashes($this->lang->line('discussion_qty')); } else echo 'Qty'; ?>
            </span></th>
          <th class="list-wid" style="width: 85px;"><span>
            <?php if($this->lang->line('discussion_unit_price') != '') { echo stripslashes($this->lang->line('discussion_unit_price')); } else echo 'Unit Price'; ?>
            </span></th>
          <th class="date-wid"><?php if($this->lang->line('discussion_sub_total') != '') { echo stripslashes($this->lang->line('discussion_sub_total')); } else echo 'Sub Total'; ?>
            <span class="sort-arrow"></span></th>
        </tr>
      </thead>
      <tbody style="background:#F2F2F2;">
        <?php foreach($ViewList->result() as $product){ ?>
        <?php $imgArr=explode(',',$product->image); ?>
        <tr class="row-1 odd">
          <td class="colsli" style="padding:0px !important; text-align:center;"><div class="colsli"> <a class="list-image12" title="<?php echo $product->product_name; ?>" style="float:none;border:none;"> <img class="" width="75" height="75" alt="<?php echo $product->product_name; ?>" src="images/product/list-image/<?php echo $imgArr[0]; ?>"> </a> </div></td>
          <td class="colsli"><?php echo $product->product_name; ?><br />
            <?php echo $product->attribute_values; ?></td>
          <td class="colsli"><?php echo $product->quantity; ?></td>
          <td class="colsli"><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$product->price,2); ?></td>
          <td class="colsli"><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*($product->price*$product->quantity),2); ?></td>
        </tr>
        <?php $subtotal=$subtotal+($product->price*$product->quantity); $shipcost=$shipcost+$product->shippingcost;} ?>
      </tbody>
    </table>
    <table class="tab_form_list_table" style="padding:none;">
      <tr>
        <td align="left" style="float:left;background:#F2F2F2;"><table class="tab_form_list_table">
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_order_id') != '') { echo stripslashes($this->lang->line('discussion_order_id')); } else echo 'Order Id'; ?>
                </strong></td>
              <td><?php echo $ViewList->row()->dealCodeNumber; ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_order_date') != '') { echo stripslashes($this->lang->line('discussion_order_date')); } else echo 'Order Date'; ?>
                </strong></td>
              <td><?php echo $ViewList->row()->created; ?></td>
            </tr>
          </table></td>
        <td align="right" style="float:right; background:#F2F2F2;"><table class="tab_form_list_table">
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_sub_total') != '') { echo stripslashes($this->lang->line('discussion_sub_total')); } else echo 'Sub Total'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$subtotal,2); ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('checkout_coupon_discount') != '') { echo stripslashes($this->lang->line('checkout_coupon_discount')); } else echo 'Coupon Discount'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$ViewList->row()->discountAmount,2); ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('checkout_gift_discount') != '') { echo stripslashes($this->lang->line('checkout_gift_discount')); } else echo 'Gift Discount'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$ViewList->row()->giftdiscountAmount,2); ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_shipping_cost') != '') { echo stripslashes($this->lang->line('discussion_shipping_cost')); } else echo 'Shipping Cost'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$shipcost,2); ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_shipping_tax') != '') { echo stripslashes($this->lang->line('discussion_shipping_tax')); } else echo 'Shipping Tax'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$ViewList->row()->tax,2); ?></td>
            </tr>
            <tr>
              <td><strong>
                <?php if($this->lang->line('discussion_grand_total') != '') { echo stripslashes($this->lang->line('discussion_grand_total')); } else echo 'Grand Total'; ?>
                </strong></td>
              <td><?php echo $currencySymbol;?> <?php echo number_format($currencyValue*$ViewList->row()->total,2); ?></td>
            </tr>
          </table></td>
      </tr>
    </table>
    <input type="hidden" id="buyerid" value="<?php echo $ViewList->row()->user_id; ?>" />
    <input type="hidden" id="sellerid" value="<?php echo $ViewList->row()->sell_id; ?>" />
    <p>
      <?php if($this->lang->line('discussion_board') != '') { echo stripslashes($this->lang->line('discussion_board')); } else echo 'Discussion Board'; ?>
      <span id="totalCmt">(<?php echo $ordercomments->num_rows; ?>)</span></p>
    <div class="post_comment_display">
      <table width="100%" id="comments">
        <?php if($ordercomments->num_rows()>0){?>
        <?php foreach($ordercomments->result() as $comments){ ?>
        <?php
							$posterinfo=$this->order_model->get_all_details(USERS,array('id'=>$comments->posted_id));
							if($posterinfo->row()->thumbnail!=''){
								$post_img=$posterinfo->row()->thumbnail;
							}else{
								$post_img='profile_pic.png';
							}
							/*time frame*/
							$datediff = time()-strtotime($comments->post_time); 
							$diffdate=floor($datediff/(60*60*24));
							if($diffdate!=0){
								if($diffdate<4){
									$cmtTime =$diffdate.' days ago';
								}else{
									$cmtTime =date('m/d/y',strtotime($comments->post_time));
								}
							}else{
								if(floor($datediff/(60*60))<1){
									if(floor($datediff/(60))>0){
										$cmtTime =floor($datediff/(60)).' mins ago';
									}else{
										$cmtTime ='just now';
									}
								}else{
									$cmtTime= floor($datediff/(60*60)).' hours ago';
								}
							}
							if($comments->posted_id==$loginCheck){
								$post_by='You - '.$posterinfo->row()->user_name;
							}else{
								$post_by=$comments->posted_by.' - '.$posterinfo->row()->user_name;
							}
							
						?>
        <tr class="postCMT">
          <td class="post_img"><a href="view-people/<?php echo $posterinfo->row()->user_name; ?>"> <img src="images/users/thumb/<?php echo $post_img; ?>" alt="<?php echo $post_img; ?>" class="post_imgthumb" /> </a> </td>
          <td class="post_msg" width="95%"><p class="post_by"><a href="view-people/<?php echo $posterinfo->row()->user_name; ?>"><strong><?php echo ucfirst($post_by); ?></strong></a></p>
            <p class="post_message"><?php echo $comments->post_message; ?></p>
            <p class="cmtTime"><?php echo $cmtTime; ?></p></td>
        </tr>
        <?php } ?>
        <?php }else{ ?>
        <tr class="post">
          <td class="post_img"><?php if($this->lang->line('discussion_no_discussion') != '') { echo stripslashes($this->lang->line('discussion_no_discussion')); } else echo 'No Discussion Available'; ?></td>
        </tr>
        <?php } ?>
      </table>
    </div>
    <div class="post_textarea">
      <textarea  style="width:500px;height:70px;border:1px #99CC99 solid;" id="postcmt" name="postcmt" placeholder="<?php if($this->lang->line('discussion_your_discussion_here') != '') { echo stripslashes($this->lang->line('discussion_your_discussion_here')); } else echo 'Your Discussion Here'; ?>"></textarea>
      <br />
      <input class="post_comment" type="button" value="<?php if($this->lang->line('discussion_post') != '') { echo stripslashes($this->lang->line('discussion_post')); } else echo 'POST'; ?>" id="postcomment" data-val-id="<?php echo $ViewList->row()->dealCodeNumber; ?>"/>
      <img src="images/ajax_loader_blue.gif" alt="Posting..." id="postLoading" style="display:none;" class="postLoading" /> </div>
  </div>
</div>
<?php $this->load->view('site/templates/footer'); ?>
