function hmgt_patient_invoice_print($invoice_id)
{
    $obj_invoice = new Hmgtinvoice();
    if ($_REQUEST['invoice_type'] == 'invoice') {
        $invoice_data = get_invoice_data($invoice_id);
    }
    if ($_REQUEST['invoice_type'] == 'income') {
        $income_data = $obj_invoice->hmgt_get_income_data($invoice_id);
    }
    if ($_REQUEST['invoice_type'] == 'expense') {
        $expense_data = $obj_invoice->hmgt_get_income_data($invoice_id);
    }
    //$invoice_data=get_invoice_data($invoice_id);
    //var_dump($income_data);
    //exit;
    ?>
		
			
			<div class="modal-body">
				<div id="invoice_print" style="width: 90%;margin:0 auto;"> 
				<div class="modal-header">
			
			<h4 class="modal-title"><?php 
    echo get_option('hmgt_hospital_name');
    ?>
</h4>
			</div>
					<table width="100%" border="0">
						<tbody>
							<tr>
								<td width="70%">
									<img style="max-height:80px;" src="<?php 
    echo get_option('hmgt_hospital_logo');
    ?>
">
								</td>
								<td width="24%" align="right">
								<h4><?php 
    if (!empty($invoice_data)) {
        $invoice_no = $invoice_data->invoice_number;
        _e('Invoice number', 'hospital_mgt');
        echo " : " . $invoice_no;
    }
    ?>
 </h4>
									<h4><?php 
    // _e('Invoice number','hospital_mgt');
    ?>
 </h4>
									<h5><?php 
    $issue_date = 'DD-MM-YYYY';
    if (!empty($income_data)) {
        $issue_date = $income_data->income_create_date;
        $payment_status = $income_data->payment_status;
    }
    if (!empty($invoice_data)) {
        $issue_date = $invoice_data->invoice_create_date;
        $payment_status = $invoice_data->status;
    }
    if (!empty($expense_data)) {
        $issue_date = $expense_data->income_create_date;
        $payment_status = $expense_data->payment_status;
    }
    echo __('Issue Date', 'hospital_mgt') . " : " . $issue_date;
    ?>
</h5>
									<h5><?php 
    echo __('Status', 'hospital_mgt') . " : " . $payment_status;
    ?>
</h5>
								</td>
							</tr>
						</tbody>
					</table>
					<hr>
					<table width="100%" border="0">
						<tbody>
							<tr>
								<td align="left">
									<h4><?php 
    _e('Payment To', 'hospital_mgt');
    ?>
 </h4>
								</td>
								<td align="right">
									<h4><?php 
    _e('Bill To', 'hospital_mgt');
    ?>
 </h4>
								</td>
							</tr>
							<tr>
								<td valign="top" align="left">
									<?php 
    echo get_option('hmgt_hospital_name') . "<br>";
    echo get_option('hmgt_hospital_address') . ",";
    echo get_option('hmgt_contry') . "<br>";
    echo get_option('hmgt_contact_number') . "<br>";
    ?>
									
								</td>
								<td valign="top" align="right">
									<?php 
    if (!empty($expense_data)) {
        echo $party_name = $expense_data->party_name;
    } else {
        if (!empty($income_data)) {
            $patiet_id = $income_data->party_name;
        }
        if (!empty($invoice_data)) {
            $patiet_id = $invoice_data->patient_id;
        }
        $patient = get_userdata($patiet_id);
        echo $patient->display_name . "<br>";
        echo get_user_meta($patiet_id, 'address', true) . ",";
        echo get_user_meta($patiet_id, 'city_name', true) . ",";
        echo get_user_meta($patiet_id, 'zip_code', true) . ",";
        echo get_user_meta($patiet_id, 'country_name', true) . "<br>";
        echo get_user_meta($patiet_id, 'mobile', true) . "<br>";
    }
    ?>
								</td>
							</tr>
						</tbody>
					</table>
					<hr>
					<h4><?php 
    _e('Invoice Entries', 'hospital_mgt');
    ?>
</h4>
					<table class="table table-bordered" width="100%" border="1" style="border-collapse:collapse;">
						<thead>
							<tr>
								<th class="text-center">#</th>
								<th width="60%"><?php 
    _e('Entry', 'hospital_mgt');
    ?>
 </th>
								<th><?php 
    _e('Price', 'hospital_mgt');
    ?>
</th>
							</tr>
						</thead>
						<tbody>
						<?php 
    $id = 1;
    $total_amount = 0;
    if (!empty($income_data) || !empty($expense_data)) {
        if (!empty($expense_data)) {
            $income_data = $expense_data;
        }
        $patient_all_income = $obj_invoice->get_onepatient_income_data($income_data->party_name);
        foreach ($patient_all_income as $result_income) {
            $income_entries = json_decode($result_income->income_entry);
            foreach ($income_entries as $each_entry) {
                $total_amount += $each_entry->amount;
                ?>
							<tr>
								<td class="text-center"><?php 
                echo $id;
                ?>
</td>
								<td><?php 
                echo $each_entry->entry;
                ?>
 </td>
								<td class="text-right"> <?php 
                echo $each_entry->amount;
                ?>
</td>
							</tr>
								<?php 
                $id += 1;
            }
        }
    }
    if (!empty($invoice_data)) {
        $total_amount = $invoice_data->invoice_amount;
        ?>
							<tr>
								<td class="text-center"><?php 
        echo $id;
        ?>
</td>
								<td><?php 
        echo $invoice_data->invoice_title;
        ?>
 </td>
								<td class="text-right"> <?php 
        echo $invoice_data->invoice_amount;
        ?>
</td>
							</tr>
							<?php 
    }
    ?>
						</tbody>
					</table>
					<table width="100%" border="0">
						<tbody>
							
							<?php 
    if (!empty($invoice_data)) {
        $vat = $total_amount * ($invoice_data->vat_percentage / 100);
        $total_with_tax = $total_amount + $vat;
        $grand_total = $total_with_tax - $invoice_data->discount;
        ?>
							<tr>
								<td width="80%" align="right"><?php 
        _e('Sub Total :', 'hospital_mgt');
        ?>
</td>
								<td align="right"><?php 
        echo $total_amount;
        ?>
</td>
							</tr>
							<tr>
								<td width="80%" align="right"><?php 
        _e('Vat Percentage :', 'hospital_mgt');
        ?>
</td>
								<td align="right"><?php 
        echo $vat;
        ?>
</td>
							</tr>
							<tr>
								<td width="80%" align="right"><?php 
        _e('Discount :', 'hospital_mgt');
        ?>
</td>
								<td align="right"><?php 
        echo $invoice_data->discount;
        ?>
</td>
							</tr>
							<tr>
								<td colspan="2">
									<hr style="margin:0px;">
								</td>
							</tr>
							<?php 
    }
    if (!empty($income_data)) {
        $grand_total = $total_amount;
    }
    ?>
								
							<tr>
								<td width="80%" align="right"><?php 
    _e('Grand Total :', 'hospital_mgt');
    ?>
</td>
								<td align="right"><h4><?php 
    echo $grand_total;
    ?>
</h4></td>
							</tr>
						</tbody>
					</table>
				</div>
				
			</div>
	
	<?php 
    die;
}
Example #2
0
function gmgt_invoice_print($invoice_id)
{
    $obj_payment = new Gmgtpayment();
    if ($_REQUEST['invoice_type'] == 'invoice') {
        $invoice_data = get_invoice_data($invoice_id);
    }
    if ($_REQUEST['invoice_type'] == 'income') {
        $income_data = $obj_payment->gmgt_get_income_data($invoice_id);
    }
    if ($_REQUEST['invoice_type'] == 'expense') {
        $expense_data = $obj_payment->gmgt_get_income_data($invoice_id);
    }
    ?>
		
			
			<div class="modal-body">
				<div id="invoice_print" style="width: 90%;margin:0 auto;"> 
				<div class="modal-header">
			
			<h4 class="modal-title"><?php 
    echo get_option('gmgt_system_name');
    ?>
</h4>
			</div>
			
					<table width="100%" border="0">
						<tbody>
							<tr>
								<td width="70%">
									<img style="max-height:80px;" src="<?php 
    echo get_option('gmgt_system_logo');
    ?>
">
								</td>
								<td align="right" width="24%">
									
									<h5><?php 
    $issue_date = 'DD-MM-YYYY';
    if (!empty($income_data)) {
        $issue_date = $income_data->invoice_date;
        $payment_status = $income_data->payment_status;
    }
    if (!empty($invoice_data)) {
        $issue_date = $invoice_data->payment_date;
        $payment_status = $invoice_data->payment_status;
    }
    if (!empty($expense_data)) {
        $issue_date = $expense_data->invoice_date;
        $payment_status = $expense_data->payment_status;
    }
    echo __('Issue Date', 'gym_mgt') . " : " . $issue_date;
    ?>
</h5>
									<h5><?php 
    echo __('Status', 'gym_mgt') . " : " . $payment_status;
    ?>
</h5>
								</td>
							</tr>
						</tbody>
					</table>
					<hr>
					<table width="100%" border="0">
						<tbody>
							<tr>
								<td align="left">
									<h4><?php 
    _e('Payment To', 'gym_mgt');
    ?>
 </h4>
								</td>
								<td align="right">
									<h4><?php 
    _e('Bill To', 'gym_mgt');
    ?>
 </h4>
								</td>
							</tr>
							<tr>
								<td valign="top" align="left">
									<?php 
    echo get_option('gmgt_system_name') . "<br>";
    echo get_option('gmgt_gym_address') . ",";
    echo get_option('gmgt_contry') . "<br>";
    echo get_option('gmgt_contact_number') . "<br>";
    ?>
									
								</td>
								<td valign="top" align="right">
									<?php 
    if (!empty($expense_data)) {
        echo $party_name = $expense_data->supplier_name;
    } else {
        if (!empty($income_data)) {
            $member_id = $income_data->supplier_name;
        }
        if (!empty($invoice_data)) {
            $member_id = $invoice_data->member_id;
        }
        $patient = get_userdata($member_id);
        echo $patient->display_name . "<br>";
        echo get_user_meta($member_id, 'address', true) . ",";
        echo get_user_meta($member_id, 'city_name', true) . ",";
        echo get_user_meta($member_id, 'mobile', true) . "<br>";
    }
    ?>
								</td>
							</tr>
						</tbody>
					</table>
					<hr>
					<h4><?php 
    _e('Invoice Entries', 'gym_mgt');
    ?>
</h4>
					<table class="table table-bordered" width="100%" border="1" style="border-collapse:collapse;">
						<thead>
							<tr>
								<th class="text-center">#</th>
								<th class="text-center"> <?php 
    _e('Date', 'gym_mgt');
    ?>
</th>
								<th width="60%"><?php 
    _e('Entry', 'gym_mgt');
    ?>
 </th>
								<th><?php 
    _e('Price', 'gym_mgt');
    ?>
</th>
								<th class="text-center"> <?php 
    _e('Username', 'gym_mgt');
    ?>
 </th>
							</tr>
						</thead>
						<tbody>
						<?php 
    $id = 1;
    $total_amount = 0;
    if (!empty($income_data) || !empty($expense_data)) {
        if (!empty($expense_data)) {
            $income_data = $expense_data;
        }
        $patient_all_income = $obj_payment->get_oneparty_income_data($income_data->supplier_name);
        foreach ($patient_all_income as $result_income) {
            $income_entries = json_decode($result_income->entry);
            foreach ($income_entries as $each_entry) {
                $total_amount += $each_entry->amount;
                ?>
							<tr>
								<td class="text-center"><?php 
                echo $id;
                ?>
</td>
								<td class="text-center"><?php 
                echo $result_income->invoice_date;
                ?>
</td>
								<td><?php 
                echo $each_entry->entry;
                ?>
 </td>
								<td class="text-right"> <?php 
                echo $each_entry->amount;
                ?>
</td>
								<td class="text-center"><?php 
                echo gym_get_display_name($result_income->receiver_id);
                ?>
</td>
							</tr>
								<?php 
                $id += 1;
            }
        }
    }
    if (!empty($invoice_data)) {
        $total_amount = $invoice_data->total_amount;
        ?>
							<tr>
								<td class="text-center"><?php 
        echo $id;
        ?>
</td>
								<td class="text-center"><?php 
        echo $invoice_data->payment_date;
        ?>
</td>
								<td><?php 
        echo $invoice_data->title;
        ?>
 </td>
								<td class="text-right"> <?php 
        echo $invoice_data->unit_price;
        ?>
</td>
								<td class="text-center"><?php 
        echo gym_get_display_name($invoice_data->receiver_id);
        ?>
</td>
							</tr>
							<?php 
    }
    ?>
						</tbody>
					</table>
					<table width="100%" border="0">
						<tbody>
							
							<?php 
    if (!empty($invoice_data)) {
        $total_amount = $invoice_data->unit_price;
        $grand_total = $invoice_data->unit_price - $invoice_data->discount;
        ?>
							<tr>
								<td width="80%" align="right"><?php 
        _e('Sub Total :', 'gym_mgt');
        ?>
</td>
								<td align="right"><?php 
        echo $total_amount;
        ?>
</td>
							</tr>
							
							<tr>
								<td width="80%" align="right"><?php 
        _e('Discount :', 'gym_mgt');
        ?>
</td>
								<td align="right"><?php 
        echo $invoice_data->discount;
        ?>
</td>
							</tr>
							<tr>
								<td colspan="2">
									<hr style="margin:0px;">
								</td>
							</tr>
							<?php 
    }
    if (!empty($income_data)) {
        $grand_total = $total_amount;
    }
    ?>
								
							<tr>
								<td width="80%" align="right"><?php 
    _e('Grand Total :', 'gym_mgt');
    ?>
</td>
								<td align="right"><h4><?php 
    echo $grand_total;
    ?>
</h4></td>
							</tr>
						</tbody>
					</table>
				</div>
	</div>
	<?php 
    die;
}