
<?php
ob_start();
session_start();
include_once("../config.php");
include_once("../functions.php");
include_once(ROOT_PATH.'library/helper.php');

$page_name = '';
$lang_code_global = "English";
$global_currency = "$";
$currency_position = "left";
$currency_sep = ".";
$localization = array();
$cookie_name = "ams_lang_code";
$cookie_name_branch = "ams_branch_code";
include_once(ROOT_PATH.'language/'.$lang_code_global.'/lang_add_fare.php');
$ams_helper = new ams_helper();


if (!check_login()) {
    header("Location: " . WEB_URL . "logout.php");
    die();
}
$building_rules = '';
$building_name = '';
$moderator_mobile = '';
$secrataty_mobile = '';
$security_guard_mobile = '';
$result_apartment = mysqli_query($link, "SELECT * FROM tblbranch LIMIT 1");
if ($row_apartment = mysqli_fetch_array($result_apartment)) {
    $building_rules = $row_apartment['building_rule'];
    $building_name = $row_apartment['branch_name'];
    $moderator_mobile = $row_apartment['moderator_mobile'];
    $secrataty_mobile = $row_apartment['secrataty_mobile'];
    $security_guard_mobile = $row_apartment['security_guard_mobile'];
}
//rent info

$receipt_id = '';
$receipt_issue_date = '';
$receipt_created_date = '';
$amount_paid = '';
$receipt_description = '';
$tenant_name = '';
$tenant_phone = '';
$tenant_email = '';
$tenant_floor = '';
$tenant_unit = '';
$tenant_bill_month = '';
$tenant_rent_bill = '0.00';
$period = 0;
$period_type = "";
$payment_type= '';
$payment_ref= '';
$balance = 0;
$bill_status = 0;
$start_date = "";
$end_date  = "";

if (isset($_GET['rec_id']) && (int)$_GET['rec_id'] > 0) {
    $get_data = get_input_serilization();
    $result = $link->query("Select * FROM rent_payment_updates_view WHERE rec_id = ".(int)$get_data['rec_id']);
    if ($row = mysqli_fetch_assoc($result)) {
        $receipt_id = $row['rec_id'];
        $receipt_created_date = date("M d, Y", strtotime($row['date']));
        $receipt_issue_date = date("M d, Y", strtotime($row['date']));
        $tenant_name = $row['r_name'];
        $payment_type =  $row['payment_type'];
        $tenant_phone = $row['r_contact'];
        $tenant_email = $row['r_email'];
        $tenant_block = $row['b_name'];
        $tenant_unit = $row['unit_no'];
        $tenant_rent_bill = $row['rate'];
        $amount_paid = $row['amount'];
        $receipt_description =$row['receipt_description'];
        $payment_ref = $row['payment_ref'];
        $tenant_amt_paid = $row['amt_paid'];
        $period = $row["period"];
        $rate_currency =$row["rate_currency"];
        $grand_total = $row["total_rent"];
        $balance = $grand_total - $tenant_amt_paid;
        $total_bill = $row['total_rent'];
        $bill_status = $row['bill_status'];
        mysqli_close($link);
    } else {
        echo 'Wrong Request';
        die();
    }
} else {
    echo 'Wrong Request';
    die();
}


//
?>
<!-- Content Header (Page header) -->
<!-- Main content -->
<section class="content">
<!-- Full Width boxes (Stat box) -->

<div class="row">
  <div class="col-md-12">
    <div align="center" style="margin-bottom:1%;"><a data-original-title="print" class="btn btn-success" onclick="javascript:printContent('PrintRentInvoice','Rent Receipt');" href="javascript:void(0);"><i class="fa fa-print"></i> Print</a></div>
    <div class="invoice-box" id="PrintRentInvoice">
      <h3 align="center"><u><?= $grand_total === $tenant_amt_paid? "RENT RECEIPT": "RENT RECEIPT" ?></u></h3>
      <table cellpadding="5" cellspacing="1">
        <tr class="top">
          <td colspan="2"><table>
              <tr>
                <td class="title" style="text-transform:uppercase;font-weight:bold;overflow:hidden;font-size:20px;"><?= $building_name; ?></td>
                <td><?= $_data['receipt_number'];?> # <?= $receipt_id; ?><br>
                  <?= $_data['receipt_issue_date'];?>: <?= $receipt_issue_date; ?><br>
                  </td>
              </tr>
            </table></td>
        </tr>
        <tr class="information">
          <td colspan="2"><table>
              <tr>
                <td><?= $row_apartment['b_address']; ?><br/>
                  <?= $_data['invoice_phone'];?>: <?= $row_apartment['b_contact_no']; ?><br/>
                  <?= $_data['invoice_email'];?>: <?= $row_apartment['b_email']; ?> </td>
               
          
                  
              </tr>
            </table></td>
        </tr>
        
        <tr class="heading">
          <td><?= $_data['invoice_receipt_details'];?> </td>
          <td></td>
        </tr>

        <tr class="item">
          <td>Name</td>
          <td><?= $tenant_name; ?> </td>
        </tr>
        <tr class="item">
          <td>Amount Paid</td>
          <td><?= $rate_currency. " ". ($amount_paid); ?> </td>
        </tr>
        
        <tr class="heading">
          <td>Description </td>
          <td></td>
        </tr>
        <tr class="item">
  
       
        <td> Rent Payment on Shop: <?= $tenant_unit ?> </td>
        <td></td>
        </tr>

	      <tr class="item">
        <td>Being: <?= $receipt_description ?> </td>
        <td></td>
        </tr>

        <tr class="item">
        <td> <?=$payment_type?> <?=$payment_ref?></td>
        <td></td>
        </tr>

        
    
        
      </table>
      
      <div class="receipt-signature">
        <div>-------------------------</div>
        <div class="signature-text"><?= $_data['receipt_signature'];?></div>
      </div>
    
     
    
  </style>
	<div class="col-md-12">
   <div class ="invoice-box" id= "PrintRentInvoice">
      <h3 align="center"><u><?= $grand_total === $tenant_amt_paid? "RENT RECEIPT": "RENT RECEIPT" ?></u></h3>
      <table cellpadding="5" cellspacing="1">
        <tr class="top">
          <td colspan="2"><table>
              <tr>
                <td class="title" style="text-transform:uppercase;font-weight:bold;overflow:hidden;font-size:20px;"><?= $building_name; ?></td>
                <td><?= $_data['receipt_number'];?> # <?= $receipt_id; ?><br>
                  <?= $_data['receipt_issue_date'];?>: <?= $receipt_issue_date; ?><br>
                  </td>
              </tr>
            </table></td>
        </tr>
        <tr class="information">
          <td colspan="2"><table>
              <tr>
                <td><?= $row_apartment['b_address']; ?><br/>
                  <?= $_data['invoice_phone'];?>: <?= $row_apartment['b_contact_no']; ?><br/>
                  <?= $_data['invoice_email'];?>: <?= $row_apartment['b_email']; ?> </td>
               
          
                  
              </tr>
            </table></td>
        </tr>
        
        <tr class="heading">
          <td><?= $_data['invoice_receipt_details'];?> </td>
          <td></td>
        </tr>

        <tr class="item">
          <td>Name</td>
          <td><?= $tenant_name; ?> </td>
        </tr>
        <tr class="item">
          <td>Amount Paid</td>
          <td><?= $rate_currency. " ". ($amount_paid); ?> </td>
        </tr>
        
        <tr class="heading">
          <td>Description </td>
          <td></td>
        </tr>
        <tr class="item">
  
       
        <td> Rent Payment on Shop: <?= $tenant_unit ?> </td>
        <td></td>
        </tr>

	      <tr class="item">
        <td>Being: <?= $receipt_description ?> </td>
        <td></td>
        </tr>

        <tr class="item">
        <td> <?=$payment_type?> <?=$payment_ref?></td>
        <td></td>
        </tr>

        
    
        
      </table>
      
      <div class="receipt-signature">
        <div>-------------------------</div>
        <div class="signature-text"><?= $_data['receipt_signature'];?></div>
      </div>
    </div>
    
  <style>
	.signature-text{
		padding-right:5%;
	}
	.receipt-signature{
		text-align:right;
		margin-top:30px;
	}
	.bill-status-logo{
		padding-left:10%;
	}
	.invoice-box {
        max-width: 900px;
        margin: auto;
        padding: 10px 30px !important;
        border: 0px solid #eee;
        font-size: 16px;
        line-height: 20px;
        color: #555;
		background:#fff;
		margin-top:2px;
    }
    
    .invoice-box table {
        width: 100%;
        line-height: inherit;
        text-align: left;
    }
    
    .invoice-box table td {
        padding: 0px;
        vertical-align: top;
    }
    
    .invoice-box table tr td:nth-child(2) {
        text-align: right;
    }
    
    .invoice-box table tr.top table td {
        padding-bottom: 23px;
    }
    
    .invoice-box table tr.top table td.title {
        font-size: 56px;
        line-height: 45px;
        color: #333;
    }
    
    .invoice-box table tr.information table td {
        padding-bottom: 40px;
    }
    
    .invoice-box table tr.heading td {
        background: #eee;
        border-bottom: 1px solid #ddd;
        font-weight: bold;
    }
    
    .invoice-box table tr.details td {
        padding-bottom: 60px;
    }
    
    .invoice-box table tr.item td{
        border-bottom: 1px solid #eee;
    }
    
    .invoice-box table tr.item.last td {
        border-bottom: none;
    }
    
    .invoice-box table tr.total td:nth-child(2) {
        border-top: 2px solid #eee;
        font-weight: bold;
    }
    
    @media only screen and (max-width: 600px) {
        .invoice-box table tr.top table td {
            width: 100%;
            display: block;
            text-align: center;
        }
        
        .invoice-box table tr.information table td {
            width: 100%;
            display: block;
            text-align: center;
        }
    }
    
    /** RTL **/
    .rtl {
        direction: rtl;
        font-family: Tahoma, 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
    }
    
    .rtl table {
        text-align: right;
    }
    
    .rtl table tr td:nth-child(2) {
        text-align: left;
    }
    </style>


	
	</div>
  </div>
  <!-- /.box -->
</div>
<!-- /.row -->

 
<style>
  .btn-success {
    color: #fff;
    background-color: #5cb85c;
    border-color: #4cae4c;
  }
  a{
	  text-decoration: none;
  }
  .btn {
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.42857143;
	text-align: center;
	white-space: nowrap;
	vertical-align: middle;
	-ms-touch-action: manipulation;
	touch-action: manipulation;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	background-image: none;
	border: 1px solid transparent;
	border-radius: 4px;
  }
</style>


<?php include_once('../footer.php'); ?>
