<?php
/*
 * BLUEBERRY HTML INVOICE THEME
 * Visit https://code-boxx.com/invoicr-php-invoice-generator for more
 */

// HTML HEADER & STYLES
$this->data = "<!DOCTYPE html><html><head><style>".
"html,body{font-family:sans-serif}#invoice{max-width:800px;margin:0 auto}#company,#billship{margin-bottom:30px}#billship{border:1px solid #9a9a9a}#billship td{border:1px solid #9a9a9a;border-bottom:none;} #billship td{border-bottom:1px solid #9a9a9a}.billship-head{border-bottom:1px solid #9a9a9a}#billship,#company,#items{width:100%;border-collapse:collapse}#company td,#billship td,#items td,#items th{padding:10px}#company td{vertical-align:top}#bigi{margin-bottom:20px;font-size:28px;font-weight:700;color:#296103}#co-addr{font-size:.95em;color:#477f21}#co-right img{max-width:180px;height:auto}#billship td{width:33%}#items th{text-align:left;background:#d8f5c4;padding:20px 10px}#items td{background:#fbfbfb;border-bottom:1px solid #c8d2d7}.idesc{color:#80592d}#items tr.ttl td{color:#ffffff;background:#9e866b;border-bottom:none;font-weight:700}.right{text-align:right}#notes{background:#d8f5c4;padding:10px;margin-top:30px}#act-image{margin: 0 auto;max-height:180px;}#items tr{height:auto;}#act-image img{max-width:180px;height:auto}.sign-img{float:right;margin-top:15px;margin-bottom:130px}.invoice-mess{font-weight:bolder;margin-bottom:1px}.invoice-mess-div{}.comp-name{font-size:17px!important}.comp-add{font-size:13px!important}.border-dark{border-bottom:1px solid #c8d2d7}.image-item{height:120px; width:120px;display:block;float:left; margin-left:70px;margin-top:15px;}.image-item-s{height:120px; width:120px;display:block;float:left; margin-left:10px;margin-top:15px;}"."</style></head><body><div id='invoice'>";

// COMPANY LOGO + INFORMATION
$this->data .= "<table id='company'><tr><td id='co-left'><div id='bigi'>ESTIMATE</div><div id='co-addr'>";
for ($i=2;$i<count($this->company);$i++) {
	$this->data .= $this->company[$i]."<br>";
}
$this->data .= "</div></td><td id='co-right' class='right'><img src='".$this->company[0]."'/></td></table>";

// BILL TO
$this->data .= "<table id='billship'><tr><td><strong>CLIENT INFORMATION:</strong><hr>";
foreach ($this->billto as $b) { $this->data .= $b."<br>"; }

// SHIP TO
$this->data .= "<br></td><td  style = 'border-bottom: #9a9a9a'><strong>SERVICE ADDRESS:</strong><hr>";
foreach ($this->shipto as $s) { $this->data .= $s."<br>"; }

// INVOICE INFO

$this->data .= "<br></td><td  style = 'border-bottom: #9a9a9a'><strong>ESTIMATE DETAILS:</strong><hr>";
foreach ($this->invoice as $i) {
	$this->data .= "<strong>$i[0]:</strong> $i[1]<br>";
} 
$this->data .= "</td></tr></table>";


// ITEMS
$this->data .= "<table id='items'><tr><th>ITEM</th><th>DESCRIPTION</th><th>QUANTITY</th><th>UNIT PRICE</th><th>AMOUNT</th></tr>";

foreach ($this->items as $i) {
	$this->data .= "<tr><td style = 'border-bottom: #e4eff5'><div><b>".$i[0]."</b></div></td>";
	
	$this->data .= "<td  style = 'text-align:justify;border-bottom: #e4eff5;padding:0px; margin:0px'>".($i[1]==""?"":"<small class='idesc'>$i[1]<br></small>")."</td>";
	
	if($i[9]== 0 || $i[9]== 1 || $i[9]== 5 || $i[9]== 6 || $i[9]== 7 || $i[9]== 8){
		$item_quant = $i[2];
	}else{
		$item_quant = "";
	}
	
	if($i[9]== 2){
		$item_quant1 = "<b>".$i[18].":</b> ".$i[20]."<br><br><b>".$i[19].": </b>".$i[21];
	}elseif($i[9]== 4){
		$item_quant1 = "<b>".$i[10].": </b>".$i[14]."<br><br><b>".$i[11].": </b>".$i[15]."<br><br><b>".$i[12].": </b>".$i[16]."<br><br><b>".$i[13].": </b>".$i[17];
	}else{
		$item_quant1 = "";
	}

	$this->data .= "<td style = 'border-bottom: #e4eff5'>".$item_quant."</td>";


	if($i[9]== 0){
		$item_amount =$i[3];
	}elseif($i[9]== 2 || $i[9]== 1 || $i[9]== 5 || $i[9]== 6 || $i[9]== 7 || $i[9]== 8){		
		$item_amount =$i[3];		
	}else{
		$item_amount = '';
	}
	$this->data .= "<td style = 'border-bottom: #e4eff5'>".$item_amount."</td>";
	
	$this->data .= "<td style = 'border-bottom: #e4eff5'>".$i[4]."</td></tr>";



if(strlen($item_quant1)>0){
	 $this->data .= "<tr>
	<td style = 'border-bottom: #e4eff5;padding:0px; margin:0px'></td><td style = 'border-bottom: #e4eff5;padding:0px; margin:0px'><span style='font-size:.75em;'>$item_quant1</span></td><td style = 'border-bottom: #e4eff5;padding:0px; margin:0px'></td><td style = 'border-bottom: #e4eff5;padding:0px; margin:0px'></td><td style = 'border-bottom: #e4eff5;padding:0px; margin:0px'></td></tr>";

}


if($i[22] == 'set'){
	$this->data .= "<tr>
	<td style = '".($i[23] == 'set'?'border-bottom: #e4eff5;':'')."' class='zero-padding-margin".($i[23] == 'set'?'':'')."'><b>".$i[24]. "</b></td><td style='".($i[23] == 'set'?'border-bottom: #e4eff5;':'')."padding:0px; margin:0px' class='zero-padding-margin".($i[23] == 'set'?'':'')."'><small class='idesc'>". $i[25] ."</small></td><td style = '".($i[23] == 'set'?'border-bottom: #e4eff5;':'')."' class='zero-padding-margin".($i[23] == 'set'?'':'')."'></td><td style = '".($i[23] == 'set'?'border-bottom: #e4eff5;':'')."' class='zero-padding-margin".($i[23] == 'set'?'':'')."'>". $i[26]. "</td><td style = '".($i[23] == 'set'?'border-bottom: #e4eff5;':'')."' class='zero-padding-margin".($i[23] == 'set'?'':'')."'></td>
	
	</tr>";

}

if($i[23] == 'set'){
	$this->data .= "<tr>
	<td class='zero-padding-margin' style = 'border-bottom: #e4eff5;'><b>".$i[27]. "</b></td><td style='padding:0px; margin:0px;border-bottom: #e4eff5;' class='zero-padding-margin'><small class='idesc'>". $i[28] ."</small></td><td class='zero-padding-margin' style = 'border-bottom: #e4eff5;'></td><td class='zero-padding-margin' style = 'border-bottom: #e4eff5;'>". $i[29]. "</td><td class='zero-padding-margin'  style = 'border-bottom: #e4eff5;'></td>
	
	</tr>";
	
}
	if(strlen($i[32]) > 0){
		$this->data .= "<tr style = ''><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[32]==""?"":"<img src='$i[32]' class='image-item' style='' />").($i[33]==""?"":"<img src='$i[33]' class='image-item-s' />").($i[34]==""?"":"<img src='$i[34]'  class='image-item-s'/>").($i[35]==""?"":"<img src='$i[35]' class='image-item-s'/>").($i[36]==""?"":"<img src='$i[36]' class='image-item-s'/>")."</td></tr>";
	}
	
	if(strlen($i[37]) > 0){
		$this->data .= "<tr><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[37]==""?"":"<img src='$i[37]'  class='image-item' />").($i[38]==""?"":"<img src='$i[38]' class='image-item-s'/>").($i[39]==""?"":"<img src='$i[39]'  class='image-item-s'/>").($i[40]==""?"":"<img src='$i[40]'  class='image-item-s'/>").($i[41]==""?"":"<img src='$i[41]'  class='image-item-s'/>")."</td></tr>";
	}	

	if(strlen($i[42]) > 0){
		$this->data .= "<tr><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[42]==""?"":"<img src='$i[42]' class='image-item' />").($i[43]==""?"":"<img src='$i[43]' class='image-item-s'/>").($i[44]==""?"":"<img src='$i[44]' class='image-item-s'/>").($i[45]==""?"":"<img src='$i[45]' class='image-item-s'/>").($i[46]==""?"":"<img src='$i[46]' class='image-item-s'/>")."</td></tr>";
	}	

	if(strlen($i[47]) > 0){
		$this->data .= "<tr><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[47]==""?"":"<img src='$i[47]' class='image-item' />").($i[48]==""?"":"<img src='$i[48]' class='image-item-s'/>").($i[49]==""?"":"<img src='$i[49]' class='image-item-s'/>").($i[50]==""?"":"<img src='$i[50]' class='image-item-s'/>").($i[51]==""?"":"<img src='$i[51]' class='image-item-s'/>")."</td></tr>";
	}	

	if(strlen($i[52]) > 0){
		$this->data .= "<tr><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[52]==""?"":"<img src='$i[52]' class='image-item' />").($i[53]==""?"":"<img src='$i[53]' class='image-item-s'/>").($i[54]==""?"":"<img src='$i[54]' class='image-item-s'/>").($i[55]==""?"":"<img src='$i[55]' class='image-item-s'/>").($i[56]==""?"":"<img src='$i[56]' class='image-item-s'/>")."</td></tr>";
	}	

	if(strlen($i[57]) > 0){
		$this->data .= "<tr><td style = 'border-bottom: #e4eff5; padding:0px; margin:0px'  class='zero-padding-margin' colspan='5'>".($i[57]==""?"":"<img src='$i[57]' class='image-item' />").($i[58]==""?"":"<img src='$i[58]' class='image-item-s'/>").($i[59]==""?"":"<img src='$i[59]' class='image-item-s'/>").($i[60]==""?"":"<img src='$i[60]' class='image-item-s'/>").($i[61]==""?"":"<img src='$i[61]' class='image-item-s'/>")."</td></tr>";
	}
	
$this->data .= "<tr>
	<td class='border-dark' colspan='5'></td>
	
	</tr>";

}

// TOTALS
if (count($this->totals)>0) { foreach ($this->totals as $t) {
	$this->data .= "<tr class='ttl'><td class='right' colspan='3'><b>$t[0]</b></td><td class='right' colspan='2'><b>$t[1]</b></td></tr>";
}}
$this->data .= "</table>";


// NOTES
if (count($this->notes)>0) {
	$this->data .= "<div id='notes'>";
	foreach ($this->notes as $n) {
		$this->data .= $n."<br>";
	}
	$this->data .= "</div>";
}

// CLOSE
$this->data .= "</div>";


$this->data .= "</body></html>";

?>