I have a transactional email which resides here:
System > Transactional Emails > Shipment Update
Here is what is inside of Shipment Update:
{{block type="core/template" template="email/header.phtml"}}
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$order.getCustomerName()}},</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
Your order # {{var order.increment_id}} has been shipped and now has a status of <strong>{{var order.getStatusLabel()}}</strong>.
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">You can check the status of your order by
Find tracking here.
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">{{var comment}}</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0;">
If you have any questions, please feel free to contact us at
{{config path='trans_email/ident_support/email'}}
or by phone at {{config path='general/store_information/phone'}}.
</p>
{{block type="core/template" template="email/footer.phtml"}}
I have a block type and file which correlates with the email above and it's located here: /email/order/shipment/track.phtml
<?php $_shipment=$this->getShipment() ?>
<?php $_order=$this->getOrder() ?>
<?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
<thead>
<tr>
<th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Shipped By') ?></th>
<th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking Number') ?></th>
<th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking URL') ?></th>
</tr>
</thead>
<tbody>
<?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?>
<tr <?php echo $i%2?'bgcolor="#F6F6F6"':'' ?>>
<td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getTitle()) ?></td>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getNumber());//getConsignmentNumber()) ?></td>
<?php $trackUrl = "https://mystore.narvar.com/mystore/tracking/fedex?tracking_numbers=";?>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $trackUrl. $_item->getNumber();?></td> </tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif; ?>
I store the track_number in our DB. Please see image below.
My question is how do i set my variables in the on the end of this URL which will be going to a third party site.
Find tracking here.
Try this:
$order = $this->getData('order');
As written in http://www.webspeaks.in/2011/06/customize-new-order-email-template-in-magento.html
Related
I'm having trouble designing the pdf of my system. here's a pic of my pdf:
What I want to do is to limit the number of items in the table by 10 items after that the rest goes to the next page with the same header and footer which is fixed already. just like this:
Purchase Request PDF
Here's my code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PDF</title>
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
<style>
#items tr{border:1px solid #000000;}
#items tbody tr td{border:1px solid #000000;}
#items thead td{background-color:#231F20;color:#FFFFFF;}
.header { position: fixed; left: 0px; top: -40px; right: 0px;}
.footer { position: fixed; left: 0px; bottom: 200px; right: 0px;}
</style>
<link rel="stylesheet" href="{{ asset('css/lato.css') }}">
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="header">
<div class="row">
<div class="col-xs-3" style="font-family: 'Libre Barcode 128', cursive; font-size: 35px;padding: 10px 0px 0px 0px;">{{$pr->pr_form_no}}</div>
<div class="col-xs-9">
<table cellspacing='0' cellpadding='5' style="border-width: 0 !important;padding:0px 0px 0px 60px;">
<tr>
<td style="padding: 10px;"><img src="{{asset('images/sfclogo.png')}}" width="50px" height="50px"></td>
<td>
<table style="text-align: center;style='width:45%'">
<tr><td>REPUBLIC OF THE PHILIPPINES</td></tr>
<tr><td>PROVINCE OF LA UNION</td></tr>
<tr><td>CITY OF SAN FERNANDO</td></tr>
</table>
</td>
<th style="padding-top: 10px;padding-left: 10px"><p style="background-color: #000;color: #FFF; text-align: center;padding: 10px;">PR</p></th>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12" style="text-align: center;color: white;background-color: black; font-size: 18px">
PURCHASE REQUEST
</div><br>
</div>
<div class="row">
<table style='width:100%;border:1px solid #000000;font-size:11pt;' cellspacing='0' cellpadding='5' class='font1'>
<tr>
<td style='width:40%'>
<table style='width:90%;padding-right: 0px;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:100%;padding:1px;padding-left:10px;' colspan='2'>DEPARTMENT:</td>
</tr>
<tr>
<td style='width:100%;padding:0px;padding-left:10px;' colspan='2'>{{$dept->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;padding-left:10px;' /></td>
</tr>
<tr>
<td style='width:15%;padding:1px;padding-left:10px;'>SECTION:</td>
<td style='width:75%;padding:0px;padding-left:0px;'>{{$section->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;' /></td>
</tr>
</table>
</td>
<td style='width:30%;'>
<table style='width:90%;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:20%;padding:1px;'>PR No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'>{{$pr->pr_form_no}}</td>
</tr>
<tr>
<td style='width:20%;padding:1px;'>SAI No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
</tr>
<tr>
<td style='width:20%;padding:1px;'>ObR No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
</tr>
</table>
</td>
<td style='width:30%'>
<table style='width:95%;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:15%;padding:1px;'>Date</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'> {{$dt->toFormattedDateString()}}</td>
</tr>
<tr>
<td style='width:15%;padding:1px;'>Budget</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'><strong> PHP {{number_format($pr->budget_alloc,2)}}</strong></td>
</tr>
<tr>
<td style='width:15%;padding:1px;'>Supplier</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000;'> {{$pr->supplier_type}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<div class="footer">
<div class="row">
<table style='width:100%;border:1px solid #000000;font-size:12px;margin-left:auto;margin-right:auto;margin-top:40px;' cellspacing='0' cellpadding='3' class='font1'>
<tr>
<td style='width:39%; font-weight:bold;text-align:left;border:1px solid #000000;'>
REQUESTING OFFICE<br/><br/><br/><br/>
</td>
<td style='width:60%;border:1px solid #000000;vertical-align:top;font-weight:bold;' colspan='2' rowspan='3'>
PURPOSE<br/>
<div style='width:100%;text-align:center;font-weight:normal;font-size:11pt;' class='font1'>
{{$pr->purpose}}
</div>
</td>
</tr>
<tr>
<td style='border:1px solid #000000;height:19px;text-align:center;text-transform:uppercase;font-weight:bold;'>
{{$pr->requestor_name}}
</td>
</tr>
<tr>
<td style='text-align:center;border:1px solid #000000;text-transform:uppercase;height:19px;font-weight:bold'>
{{$pr->requestor_position}}
</td>
</tr>
<tr>
<td colspan='3' style='background-color:#000000;height:20px;'>
</tr>
<tr>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
APPROPRIATION AVAILABLE
</td>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
FUNDS AVAILABLE
</td>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
APPROVED
</td>
</tr>
<tr>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
</tr>
<tr>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$aa->name}}<br/>
{{$aa->position}}
</td>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$c->name}}<br/>
{{$c->position}}
</td>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$approval->name}}<br/>
{{$approval->position}}
</td>
</tr>
</table>
</div>
<div class="row">
<div style='float:left;font-weight:normal;font-style:italic;font-size:7pt;width:40%;text-align:left;'>{{$created_code}}</div>
</div>
</div>
<div class="content" >
<div class="row">
<table style='width:100%;font-size:14px;text-align:center;border:1px solid #000000;' id='items' cellpadding='0' cellspacing='0'>
<thead>
<tr>
<td style='width:7%;font-weight:bold;'>ITEM NO.</td>
<td style='width:7%;font-weight:bold;'>QTY</td>
<td style='width:7%;font-weight:bold;'>UNIT</td>
<td style='width:49%;font-weight:bold;'>DESCRIPTION</td>
<td style='width:15%;font-weight:bold;'>ESTIMATED UNIT OF</td>
<td style='width:15%;font-weight:bold;'>ESTIMATED COST</td>
</tr>
</thead>
<tbody >
#foreach($list as $indexKey => $list)
<tr>
<td>{{$indexKey}}</td>
<td>{{$list->pr_qty}}</td>
<td>{{$list->pr_unit}}</td>
<td>{{$list->pr_description}}</td>
<td style='text-align: right;'>{{$list->pr_cost_per_unit}}</td>
<td style='text-align: right;'>{{$list->pr_estimated_cost}}</td>
</tr>
#if($indexKey >= 9)
#break
#endif
#endforeach
#for($i = $count; $i < 10; $i++)
<tr><td> </td><td> </td> <td> </td><td> </td><td> </td><td> </td></tr>
#endfor
</tbody>
<tfoot>
<tr style="background-color: #b0b1b2;">
<td colspan="5" style="text-align: right; font-weight: bold;">GRAND TOTAL</td>
<td style="text-align: right; font-weight: bold;">
{{number_format($grand_total,2)}}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
</body>
</html>
I already attempted to use the break function of the blade to stop the loop when the items shown is already 10.
*Also sorry if the code looks like hell.
you can use some css styling for it just like below:
<style>
.page-break {
page-break-after: always;
}
</style>
<h1>page</h1>
<div class="page-break"></div>
<h1>Someother Page</h1>
if you want to make a page break after for example 5 divs then you can do something like this:
#php $check=0 #endphp
#foreach($array as $item)
#php $check++ #endphp
<!-- your code or something like divs -->
#if( $check % 5 == 0 )
#php echo '<div class="page-break"></div>'; #endphp ....
#endif
#endforeach
Hope you will get the idea from it.
The code provided is while-loop, which work, part of the loop is to update database and to return the updated info back to loop that work too. The problem I am having is if the return result is more than one it should not loop that result only echo it once.
I have tried other ways of doing this, but nothing giving me the result I need, I have the amount of knowledge I have on PHP. If someone could please help me, there help would be greatly appreciated.
<?php
//////////////////////// non-spouse kid start ///////////////////////
$nonspouseKidSql=("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='son' AND familySide='other' OR memberEmail='$login_mem' AND familyRelationship='daughter' AND familySide='other' OR fam
ilyEmail='$login_mem' AND familyRelationship='father' AND familySide='other' OR familyEmail='$login_mem' AND familyRelationship='mother' AND familySide='other'");
$nonspouseKidQuery=mysql_query($nonspouseKidSql)or die ("error 1 Sorry we have a mysql error!");
$num_rowsNonspouseKid=mysql_num_rows($nonspouseKidQuery);
if ($num_rowsNonspouseKid < 1){echo '';}
else{
while($getnonspouseKidRow=mysql_fetch_array($nonspouseKidQuery)){
$getnonspouseKidEmail = $getnonspouseKidRow['familyEmail'];
$getNSPEmail = $getnonspouseKidRow['memberEmail'];
$nonspouseKid_relationship = $getnonspouseKidRow['familyRelationship'];
if($getNSPEmail == $login_mem){$nonspouseKidEmail = $getnonspouseKidEmail;}elseif($getnonspouseKidEmail == $login_mem){$nonspouseKidEmail = $getNSPEmail;}
$sql=("SELECT * FROM members WHERE email='$nonspouseKidEmail'");
$query=mysql_query($sql)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
while($row=mysql_fetch_array($query)){
$familyNonspouseKid_id = $row["id"];
$familyNonspouseKid_firstName = $row["firstName"];
$familyNonspouseKid_lastName = $row["lastName"];
$familyNonspouseKid_email= $row["email"];
$familyNonspouseKid_profile_pic = $row["profile_pic"];
$familyNonspouseKid_status = $row["status"];
$familyNonspouseKid_gender = $row["gender"];
if($nonspouseKid_relationship=="son"){$familyNonspouseKid_relationship ='son';}elseif($nonspouseKid_relationship=="daughter"){$familyNonspouseKid_relationship ='daughter';}
$member_familyPicNonspouseSon='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseSon='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a><div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseSon='<div id="connection_non-spouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
$member_familyPicNonspouseDaughter='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
if($familyNonspouseKid_relationship =='son'){echo $member_familyPicNonspouseSon;}else{echo $member_familyPicNonspouseDaughter;}
}
?>
<?php
//////// non-spouse kid end //////////////////////////////
?>
<?php
//////////////// child parent not spouse start ////////
?>
<div id="connection_childParent" class="connection_childParent"></div>
<div id="memFamilyPic_childParent" class="memFamilyPic_childParent">
<?php
$getGender = $mem["gender"];
if($getGender=='male'){$parentGender='Mother';}else{$parentGender='Father';}
$parentNameSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$nonspouseKidEmail' AND familyRelationship='mother' OR memberEmail='$nonspouseKidEmail' AND familyRelationship='father'")or die ("Sorry can't
get parent name!");
$parentNameRow=mysql_fetch_array($parentNameSql);
$parentName = $parentNameRow['familySide'];
$childParentSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='childmother' AND child_Id='$familyNonspouseKid_id' OR memberEmail='$login_mem' AND
familyRelationship='childfather' AND child_Id='$familyNonspouseKid_id'")or die ("Sorry can't get child parent!");
$childParentRow=mysql_fetch_array($childParentSql);
if($childParentRow < 1){echo '<p id="'.$familyNonspouseKid_id.'" class="mysql_returnNonspouseKid" align="center" style="color: #999; font-size:13px;">Child '.$parentGender.'</p>';
}else if($childParentRow > 2){
$childParentEmail = $childParentRow['familyEmail'];
$familyChildParent_relationship = $childParentRow["familyRelationship"];
$childParent=("SELECT * FROM members WHERE email='$childParentEmail'");
$query=mysql_query($childParent)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
if($childParentRow > 2){
while($row=mysql_fetch_array($query)){
$familyChildParent_id = $row["id"];
$familyChildParent_firstName = $row["firstName"];
$familyChildParent_lastName=$row["lastName"];
$familyChildParent_email=$row["email"];
$familyChildParent_profile_pic = $row["profile_pic"];
$familyChildParent_status=$row["status"];
$member_familyPicChildParent='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyChildParent_id.'/'.$familyChildParent_profile_pic.'';
if($familyChildParent_profile_pic!==""){
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyChildParent_id.'/'.
$familyChildParent_profile_pic.'" style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>';
}else{
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img
src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt=""/></a>';
}
}
if($familyChildParent_relationship =='childmother' or $familyChildParent_relationship =='childfather'){echo $member_familyPicChildParent;}
}}else{}
?>
<div id="familyDisplayDiv<?php echo $familyChildParent_id; ?>" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your <?php echo $familyChildParent_relationship; ?></span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;"><?php echo $familyChildParent_firstName; ?> <?php echo $familyChildParent_lastName; ?></span></td>
</tr>
</table>
</div>
</div>
<?php
}}
///////////////// child parent not spouse end //////////////
?>
I am trying to generate pdf using dom pdf
But in header part of pdf, image and text are overlapping.
Couldn't identify what exactly is wrong in my code?
CodeIgniter controller function:
$dompdf = new Dompdf();
$dompdf->set_option('enable_css_float', true);
$contxt = stream_context_create([
'ssl' => [
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
'allow_self_signed'=> TRUE
]
]);
$options = new Options();
$dompdf->setHttpContext($contxt);
$dompdf->set_option('isRemoteEnabled', true);
$dompdf->set_option('debugKeepTemp', true);
$dompdf->set_option('isHtml5ParserEnabled', true);
$dompdf->loadHtml($pdfdata);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$output = $dompdf->output();
Codeigniter View
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
<link rel="stylesheet" href="<?php echo CSS_PATH_BACKEND; ?>bootstrap.min.css">
<style>
#page { margin: 20px 30px; }
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:6px;}
.table-bordered{border:2px solid #000;}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{border:2px solid #000;}
.list-inline>li{ display: inline-block;
padding-right: 35px;
padding-left: 35px;
padding-top: 10px;
font-weight: 700;}
body{font-size:13px;}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:5px 0 5px 10px;}
.goods-table td{border:2px solid #000; }
thead:before, thead:after { display: none; }
tbody:before, tbody:after { display: none; }
tbody:before, tbody:after { display: none; }
.invoice tr td{}
.product_invoice td{padding:4px 5px !important;}
li{padding: 10px 0;}
li:before{content:''; font-size:60px; line-height:20px; vertical-align:middle;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr>
<td>
<div class="invoice-title">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;width:380px;height:76px;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
<p style="padding: 5px 0 0 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Corporate Office: Some address</p>
<p style="padding: 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Phone: 87945456 Cell: 321456789 Email: info#example.com Website: www.example.com</p>
</div>
<div class="invoice-title">
<span class="text-center" style="margin: 5px 0 0 0;font-weight:700;text-align: center;display: block;font-size: 18px;">TAX INVOICE CUM CHALLAN</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="">
<div class="">
<div class="table-responsive">
<!--<table class="table table-condensed">-->
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr style="border:2px solid #000;">
<td rowspan="4" style="width:40%;" colspan="2">
<!--StartFragment-->
<p style="padding: 0;margin: 0;font-size: 13px;"><span >To,</span></p>
<p style="padding: 0;margin: 0;font-weight: 700;font-size: 13px;"><span ><?php echo $customer['name']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address1']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['city']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span >Phone No: <?php echo $customer['contact_no']; ?></span></p>
</td>
<td style="vertical-align:middle;width:30%;border:2px solid #000;">Invoice No: <span style="font-weight: 700;"><?php echo $invoice['invoice_no']; ?></span></td>
<td style="vertical-align:middle;width:30%;border:1px solid #000;" colspan="3" >Contact Person: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_name']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="vertical-align:middle;">Date: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['created_date'])); ?></span></td>
<td style="vertical-align:middle;" colspan="3">Mobile No: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_no']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" rowspan="2">RIN No: <span style="font-weight: 700;">87455454</span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" colspan="3"> VAT No: <span style="font-weight: 700;"></span></td>
</tr>
<tr style="border:2px solid #000;">
<!--<td >Company Executive: <?php echo ucwords($user['fname'] . ' ' . $user['lname']); ?></td>-->
<td colspan="1">Date of Activation: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['activation_date'])); ?></span></td>
<td colspan="3">Next Renewal: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['renewal_date'])); ?></span></td>
</tr>
</tbody>
</table>
<table width="100%" class="table goods-table invoice" style="margin-bottom: 0; font-size: 12px; border-top: 1px solid #202020; ">
<tbody>
<tr>
<td style="font-weight: 700;font-size: 13px;width:10%;">Sr. No</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Software ID</td>
<td style="font-weight: 700;font-size: 13px;width:35%;">Description</td>
<td style="font-weight: 700;font-size: 13px;width:10%;">Quantity</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Unit Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
<td style="font-weight: 700;font-size: 13px;width:15%" colspan="2">Total Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
</tr>
<?php
$cnt = 1;
foreach ($product_invoice as $key => $value) {
?> <tr <?php
if (count($product_invoice) < 9) {
echo 'class';
} else {
echo 'class="product_invoice"';
}
?>>
<td
<?php if (count($product_invoice) == 1) { ?> style="height:650px;"<?php } ?>
<?php if (count($product_invoice) == 2 && ($key == (count($product_invoice)) - 1)) { ?> style="height:590px;"<?php } ?>
<?php if (count($product_invoice) == 3 && ($key == (count($product_invoice)) - 1)) { ?> style="height:180px;"<?php } ?>
<?php if (count($product_invoice) == 4 && ($key == (count($product_invoice)) - 1)) { ?> style="height:160px;"<?php } ?>
<?php if (count($product_invoice) == 5 && ($key == (count($product_invoice)) - 1)) { ?> style="height:110px;"<?php } ?>
<?php if (count($product_invoice) == 6 && ($key == (count($product_invoice)) - 1)) { ?> style="height:50px;"<?php } ?>
<?php if (count($product_invoice) == 7 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 8 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 9 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 10 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>>
<?php echo $cnt++; ?></td>
<td><?php echo $value['software_id']; ?></td>
<td><?php echo $value['description']; ?></td>
<td><?php echo $value['qty']; ?></td>
<td colspan="2"><?php echo $value['unit_price']; ?></td>
<td><?php echo $value['total_price']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<table width="100%" class="table goods-table" style="margin-bottom: 0; font-size: 13px; padding: 15px 5px; ">
<tbody>
<tr>
<td colspan="2" rowspan="6" style="font-weight: 700;width:70%; padding: 10px 15px;">
<span style="font-weight:700;">Comments: </span>
</td>
<td style="width:15%;height:10px;">Sub Total</td>
<td style="width:25%;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['sub_total']; ?></td>
</tr>
<tr>
<td style="height:10px;">Other</td>
<td style="height:10px;"colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['other']; ?></td>
</tr>
<tr>
<td style="height:10px;">VAT</td>
<td style="height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['vat']; ?></td>
</tr>
<tr >
<td style="font-weight: 700;height:10px;font-size: 14px;">Grand Total</td>
<td style="font-weight: 700;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['total_price']; ?></td>
</tr>
<tr>
<td style="height:10px;">Mode Of Payment</td>
<td style="height:10px;" colspan="2"><?php
if ($invoice['paymode_mode'] == 1) {
echo 'Cash';
}
if ($invoice['paymode_mode'] == 2) {
echo 'Cheque';
}
if ($invoice['paymode_mode'] == 3) {
echo 'Cash and Cheque';
}
?></td>
</tr>
<tr>
<td colspan="3" >In Words: <?php echo ucwords(convert_number_to_words($invoice['total_price'])); ?> Rupees Only</td>
</tr>
<tr>
<td colspan="2">Installation Done<br>
<br><br><br>
Receiver's Signature with Seal
</td>
<td style="text-align: center;" colspan="3"><span style="font-weight: 700;font-size: 14px;">For </span><span style="font-weight: 700;font-size: 14px;">oft</span>
<?php if ($seg == "preview") {
?>
<img src="<?php echo IMAGE_PATH_BACKEND; ?>test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://example.com/images/backend/test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php } ?>
Authorized Signatory
</td>
</tr>
</tbody>
</table>
<table width="100%" class="table " style="margin-bottom: 0; font-size: 13px; border-bottom: 2px solid #000; border-left: 2px solid #000; border-right: 2px solid #000;">
<tbody>
<tr>
<td style="border-right: 2px solid #000;font-weight: 700;width: 100px;">Branches</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">sddsa</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">ewew</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 132px;">ewewq</td>
</tr>
<tr>
<td colspan="5" style="border : 2px solid #000;text-align: center;"><span style="font-weight:700;font-size: 13px;">Note: Computer generated Invoice and requires no signature.</span><br></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
There's a bug in Dompdf (current release 0.8.0) where styling an image with auto margins will cause it to no longer take up any vertical space in the layout.
Luckily your layout is such that working around the issue is fairly simple. Change the code around your image to the following:
<div class="text-center">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
</div>
Also of note: don't modify the display styling of images. Currently dompdf requires a special styling to render these correctly and if you change the styling (e.g. to display: block;) you may get unexpected results.
I am trying to figure out the problem in this, but not able to. Query is proper, Result i am getting. If i echo $html i get result, but nothing for WriteHTML();
Here is my code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("connect.php");
$id = $_GET['id'];
include("mpdf/mpdf.php");
$mpdf=new mPDF('utf-8', 'A4');
$mpdf->debug = true;
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetProtection(array());
$mpdf->SetTitle("My Company");
$mpdf->SetAuthor("MeAuthor");
$mpdf->SetWatermarkText("Demo");
$mpdf->showWatermarkText = false;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$s1 = "SELECT * FROM mytable WHERE cid=".$id."";
$sql = mysqli_query($con, $s1) or die (mysqli_error($con));
$row = mysqli_fetch_array($sql);
$html = '
<html>
<head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="80%" style="text-align: center; font-size: 16pt;">Company Name<br>
<span style="font-size: 11pt;text-align: center;">Address 123, Lorel Ipsum, sdfsdf sdsdgsdg,</span><br>
<span style="font-size: 11pt;text-align:center;">sdfdsfdsf, sfsdf - 100066
</td>
</tr>
</table>
</htmlpageheader>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="off" />
mpdf-->
<table width="100%">
<tr><td colspan="2" align="right" width="40%"> Vocher No : '.$id.' </td></tr>
<tr>
<td width="70%">Debit A/C. : '.$row['account_no'].' </td>
<td width="30%" style="text-align: right">Date: '.date("d-m-Y").'</td></tr>
</table>
<div style="border: 1px solid black">
<table border="0" style="white-space:nowrap; border-spacing:0;" height="100%" cellspacing="5"><thead>
<tr>
<th width="30%" style="border-right:1px solid #000;">Name</th>
<th width="20%" style="border-right:1px solid #000;">E-Mail</th>
<th width="20%" style="border-right:1px solid #000;">Mobile</th>
<th width="30%" style="border-right:1px solid #000;">Particulars</th>
<th width="15%" style="border-right:1px solid #000;">RS.</th>
<th width="5%" style="border-right:1px solid #000;">P.</th>
</tr>
</thead>
<tr>
<td style="border-right:1px solid #000;" width="30%" height="100px;" >'.$row['name'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['email'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['mobile'].'</td>
<td style="border-right:1px solid #000;" width="30%">'.$row['purpose'].'</td>
<td style="border-right:1px solid #000;" width="15%">'.$row['amount'].'</td>
<td style="border-right:1px solid #000;" width="5%">00</td>
</tr>
<tr><td colspan="4" style="font-weight:bold;">Total Rs.</td> '.$row['amount'].'<td></tr>
</table></div>
<br>
<table border="0"><tr><td style="width=50%;">Mode of Payment : '.$row['mode'].' </td><td width="50%">Date : '.date('Y-m-d').'</td></tr>
<tr><td colspan="2">Rupees : </td></tr>
</table>
<br><br><br>
<table width="100%" border="0">
<tr><td width="20%"> Hon. Secretary </td>
<td width="20%">Hon. Treasurer</td>
<td width="20%">Hon. Trustee</td>
<td width="20%">Receiver s Signature</td></tr>
</table>
</body>
</html>
';
//echo $html;
echo $mpdf->WriteHTML($html);
//$mpdf->Output('Receipt.pdf','D');
$mpdf->Output();
?>
Method WriteHTML() returns void! So you'll not get any echo.
Note that you have not send anything to browser (even http-header) before Output().
I am using this code to add some buttons with shortcode in functions.php## Heading ## then it is working :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<p><b>Setup/Medicine Download<b></p>[maxbutton id="1"]';
$content .= '[maxbutton id="2"]';
$content .= '[maxbutton id="3"]';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
But when I add some Html code after that then it does not work :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">About Author</span> </b>
<input type="hidden" name="stats" value="2498">
</h3>you can be an author too, join mhktricks and show you skills</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="http://mhktricks.net/user-registration/" target="_blank">
<input class="p2graybtn" style="height: 26px; width:150px;" type="button" value="Join Us">
</a>
</td>
</tr>
</tbody>
</table>
<hr>
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<?php echo get_avatar( get_the_author_meta( 'user_email' ), 70 ); ?>
</td>
<td style="border: solid 1px #ffffff;">
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<span style="color: #555;font-size:20px;font-family: Open Sans;font-weight: 400;font-style: normal;text-decoration: none;">
<?php echo get_the_author(); ?>
</span>
<br><div style="margin-left:1px;">
<?php echo get_author_role(); ?>
<span style="position:relative;top:1px;margin-left:5px;"><img src="http://i2.wp.com/codex.onhax.net/img/verified.png" height="12" width="12"></span>
</div>
</td>
<td style="border: solid 1px #ffffff;">
<div style="margin-left: 3px;margin-top: -17px;border: #B8B8B8 1px solid;border-radius:2px;padding: 0px 5px 0px 5px;font-size:10px;">
<?php the_author_posts(); ?> POSTS</div>';
</td>
</tr>
</tbody>
</table><div style="margin-top:-12px;">
</div>
<div style="margin-left:3px;margin-top:2px;padding-right:60px;">
<?php the_author_meta( 'description' ); ?>
<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
View all posts by me
<?php get_the_author(); ?>
<span class="meta-nav">→</span>
</a>
</div>
</td>
</tr>
</tbody>
</table>
<hr color="white">
<hr color="white">
<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">Discussion</span></b></h3>
share your knowledge.mind to help others</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="#" class="show-comments">
<input class="p2graybtn" style="height: 26px;" type="button" value="Toggle Comments">
</a>
</td>
</tr>
</tbody>
</table>';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
When I add the above code the page even doesn't load.
I just want to add author box below posts but it does not work. Help Please !
If you'd bothered to look, you have a ' in your html, which is terminating your string assignment:
[...long snip...] the_author_posts(); ?> POSTS</div>';
^---
</td>
which turns that </td> into PHP code, causing a fatal parse error.
This is why massive multi-line strings like this are a horrible idea. If you need to dump text like that, use a HEREDOC, or drop out of PHP mode. e.g.
$content = <<<EOL
blah blah blah all your html here blah blah blah
EOL;
HEREDOCs removes the need to worry about quotes.
You should also turn on display_errors and error_reporting, which would have told you about the fatal error. They should NEVER be off on a devel/debug system.