<!doctype html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Due Invoce Email</title>
  <style type="text/css">
  body {
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   margin:0 !important;
   width: 100% !important;
   -webkit-text-size-adjust: 100% !important;
   -ms-text-size-adjust: 100% !important;
   -webkit-font-smoothing: antialiased !important;
 }
 .tableContent img {
   border: 0 !important;
   display: block !important;
   outline: none !important;
 }
 a{
  color:#382F2E;
}

p, h1,h2,ul,ol,li,div{
  margin:0;
  padding:0;
}

h1,h2{
  font-weight: normal;
  background:transparent !important;
  border:none !important;
}

@media only screen and (max-width:480px)
		
{
		
table[class="MainContainer"], td[class="cell"] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class="specbundle"] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:15px !important;
	}	
td[class="specbundle2"] 
	{
		width:80% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:10px !important;
		padding-left:10% !important;
		padding-right:10% !important;
	}
		
td[class="spechide"] 
	{
		display:none !important;
	}
	    img[class="banner"] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class="left_pad"] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		 
}
	
@media only screen and (max-width:540px) 

{
		
table[class="MainContainer"], td[class="cell"] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class="specbundle"] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:15px !important;
	}	
td[class="specbundle2"] 
	{
		width:80% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:10px !important;
		padding-left:10% !important;
		padding-right:10% !important;
	}
		
td[class="spechide"] 
	{
		display:none !important;
	}
	    img[class="banner"] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class="left_pad"] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		
}

.contentEditable h2.big,.contentEditable h1.big{
  font-size: 26px !important;
}

 .contentEditable h2.bigger,.contentEditable h1.bigger{
  font-size: 37px !important;
}

td,table{
  vertical-align: top;
}
td.middle{
  vertical-align: middle;
}

a.link1{
  font-size:13px;
  color:#27A1E5;
  line-height: 24px;
  text-decoration:none;
}
a{
  text-decoration: none;
}

.link2{
color:#ffffff;
border-top:5px solid #27A1E5;
border-bottom:5px solid #27A1E5;
border-left:18px solid #27A1E5;
border-right:18px solid #27A1E5;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}

.link3{
color:#ffffff;
border:1px solid #cccccc;
padding:15px 50px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
background:#27a1e5;
font-size:18px;
}

.link4{
color:#27A1E5;
line-height: 24px;
}

h2,h1{
line-height: 20px;
}
p{
  font-size: 14px;
  line-height: 21px;
  /*color:#AAAAAA;*/
}

.contentEditable li{
 
}

.appart p{
 
}
.bgItem{
background: #ffffff;
}
.bgBody{
background: #3B5998;
}

img { 
  outline:none; 
  text-decoration:none; 
  -ms-interpolation-mode: bicubic;
  width: auto;
  max-width: 100%; 
  clear: both; 
  display: block;
  float: none;
}

</style>


</head>
<body paddingwidth="0" paddingheight="0" style="padding-top: 0; padding-bottom: 0; padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;" offset="0" toppadding="0" leftpadding="0">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#3B5998">
  <tbody>
      <tr>
	  <td height="15"></td>
	  </tr>
    <tr> <!-- tr1 Start -->
      <td>
		<table width="700" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff" style="font-family:helvetica, sans-serif;" class="MainContainer">
			<!-- =============== START HEADER =============== -->
		  <tbody>
			<tr>
			  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tbody>
			<tr>
			  <td valign="top" width="20">&nbsp;</td>
			  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tbody>
			<tr>
			  <td class="movableContentContainer">
			  <div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
			  <table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tbody>
					<tr>
					  <td height="5"></td>
					</tr>
					<tr>
					  <td>
					  <table width="100%" border="0" cellspacing="0" cellpadding="0">
						  <tbody>
							<tr>
							  <td valign="top">
								
							  </td>
							  <td valign="top" width="90" class="spechide">&nbsp;</td>
							  <td valign="middle" style='vertical-align: middle;' width='150'>
								  <img src="{{ asset('public/backend/dist/img/infolink_logo.jpg') }}" alt="Logo" title="Logo" data-max-width="100">
								</td>
							</tr>
						  </tbody>
						</table>
					</td>
					</tr>
					
					<tr>
					   <td><hr style='height:1px;background:#82BEFA;border:none;'></td>
					</tr>
				  </tbody>
				</table>
			  </div>
			  <!-- =============== END HEADER =============== -->
			  
			<!-- =============== START BODY =============== -->
			  
			  <div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
			  <table width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tbody>
				<tr>
				  <td>
				      <div class='contentEditableContainer contentTextEditable'>
                            <div class='contentEditable'>
					<?php
					$settings = DB::table('company_settings')->select('base_url')->first();
					if($settings){
					    $base_url = $settings->base_url;
					}else{
					    $base_url = "";
					}
					
            		$client_info = DB::table('client')->where('client_id',$client_id)->first();
            		
            		$invoice_data = DB::table('invoice')->where('invoice_id',$invoice_id)->first();
            		$item_list = DB::table('invoice_details')->where('invoice_id',$invoice_id)->get();
            		
                    $amount = 0;
            		$vat = 0;
            		$v = 0;
            		foreach($item_list as $invoice_info)
            		{
            			$amount += (float)$invoice_info->price * (float)$invoice_info->quantity;
            			$vat += ((float)$invoice_info->quantity * (float)$invoice_info->price * (float)$invoice_info->vat*.01);
            			$v += (float)$invoice_info->vat;
            		}
            		$total_vat = $vat;
            		$total_amount = $amount-$invoice_data->discount;
            		if($invoice_data->vat_status==1)
            		{
            			$t_amount = $total_vat + $total_amount;
            		}else{
            			$t_amount = $total_amount;
            		}
                    
                    $paid_amounts = 0;
                    $result = DB::table('payment')->where('invoice_id',$invoice_id)->get();
            		if($result){
            		    foreach($result as $rows)
                		{
                			if($rows->status==1){
                				$paid_amounts += $rows->amount;
                			}else{
                				$paid_amounts += 0;
                			}
                		}
            		}
            		$total_due = ($t_amount - $paid_amounts);
            		
            		if($invoice_data->status == 0 OR $invoice_data->status == 2 OR $invoice_data->status == 3){
						$invoice_link 	= '<center><a href="https://db.infolinkbd.com/index.php/invoice/mpdf/'.base64_encode($client_id).'/'.base64_encode($invoice_id).'" class="link3">Download Invoice</a></center>';
					}else{
						/*$invoice_link 	= '<center>
					                    <a href="https://care.infolinkbd.com/index.php/paynow/process/'.base64_encode($invoice_id).'" class="link3">Pay Now (Online)</a>
					                    <br/>
					                    <a href="https://care.infolinkbd.com/index.php/index.php/invoice/mpdf/'.base64_encode($client_id).'/'.base64_encode($invoice_id).'" class="link3">Download Invoice</a>
					                    </center>';*/
					   $invoice_link 	= '<center>
					                    <a href="http://infolinkbd.com/" class="link3">Pay Now (Online)</a>
					                    <br/>
					                    <a href="https://db.infolinkbd.com/index.php/index.php/invoice/mpdf/'.base64_encode($client_id).'/'.base64_encode($invoice_id).'" class="link3">Download Invoice</a>
					                    </center>';
					}
            		//$invoice_link 	= base_url().'index.php/invoice/mpdf/'.base64_encode($client_id).'/'.base64_encode($invoice_id);
            		
            		$due_date_time 	= time() + (10 * 24 * 60 * 60);
            		
            		$notification = DB::table('notification')->where('id',4)->first();
            		
            		$m = str_replace('[[contact_person]]',$client_info->contact_person,$notification->message);
            		
            		$m1 = str_replace('[[bill_period]]',$invoice_data->bill_period,$m);
            		
            		$m2 = str_replace('[[invoice_link]]',$invoice_link,$m1);
            		
            		$m3 = str_replace('[[total_due]]',"BDT ".number_format($total_due)." /-",$m2);
            		
            		$m4 = str_replace('[[due_date_time]]',date('d-m-Y',$due_date_time),$m3);
            		
					echo $m4;
				 	//die();
					?>
					</div>
					</div>
				  </td>
				</tr>
				<!-- <tr><td height='5' colspan="3"></td></tr>
				<tr><td colspan="3"><hr style='height:1px;background:#82BEFA;border:none;'></td></tr> -->
			  </tbody>
			</table>
			  </div>
			  
			  <!-- =============== END BODY =============== -->
		<!-- =============== START FOOTER =============== -->
			  
			  </td>
			</tr>
		  </tbody>
		</table>
		</td>
			  <td valign="top" width="20">&nbsp;</td>
			</tr>
		  </tbody>
		</table>
		</td>
			</tr>
		  </tbody>
		</table>
		</td>
    </tr> <!-- tr1 End -->
    <tr>
					  <td height="15"></td>
					</tr>
  </tbody>
</table>

  </body>
  </html>


