<?php
$this->load->view("partial/header");
?>

<?php





if($customer_gs_id=="28946"){
	//==================================================================================////
	$bank_name_shawpon['']="Select Bank Name";
	$bank_name_shawpon['AB Bank Limited']="AB Bank Limited";
	$bank_name_shawpon['Al-Arafah Islami Bank Limited']="Al-Arafah Islami Bank Limited";
	$bank_name_shawpon['Bank Asia Limited']="Bank Asia Limited";
	$bank_name_shawpon['BRAC Bank Limited']="BRAC Bank Limited";
	$bank_name_shawpon['Dhaka Bank Limited']="Dhaka Bank Limited";
	$bank_name_shawpon['Dutch-Bangla Bank Limited']="Dutch-Bangla Bank Limited";
	$bank_name_shawpon['Eastern Bank Limited']="Eastern Bank Limited";
	$bank_name_shawpon['Islami Bank Bangladesh Ltd']="Islami Bank Bangladesh Ltd";
	$bank_name_shawpon['LankaBangla Finance']="LankaBangla Finance";
	$bank_name_shawpon['Mutual Trust Bank Limited']="Mutual Trust Bank Limited";
	$bank_name_shawpon['National Bank Limited']="National Bank Limited";
	$bank_name_shawpon['Premier Bank Limited']="Premier Bank Limited";
	$bank_name_shawpon['Prime Bank Ltd']="Prime Bank Ltd";
	$bank_name_shawpon['Pubali Bank Limited']="Pubali Bank Limited";
	$bank_name_shawpon['Southeast Bank Limited']="Southeast Bank Limited";
	$bank_name_shawpon['Standard Chartered Bank']="Standard Chartered Bank";
	$bank_name_shawpon['The City Bank Ltd']="The City Bank Ltd";
	$bank_name_shawpon['United Commercial Bank Limited']="United Commercial Bank Limited";
	ksort($bank_name_shawpon);

	$payment_options=array();
	$payment_options['Credit Card']="Credit Card";
	$payment_options['AMEX Card']="AMEX Card";
	$payment_options['Debit Card']="Debit Card";
	$payment_options['Purchase Bonus']="Special Sales Discount";


}else{
	$bank_name_shawpon['']="Select Bank Name";
	$bank_name_shawpon['AB Bank Limited']="AB Bank Limited";
	$bank_name_shawpon['Agrani Bank Limited']="Agrani Bank Limited";
	$bank_name_shawpon['Al-Arafah Islami Bank Limited']="Al-Arafah Islami Bank Limited";
	$bank_name_shawpon['Bangladesh Commerce Bank Limited']="Bangladesh Commerce Bank Limited";
	$bank_name_shawpon['Bangladesh Development Bank Limited']="Bangladesh Development Bank Limited";
	$bank_name_shawpon['Bangladesh Krishi Bank']="Bangladesh Krishi Bank";
	$bank_name_shawpon['Bank Al-Falah Limited']="Bank Al-Falah Limited";
	$bank_name_shawpon['Bank Asia Limited']="Bank Asia Limited";
	$bank_name_shawpon['BASIC Bank Limited']="BASIC Bank Limited";
	$bank_name_shawpon['Bengal Commercial Bank Limited']="Bengal Commercial Bank Limited";
	$bank_name_shawpon['BRAC Bank Limited']="BRAC Bank Limited";
	$bank_name_shawpon['Citibank N.A']="Citibank N.A";
	$bank_name_shawpon['Citizens Bank PLC']="Citizens Bank PLC";
	$bank_name_shawpon['Commercial Bank of Ceylon Limited']="Commercial Bank of Ceylon Limited";
	$bank_name_shawpon['Community Bank Bangladesh Limited']="Community Bank Bangladesh Limited";
	$bank_name_shawpon['Dhaka Bank Limited']="Dhaka Bank Limited";
	$bank_name_shawpon['Dutch-Bangla Bank Limited']="Dutch-Bangla Bank Limited";
	$bank_name_shawpon['Eastern Bank Limited']="Eastern Bank Limited";
	$bank_name_shawpon['EXIM Bank Limited']="EXIM Bank Limited";
	$bank_name_shawpon['First Security Islami Bank Limited']="First Security Islami Bank Limited";
	$bank_name_shawpon['Global Islami Bank Limited']="Global Islami Bank Limited";
	$bank_name_shawpon['Habib Bank Ltd']="Habib Bank Ltd";
	$bank_name_shawpon['HSBC']="HSBC";
	$bank_name_shawpon['ICB Islamic Bank Ltd']="ICB Islamic Bank Ltd";
	$bank_name_shawpon['ICICI Bank']="ICICI Bank";
	$bank_name_shawpon['IFIC Bank Limited']="IFIC Bank Limited";
	$bank_name_shawpon['Islami Bank Bangladesh Ltd']="Islami Bank Bangladesh Ltd";
	$bank_name_shawpon['LankaBangla Finance']="LankaBangla Finance";
	$bank_name_shawpon['Jamuna Bank Ltd']="Jamuna Bank Ltd";
	$bank_name_shawpon['Janata Bank Limited']="Janata Bank Limited";
	$bank_name_shawpon['Meghna Bank Limited']="Meghna Bank Limited";
	$bank_name_shawpon['Mercantile Bank Limited']="Mercantile Bank Limited";
	$bank_name_shawpon['Midland Bank Limited']="Midland Bank Limited";
	$bank_name_shawpon['Modhumoti Bank Limited']="Modhumoti Bank Limited";
	$bank_name_shawpon['Mutual Trust Bank Limited']="Mutual Trust Bank Limited";
	$bank_name_shawpon['National Bank Limited']="National Bank Limited";
	$bank_name_shawpon['National Bank of Pakistan']="National Bank of Pakistan";
	$bank_name_shawpon['National Credit & Commerce Bank Ltd']="National Credit & Commerce Bank Ltd";
	$bank_name_shawpon['NRB Bank Limited']="NRB Bank Limited";
	$bank_name_shawpon['NRB Commercial Bank Limited']="NRB Commercial Bank Limited";
	$bank_name_shawpon['One Bank Limited']="One Bank Limited";
	$bank_name_shawpon['Padma Bank Limited']="Padma Bank Limited";
	$bank_name_shawpon['Premier Bank Limited']="Premier Bank Limited";
	$bank_name_shawpon['Prime Bank Ltd']="Prime Bank Ltd";
	$bank_name_shawpon['Probashi Kollyan Bank']="Probashi Kollyan Bank";
	$bank_name_shawpon['Pubali Bank Limited']="Pubali Bank Limited";
	$bank_name_shawpon['Rajshahi Krishi Unnayan Bank']="Rajshahi Krishi Unnayan Bank";
	$bank_name_shawpon['Rupali Bank Limited']="Rupali Bank Limited";
	$bank_name_shawpon['Shahjalal Islami Bank Limited']="Shahjalal Islami Bank Limited";
	$bank_name_shawpon['Shimanto Bank Limited']="Shimanto Bank Limited";
	$bank_name_shawpon['Social Islami Bank Ltd']="Social Islami Bank Ltd";
	$bank_name_shawpon['Sonali Bank Limited']="Sonali Bank Limited";
	$bank_name_shawpon['South Bangla Agriculture & Commerce Bank Limited']="South Bangla Agriculture & Commerce Bank Limited";
	$bank_name_shawpon['Southeast Bank Limited']="Southeast Bank Limited";
	$bank_name_shawpon['Standard Bank Limited']="Standard Bank Limited";
	$bank_name_shawpon['Standard Chartered Bank']="Standard Chartered Bank";
	$bank_name_shawpon['State Bank of India']="State Bank of India";
	$bank_name_shawpon['The City Bank Ltd']="The City Bank Ltd";
	$bank_name_shawpon['The Hong Kong and Shanghai Banking Corporation. Ltd']="The Hong Kong and Shanghai Banking Corporation. Ltd";
	$bank_name_shawpon['Trust Bank Limited']="Trust Bank Limited";
	$bank_name_shawpon['Union Bank Limited']="Union Bank Limited";
	$bank_name_shawpon['United Commercial Bank Limited']="United Commercial Bank Limited";
	$bank_name_shawpon['Uttara Bank Limited']="Uttara Bank Limited";
	$bank_name_shawpon['Woori Bank']="Woori Bank";

	ksort($bank_name_shawpon);
	$bank_name_shawpon['Other Bangladeshi Bank']="Other Bangladeshi Bank";
	$bank_name_shawpon['Other International Bank']="Other International Bank";
}

?>



<style>
.dlg-dialog {
    position: fixed;
    top: 0;
    bottom: 0;
    box-sizing: border-box;
    min-width: 300px;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    max-width: 500px;
	margin: auto;
	border-radius: 5px;
}

.dlg-header {
    padding: .5em;
    
}

.dlg-caption {
    font-size: 1.17em;
    margin: 0;
    padding-right: 2em;
}

.dlg-close-button {
    position: absolute;
    right: .5em;
    top: .5em;
    width: 1.17em;
    height: 1.17em;
    cursor: pointer;
    display:none;
}

.dlg-close-button::before {
    transform: rotate(45deg);
}

.dlg-close-button::after{
    transform: rotate(-45deg);
}

.dlg-close-button::before,
.dlg-close-button::after {
    content: '';
    position: absolute;
    height: 1px;
    width: 100%;
    /*top: 540px;*/
    left:0;
    background-color: black;
}

.dlg-body {
    padding: .5em;
    background-color: #CDF3F7;
}

.dlg-content {
    padding: .5em;
    overflow: auto;
    border: 0px solid #848484;
	background-color: #CDF3F7;
	text-align:center;
}
.dlg-salesMessage {
    padding: 0;
    overflow: auto;
    border: 0px solid #848484;
	background-color: #CDF3F7;
	font-size: 14px;
	font-weight: bold;
	color:#8B00FF;
	line-height: 22px;
	text-align:center;
}

.dlg-button-area {
    padding-top: 15px;
text-align: center;
padding-bottom: 6px;
}

.dlg-button-area button {
   padding: .3em .4em;
margin-left: 1em;
width: 5em;
text-align: center;
background-color: #035c72;
color: #FFF;
font-size: 14px;
}
.dlg-dialog {
    border: none;
    box-shadow: 10px 10px 20px gray;
}

.dlg-header {
    background-color: #035c72;
    color: white;
}

.dlg-caption {
    height: 1.17em;
    text-shadow: 1px 1px 1px black;
}
.dlg-close-button::before,
.dlg-close-button::after {
    background-color: white;
}


</style>

<script>
/**
* class Dialog {
*
* author: nemo
*   date: 2017-06-20
*      v: 1.1
* }
*/
{
'use strict';

class Dialog {

	constructor(opt) {
		Object.assign(this.option = {
			caption: '',
			message: '',
			salesMessage: '',
			content: undefined,
			buttons: Dialog.buttons.NONE,

			resize: 'none',

			cancelable: true,

			showHeader: true,
			showClose: true,
			showFooter: false,

			// handler
			abortHandler: undefined,
			cancelHandler: () => { this.close(); },
			ignoreHandler: undefined,
			noHandler: undefined,
			okHandler: () => { this.close(); },
			retryHandler: undefined,
			yesHandler: undefined,

			// events
			beforeClosing: () => { return true; }, // set to false to prevent close
			closed: undefined,
		}, opt);
		this.init();
	}

	/**
	* START init
	*/
	init() {
		return this
		.initLayout()
		.initAttributes()
		.initContent()
		.initEvents();
	}

	initLayout() {
		this.dialog = create('dialog', 'dialog');
		this.dialog.style.resize = this.option.resize,
		appendTo(this.dialog, document.body);
		this.show();

		this.container = this.dialog;

		this.header = create('header', 'header');
		this.caption = create('h3', 'caption');
		this.closeButton = create('em', 'close-button');

		this.body = create('div', 'body');
		this.salesMessage = create('section', 'salesMessage');
		this.content = create('section', 'content');
		this.buttonArea = create('div', 'button-area');

		this.footer = create('footer', 'footer');

		// assembly dom
		this.header.appendChild(this.caption);
		if (this.option.showClose)
		this.header.appendChild(this.closeButton);
		if (this.option.showHeader)
		this.dialog.appendChild(this.header);

		this.body.appendChild(this.salesMessage);
		this.body.appendChild(this.content);
		this.body.appendChild(this.buttonArea);
		this.assemblyButtons();
		this.dialog.appendChild(this.body);

		if (this.option.showFooter)
		this.dialog.appendChild(this.footer);

		return this;
	}

	initAttributes() {
		this.dialog.wrapper = this;

		this.cancelable = this.option.cancelable;

		return this;
	}

	assemblyButtons() {
		switch (this.option.buttons) {
			case Dialog.buttons.ABORT_RETRY_IGNORE:
			new DialogButton(this, Dialog.button.ABORT).assembly();
			new DialogButton(this, Dialog.button.RETRY).assembly().focus();
			new DialogButton(this, Dialog.button.IGNORE).assembly();
			break;
			case Dialog.buttons.OK:
			new DialogButton(this, Dialog.button.OK).assembly().focus();
			break;
			case Dialog.buttons.OK_CANCEL:
			new DialogButton(this, Dialog.button.OK).assembly();
			new DialogButton(this, Dialog.button.CANCEL).assembly().focus();
			break;
			case Dialog.buttons.RETRY_CANCEL:
			new DialogButton(this, Dialog.button.RETRY).assembly().focus();
			new DialogButton(this, Dialog.button.CANCEL).assembly();
			break;
			case Dialog.buttons.YES_NO:
			new DialogButton(this, Dialog.button.YES).assembly();
			new DialogButton(this, Dialog.button.NO).assembly().focus();
			break;
			case Dialog.buttons.YES_NO_CANCEL:
			new DialogButton(this, Dialog.button.YES).assembly();
			new DialogButton(this, Dialog.button.NO).assembly();
			new DialogButton(this, Dialog.button.CANCEL).assembly().focus();
			break;
			default:
			// no button
			break;
		}

		return this;
	}

	appendButton(btn) {
		this.buttonArea.appendChild(btn.button);
		return this;
	}

	removeButton(btn) {
		this.buttonArea.removeChild(btn.button);
		return this;
	}

	initContent() {
		this.caption.innerText = this.option.caption;
		if (this.option.content == undefined) {
			this.content.innerText = this.option.message;
		} else {
			this.content.innerHTML = this.option.content;
		}
		this.salesMessage.innerHTML = this.option.salesMessage;

		return this;
	}

	initEvents() {
		this.closeButton.addEventListener('click', () => {
			this.close();
		});

		// prevent esc
		this.dialog.addEventListener('cancel', (e) => {
			!this.cancelable && e.preventDefault();
		});

		return this;
	}
	/**
	* END init
	*/

	//:~

	trigger(type) {
		switch (type) {
			case Dialog.button.ABORT:
			callHandler(this.option.abortHandler, this);
			break;
			case Dialog.button.CANCEL:
			callHandler(this.option.cancelHandler, this);
			break;
			case Dialog.button.IGNORE:
			callHandler(this.option.ignoreHandler, this);
			break;
			case Dialog.button.NO:
			callHandler(this.option.noHandler, this);
			break;
			case Dialog.button.OK:
			callHandler(this.option.okHandler, this);
			break;
			case Dialog.button.RETRY:
			callHandler(this.option.retryHandler, this);
			break;
			case Dialog.button.YES:
			callHandler(this.option.yesHandler, this);
			break;
			default:
			console.log(`Unknown type:${type}`);
			break;
		}

		return this;
	}

	beforeClosing(func) {
		this.option.beforeClosing = func;

		return this;
	}

	closed(func) {
		this.dialog.addEventListener('close', func);

		return this;
	}

	get cancelable() {
		return this.option.cancelable;
	}

	set cancelable(value) {
		this.option.cancelable = !!value;
	}

	show() {
		if (this.dialog.open)
		return this;

		try {
			this.dialog.showModal();
		} catch (e) {
			appendTo(this.dialog, document.body);
			this.dialog.showModal();
		}

		return this;
	}

	hide(dispose = true) {
		if (!this.dialog.open)
		return this;

		if (typeof this.option.beforeClosing != 'function' ||
		!!this.option.beforeClosing()) {
			this.dialog.close();

			try {
				dispose && document.body.removeChild(this.dialog);
			} finally { }
		}

		return this;
	}

	close(dispose = true) {
		return this.hide(dispose);
	}

	addClass(className) {
		addClass(this.dialog, className);
	}

	//:~

	/**
	* START static helper
	*/
	static alert(message, caption = '') {
		return new Dialog({
			caption: `${caption}`,
			message: `${message}`,
			buttons: Dialog.buttons.OK,
		});
	}

	static confirm(message, caption = '', ok, cancel,salesMessage='') {
		return new Dialog({
			caption: `${caption}`,
			message: `${message}`,
			buttons: Dialog.buttons.OK_CANCEL,
			okHandler: ok,
			cancelHandler: cancel,
			salesMessage: `${salesMessage}`,
		});
	}

	static template(dom, caption = '') {
		return new Dialog({
			caption: `${caption}`,
			content: dom.innerHTML,
		});
	}

	static templet(dom, caption) {
		return template(dom, caption);
	}

	static iframe(src, caption = '', width = 'auto', height = 'auto') {
		let dlg = new Dialog({
			caption: `${caption}`,
			content: `<iframe style="border: none;" src="${src}"></iframe>`,
		});
		let iframe = dlg.content.childNodes[0];
		iframe.style.width = width;
		iframe.style.height = height;
	}
	/**
	* END static helper
	*/
}

class DialogButton {
	constructor(dialog, type) {
		this.dialog = dialog;
		this.type = type;

		this.button = create('button', `btn-${type}`);
		this.button.type = 'button';
		this.button.innerText = Dialog.buttonText[type];

		this.click(() => {
			this.dialog.trigger(this.type);
		});
	}

	assembly() {
		this.dialog.appendButton(this);

		return this;
	}

	click(func) {
		this.button.addEventListener('click', func);

		return this;
	}

	focus() {
		window.setTimeout(() => {
			this.button.focus();
		}, 1);

		return this;
	}
}

Object.assign(Dialog, {

	buttons: {
		ABORT_RETRY_IGNORE: 1,
		OK: 2,
		OK_CANCEL: 3,
		RETRY_CANCEL: 4,
		YES_NO: 5,
		YES_NO_CANCEL: 6,
	},

	button: {
		NONE: 0,
		ABORT: 1,
		CANCEL: 2,
		IGNORE: 3,
		NO: 4,
		OK: 5,
		RETRY: 6,
		YES: 7,
	},

	buttonText: [
	undefined,
	'Abort',
	'Cancel',
	'Ignore',
	'NO',
	'OK',
	'Retry',
	'Yes',
	],
});

let callHandler = (func, dlg) => {
	return typeof func == 'function' ?
	func(dlg) : undefined;
}

let cls = (cls) => {
	return `dlg-${cls}`;
}

let addClass = (dom, className) => {
	let c = dom.className;
	let add = cls(className);
	if (c == '') {
		return add;
	} else {
		return c + ' ' + add;
	}
}

let prependTo = (sub, base) => {
	if (base.hasChildNodes()) {
		base.insertBefore(sub, base.firstChild);
	} else {
		base.appendChild(sub);
	}
}

let appendTo = (sub, base) => {
	base.appendChild(sub);
}

let show = (dom, display = 'block') => {
	visible(dom, true, display);
}

let hide = (dom) => {
	visible(dom, true);
}

let visible = (dom, v, display) => {
	if (dom == undefined || dom.style == undefined)
	return;
	else
	dom.style.display = v ? display : 'none';
}

let create = (name, className) => {
	let e = document.createElement(name);
	if (typeof className == 'string')
	e.className = cls(className);
	return e;
}

// export { Dialog } // ES6
window['Dialog'] = Dialog;
}
'use strict';
/**
* Polyfill of dialog
* for Firefox
*
* author Nemo
*
* v1.1
* Supports:
* show
* hide
* showModal
* cancel(ESC)
*/
{

	const UA = window.navigator.userAgent;
	const browser = {
		isFirefox: UA.includes('Firefox'),
	};

	const dlg = document.createElement('dialog');
	let mask = undefined;

	const initMask = () => {
		if (mask != undefined)
		return;

		mask = document.createElement('div');
		mask.style.display = 'none';
		mask.style.position = 'fixed';
		mask.style.zIndex = 999998;
		mask.style.height = window.innerHeight;
		mask.style.top = 0;
		mask.style.left = 0;
		mask.style.right = 0;
		mask.style.bottom = 0;
		mask.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
		document.body.appendChild(mask);
	};

	// show support
	if (!dlg.__proto__.show) {
		dlg.__proto__.open = false;

		dlg.__proto__.show = function() {
			this.open = true;

			var modal_position=0;
			var windowscrollY=window.scrollY;
			var windowHeight = window.innerHeight;
			modal_position=((windowHeight/2)+windowscrollY);
			this.style.backgroundColor = 'white';
			this.style.position = 'absolute';
			this.style.zIndex = 999999;
			this.style.display = 'table';
			this.style.top = modal_position+"px";
			this.style.transform = 'translate(0, -50%)';

			return this;
		};
	}

	// showModal support
	if (!dlg.__proto__.showModal) {
		initMask();

		dlg.__proto__.showModal = function() {
			mask.style.display = 'block';
			this.show();

			return this;
		};
	}

	// hide support
	if (!dlg.__proto__.close) {
		initMask();

		dlg.__proto__.close = function() {
			this.open = false;

			mask.style.display = 'none';
			this.style.display = 'none';

			return this;
		}
	}

	// cancel(ESC) support
	if (dlg.oncancel === void 0) {
		const dialogClass = 'dlg-dialog';
		document.addEventListener('keypress', (e) => {
			if (e.code !== 'Escape')
			return;

			let dlgs = document.querySelectorAll(`.${dialogClass}`);
			for (let i = 0; i < dlgs.length; i++) {
				let d = dlgs[i];
				if (d.style.display === 'none')
				continue;

				if (d.wrapper.cancelable) {
					d.close();
				}
			}
		});
	}

}

</script>


<!--ALERT BOX-->
<style>
#modalContainerError{
    background-color:rgba(0, 0, 0, 0.7);
    position:absolute;
    width:100%;
    height:100%;
    top:0px;
    left:0px;
    z-index:10000;
}

#alertBoxError {
    position:relative;
    width:400px;
    min-height:100px;
    margin-top:116px;
    border:1px solid #666;
    background-color:#FFFFFF;
    background-repeat:no-repeat;
    background-position:20px 30px;
    border-radius: 5px;
    box-shadow: 0 0 10px #2297b4;
}

#modalContainerError > #alertBoxError {
    position:fixed;
}

#alertBoxError h1 {
    margin:0;
    font-weight:bold;
    background-color:#A40000;
    color:#FFF;
    border-bottom:1px solid #000;
    padding: 8px 0 8px 0px;
	text-align: center;
	color: #FFFFFF;
	font-size: 18px;
	border-top-left-radius: 5px;
	border-top-right-radius: 5px;
}

#alertBoxError p {
    margin:11px;
    font-size:14px;
    text-align: center;
    font-weight: bold;
}

#alertBoxError p:hover {
    color:#000000;
    background-color:#FFFFFF;
}

#alertBoxError #closeBtnError {
    display:block;
    position:relative;
    margin:5px auto;
    padding:7px;
    border:0 none;
    width:70px;
    text-transform:uppercase;
    text-align:center;
    color:#FFF;
    background-color:#BD3535;
    border-radius: 3px;
    text-decoration:none;
}
</style>
<script>
var ALERT_TITLE = "ERROR";
var ALERT_BUTTON_TEXT = "Close";
function createCustomAlertError(txt) {
	d = document;
	if(d.getElementById("modalContainerError")) return;

	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainerError";
	mObj.style.height = d.documentElement.scrollHeight + "px";

	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBoxError";
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
	alertObj.style.visiblity="visible";

	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	msg = alertObj.appendChild(d.createElement("p"));
	msg.innerHTML = txt;

	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtnError";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	btn.focus();
	btn.onclick = function() { removeCustomAlertError();return false; }

	alertObj.style.display = "block";

}
function removeCustomAlertError() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainerError"));
}
</script>

<?php
if(intval($error_alert_qty)){
	echo '<script>createCustomAlertError("Submitted quantity is  not valid.<p>Please submit the vaild quantity.</p><p>For RETURN item quantity must be less than ZERO.</p><p>SALES item quantity must be greater than ZERO.</p>");</script>';
}

if(intval($sales_unable_to_add_item_flag)){
	echo '<script>createCustomAlertError("The Product is not found in your invetory.<p>So,unable to add in sales register.</p><p>Its happened for one of following reasons</p><p>1. Barcode cannot read by scanner properly.</p><p>2. Scanned/inputed item code is not exist in your inventory database.</p>");</script>';
}



$total_sale=0;
$total_return=0;
$total_qty=0;
$elegible_for_coupon_amount=0;

foreach ($cart as $cart_key => $cart_value) {
	if($cart_value['quantity']>0){
		$total_qty+=$cart_value['quantity'];
		$total_sale+=$cart_value['quantity'];
	}else{
		$total_return+=abs($cart_value['quantity']);
	}
	////////////////ELEGIBLE FOR COUPON//////////////////
	$elegible_for_coupon_amount+=($cart_value['quantity']*$cart_value['price'])-(intval(((($cart_value['quantity']*$cart_value['price'])*$cart_value['discount'])/100)));
}


?>
<style>
       .blink_me {
  animation: blinker 1s step-start infinite;
}

@keyframes blinker {
  50% {
    opacity: 0;
  }
}
    </style>

<div id="page_title" style="margin-bottom:0px;">
    <table width="100%">
    <tr>
     <?php 


     if(intval($new_customer_added_success)==1){
     	$inventory_total=$included_vat_sub_total_inv_amount+$exclued_vat_sub_total_inv_amount;
     	$inventory_vat_amount=$included_vat_sub_total_vat_amount+$exclued_vat_sub_total_vat_amount;
     	$card_amount_amount_vat=($inventory_vat_amount*$purchase_discount_elegible_percentage_amount)/$inventory_total;

     	$sales_total_with_vat_for_interface=round($purchase_discount_elegible_percentage_amount+$card_amount_amount_vat);

     	$card_discount_total_with_vat_for_interface=round((round($sales_total_with_vat_for_interface-$total_provide_discount)*$purchase_discount_percentage)/100);

     }else{
     	$sales_total_with_vat_for_interface=round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount);
     	$card_discount_total_with_vat_for_interface=round((round($sales_total_with_vat_for_interface-$total_provide_discount)*$purchase_discount_percentage)/100);
     }



     if(intval($coupon_card_maximum_discout)>0){
     	$compare_amount=round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount)-round($card_discount_total_with_vat_for_interface)-round($total_provide_discount)-round($cart_point_cost);
     	if(intval($compare_amount)<intval($coupon_card_maximum_discout)){
     		$coupon_card_discout=intval($compare_amount);
     	}else{
     		$coupon_card_discout=intval($coupon_card_maximum_discout);
     	}
     }else{
     	$coupon_card_discout=0;
     }


     if($mode=="sale"){?><td width="37%" style="text-align:left;color:#50FF00;font-size: 22px;"><?php echo "&nbsp;&nbsp;SALE";}
     elseif($mode=="return"){?><td width="37%" style="text-align:left;color:#FF0000;font-size: 22px;"><?php echo "<div class='blink_me'>&nbsp;&nbsp;RETURN</div>";}
     elseif($mode=="global"){?><td width="37%" style="text-align:left;color:#50FF00;font-size: 22px;"><?php echo "&nbsp;&nbsp;GLOBAL SALE";}
     elseif($mode=="global_delivery"){?><td width="37%" style="text-align:left;color:#FF0000;font-size: 22px;"><?php echo "&nbsp;&nbsp;GLOBAL RETURN";}
     ?>
     
     </td>
     
    
     <td width="23%" style="text-align:left;">
     <?php echo $this->lang->line('sales_register'); ?>
     </td>  
     <?php if (count($cart) == 0) { ?>
     <td width="43%" style="text-align:right;">
     <?php if ($previous_amount_due-intval($previous_coupon_card_discout)< 0) { ?>
     <?php echo "<font style='color:#A3F6FF;font-size:22px;'>Previous Refunds: ".to_currency(abs($previous_amount_due-intval($previous_coupon_card_discout)))."&nbsp;&nbsp;</font>" ?>
     <?php }elseif ($previous_amount_due-intval($previous_coupon_card_discout)>0) {?>
     <?php echo "<font style='color:#F70000;font-size:22px;'>Previous Due: ".to_currency(abs($previous_amount_due-intval($previous_coupon_card_discout)))."&nbsp;&nbsp;</font>" ?>
     <?php }else if(intval($previous_sales_total-intval($previous_coupon_card_discout))){?>
      <?php echo "<font style='color:#50FF00;font-size:22px;'>Previous(FULL PAID): ".to_currency(abs($previous_sales_total-intval($previous_coupon_card_discout)))."&nbsp;&nbsp;</font>" ?>
     <?php }?>
     </td> 
     
   <?php }elseif (count($cart)) { 



   	?>
     <td width="43%" style="text-align:right;">
     <?php if (($amount_due-intval($coupon_card_discout))< 0) { ?>
     <?php echo "<font style='color:#A3F6FF;font-size:22px;'>Refunds: ".to_currency(abs($amount_due-intval($coupon_card_discout)))."&nbsp;&nbsp;</font>" ?>
     <?php }elseif (($amount_due-intval($coupon_card_discout))==0) {?>
      
      <?php echo "<font style='color:#50FF00;font-size:22px;'>FULL PAID&nbsp;&nbsp;</font>" ?>
     <?php }else{?>
      <?php echo "<font style='color:#F70000;font-size:22px;'>Due: ".to_currency(abs($amount_due-intval($coupon_card_discout)))."&nbsp;&nbsp;</font>" ?>
     <?php }?>
     </td> 
    
     <?php }else{ ?>
     <td width="43%" style="text-align:right;">&nbsp;</td>
     <?php }?>
    </tr>
    </table>
</div>
<!--<div id="current_add" ><p>shad</p></div>-->
<?php
if (isset($error)) {
	echo "<div class='error_message' style='margin-top: -8px;padding: 4px;'>" . $error . "</div>";
}elseif (isset($warning)) {
	echo "<div class='warning_mesage' style='margin-top: -8px;padding: 4px;'>" . $warning . "</div>";
}elseif (isset($success)) {
	echo "<div class='success_message' style='margin-top: -8px;padding: 4px;'>" . $success . "</div>";
}elseif (isset($error_message_coupon)) {
	echo "<div class='error_message' style='margin-top: -8px;padding: 4px;'>" . $error_message_coupon . "</div>";
}
?>
<div id="register_wrapper">

<?php echo form_open("sales/change_mode", array('id' => 'mode_form')); 

echo form_hidden('facebook_customer', $facebook_customer);
echo form_hidden('mobile_no', $customer_gs_card);
echo form_hidden('facebook_customer_id', $customer_gs_id);
echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
echo form_hidden('facebook_otp', $facebook_otp);

echo form_hidden('coupon_card_discout', $coupon_card_discout);
echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
echo form_hidden('coupon_card_number', $coupon_card_number);



?>

<?php if($this->session->userdata['reprint_perission']!="reprint_password_ok"){ ?>
<table style="width:100">
	<tr>
		<td>
		<span><?php echo $this->lang->line('sales_mode') ?></span>
    <?php echo form_dropdown('mode', $modes, $mode, 'onchange="$(\'#mode_form\').submit();"id="change" style="border: 1px solid #FF0000;padding:4px;"'); ?>
		</td>
		<td style="padding-left:10px; width:64%;">
			<table width="100%">
				<tr>
					<td style="text-align:left; font-weight: bold; font-size:20px;" width="46%">
					<font style="background-color:#19651e;padding-top: 2px;padding-bottom: 5px;color:#FFFFFF;">&nbsp;New: <?php echo $total_qty; ?>&nbsp;</font><font style="background-color:#FF4848;padding-top: 2px;padding-bottom: 5px;color:#FFFFFF;">&nbsp;R: <?php echo $total_return; ?>&nbsp;</font>
					</td>
					<td style="text-align:left;font-weight: bold;font-size:20px;" width="100%">
					<?php if((round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount)-round($card_discount_total_with_vat_for_interface)-round($total_provide_discount)-round($cart_point_cost)-round($coupon_card_discout))==0){
						if(count($cart)){
						?>
					<font style="padding-top: 2px;padding-bottom: 5px;">TK: <?php echo to_currency(0); ?></font>
					<?php
						}else{
						?>
						<font style="padding-top: 2px;padding-bottom: 5px;">TK: <?php echo to_currency(0); ?></font>
						<?php
						}

					}else{

						$total_taxes_view=0;
						foreach ($taxes as $txkey => $txvalue) {
							$total_taxes_view+=$txvalue;
						}
						if(round($vat_enable_subtotal+$total_taxes_view)<0){
							$style_tk="style='color:#FF0000;'";
						}
						if(count($cart)){


						?>
					<font style="padding-top: 2px;padding-bottom: 5px;">TK: <font <?php echo $style_tk;?>><?php echo to_currency((round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount)-round($card_discount_total_with_vat_for_interface)-round($total_provide_discount)-round($cart_point_cost))); ?></font></font>
					<?php }else{
						?>
						<font style="padding-top: 2px;padding-bottom: 5px;">TK: <font <?php echo $style_tk;?>><?php echo to_currency(0); ?></font></font>
						<?php
					}
					}?>
					</td>
				</tr>
		
			</table>
		</td>
		<td>
		<div id="show_suspended_sales_button">
        <?php
        echo anchor("sales/suspended/width:700", "<div class='button_new'><span>" . $this->lang->line('sales_suspended_sales') . "</span></div>", array('class' => 'thickbox none', 'title' => $this->lang->line('sales_suspended_sales')." <font style='color:#FF1ADB;'>[DATE :".date("d-M-Y")."]</font>"));
        ?>
    </div>
		</td>	
	</tr>

</table>
<?php }?>


    
    
</form>
<?php echo form_open("sales/add", array('id' => 'add_item_form')); 
echo form_hidden('facebook_customer', $facebook_customer);
echo form_hidden('mobile_no', $customer_gs_card);
echo form_hidden('facebook_customer_id', $customer_gs_id);
echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
echo form_hidden('facebook_otp', $facebook_otp);
echo form_hidden('coupon_card_discout', $coupon_card_discout);
echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
echo form_hidden('coupon_card_number', $coupon_card_number);
echo form_hidden('coupon_card_number', $coupon_card_number);
?>

<table width="100%">
	<tr>
	<?php 
	if($this->session->userdata['reprint_perission']=="reprint_password_ok"){ ?>
		<td style="width:100%;text-align:center;padding:5px;font-size:20px;color:#FF0000;font-weight:bold;background-color:#8EFFEF;">
		<?php echo "You have no permission to sale using this access."; ?>
		</td>
		<?php
	}else{
	?>
		<td style="width:180px;text-align:right;padding-right:5px;">
		
<label id="item_label" for="item">
    <?php
    if ($mode == 'sale' || $mode == 'global') {
    	echo $this->lang->line('sales_find_or_scan_item');
    } else {
    	echo $this->lang->line('sales_find_or_scan_item_or_receipt');
    }
    ?>
</label>
		</td>
		<td>
		<?php
		if ($mode == 'global') {
			echo form_input(array('name' => 'item', 'id' => 'find', 'size' => '65'));
		} else if($mode == 'global_delivery'){
			echo form_input(array('name' => 'recept_id', 'id' => 'recept_id', 'size' => '65'));
		}else {
			echo form_input(array('name' => 'item', 'id' => 'item', 'size' => ''),'' ,"style='width:90%;border:1px solid #FF0000'");
		}
		?>

		</td>
	</tr>
</table>



<?php if ($mode == 'global'){?>
<div id="item_find" >
    <?php 
    //echo anchor("sales/globalsearch/-1/width:600", "<div class='button_new' id='find' ><span>" . $this->lang->line('sales_find') . "</span></div>", array('class' => 'thickbox none', 'id' => "button_find", 'title' => $this->lang->line('sales_find')));
    echo anchor("sales/globalsearch", "<div class='button_new' id='find' ><span>" . $this->lang->line('sales_find') . "</span></div>", array('class' => 'thickbox none', 'id' => "button_find", 'title' => $this->lang->line('sales_find')));
    ?>
</div>
<?php } else if($mode == 'global_delivery'){?>
<div id="item_find" >
<?php echo anchor("sales/global_delivery/-1/width:600", "<div class='button_new' id='recept_id' ><span>" . $this->lang->line('sales_find') . "</span></div>", array('class' => 'thickbox none', 'id' => "button_find", 'title' => $this->lang->line('sales_find'))); ?>
</div>    
<?php }?>

<?php //if ($mode != 'global') { ?>
    <!--<div id="new_item_button_register" >-->
        <?php
        //echo anchor("items/view/-1/width:360", "<div class='button_new'><span>" . $this->lang->line('sales_new_item') . "</span></div>", array('class' => 'thickbox none', 'title' => $this->lang->line('sales_new_item')));
        ?>
    <!--</div>-->
<?php //} else { ?>

    <!--<div id="item_find" >-->
        <?php
        //echo anchor("sales/globalsearch/-1/width:480", "<div class='button_new' id='find' ><span>" . $this->lang->line('sales_find') . "</span></div>", array('class' => 'thickbox none', 'id' => "button_find", 'title' => $this->lang->line('sales_find')));
        ?>
    <!--</div>-->
<?php //} ?>
<!--</form>-->
<?php
//echo '<pre>';
//print_r($cart);
//print_r($lot_details);
?>
<?php }?>
<table id="register" style="padding-top:10px;">
    <thead>
        <tr>
            <th style="width:11%;"><?php echo $this->lang->line('common_delete'); ?></th>
            <th style="width:10%;"><?php echo $this->lang->line('sales_item_number'); ?></th>
            <th style="width:30%;"><?php echo $this->lang->line('sales_item_name'); ?></th>
            <th style="width:11%;"><?php echo "Inv. Price" ?></th>
            <th style="width:11%;"><?php echo "Incl.VAT"; ?></th>
            <th style="width:11%;"><?php echo "TAG Price"; ?></th>
            <th style="width:11%;"><?php echo $this->lang->line('sales_quantity'); ?></th>
            <th style="width:11%;"><?php echo $this->lang->line('sales_discount'); ?></th>
            <th style="width:15%;"><?php echo $this->lang->line('sales_head_total'); ?></th>
            <?php if ($mode == 'global') { ?>
                <th style="width:15%;"><?php echo $this->lang->line('location'); ?></th>    
                <?php
            } else {
                ?>
                <th style="width:15%;"><?php echo $this->lang->line('sales_edit'); ?></th>  
                <?php
            }
            ?>
        </tr>
    </thead>
    <tbody id="cart_contents">
        <?php
        if (count($cart) == 0) {
            ?>
            <tr><td colspan='10'>
                    <div class='warning_message' style='padding:7px;'><?php echo $this->lang->line('sales_no_items_in_cart'); ?></div>
            </tr></tr>
            <?php
        } else {
        	 echo form_open("sales/edit_item_shawpon", array('id' => 'edit_item_shawpon_form')); ?></form>
        <?php

        $return_cart=array();
        $sales_cart=array();

        $real_sale_amount=0;

        foreach (array_reverse($cart, true) as $line => $item) {
        	if($item['status']=="return"){
        		$return_cart[$line]=$item;
        		//
        	}else{
        		$sales_cart[$line]=$item;
        	}
        	$real_sale_amount+=number_format(($item['price'] * $item['quantity']) - (($item['price'] * $item['quantity']) * ($item['discount'] / 100)), 2, '.', '');
        }

        $cart_view=array();
        if(count($sales_cart)){
        	foreach ($sales_cart as $key => $value) {
        		$cart_view[$key]=$value;
        	}
        }if(count($return_cart)){
        	foreach ($return_cart as $key => $value) {
        		$cart_view[$key]=$value;
        	}
        }

        $total_qty=0;
        $total_vat=0;
        $total_inventory_price=0;
        $total_tag_price=0;
        $total_discount=0;
        $total_sale_price=0;


        foreach ($cart_view as $line => $item) {



        	$total_vat+=$item['vat_amount']*$item['quantity'];

        	$total_qty+=$item['quantity'];
        	$total_inventory_price+=number_format((round($item['price']) * $item['quantity']), 2, '.', '');


        	$item_price=0;

        	if($item['vat_amount']==0){
        		$item_price=round(round($item['price_with_vat'])+(round($item['price_with_vat'])*$item['vat_rate']/100));
        	}else{
        		$item_price=round($item['price_with_vat']);
        	}

        	$tmp_tag_price=number_format((round($item_price) * $item['quantity']), 2, '.', '');
        	// $tmp_total_sale_price=number_format(round(($item['price_with_vat'] * $item['quantity']) - (($item['price_with_vat'] * $item['quantity']) * ($item['discount'] / 100))), 2, '.', '');
        	$tmp_total_sale_price=number_format(round(round(round($item_price) -(round($item_price)* $item['discount'] / 100)) * $item['quantity']), 2, '.', '');




        	$total_tag_price+=$item['price_with_vat'];
        	$total_sale_price+=$tmp_total_sale_price;
        	$total_discount+=round($tmp_tag_price-$tmp_total_sale_price);

        	// $cur_item_info = $this->Item->get_info_shawpon($item['item_id'],$item['lot_no']);
        	echo form_open("sales/edit_item/$line");

        	echo form_hidden('facebook_customer', $facebook_customer);
        	echo form_hidden('mobile_no', $customer_gs_card);
        	echo form_hidden('facebook_customer_id', $customer_gs_id);
        	echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
        	echo form_hidden('facebook_otp', $facebook_otp);
        	echo form_hidden('coupon_card_discout', $coupon_card_discout);
        	echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
        	echo form_hidden('coupon_card_number', $coupon_card_number);
        	if($facebook_customer_otp_correct==1){
        		$send_str="C4CA4238A0B923820DCC509A6F75849B";
        	}elseif($facebook_customer_otp_correct==0){
        		$send_str="CFCD208495D565EF66E7DFF9F98764DA";
        	}

        	if($item['status']=="global_delivery"){
        		$style="style='background-color:#A6EEB6;'";
        		$style_center="style='background-color:#A6EEB6;align:center;'";
        	}elseif($item['status']=="global"){
        		$style="style='background-color:#A6EEB6;'";
        		$style_center="style='background-color:#A6EEB6;align:center;'";
        	}
        	elseif($item['status']=="return"){
        		$style="style='background-color:#FFAFAF;'";
        		$style_center="style='background-color:#FFAFAF;align:center;'";
        	}else{
        		$style="style='background-color:#AFFFF0;'";

        		$style_center="style='background-color:#AFFFF0;align:center;'";
        	}
        	$style_unit_price_include_vat="style='background-color:#0E738A;color:#FFFFFF;'";
        	$style_unit_price_exclude_vat="style='background-color:#910619;color:#FFFFFF;'";


                ?>
                <tr>
                    <td <?php echo $style; ?>>
                    
                    <?php echo anchor_delete("sales/delete_item/$line/$send_str/".intval($coupon_card_discout)."/".intval($coupon_card_maximum_discout)."/".$coupon_card_number, '<b style="font-weight:bold;background-color:#F9FF49;padding:3px;border: 1px solid #FF0000;">' . $this->lang->line('common_delete') . '</b>','',$item['item_id'],$item['name'],$item['lot_no']); ?>
                    
                   <!-- //START::22-12-2018-->
                   
                   <?php 

                   include('application/config/config.php');
                   if(trim($item['serialnumber']) OR intval($item['permission_discount'])){
                   	if(LOCATION_CODE=="BNK"){
                   ?>
                   
                    </br></br><font style="color:#000000;font-weight:bold;border: 1px solid <?php echo $employee_code[$item['serialnumber']]['color_code']?>;width:120px;background-color:<?php echo $employee_code[$item['serialnumber']]['color_code']?>"><?php echo $employee_code[$item['serialnumber']]['short_name'];?></font><?php echo "&nbsp;<font style='color:#000000;font-weight:normal;background-color:#9B8F8F;font-size:10px;'>".$item['permission_discount']."<font>"?>
                    <?php 
                   	}
                   	}else{?>
                    </br></br>
                    <hr size="15" style="background-color:#A6EEB6;border: 1px solid #FF0000;">
                    <?php }?>
                    
                    
                   <!-- //END::22-12-2018-->
                   
                   
                    </td>

                    <?php
                    $price_list=array();
                    if(count($item['price_list_for_dropdown'])){
                    	$item['stock_qty']=$item['price_list_for_dropdown'][number_format($item['price'], 2,".","")];
                    	$price_list=$item['price_list_for_dropdown'];
                    }
                    ?>

				   <td <?php echo $style; ?>><?php echo $item['item_id']."</br>L: ".$item['lot_no']; ?></td>
                    <td <?php echo $style_center; ?>><?php echo $item['name']; ?><br /> <?php echo ($mode != 'global') ? '[' . $item['stock_qty'] . ' in stock]' : '' ?></td>

                    <?php
                    if ($items_module_allowed) {
                        ?>
                        <td>
                            <?php //echo form_input(array('name' => 'price', 'value' => $item['price'], 'size' => '6')); ?>
                            <?php //echo number_format($item['price'], 2, '.', ''); ?>
                            <?php //echo form_hidden('price', $item['price']); ?>
                        </td>
                        <?php
                    } else {
                        ?>
                        <td <?php echo $style; ?>>
                        
                        <?php 


                        if(count($price_list)>1){
                        ?>
                         <select name="price" id="price" onchange="this.form.submit()">
                         
                      <?php foreach ($price_list as $_p_key => $p_value) { ?>
                      
                       <?php if(number_format($_p_key, 2,".","")==number_format($item['price'], 2,".","")){?>
                       <option value="<?php echo number_format($_p_key, 2,".","");?>" selected><?php echo number_format($_p_key, 2,".","");?></option>
                       <?php }else{?>
                      
                      	 <option value="<?php echo number_format($_p_key, 2,".","");?>"><?php echo number_format($_p_key, 2,".","");?></option>
                      	<?php }?>
                      	
                      <?php }?>  
                        
    </select>
                        <?php }else{?>
                            <?php echo number_format($item['price'], 2, '.', ''); ?>
                            <?php echo form_hidden('price', $item['price']); ?>
                            
                            <?php }?>
                        </td>
                        <?php
                    }
                    ?>

                     <td <?php echo $style; ?>>
                    <?php echo number_format($item['vat_amount'], 2, '.', ''); ?>
                    </td>
                    <?php if(doubleval($item['vat_amount'])>0){?>
                    
                     <td <?php echo $style_unit_price_include_vat; ?>>
                    <?php echo number_format($item['price_with_vat'], 2, '.', ''); ?>
                    </td>
                    <?php }else{?>
                    
                     <td <?php echo $style_unit_price_exclude_vat; ?>>
                    <?php echo number_format($item['price_with_vat'], 2, '.', ''); ?>
                    </td>
                    <?php }

                    ?>
                    
                    
                    
                    <td <?php echo $style; ?>>
                        <?php

                        if ($mode == 'global') {
                        	echo $item['quantity'];
                        	echo form_hidden('quantity', $item['quantity']);
                        } else {
                        	echo form_input(array('name' => 'quantity', 'value' => $item['quantity'], 'size' => '3'));
                        	// echo $item['quantity'];
                        	//echo form_hidden('quantity', $item['quantity']);
                        }
                        ?>
                    </td>

                    <td <?php echo $style; ?>><?php 
                    if ($mode == 'global') {
                    	echo $item['discount'];
                    	echo form_hidden('discount', $item['discount']);
                    } else {
                    	echo form_hidden('discount', $item['discount']);
                    	echo "<input type='text' id='discount' name='discount' size='3' autocomplete='off' value='".$item['discount']."' readonly>";/////////////////////DURING FLAT 40P
                    	//echo "<input type='text' id='discount' name='discount' size='3' autocomplete='off' value='".$item['discount']."'>";

                    }
                    	?>
                    </td>
                    <td <?php echo $style; ?>><?php echo number_format(round(($item['price_with_vat'] * $item['quantity']) - (($item['price_with_vat'] * $item['quantity']) * ($item['discount'] / 100))), 2, '.', ''); ?></td>
                    <?php
                    if ($mode == 'global') {
                    	echo '<td>' . $item['location'] . ' </td>';
                    } else {
                        ?>

                        <td <?php echo $style; ?>><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'),'style="font-weight:bold;background-color:#04530D;padding:3px;border: 1px solid #FF0000;color:#FFFFFF;cursor:pointer"'); ?></td>
                    <?php } ?>

                    <?php 

                    ?>
                    
                </tr>
                <?php /*
                    <tr>
                    <td style="color:#2F4F4F";><?php echo $this->lang->line('sales_description_abbrv') . ':'; ?></td>
                    <td colspan=2 style="text-align:left;">

                    <?php
                    if ($item['allow_alt_description'] == 1) {
                    echo form_input(array('name' => 'description', 'value' => $item['description'], 'size' => '20'));
                    } else {
                    if ($item['description'] != '') {
                    echo $item['description'];
                    echo form_hidden('description', $item['description']);
                    } else {
                    echo 'None';
                    echo form_hidden('description', '');
                    }
                    }
                    ?>
                    </td>
                    <td>&nbsp;</td>
                    <td style="color:#2F4F4F";>
                    <?php
                    if ($item['is_serialized'] == 1) {
                    echo $this->lang->line('sales_serial') . ':';
                    }
                    ?>
                    </td>
                    <td colspan=3 style="text-align:left;">
                    <?php
                    if ($item['is_serialized'] == 1) {
                    echo form_input(array('name' => 'serialnumber', 'value' => $item['serialnumber'], 'size' => '20'));
                    } else {
                    echo form_hidden('serialnumber', '');
                    }
                    ?>
                    </td>


                    </tr>
                 */ ?>
                <tr style="height:2px">
                    <td colspan=10 style="background-color:#318ee1;padding: 2px;"> </td>
                </tr>		
                <?php
                echo form_hidden('coupon_card_discout', $coupon_card_discout);
                echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
                echo form_hidden('coupon_card_number', $coupon_card_number);
                ?>
                </form>
                <?php
        }
        ?>
        <tr>
            <th style="width:11%;">&nbsp;</th>
            <th style="width:10%;">&nbsp;</th>
            <th style="width:30%;">TOTAL</th>
            <th style="width:11%;border-right: 1px solid;border-left: 1px solid;font-weight:normal;background-color:#04bb6e;"><?php echo number_format($total_inventory_price, 2, '.', ''); ?></th>
            <th style="width:11%;border-right: 1px solid;font-weight:normal;"><?php echo number_format($total_vat, 2, '.', ''); ?></th>
            <th style="width:11%;border-right: 1px solid;font-weight:normal;"><?php echo number_format($total_tag_price, 2, '.', ''); ?></th>
            <th style="width:11%;border-right: 1px solid;font-weight:normal;background-color:#04bb6e;"><?php echo number_format($total_qty, 2, '.', ''); ?></th>
            <th style="width:11%;border-right: 1px solid;font-weight:normal;"><?php echo number_format($total_discount, 2, '.', ''); ?></th>
            <th style="width:15%;font-weight:normal;"><?php echo number_format($total_sale_price, 2, '.', ''); ?></th>
            <th style="width:15%;">&nbsp;</th>    
        </tr>
        
        <?php
        }
        ?>
    </tbody>
</table>
</div>

<div id="overall_sale">
    <?php
    if (count($cart) > 0) {
    	if (trim($customer)) {
    		?>
    		<table style="border: 0px solid #000; width:100%;background-color: #90e9ff;box-shadow: 0px 8px 8px #000;">
	    		<tr>
		    		<td style="font-weight:bold; padding-top:5px;padding-bottom:5px;width: 26%;">
		    		<?php echo "&nbsp;".$this->lang->line("sales_customer").":&nbsp;";?>
		    		</td>
		    		<td style="font-weight:bold; padding-top:5px;padding-bottom:5px;">
		    		<?php echo $customer;?>
		    		</td>
	    		</tr>
	    		<tr>
		    		<td style="font-weight:bold; padding-bottom:5px;width: 26%;">
		    		<?php echo "&nbsp;Card No:&nbsp;";?>
		    		</td>
		    		<td style="font-weight:bold; padding-bottom:5px;">
		    		<?php echo $customer_gs_card;?>
		    		</td>
	    		</tr>
	    		<tr>
		    		<td style="font-weight:bold; padding-bottom:5px;width: 26%;">
		    		<?php echo "&nbsp;Phone No:&nbsp;";?>
		    		</td>
		    		<td style="font-weight:bold; padding-bottom:5px;">
		    		<?php echo $mobile_no;?>
		    		</td>
	    		</tr>
	    		<tr>
		    		<td colspan="2" style="font-weight:bold; padding-top:5px;padding-bottom:11px;text-align:center;">
		    		<?php echo anchor("sales/remove_customer/".intval($coupon_card_discout)."/".intval($coupon_card_maximum_discout)."/".$coupon_card_number, '<b style="font-weight:bold;background-color:#940909;color:#FFFFFF;padding:3px;border: 1px solid #FF0000;">'. $this->lang->line('common_remove') . ' ' . $this->lang->line('customers_customer') . '</b>');?>
		    		</td>
	    		</tr>
    		</table>
    		
        <table style="border: 1px solid #000; width:100%">
            <?php
            $can_complete=0;
            if (isset($customer_gs_id)) {
            	if(intval($facebook_customer)==1){
            		if(intval($facebook_customer_otp_correct)==0){
            			echo form_open("sales/check_otp", array('id' => 'select_new_otp_form'));
            		?>
            		<tr>
		            	<th colspan="2" style="text-align:left; background-color: #b60b05;border: 0px solid #000; width:100%;color:#FFFFFF;vertical-align: middle;padding-top: 3px;height: 36px;">
            		<?php
            		echo "&nbsp;".form_input(array('name' => 'facebook_otp', 'size' => '17')). '</b>';
            		?>
            		 	</th> 
            		 	<th  style="text-align:left; background-color: #b60b05;border: 0px solid #000;color:#FFFFFF;">
            		 	<?php
            		 	echo "<div class='button_new' id='add_check_otp_button' style='float:left;margin-top:5px;'><span>OTP Submit</span></div>";
            		 	?>
            		 	</th>
	            	</tr>
	            	<?php
	            	echo form_hidden('facebook_customer', $facebook_customer);
	            	echo form_hidden('mobile_no', $customer_gs_card);
	            	echo form_hidden('facebook_customer_id', $customer_gs_id);
	            	echo form_hidden('coupon_card_discout', $coupon_card_discout);
	            	echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
	            	echo form_hidden('coupon_card_number', $coupon_card_number);
	            	?>
	            	</form>
            	<?php
            	$can_complete=1;
            		}else{
            			echo form_hidden('facebook_customer', $facebook_customer);
            			echo form_hidden('mobile_no', $customer_gs_card);
            			echo form_hidden('facebook_customer_id', $customer_gs_id);
            			echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
            			echo form_hidden('facebook_otp', $facebook_otp);
            			echo form_hidden('coupon_card_discout', $coupon_card_discout);
            			echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
            			echo form_hidden('coupon_card_number', $coupon_card_number);
            		}
            	}

            }
            ?>
    </table>
        
       <!-- <div style="margin-top:5px;text-align:left;">
            
            <?php if ($previous_due > 0) { ?>
                <font style="font-weight:bold;">Previous Due: </font><font style="font-weight:bold;color:#FF0000;"><?php echo to_currency($previous_due); ?></font>
            <?php } else if ($previous_due < 0) { ?>
                <font style="font-weight:bold;">Previous Advance: </font><font style="font-weight:bold;color:#078d20;"><?php echo to_currency(abs($previous_due)); ?></font>
            <?php } else { ?>
                <font style="font-weight:bold;">Previous Due: </font><font style="font-weight:bold;color:#000000;"><?php echo to_currency($previous_due); ?></font>
            <?php } ?>
        </div>
        <div style="margin-top:5px;text-align:left;">
            <font style="font-weight:bold;">This Year User Points:</font><font style="font-weight:bold;color:#078d20;"> <?php echo!empty($user_points) ? $user_points : 0 ?></font>
        </div>
        <div style="margin-top:5px;text-align:left;">
            <font style="font-weight:bold;">This Year Purchase:</font><font style="font-weight:bold;color:#078d20;"> <?php echo!empty($user_points) ? $user_points*100 : 0 ?> BDT</font>
        </div>-->
        <?php
    	} else {
    		echo form_open("sales/select_customer", array('id' => 'select_customer_form'));
        ?>
        
        <table width="100%">
        	<tr>
        		<td>
        		 <label id="customer_label" for="customer"><?php echo $this->lang->line('sales_select_customer'); ?></label>
        		</td>
        	</tr>
        	<tr>
        		<td>
        		 <?php echo form_input(array('name' => 'customer', 'id' => 'customer', 'size' => '', 'value' => $this->lang->line('sales_start_typing_customer_name')),'','style="width:95%;border: 1px solid #FF0000;padding: 4px;margin-bottom:5px;"'); ?>
        		</td>
        	</tr>
        
        </table>
        
        <?php
        echo anchor("customers/view/-1/width:425",
        "<div class='button_new' style='float: left;'><span>".$this->lang->line('customers_new')."</span></div>",
        array('class'=>'thickbox none','title'=>$this->lang->line('customers_new')));
        echo form_hidden('coupon_card_discout', $coupon_card_discout);
        echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
        echo form_hidden('coupon_card_number', $coupon_card_number);
        ?>
        
    </form>
    <div style="margin-top:5px;text-align:center;">
    <!--     <h3 style="margin: 5px 0 5px 0"><?php echo $this->lang->line('common_or'); ?></h3> -->
        <?php
        //     echo anchor("customers/view/-1/width:350", "<div class='button_new' style='margin:0 auto;'><span>" . $this->lang->line('sales_new_customer') . "</span></div>", array('class' => 'thickbox none', 'title' => $this->lang->line('sales_new_customer')));
        ?>
    </div>
    <div class="clearfix">&nbsp;</div>
    <?php
    	}
    }

    if(count($cart)==0){
    	$totalsubtotal=0;
    	$total_provide_discount=0;
    	$previous_due=0;
    	$cart_point_cost=0;
    	$vat_enable_subtotal=0;
    	$taxes=array();
    	$adjectment_show=0;
    	$vat_enable_subtotal=0;
    	$total_tax=0;
    }
?>
<!--</br>
<table style="box-shadow: 0px 8px 8px #000;" width="100%">
<tr>
<td style="background-color: #318ee1;padding: 6px;">
<div id='sale_details' style="border-top: 0px solid #000;">
	<div class="float_left" style="width:55%;font-weight:bold;background-color:#318ee1;color:#FFFFFF;"><?php echo "&nbsp;Inv. Total Sale (".($included_vat_sub_total_qty+$exclued_vat_sub_total_qty).")"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;background-color:#318ee1;color:#FFFFFF;"><?php echo to_currency($included_vat_sub_total_inv_amount+$exclued_vat_sub_total_inv_amount)."&nbsp;"; ?></div>
    
</div>
</td>
</tr>
</table>-->
<div class="clearfix" style="height:7px;">&nbsp;</div>

<?php if(intval($new_customer_added_success)==1){
	$inventory_total=$included_vat_sub_total_inv_amount+$exclued_vat_sub_total_inv_amount;
	$inventory_vat_amount=$included_vat_sub_total_vat_amount+$exclued_vat_sub_total_vat_amount;
	$card_amount_amount_vat=($inventory_vat_amount*$purchase_discount_elegible_percentage_amount)/$inventory_total;

	$sales_total_with_vat_for_interface=round($purchase_discount_elegible_percentage_amount+$card_amount_amount_vat);

	$card_discount_total_with_vat_for_interface=round((round($sales_total_with_vat_for_interface-$total_provide_discount)*$purchase_discount_percentage)/100);

}else{
	$sales_total_with_vat_for_interface=round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount);
	$card_discount_total_with_vat_for_interface=round((round($sales_total_with_vat_for_interface-$total_provide_discount)*$purchase_discount_percentage)/100);
}

?>

<table style="box-shadow: 0px 8px 8px #000;">
<tr>
<td style="background-color: #E3F3FF;padding: 6px;">

<div id='sale_details' style="border-top: 0px solid #000;">

    
    <div class="float_left" style="width:55%;font-weight:bold;background-color:#0E738A;padding-top: 2px;padding-bottom: 2px;color:#FFFFFF;"><?php echo "&nbsp;Incl. VAT Sale (".$included_vat_sub_total_qty.")"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;background-color:#0E738A;padding-top: 2px;padding-bottom: 2px;color:#FFFFFF;"><?php echo to_currency($included_vat_sub_total_amount)."&nbsp;"; ?></div>
    
    <div class="float_left" style="width:55%;font-weight:bold;background-color:#910619;padding-top: 2px;padding-bottom: 2px;color:#FFFFFF;"><?php echo "&nbsp;VATable Sale (".$exclued_vat_sub_total_qty.")"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;background-color:#910619;padding-top: 2px;padding-bottom: 2px;color:#FFFFFF;"><?php echo to_currency($exclued_vat_sub_total_amount)."&nbsp;"; ?></div>

    <div class="float_left" style="width:55%;font-weight:bold;background-color:#2b2884;padding-top: 5px;padding-bottom: 5px;color:#12fa0b;"><?php echo "&nbsp;Sales Sub Total (".($included_vat_sub_total_qty+$exclued_vat_sub_total_qty).")"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;background-color:#2b2884;padding-top: 5px;padding-bottom: 5px;color:#12fa0b;"><?php echo to_currency($included_vat_sub_total_amount+$exclued_vat_sub_total_amount)."&nbsp;"; ?></div>
    
    
    <div class="float_left" style="width:55%;color:#2000FF;font-weight:bold;padding-top: 2px;padding-bottom: 2px;"><?php echo "&nbsp;VAT On <font style='background-color:#910619;color:#FFFFFF;'>".number_format($exclued_vat_sub_total_amount, 2, '.', '')."</font>"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;color:#2000FF;padding-top: 2px;padding-bottom: 2px;"><?php echo to_currency($exclued_vat_sub_total_vat_amount)."&nbsp;"; ?></div>
        
    <?php

    $adjectment=0;
    $adjectment_show = number_format(round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount) - ($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount),2);

    if (trim($customer)=="") {
    	$purchase_discount_amount=0;
    }
    ?>
    <div class="float_left" style='width:55%;font-weight:bold;padding-top: 2px;padding-bottom: 2px;'>&nbsp;Adjustment(+/-):</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;padding-top: 2px;padding-bottom: 4px;"><?php echo ($adjectment_show > 0 ? "+" . to_currency($adjectment_show) : to_currency($adjectment_show))."&nbsp;"; ?></div>
    <div class="float_left" style='width:55%;color:#2000FF;font-weight:bold;font-weight:bold;background-color:#000000;padding-top: 5px;padding-bottom: 5px;color:#FFFFFF;'><?php echo "&nbsp;Sales Total"; ?>:</div>
    <div class="float_left" style="width:45%;color:#2000FF;font-weight:bold;text-align:right;font-weight:bold;background-color:#000000;padding-top: 5px;padding-bottom: 5px;color:#FFFFFF;"><?php echo to_currency(round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount))."&nbsp;"; ?></div>
	
    
    <div class="float_left" style="width:55%; color:#FF0000;font-weight:bold;padding-top: 4px;padding-bottom: 2px;"><?php echo "&nbsp;Clearance Discount"; ?>:</div>
    <div class="float_left" style="width:45%;font-weight:bold;text-align:right;color:#FF0000;padding-top: 2px;padding-bottom: 2px;"><?php echo to_currency($total_provide_discount)."&nbsp;"; ?></div>
    
    
    
    
    <?php if ($this->session->userdata['customer'] != -1) { ?>
    <?php if (doubleval($previous_due)!= 0) { ?>
        <?php if ($previous_due >= 0) { ?>
            <div class="float_left" style="width:55%;font-weight:bold;color:#FF0000;padding-top: 2px;padding-bottom: 2px;"><?php echo "&nbsp;Previous Due"; ?>:</div>
        <?php } else { ?>
            <div class="float_left" style="width:55%;font-weight:bold;color:#FF0000;padding-top: 2px;padding-bottom: 2px;"><?php echo "&nbsp;Previous Advance"; ?>:</div>
        <?php } ?>
 
        <div class="float_left" style="width:45%;font-weight:bold;text-align:right;color:#FF0000;padding-top: 2px;padding-bottom: 2px;"><?php echo to_currency($previous_due)."&nbsp;"; ?></div>

        <?php
    }
    }
    ?>
   

    <?php if ($this->session->userdata['customer'] != -1) { ?>
        <?php if($cart_point>0){?>
        <div class="float_left" style='width:70%;color:#FF0000;font-weight:bold;padding-top: 2px;padding-bottom: 2px;'>&nbsp;Redeem Point(<?php echo ($cart_point>0?$cart_point:0) . ' * ' . to_currency($cart_point_value) ?>) : </div>
        <div class="float_left" style="width:30%;font-weight:bold;text-align:right;color:#FF0000;padding-top: 2px;padding-bottom: 2px;"><?php echo to_currency($cart_point_cost)."&nbsp;"; ?></div>
        
        <?php 	}if(POINT_CARD_ACTIVE==1){ ?>
        <div class="float_left" style='width:70%;color:#FF0000;font-weight:bold;padding-top: 2px;padding-bottom: 4px;'>&nbsp;Card Discount (<?php echo $purchase_discount_percentage; ?> %) : </div>
        <div class="float_left" style="width:30%;font-weight:bold;text-align:right;color:#FF0000;padding-top: 4px;padding-bottom: 2px;"><?php echo to_currency($card_discount_total_with_vat_for_interface)."&nbsp;"; ?></div>
    <?php 
        }
    }
    if(intval($coupon_card_maximum_discout)>0){
        	?>
        <div class="float_left" style='width:70%;color:#FF0000;font-weight:bold;padding-top: 2px;padding-bottom: 4px;'>&nbsp;Gift Card Discount : </div>
        <div class="float_left" style="width:30%;font-weight:bold;text-align:right;color:#FF0000;padding-top: 4px;padding-bottom: 2px;"><?php echo to_currency(intval($coupon_card_discout))."&nbsp;"; ?></div>
    <?php 

        } ?>
         <div class="float_left" style='width:55%;color:#2000FF;font-weight:bold;font-weight:bold;background-color:#0c0979;padding-top: 5px;padding-bottom: 5px;color:#FFFFFF;'><?php echo "&nbsp;Total Invoice Amount"; ?>:</div>
    <div class="float_left" style="width:45%;color:#2000FF;font-weight:bold;text-align:right;font-weight:bold;background-color:#0c0979;padding-top: 5px;padding-bottom: 5px;color:#FFFFFF;"><?php echo to_currency(round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount)-round($card_discount_total_with_vat_for_interface)-round($total_provide_discount)-round($cart_point_cost)-round($coupon_card_discout))."&nbsp;"; ?></div>
	
    
</div>
</td>
</tr>
</table>

<?php
if(count($cart)==0){


	$has_permission=array();

	$has_permission['BNK']="BNK";
	$has_permission['SDB']="SDB";
	$has_permission['ADB']="ADB";
	$has_permission['KLB']="KLB";
	$has_permission['TAL']="TAL";
	$has_permission['UTA']="UTA";
	$has_permission['MYN']="MYN";
	$has_permission['SYL']="SYL";
	$has_permission['RAJ']="RAJ";
	$has_permission['RAN']="RAN";
	$has_permission['CHK']="CHK";
	$has_permission['DNJ']="DNJ";


	$permission_loc=0;

	if(trim($has_permission[LOCATION_CODE])){
		$permission_loc=1;
	}

	$last_sale_data=array();
	if(intval($permission_loc)==0){
		$query = $this->db->query("SELECT sale_id,sale_time,receipt_no
			        FROM  ospos_sales
				    WHERE DATE_FORMAT(sale_time,'%Y-%m-%d')='".mysql_real_escape_string(date("Y-m-d"))."'
				    ORDER BY sale_time DESC LIMIT 2");
		foreach ($query->result() as $row) {
			$last_sale_data[]=$row;
		}

	}else{
		$query = $this->db->query("SELECT sale_id,sale_time,receipt_no
			        FROM  ospos_sales_reprint
				    WHERE DATE_FORMAT(sale_time,'%Y-%m-%d')='".mysql_real_escape_string(date("Y-m-d"))."'
				    ORDER BY sale_time DESC LIMIT 2");

		foreach ($query->result() as $row) {
			$last_sale_data[]=$row;
		}
	}
}
?>



<?php if(count($cart)==0){?>

<div class="clearfix" style="height:7px;">&nbsp;</div>
<table style="box-shadow: 0px 8px 8px #000;" width="100%">

<tr>
	<td style="background-color: #F4F1D3;padding: 6px;text-align:center;font-weight:bold;" colspan="3">
	<font style="font-size:15px; text-align:right;text-shadow: 2px 2px 4px #00FF93;vertical-align: top;"> <?php echo date("l,jS-F,Y h:i:s A") ?></font>
	</td>
</tr>
<tr>
	<td style="background-color: #78FFFF;padding: 6px;text-align:center;font-weight:bold;" colspan="3">
	LAST 2 SALES IN DATABASE
	</td>
</tr>

<?php if(count($last_sale_data)==0){?>
<tr>
	<td style="background-color: #FFCACA;padding: 6px;text-align:center;font-weight:normal;" colspan="3">
	NO SALE YET
	</td>
</tr>
<?php }else{?>

<?php 
$count=1;
foreach ($last_sale_data as $last_key => $last_value) {

	$last_sale_id= $last_value->sale_id;
	$last_sale_time= $last_value->sale_time;
	$last_receipt_no= $last_value->receipt_no;

	$last_sale_price=0;
	$time_ago_message="";
	$datetime1 = new DateTime($last_sale_time);
	$datetime2 = new DateTime(date("Y-m-d H:i:s"));
	$interval = $datetime1->diff($datetime2);
	$time_ago_message="<font style='background-color: #F0F79F;'>[".$interval->format('%h')." H ".$interval->format('%i')." M ".$interval->format('%s')." S Ago]</font>";

	$color_show="#E3F3FF";

	if($count%2==0){
		$color_show="#C4FBC5";
	}else{
		$color_show="#E3F3FF";
	}
?>

<tr>
	<td style="background-color: <?php echo $color_show;?>;padding: 6px;font-size:11px;">
	<?php echo $last_receipt_no;?>
	</td>
	<td style="background-color: <?php echo $color_show;?>;padding: 6px;font-size:11px;">
	<?php echo date("h:i:s A",strtotime($last_sale_time)); ?>
	</td>
	<td style="background-color: <?php echo $color_show;?>;padding: 6px;font-size:11px;">
	<?php echo $time_ago_message;?>
	</td>
</tr>
<?php 
$count++;
}?>



<?php }?>
</table>
<?php }?>
<div class="clearfix">&nbsp;</div>


<?php
// Only show this part if there are Items already in the sale.
if (count($cart) > 0) {
	if ($mode != 'global') {?>
<table>
 <tr>
  <td style="width:169px;">
    <div id="Cancel_sale">
        <?php echo form_open("sales/cancel_sale", array('id' => 'cancel_sale_form')); ?>
        <div class='button_new_cancel' id='cancel_sale_button' style='margin-top:5px;'><span><?php echo $this->lang->line('sales_cancel_sale'); ?></span></div>
        </form>
    </div> 
    </td>
    <td>
    <div id="Cancel_sale">
        <?php echo form_open("sales/complete", array('id' => 'finish_sale_form')); 
        echo form_hidden('amount_due_for_post_submit', $amount_due);
        echo form_hidden('card_discount_total_with_vat_for_interface', $card_discount_total_with_vat_for_interface);
        echo form_hidden('coupon_card_discout', $coupon_card_discout);
        echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
        echo form_hidden('coupon_card_number', $coupon_card_number);
        ?>
        
        <?php echo "<div class='button_new' id='suspend_sale_button' style='float:right;margin-top:5px;'><span>" . $this->lang->line('sales_suspend_sale') . "</span></div>"; ?>
        </form>
    </div>
    </td> 
  </tr>
</table>

<?php }else{?>
<div id="Cancel_sale">
        <?php echo form_open("sales/cancel_sale", array('id' => 'cancel_sale_form')); ?>
        <div class='button_new' id='cancel_sale_button' style='margin-top:5px;'><span><?php echo $this->lang->line('sales_cancel_sale'); ?></span></div>
        </form>
    </div>
<?php }?>
    <div class="clearfix" style="margin-bottom:1px;background-color: #FEEEEE;">&nbsp;</div>
    <table style="border: 1px solid #000; width:100%">
            <?php
            $can_complete=0;

            if (isset($customer)) {
            	if(trim($customer_gs_card)==""){

            		if($purchase_discount_elegible_percentage_amount>=0){
            			echo form_open("sales/new_card", array('id' => 'select_new_card_form'));

            		?>
            		<tr>
		            	<th colspan="2" style="text-align:left; background-color: #b60b05;border: 0px solid #000; width:100%;color:#FFFFFF;vertical-align: middle;padding-top: 3px;height: 36px;padding-bottom:6px;">
            		<?php
            		echo "&nbsp;".form_input(array('name' => 'new_card_number', 'size' => '17','value'=>$mobile_no)). '</b>';
            		?>
            		 	</th> 
            		 	<th  style="text-align:left; background-color: #b60b05;border: 0px solid #000;color:#FFFFFF;">
            		 	<?php
            		 	echo "<div class='button_new' id='add_new_card_button' style='float:left;margin-top:5px;'><span>Add Card</span></div>";
            		 	?>
            		 	</th>
	            	</tr>
	            	<?php
	            	echo form_hidden('purchase_discount_elegible_percentage_amount', $purchase_discount_elegible_percentage_amount);
	            	echo form_hidden('customer_gs_id', $customer_gs_id);
	            	echo form_hidden('customer_gs_card', $customer_gs_card);
	            	echo form_hidden('coupon_card_discout', $coupon_card_discout);
	            	echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
	            	echo form_hidden('coupon_card_number', $coupon_card_number);
	            	?>
	            	</form>
	            	
            	<?php
            	$can_complete=1;
            		}
            	}

            }
            ?>
            
            
            <?php
            $current_date_coupon=date("Y-m-d");
            if($current_date_coupon<='2022-05-05'){

            	$total_product_price_consider=5000;
            	if($elegible_for_coupon_amount>$total_product_price_consider){
            			?>
            			<tr>
		            	<th colspan="3" style="text-align:center; background-color: #fc8404;border: 0px solid #000; width:100%;color:#FFFFFF;vertical-align: middle;padding-top: 6px;padding-bottom:6px;">
            		<?php
            		echo "&nbsp;<b>This invoice eligible for gift card.</b>";
            		?>
            		 	</th> 
            		 	
	            	</tr>

            			<?php
            	}
            }
            if($current_date_coupon<='2022-06-30'){

            	if(intval($coupon_card_maximum_discout)>0){ ?>

            	<tr>
		           <th colspan="2" style="text-align:right; background-color: #0a7634;border: 0px solid #000;color:#FFFFFF;vertical-align: middle;padding-top: 3px;height: 36px;padding-bottom:6px;">
            		<?php
            		echo "&nbsp;Gift Amount:&nbsp;".number_format(intval($coupon_card_maximum_discout),0, '.', ','). ' BDT&nbsp;&nbsp;
            		<br/> <font style="color:#F7FF00;">Remain Amount: &nbsp;'.number_format(intval($coupon_card_maximum_discout)-intval($coupon_card_discout),0, '.', ',').' BDT&nbsp;&nbsp;</font></b>';
            		?>
            		 	</th> 
            		 	<th style="text-align:left; background-color: #0a7634;border: 0px solid #000;color:#FFFFFF; vertical-align: middle;">
            		 	<?php
            		 	//echo "<div class='button_new' id='add_coupon_button' style='float:left;margin-top:5px;'><span>Add Gift Card</span></div>";

            		 	?>
            		 	<?php echo anchor("sales/remove_coupon_card", '<b style="font-weight:bold;background-color:#940909;color:#FFFFFF;padding:3px;border: 1px solid #FF0000;">'. $this->lang->line('common_remove') . ' Gift Card</b>');?>
            		 	</th>
	            	</tr>
            	
            	
            	<?php }else{

            		echo form_open("sales/add_coupon", array('id' => 'select_add_coupon_form'));

            		?>
            		<tr>
		            	<th colspan="2" style="text-align:right; background-color: #0a7634;border: 0px solid #000; width:100%;color:#FFFFFF;vertical-align: middle;padding-top: 3px;height: 36px;padding-bottom:6px;">
            		<?php
            		echo "&nbsp;".form_input(array('name' => 'new_coupon_number', 'size' => '17','value'=>'','placeholder'=>'Previous Gift Card')). '&nbsp;&nbsp;&nbsp;</b>';
            		?>
            		 	</th> 
            		 	<th  style="width:200px;text-align:left; background-color: #0a7634;border: 0px solid #000;color:#FFFFFF;">
            		 	<?php
            		 	echo "<div class='button_new' id='add_coupon_button' style='float:left;margin-top:5px;'><span>Add Gift Card</span></div>";
            		 	?>
            		 	</th>
	            	</tr>
	            	<?php
	            	echo form_hidden('coupon_card_discout', $coupon_card_discout);
	            	echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
	            	echo form_hidden('coupon_card_number', $coupon_card_number);
	            	?>
	            	</form>
	            	
            	<?php
            	}
            }
            ?>
            
    </table>
     <?php

     if (doubleval($amount_due-intval($coupon_card_discout))<=0) {
     	if ($mode == 'global') {
     		$posLocations = [0 => $this->lang->line('select_locations'), LOCATION_CODE => LOCATION_NAME];
     		if ($this->session->userdata('global_receive_location_code') != LOCATION_CODE) {
     			$posLocations[$this->session->userdata('global_receive_location_code')] = $this->session->userdata('global_receive_location');
     		}
     	}
        ?>
        <div id="finish_sale" style="background-color: #BFE4FF;">
           
            <table style="border: 1px solid #000; width:100%">
             <?php echo form_open("sales/complete", array('id' => 'finish_sale_form')); 

             echo form_hidden('card_discount_total_with_vat_for_interface', $card_discount_total_with_vat_for_interface);
             echo form_hidden('facebook_customer', $facebook_customer);
             echo form_hidden('mobile_no', $customer_gs_card);
             echo form_hidden('facebook_customer_id', $customer_gs_id);
             echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
             echo form_hidden('facebook_otp', $facebook_otp);
             echo form_hidden('coupon_card_discout', $coupon_card_discout);
             echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
             echo form_hidden('coupon_card_number', $coupon_card_number);

             ?>
            <?php if ($mode == 'global') { ?>
                <label id="comment_label" for="comment" style="font-weight:bold;color:#2F38F2;"><?php echo $this->lang->line('common_locations'); ?>:</label>
                <?php echo form_dropdown('receive_location', $posLocations, '', 'id="receive_location"'); ?><br/><br/>
            <?php } 

            echo form_hidden('purchase_discount_elegible_percentage_amount', $purchase_discount_elegible_percentage_amount);
            echo form_hidden('customer_gs_id', $customer_gs_id);
            echo form_hidden('customer_gs_card', $customer_gs_card);
            echo form_hidden('coupon_card_discout', $coupon_card_discout);
            echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
            echo form_hidden('coupon_card_number', $coupon_card_number);

            ?>
	            <tr>
		            <th colspan="3" style="text-align:center; background-color: #9be7ff;border: 1px solid #000; width:100%">
		            BAG
		            </th> 
	            </tr>
             	<tr>
		            <th style="text-align:center; background-color: #9be7ff;border: 1px solid #000; width:33%">
		            Big
		            </th>
		           <th style="text-align:center; background-color: #9be7ff;border: 1px solid #000; width:33%">
		            Medium
		            </th>  
		            <th style="text-align:center; background-color: #9be7ff;border: 1px solid #000; width:33%">
		            Small
		            </th> 
	            </tr>
            	<tr>
		            <th style="text-align:center; background-color: #009cc3;border: 1px solid #000; width:33%">
		            <?php echo form_input(array('name' => 'bag_big', 'value' => $bag_big, 'size' => '2'));?>
		            </th>
		           <th style="text-align:center; background-color: #009cc3;border: 1px solid #000; width:33%">
		            <?php echo form_input(array('name' => 'bag_medium', 'value' => $bag_medium, 'size' => '2'));?>
		            </th>  
		            <th style="text-align:center; background-color: #009cc3;border: 1px solid #000; width:33%">
		             <?php echo form_input(array('name' => 'bag_small', 'value' => $bag_small, 'size' => '2'));?>
		            </th> 
	            </tr>
	            <tr>
		            <th colspan="3" style="text-align:center; background-color: #cdf4fe;border: 0px solid #000; width:100%;padding-top:6px;padding-bottom:6px;">
		                 
            <label id="comment_label" for="comment" style="padding-left:6px;"><?php echo $this->lang->line('common_comments'); ?>:
            <?php echo form_input(array('name' => 'comment', 'id' => 'comment','value' => $comment, 'size' => ''),'',"style='width:63%;'");?></label>
            
		            </th>
		        </tr>
		         <?php
            if (!empty($customer_email)) { ?>
	            <tr> 
		            <th colspan="3" style="text-align:center; background-color: #cdf4fe;border: 0px solid #000; width:100%;padding-top:0px;padding-bottom:6px;">
           <?php
           echo  form_checkbox(array(
           'name' => 'email_receipt',
           'id' => 'email_receipt',
           'value' => '1',
           'checked' => (boolean) $email_receipt,
           ))."&nbsp;".$this->lang->line('sales_email_receipt') . ': '. $customer_email . ')<br />';
            ?>

		            </th>
	            </tr>
	            <?php } ?>
            
            </table>
            
             <?php echo form_hidden('purchase_discount_amount', $purchase_discount_amount); ?>
             
            <?php
            if ($payments_cover_total) {
            	if($can_complete==0 && $real_sale_amount>=0){ ?>
            	    <table style="background-color:#FEEEEE; width:100%">
            	      <tr>
            	      	<td style="width:100%;padding-top:8px;">
            	      	<?php echo "<div class='button_new' id='finish_sale_button' style='float:left;margin-top:5px;'><span>" . $this->lang->line('sales_complete_sale') . "</span></div>"; ?>
            	      	</td>
            	      </tr>
            	    
            	    </table>
            		<?php
            	}
            }


            $payment_string_altert="";
            foreach ($payments as $payment_id => $payment) {
            	if ($payment['payment_type'] != 'User Point') {

            		$payment_type_show=$payment['payment_type'];
            		if($payment['payment_type']=="Purchase Discount"){
            			$payment_type_show="Sales Discount";
            		}elseif($payment['payment_type']=="Purchase Bonus"){
            			$payment_type_show="Special Sales Discount";
            		}

            		$payment_string_altert.=$payment_type_show.": ".to_currency($payment['payment_amount'])."<br />";

            	}else{
            		$payment_string_altert.="Redeem Point".": ".to_currency($cart_point_cost)."<br />";

            	}
            }
            if(trim($payment_string_altert)){
            	$payment_string_altert="PAYMENT DETAILS<br />".$payment_string_altert;
            }else{
            	$payment_string_altert="PAYMENT DETAILS<br />"."No Transaction. May be same price product return.<br />";
            }

            $payment_string_altert.="PAYMENT STATUS: ";

            if ($amount_due< 0) {
            	$payment_string_altert.="[Refunds: ".to_currency(abs($amount_due))."]";
            } elseif ($amount_due==0) {
            	$payment_string_altert.="[FULL PAID]";
            }else{
            	$payment_string_altert.="[Due: ".to_currency(abs($amount_due))."]";
            }
            ?>
        </div>
        
        <input type="hidden" id="totalSaleAlert" name="totalSaleAlert" value="<?php echo "Total New Qty: ".($included_vat_sub_total_qty+$exclued_vat_sub_total_qty)."<br />Total Return Qty: ".(($included_vat_sub_total_qty_return+$exclued_vat_sub_total_qty_return)*-1)."<br />Total Invoice Amount: ".to_currency(round($exclued_vat_sub_total_vat_amount+$exclued_vat_sub_total_amount+$included_vat_sub_total_amount)-round($card_discount_total_with_vat_for_interface)-round($total_provide_discount)-round($cart_point_cost)-round($coupon_card_discout)); ?>">
        <input type="hidden" id="totalPaymentAlert" name="totalPaymentAlert" value="<?php echo $payment_string_altert; ?>">
        </form>
        </br>
        <?php
     }
    ?>
    <table width="100%" style="background-color: #93FFFA;box-shadow: 0px 8px 8px #000;">
        <tr>
            <td style="width:50%; padding-top: 4px;padding-left:6px;font-weight:bold;font-size: 16px;"><?php echo 'Payment Total:' ?></td>
            <td style="width:60%; text-align:right;padding-right:6px;font-weight:bold;font-size: 19px;"><?php echo to_currency($payments_total); ?></td>
        </tr>
       <!-- <?php if (!empty($cart_point)) { ?>
            <tr>
                <td style="width:50%; padding-top: 4px;padding-left:6px;font-weight:bold;font-size: 16px;"><?php echo 'Redeem Point:' ?></td>
                <td style="width:60%; text-align:right;padding-right:6px;font-weight:bold;font-size: 19px;"><?php echo "(".$cart_point. '*'.$cart_point_value."=" . to_currency($cart_point*$cart_point_value).")" ?></td>
            </tr>
        <?php } 
        ?>-->
        <tr>
            <?php if ($amount_due-intval($coupon_card_discout)< 0) { ?>
                <td style="width:50%; padding-top: 4px;padding-left:6px;font-weight:bold;font-size: 16px;"><?php echo 'Amount Return:' ?></td>
                <td style="width:50%; text-align:right;padding-right:6px;font-weight:bold;font-size: 19px;color:#6801FF;"><?php echo to_currency(abs($amount_due-intval($coupon_card_discout))); ?></td>
            <?php } elseif($amount_due + $previous_due-intval($coupon_card_discout) ==0) { ?>
                <td style="width:50%; padding-top: 4px;padding-left:6px;font-weight:bold;font-size: 16px;"><?php echo 'Amount Due:' ?></td>
                <td style="width:60%; text-align:right;padding-right:6px;font-weight:bold;font-size: 19px;color:#6801FF;">FULL PAID</td>
            <?php } else { ?>
                <td style="width:50%; padding-top: 4px;padding-left:6px;font-weight:bold;font-size: 16px;"><?php echo 'Amount Due:' ?></td>
                <td style="width:60%; text-align:right;padding-right:6px;font-weight:bold;font-size: 19px;color:#FF0000;"><?php echo to_currency(abs($amount_due-intval($coupon_card_discout))); ?></td>
            <?php } ?>
        </tr>
    </table>

    <div id="Payment_Types" >

        <div style="height:auto;">

            <?php echo form_open("sales/add_payment", array('id' => 'add_payment_form')); 
            echo form_hidden('facebook_customer', $facebook_customer);
            echo form_hidden('mobile_no', $customer_gs_card);
            echo form_hidden('facebook_customer_id', $customer_gs_id);
            echo form_hidden('facebook_customer_otp_correct', $facebook_customer_otp_correct);
            echo form_hidden('facebook_otp', $facebook_otp);
            echo form_hidden('coupon_card_discout', $coupon_card_discout);
            echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
            echo form_hidden('coupon_card_number', $coupon_card_number);


            $amount_due=$amount_due-$coupon_card_discout;
            ?>
            <table width="100%">
                <tr>
                    <td style="padding-bottom: 5px;padding-top: 5px;background-color:#7FEDFE;padding-left: 6px;font-weight:bold; vertical-align: middle;">
                        <?php echo $this->lang->line('sales_payment') . ':   '; ?>
                    </td>
                    <td style="padding-bottom: 5px;padding-top: 5px;background-color:#7FEDFE;">
                        <?php echo form_dropdown('payment_type', $payment_options, array(), 'id="payment_types" style="border: 1px solid #FF0000;padding:4px;"'); ?>
                    </td>
                </tr>
                <tr id="hide-row">
                    <td style="padding-bottom: 5px;padding-top: 5px;background-color:#D2FFD5;padding-left: 6px;font-weight:bold;">
                        <?php echo $this->lang->line('sales_amount_tendered') . ': '; ?></span>
                    </td>
                    <td style="padding-bottom: 5px;padding-top: 5px;background-color:#D2FFD5;">
                        <?php 
                        echo form_input(array('name' => 'amount_tendered', 'id' => 'amount_tendered', 'value' => to_currency_no_money($amount_due + $previous_due), 'size' => '22')); ?>
                    </td>
                </tr>
            </table>
            <?php
            // add div which depend(Change or Hide) on dropdown value
            //-------------------------------------start----------------------
            ?>

            
            <div id="cod" style="display: none">
                <table width="100%">

                    <tr>
                        <td><?php echo 'Trans. ID' . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'transaction_payment_id_cod', 'id' => 'transaction_payment_id_cod', 'value' => '', 'size' => '10')); ?></td>
                    </tr>
                </table>

            </div> 
            <div id="ssl" style="display: none">
                <table width="100%">

                    <tr>
                        <td><?php echo 'Trans. ID' . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'transaction_payment_id_ssl', 'id' => 'transaction_payment_id_ssl', 'value' => '', 'size' => '10')); ?></td>
                    </tr>
                </table>

            </div>  
            <div id="bkash" style="display: none">
                <table width="100%">

                   <!-- <tr>
                        <td style="color:#FF0000;"><?php //echo 'BKash Discount (10%)' . ': '; ?></td>
                        <td><?php //echo form_input(array('name' => 'bkash_discount', 'id' => 'bkash_discount', 'value' => '', 'size' => '10','readonly'=>'true')); ?></td>
                    </tr>--> 
                    <tr>
                        <td><?php echo 'Phone No' . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'transaction_phone_no_bkash', 'id' => 'transaction_phone_no_bkash', 'value' => '', 'size' => '21')); ?></td>
                    </tr> 
                    <tr>
                        <td><?php echo 'Trans. ID' . ':&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; ?></td>
                        <td><?php echo form_input(array('name' => 'transaction_payment_id_bkash', 'id' => 'transaction_payment_id_bkash', 'value' => '', 'size' => '21')); ?></td>
                    </tr>
                </table>

            </div> 

            <div id="check" style="display: none">
                <table width="100%">

                    <tr>
                        <td><?php echo $this->lang->line('check_no') . ': '; ?></td>

                        <td><?php echo form_input(array('name' => 'check_name', 'id' => 'check_name', 'value' => '', 'size' => '20')); ?></td>
                    </tr>
                    <tr>
                        <td> <?php echo '<label>' . $this->lang->line('ac_no') . ': ' . '</label>'; ?></td>

                        <td> <?php echo form_input(array('name' => 'ac_no_check', 'id' => 'ac_no_check', 'value' => '', 'size' => '20')); ?></td>
                    </tr>
                    <tr>
                        <td>  <?php echo $this->lang->line('holder_name') . ': '; ?></td>

                        <td>  <?php echo form_input(array('name' => 'holder_name_check', 'id' => 'holder_name_check', 'value' => '', 'size' => '20')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('bank_name') . ':'; ?></td>
                        <td> <?php echo form_dropdown('bank_name_check', $bank_id, array(), 'id="bank_name_check"'); ?></td>
                    </tr>
                    <tr>
                        <td> <?php echo $this->lang->line('branch_name') . ': '; ?></td>
                        <td>                <?php echo form_input(array('name' => 'branch_name_check', 'id' => 'branch_name_check', 'value' => '', 'size' => '20')); ?>
                        </td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('check_date') . ': '; ?> </td>
                        <td><?php echo form_input(array('name' => 'check_date', 'id' => 'check_date', 'value' => '', 'size' => '20')); ?>
                        </td>
                    </tr>
                </table>

            </div>

            <div id="debit" style="display: none">
                <table>
                    <tr>
                        <td><?php echo $this->lang->line('bank_name') . ':'; ?></td>
                        <td><?php echo form_dropdown('bank_name_debit_shawpon', $bank_name_shawpon, array(), 'id="bank_name_debit_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('card_no') . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'card_no_debit_shawpon', 'id' => 'card_no_debit_shawpon', 'value' => $_POST['card_no_debit_shawpon'], 'size' => '21')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('holder_name') . ':&nbsp;'; ?></td>
                        <td><?php echo form_input(array('name' => 'holder_name_debit_shawpon', 'id' => 'holder_name_debit_shawpon', 'value' => $_POST['holder_name_debit_shawpon'], 'size' => '21')); ?></td>
                    </tr>
                </table>

            </div>
			<div id="okwall" style="display: none">
                <table>
                    <tr>
                        <td>Transaction No:</td>
                        <td> <?php echo form_input(array('name' => 'ac_no_check', 'id' => 'ac_no_check', 'value' => '', 'size' => '20')); ?></td>
                    </tr>
                </table>

            </div>

            <div id="credit" style="display: none">
                <table>
                    <tr>
                        <td><?php echo $this->lang->line('bank_name') . ':'; ?></td>
                        <td><?php echo form_dropdown('bank_name_credit_shawpon', $bank_name_shawpon, array(), 'id="bank_name_credit_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('card_no') . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'card_no_credit_shawpon', 'id' => 'card_no_credit_shawpon', 'value' => $_POST['card_no_credit_shawpon'], 'size' => '21')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('holder_name') . ':&nbsp;'; ?></td>
                        <td><?php echo form_input(array('name' => 'holder_name_credit_shawpon', 'id' => 'holder_name_credit_shawpon', 'value' => $_POST['holder_name_credit_shawpon'], 'size' => '21')); ?></td>
                    </tr>

                    <tr>
                        <td><?php echo $this->lang->line('card_expire_month') . ':'; ?></td>
                        <td><?php echo form_dropdown('card_expire_month_shawpon', $month, array(), 'id="card_expire_month_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('card_expire_year') . ':'; ?></td>
                         <td><?php echo form_dropdown('card_expire_year_shawpon', $year, array(), 'id="card_expire_year_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                    </tr>

                </table>

            </div>
			<div id="amexcard" style="display: none">
                <table>
                    <tr>
                        <td><?php echo $this->lang->line('bank_name') . ':'; ?></td>
                         <td><?php echo form_input(array('name' => 'bank_name_amex_shawpon', 'id' => 'bank_name_amex_shawpon', 'value' => 'The City Bank Ltd', 'size' => '21')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('card_no') . ': '; ?></td>
                        <td><?php echo form_input(array('name' => 'card_no_amex_shawpon', 'id' => 'card_no_amex_shawpon', 'value' => $_POST['card_no_amex_shawpon'], 'size' => '21')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('holder_name') . ':&nbsp;'; ?></td>
                        <td><?php echo form_input(array('name' => 'holder_name_amex_shawpon', 'id' => 'holder_name_amex_shawpon', 'value' => $_POST['holder_name_amex_shawpon'], 'size' => '21')); ?></td>
                    </tr>

                    <tr>
                        <td><?php echo $this->lang->line('card_expire_month') . ':'; ?></td>
                        <td><?php echo form_dropdown('amex_expire_month_shawpon', $month, array(), 'id="amex_expire_month_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                        
                        
                    </tr>
                    <tr>
                        <td><?php echo $this->lang->line('card_expire_year') . ':'; ?></td>
                        <td><?php echo form_dropdown('amex_expire_year_shawpon', $year, array(), 'id="amex_expire_year_shawpon" style="border: 1px solid #FF0000;padding:4px;width: 157px;"'); ?></td>
                    </tr>

                </table>

            </div>
            <div id="points" style="display: none">
                <table>
                    <tr>
                        <td>
                            <?php echo 'Redeem User Point: '; ?></span>
                        </td>
                        <td>
                            <?php echo form_input(array('name' => 'user_point', 'id' => 'user_point', 'value' => '', 'size' => '10')); ?>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="due" style="display: none">
               
            </div>

            <?php
            if(($amount_due + $previous_due)>0){

            ?>
            <div class='button_new' id='add_payment_button' style='float:left;margin-top:5px;'>
                <span><?php echo $this->lang->line('sales_add_payment'); ?></span>
            </div>
<?php }?>
        </div>
        </form>
    </div>
    <div>&nbsp;</div>
    <?php
    // Only show this part if there is at least one payment entered.
    if (count($payments) > 0 || !empty($cart_point)) {
        ?>
        <table id="register">
            <thead>
                <tr>
                    <th style="width:11%;"><?php echo $this->lang->line('common_delete'); ?></th>
                    <th style="width:60%;"><?php echo 'Type'; ?></th>
                    <th style="width:18%;"><?php echo 'Amount'; ?></th>


                </tr>
            </thead>
            <tbody id="payment_contents">
                <?php
                $color_loop=1;
                foreach ($payments as $payment_id => $payment) {
                	if ($payment['payment_type'] != 'User Point') {

                		$payment_type_show=$payment['payment_type'];
                		if($payment['payment_type']=="Purchase Discount"){
                			$payment_type_show="Sales Discount";
                		}elseif($payment['payment_type']=="Purchase Bonus"){
                			$payment_type_show="Special Sales Discount";
                		}
                		$send_str="";
                		if($facebook_customer_otp_correct==1){
                			$send_str="C4CA4238A0B923820DCC509A6F75849B";
                		}elseif($facebook_customer_otp_correct==0){
                			$send_str="CFCD208495D565EF66E7DFF9F98764DA";
                		}
                		if($color_loop%2){
                			$color_loop_style='background-color: #B8FFF2;';
                		}else{
                			$color_loop_style='background-color: #93ebff;';
                		}
                		$color_loop++;
                        ?>
                        <tr>
                            <td style="padding:8px;<?php echo $color_loop_style;?>" ><?php echo anchor("sales/delete_payment/$payment_id/$send_str/".intval($coupon_card_discout)."/".intval($coupon_card_maximum_discout)."/".$coupon_card_number, '<b style="font-weight:bold;background-color:#940909;color:#FFFFFF;padding:3px;border: 1px solid #FF0000;">'. $this->lang->line('common_delete') . '</b>'); ?></td>
                            <td style="padding:8px;<?php echo $color_loop_style;?>" ><?php echo $payment_type_show; ?></td>
                            <td style="padding:8px; text-align:right;<?php echo $color_loop_style;?>" ><?php echo to_currency($payment['payment_amount']); ?></td>
                        </tr>
                        <?php 
                        echo form_hidden('coupon_card_discout', $coupon_card_discout);
                        echo form_hidden('coupon_card_maximum_discout', $coupon_card_maximum_discout);
                        echo form_hidden('coupon_card_number', $coupon_card_number);
                        ?>
                        </form>
                        <?php
                	}
                }
                ?>
                <?php
                if($color_loop%2){
                	$color_loop_style='background-color: #B8FFF2;';
                }else{
                	$color_loop_style='background-color: #93ebff;';
                }
                if (!empty($cart_point)) {
                    ?>
                    <tr>
                        <td style="padding:8px;<?php echo $color_loop_style;?>" ><?php echo anchor("sales/delete_point", '<b style="font-weight:bold;background-color:#940909;color:#FFFFFF;padding:3px;border: 1px solid #FF0000;">'. $this->lang->line('common_delete') . '</b>'); ?></td>
                        <td style="padding:8px;<?php echo $color_loop_style;?>" >Redeem Point (<?php echo $cart_point ?>)</td>
                        <td style="padding:8px; text-align:right;<?php echo $color_loop_style;?>" ><?php echo '-' . to_currency($cart_point_cost); ?></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
        <br />
        <?php
    }
}
?>
</div>
<div class="clearfix" style="margin-bottom:30px;">&nbsp;</div>


<?php $this->load->view("partial/footer"); ?>

<script type="text/javascript" language="javascript">


function doConfirm() {

	var total_sale = $("#totalSaleAlert").val();
	var total_payment = $("#totalPaymentAlert").val();

	Dialog.confirm('<?php echo $this->lang->line("sales_confirm_finish_sale"); ?>', 'Sales Confirmation', (dlg) => {
		$('#finish_sale_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	},total_sale+"<br />"+total_payment+"");
}
function doConfirmSuspend() {
	Dialog.confirm('<?php echo $this->lang->line("sales_confirm_suspend_sale"); ?>', 'Sales Suspend', (dlg) => {
		$('#finish_sale_form').attr('action', '<?php echo site_url("sales/suspend"); ?>');
		$('#finish_sale_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	});
}
function doConfirmCancel() {
	Dialog.confirm('<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>', 'Sales Cancel', (dlg) => {
		$('#cancel_sale_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	});
}
function doConfirmNewCard() {
	Dialog.confirm('<?php echo "Are you sure you want to add this card? This cannot be undone."; ?>', 'New Card Confimation', (dlg) => {
		$('#select_new_card_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	});
}
function doConfirmNewCoupon() {
	Dialog.confirm('<?php echo "Are you sure you want to add this gift card? This cannot be undone."; ?>', 'Add Gift Card Confimation', (dlg) => {
		$('#select_add_coupon_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	});
}
function doConfirmNewOtp() {
	Dialog.confirm('<?php echo "Are you sure about OTP?"; ?>', 'OTP Confimation', (dlg) => {
		$('#select_new_otp_form').submit();
		dlg.close();
	}, (dlg) => {
		dlg.close();
	});
}

$(document).ready(function ()
{
	$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	$("#find").blur(function () {
		var find_val = $(this).val();

		$("#button_find").attr('href', '<?php echo base_url(); ?>index.php/sales/globalsearch/' + find_val + '/width:480');
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$("#recept_id").blur(function () {
		var find_val = $(this).val();

		$("#button_find").attr('href', '<?php echo base_url(); ?>index.php/sales/global_delivery/' + find_val + '/width:480');
		$(this).attr('placeholder', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$('#item').bind('keyup', function() {

		var itemLength = $("#item").val().length;
		if(itemLength==14){
			if($("#item").val().match(/^\d+$/)) {
				$('#add_item_form').submit();

			}
		}
	});

	$("#item").autocomplete('<?php echo site_url("sales/item_search"); ?>',
	{
		minChars: 0,
		max: 100,
		selectFirst: false,
		delay: 10,
		formatItem: function (row) {
			//return row[1];
			return (row.length > 1 && row[1]) || row[0];
		}
	});


	$("#item").result(function (event, data, formatted)
	{
		$("#add_item_form").submit();
	});
	//
	//        var modechange = $("#change").val();
	//     $("#mode_form").change(function() {
	//
	//            var mode = $("#change").val();
	//
	//              alert(modechange);
	//                    $.ajax({
	//                            type: "POST",
	//                            url: '<?php echo site_url("sales/change_mode"); ?>',
	//                            data: { change: modechange },
	//                            success:function(data){
	//                                alert(data);
	//                            }
	//
	//                            });
	//
	//
	//                });
	//





	$('#item').focus();
	$('#find').focus();
	$('#recept_id').focus();

	$('#item').blur(function ()
	{
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$("#find").autocomplete('<?php echo site_url("sales/item_search"); ?>',
	{
		minChars: 0,
		max: 100,
		selectFirst: false,
		delay: 10,
		formatItem: function (row) {
			return row[1];
		}
	});

	$('#check_date').datePicker();


	$('#item,#customer,#find,#recept_id').click(function ()
	{
		$(this).attr('value', '');

	});

	$("#customer").autocomplete('<?php echo site_url("sales/customer_search"); ?>',
	{
		minChars: 0,
		delay: 10,
		max: 100,
		formatItem: function (row) {
			return row[1];
		}
	});

	$("#customer").result(function (event, data, formatted)
	{
		$("#select_customer_form").submit();
	});

	$('#customer').blur(function ()
	{
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>");
	});

	$('#comment').change(function ()
	{
		$.post('<?php echo site_url("sales/set_comment"); ?>', {comment: $('#comment').val()});
	});

	$('#receive_location').change(function ()
	{
		$.post('<?php echo site_url("sales/set_receive_location"); ?>', {receive_location: $('#receive_location').val()});
	});

	$('#email_receipt').change(function ()
	{
		$.post('<?php echo site_url("sales/set_email_receipt"); ?>', {email_receipt: $('#email_receipt').is(':checked') ? '1' : '0'});
	});


	$("#finish_sale_button").click(function ()
	{

		doConfirm();
		/*
		if (confirm('<?php echo $this->lang->line("sales_confirm_finish_sale"); ?>'))
		{
		$('#finish_sale_form').submit();
		}*/
	});
	$("#add_new_card_button").click(function ()
	{
		doConfirmNewCard();
		/*if (confirm('<?php echo "Are you sure you want to add this card? This cannot be undone."; ?>'))
		{
		$('#select_new_card_form').submit();
		}*/
	});
	$("#add_coupon_button").click(function ()
	{
		doConfirmNewCoupon();
		/*if (confirm('<?php echo "Are you sure you want to add this card? This cannot be undone."; ?>'))
		{
		$('#select_new_card_form').submit();
		}*/
	});
	$("#add_check_otp_button").click(function ()
	{

		doConfirmNewOtp();
		/*if (confirm('<?php echo "Are you sure you about OTP?"; ?>'))
		{
		$('#select_new_otp_form').submit();
		}*/
	});

	$("#suspend_sale_button").click(function ()
	{
		doConfirmSuspend();
		/*
		if (confirm('<?php echo $this->lang->line("sales_confirm_suspend_sale"); ?>'))
		{
		$('#finish_sale_form').attr('action', '<?php echo site_url("sales/suspend"); ?>');
		$('#finish_sale_form').submit();
		}*/
	});


	$("#cancel_sale_button").click(function ()
	{
		doConfirmCancel();
		/*if (confirm('<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>'))
		{
		$('#cancel_sale_form').submit();
		}*/
	});

	$("#edit_item_shawpon_button").click(function ()
	{
		$('#edit_item_shawpon_form').submit();
	});

	$("#add_payment_button").click(function ()
	{
		$('#add_payment_form').submit();
	});



	$("#payment_types").change(checkPaymentTypeGiftcard).ready(checkPaymentTypeGiftcard)
});

function post_item_form_submit(response)
{
	if (response.success)
	{
		$("#item").attr("value", response.item_id);
		$("#add_item_form").submit();
	}
}

function post_person_form_submit(response)
{
	if (response.success)
	{
		$("#customer").attr("value", response.person_id);
		$("#select_customer_form").submit();
	}
}
function checkPaymentTypeGiftcard()
{
	if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_giftcard'); ?>")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_giftcard_number'); ?>");
		$("#amount_tendered").val('');
		$("#amount_tendered").focus();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_cash'); ?>")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cash").show();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "Purchase Bonus")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cash").show();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "COD Pathao")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cod").show();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	}
	else if ($("#payment_types").val() == "SSL COMMERZ")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cod").hide();
		$("#ssl").show();
		$("#bkash").hide();
		$("#cash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	}

	else if ($("#payment_types").val() == "BKash" || $("#payment_types").val() == "BKash Apps")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").show();
		$("#cash").hide();
		$("#check").hide();
		$("#debit").hide();
		$("#amexcard").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	}


	else if ($("#payment_types").val() == "Due")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#cash").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#check").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").show();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_check'); ?>")
	{

		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#check").show();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#credit").hide();
		$("#gift").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_debit'); ?>")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#credit").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#gift").hide();
		$("#check").hide();
		$("#cash").hide();
		$("#amexcard").hide();
		$("#debit").show();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	} else if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_credit'); ?>")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#check").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#amexcard").hide();
		$("#debit").hide();
		$("#gift").hide();
		$("#credit").show();
		$("#points").hide();
		$("#due").hide();
		$('#hide-row').show();
		$('#okwall').hide();
		$('#amount_tendered').show();
	}else if ($("#payment_types").val() == "AMEX Card")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#check").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#debit").hide();
		$("#gift").hide();
		$("#credit").hide();
		$("#amexcard").show();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').hide();
		$('#hide-row').show();
		$('#amount_tendered').show();
	}
	else if ($("#payment_types").val() == "OkWallet")
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
		$("#amount_tendered").val('<?php echo to_currency_no_money($amount_due + $previous_due + $adjectment); ?>');
		$("#check").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#cash").hide();
		$("#debit").hide();
		$("#gift").hide();
		$("#credit").hide();
		$("#amexcard").hide();
		$("#points").hide();
		$("#due").hide();
		$('#okwall').show();
		$('#hide-row').show();
		$('#amount_tendered').show();
	}
	else if ($("#payment_types").val() == "User Point") {
		$('#hide-row').hide();
		$("#amount_tendered").val('');
		$("#amount_tendered").hide();
		$("#check").hide();
		$("#cod").hide();
		$("#ssl").hide();
		$("#bkash").hide();
		$("#amexcard").hide();
		$("#cash").hide();
		$("#debit").hide();
		$("#gift").hide();
		$("#credit").hide();
		$("#due").hide();
		$('#okwall').hide();
		$("#points").show();
	} else
	{
		$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
	}
}



//$("#add_payment_button").click(function(){
//
//       $.ajax({
//                    type: 'POST',
//                    data: $('#add_payment_form').serialize(),
//                    url: 'index.php/sales/add_payment',
//                    success: function (resp) {
//                        if (resp) {
//                           alert('hi');
//                        }
//
//                    }
//                });
//
//
//    });
//







</script>