<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div class="layout-app">
				<div class="container"><div class="row row-app" style="width:1200px !important;">
					<div class="col-md-12">
						<div class="col-separator col-separator-first col-unscrollable bg-none">
							<div class="col-table">
								<div class="row">
									<div class="col-md-12">
										<div class="widget">
											<div class="widget-head">
												<!-- <a href="#" data-toggle="modal" class="btn btn-inverse pull-right mar"><i class="fa fa-share-square-o fa-fw"></i>Export File</a>-->
												<h4 class="heading">Transaction</h4>

											</div>

											<div class="widget-body">
                                                <form action="" method="GET" >
												<div class="col-md-12 selectBox">
													<div class="col-xs-4 col-md-2 bot-mar">
														<label class="col-xs-12">Transaction ID</label>
														<input type="text" class="form-control " name="transaction_id" value="<?php if ($arrGetData['transaction_id'] != "") echo $arrGetData['transaction_id']; ?>"/>
													</div>
													<div class="col-xs-4 col-md-2 bot-mar">
														<label class="col-xs-12">Mode of Payment</label>
														<select class="cust_select col-xs-12" name = "payment_mode">
                                                            <option value = "">--All--</option>
                                                            <option value = "1"
                                                            <?php if($_GET['payment_mode'] == 1) {?> selected
                                                            <?php } ?>>Cash</option>
                                                            <option value = "2" <?php if($_GET['payment_mode'] == 2) {?> selected
                                                            <?php } ?>>Cheque</option>
                                                            <option value = "3" <?php if($_GET['payment_mode'] == 3) {?> selected
                                                            <?php } ?>>Credit card</option>
                                                            <option value = "4" <?php if($_GET['payment_mode'] == 4) {?> selected
                                                            <?php } ?>>Online banking</option>
                                                            <option value = "5" <?php if($_GET['payment_mode'] == 5) {?> selected
                                                            <?php } ?>>Club Membership</option>
                                                            <option value = "6" <?php if($_GET['payment_mode'] == 6) {?> selected
                                                            <?php } ?>>Complementary</option>
                                                            <option value = "7" <?php if($_GET['payment_mode'] == 7) {?> selected
                                                            <?php } ?>>Replacement</option>
                                                            <option value = "8" <?php if($_GET['payment_mode'] == 8) {?> selected
                                                            <?php } ?>>Invoice</option>

														</select>
													</div>
													<div class="col-xs-4 col-md-2 bot-mar">
														<label class="col-xs-12">Status</label>
														<select class="cust_select col-xs-12" name = "status">
															<option value = "">--All--</option>
															<option value = "1" <?php if($_GET['status'] == 1) {?> selected
                                                            <?php } ?>>Unpaid</option>
															<option value = "2" <?php if($_GET['status'] == 2) {?> selected
                                                            <?php } ?>>processing</option>
															<option value = "3" <?php if($_GET['status'] == 3) {?> selected
                                                            <?php } ?>>Paid</option>
                                                            <option value = "6" <?php if($_GET['status'] == 6) {?> selected
                                                            <?php } ?>>Reprocess</option>
                                                            <option value = "5" <?php if($_GET['status'] == 6) {?> selected
                                                            <?php } ?>>Renewed</option>
														</select>
													</div>


													<div class="col-xs-4 col-md-2 bot-mar">
														<label class="col-xs-12">&nbsp;</label>
														<div>
															<button type="submit" class="btn btn-primary">Search</button>
														</div>
													</div>
                                                </form>
													<div class="clearfix"></div>
												</div>
											<table class="table table-white table-vertical-center margin-none table-striped footable">
												<thead>
													<tr>

														<th data-class="highlight"  class="text-center">Sr.no.</th>
														<th data-class="highlight"  class="text-center">Transaction Id</th>
														<th  class="text-center">Date</th>
														<th data-hide="phone" class="text-center">Subscriber Name</th>
														<th data-hide="phone" class="text-center">Product ID</th>
														<th class="text-center">Mode of Payment</th>
														<th class="text-center">Amount</th>
														<th data-hide="phone,tablet" class="text-center">Status</th>
														<th data-hide="phone,tablet" class="text-center">Overview</th>
														<th data-hide="phone,tablet" class="text-center">Transaction Details</th>
													</tr>
												</thead>
												<tbody>
                                                <?php
                                                if (count($arrData) > 0) {
                                                $intCounter = 1;
                                                foreach($arrData as $data) { ?>
													<tr>

														<td class="text-center"><?php echo $intCounter ?></td>
														<td class="text-center"><?php echo $data['transaction_id'] ?></td>
														<td class="text-center" ><?php echo date('d M Y',strtotime($data['transaction_date'])); ?></td>
														<td class="text-left"><?php echo $data['sub_name'] ?></td>
														<td class="text-center"><?php echo $data['magezine_id'] ?></td>
														<td class="text-center"><?php echo $data['mode'] ?></td>
														<td class="text-center"><?php echo number_format($data['amount'], 2)." ".$data['name'] ?></td>
                                                        <td class="text-center">
                                                            <?php if ($data['status'] == 'unpaid') {
                                                                $strClassForButton = 'btn-danger';
                                                            }
                                                            if ($data['status'] == 'unpaid' && $data['active_status'] == '1') {
                                                                $strClassForButton = 'btn-info';
                                                                $data['status'] = 'Reprocess';
                                                            }elseif($data['status'] == 'processing') {
                                                                $strClassForButton = 'btn-warning';
                                                            } elseif($data['status'] == 'paid') {
                                                                //$strClassForButton = 'btn-success';
                                                                switch($data['is_active']) {
                                                                    case 0:
                                                                        $data['status'] = 'Expired';
                                                                        $strClassForButton = '';
                                                                        break;
                                                                    case 1:
                                                                        $data['status'] = 'Active';
                                                                        $strClassForButton = 'btn-success';
                                                                        break;
                                                                    case 2:
                                                                        $data['status'] = 'Refunded';
                                                                        $strClassForButton = 'btn-info disabled';
                                                                        break;
                                                                    case 3:
                                                                        $data['status'] = 'Transferred';
                                                                        $strClassForButton = 'btn-info';
                                                                        break;
                                                                    case 4:
                                                                        $data['status'] = 'Deleted';
                                                                        $strClassForButton = 'btn-danger disabled';
                                                                        break;
                                                                    case 5:
                                                                        $data['status'] = 'Renewed';
                                                                        $strClassForButton = 'btn-warning disabled';
                                                                        break;    
                                                                }
                                                            }
                                                            ?>
                                                            <?php $strDecodedId = base64_encode($data['id']);
                                                                  $strEncodedTransactionId = base64_encode($data['transaction_id']);
                                                                  $strEncodedId = base64_encode($data['subscriber_id'])  ?>
                                                            <?php if ($data['status'] == 'Reprocess' || $data['status'] == 'unpaid') {?>
                                                                <a href="<?php echo base_url();?>index.php/subscriber/make_payment/?transaction_id=<?php echo $strEncodedTransactionId; ?>&sub_id=<?php echo $strEncodedId;?>" >
                                                                    <button class="btn <?php echo $strClassForButton; ?>"><?php echo ucwords($data['status']); ?></button>
                                                                </a>
                                                            <?php } else {   ?>

                                                                <button class="btn <?php echo $strClassForButton; ?>"><?php echo ucwords($data['status']); ?></button>
                                                            <?php } ?>

                                                        </td>
                                                        <td class="text-center">
                                                            <?php $strDecodedId = base64_encode($data['id']);
                                                            $strDecodedCommonTransactionid = base64_encode($data['transaction_id']); ?>
                                                            <a href="#editSub" data-toggle="modal" onclick="return fnGetPreview(<?php echo $data['transaction_id'];?>)"><i class="fa fa-2x fa-list"></i></a>
                                                        </td>
                                                        <td class="text-center">

                                                            <a href="<?php echo base_url(); ?>index.php/subscriber/fnGenerateTransactionReport/?id=<?php echo $strDecodedCommonTransactionid; ?>">
                                                                <i class="fa fa-2x fa-file-excel-o" title="Details of Transaction using Campaign"></i>
                                                            </a>
                                                        </td>

													</tr>
                                                <?php $intCounter ++; } } else {?>
                                                    <tr>
                                                        <td class="text-center" colspan="7">Sorry, no transactions found</td>
                                                    </tr>
                                                <?php } ?>

												</tbody>
											</table>
                                            <?php
                                            if ($limit < count($arrData)) { ?>
                                                <div class="text-center innerAll border-top pagination margin-none" align = "center">
                                                <?php echo $pagination; ?>
                                            </div>
                                            <?php } ?>

										</div>
										<!-- // END TRENDS -->
										
										
									</div>


								</div>

							</div>
							<div class="col-separator-h"></div>
						</div>
					</div>
					</div>
				</div>
			</div>
<div class="modal fade" id="editSub">
    <div class="modal-dialog">
        <div class="modal-content" id="tran_preview">

        </div>
    </div>
</div>
<script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_multiselect/js/jquery.multi-select.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_fuelux-radio/fuelux-radio.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_multiselect/multiselect.init.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>
<script>
    $(document).ready(function() {
        $(".container article").click(function() {
            $(this).toggleClass("expand");
        })
    });
    function fnGetPreview(intTransactionId)
    {
        $.ajax({
            url:"<?php echo base_url();?>index.php/users/transaction_preview",
            'type' : 'GET',
            'data' : {
                'transaction_id' :intTransactionId
            },
            success:function(result){
                $("#tran_preview").html(result);
            }
        });
    }
</script>