I am creating a pdf of 9 columns using mpdf that shows a list of users In each row, 1 column is used for photograph. My problem is that I want the columns to be almost equal in width but in result, I am getting columns with different widths.
I have tried to set CSS of table as well as through mpdf option, but none of them worked.
My code is as under:
$a='<style>#page {
margin: 10pt;
}</style>';
$a .= '<table autosize="1" border="1" class="atable" style="font-family:Arial"><tr>
<th style="min-width: 60pt;max-width: 60pt; font-size:7pt">Sr.<br>No.</th>
<th style="min-width: 60pt;max-width: 60pt; font-size:7pt">Admission No.<br>Boarder/DayScholar<br>Admit Class<br>Admit Date<br>Exit Class<br>Exit Date</th>
<th style="min-width: 60pt;max-width: 60pt; font-size:7pt">Photograph</th>
<th style="min-width: 60pt;max-width: 60pt; font-size:7pt">Student Details<br>[Student Name<br>Father Name<br>Father Occupation<br>Mother Name<br>Mother Occupation]</th>
<th style="min-width: 60pt;max-width: 60pt; font-size:7pt">Date of Birth<br>Current Class<br>Current City<br>Board Roll No.<br>Percentage</th>
<th style="min-width: 60pt;max-width: 70pt; font-size:7pt">Old Details<br>[Address<br>Father Email<br>Father Mobile]</th>
<th style="min-width: 60pt;max-width: 75pt; font-size:7pt">Present Profile<br>(Alumi,<br>Ex-Student,<br>Current Student)</th>
<th style="min-width: 60pt;max-width: 65pt; font-size:7pt">Contact Details<br>[Email Id<br>Mobile<br>Father Mobile<br>Facebook Id<br>Twitter Id<br>Linked In Id]</th>
<th style="min-width: 60pt;max-width: 65pt; font-size:7pt">Remarks</th>
</tr><tr>'
//Here goes the data fetching php code followed by the below code
<td style="font-size: 10pt !important; text-align:center;">' . ++$i . '</td>
<td style="font-size:10pt !important; text-align:center;">' . $row['adm_no'] .'<br><font color="green">' . $row['d_b'] . '</font><br>' . $row['adm_class'] . '<br><font color="green">' . $fadmdate . '</font><br>' . $row['exit_class'] . '<br><font color="green">' . $fexit . '</font></td>
<td style="font-size:10pt !important; text-align:center;">'. '<div id="testimage"><img src="' . $gdImage . '" width="60pt" /></div></td><td style="font-size:10pt !important; text-align:center;">'. $row['stu_name'] .
'<br><font color="green">' . $row['fat_name'] . '</font><br>' . $row['fat_occ'] . '<br><font color="green">' . $row['mot_name'] . '</font><br>' . $row['mot_occ'] . '</td>
<td style="font-size:10pt !important; text-align:center;">'.
$fdob . '<br><font color="green">' . $row['stu_class'] . '</font><br>' . $row['cur_city'] . '<br><font color="green">' .$row['board_roll'] . '</font><br>' . $row['perc'] . '</td>
<td style="font-size:10pt !important; text-align:center;">'.
$row['addr']. '<br><font color="green">' . $row['fat_email'] . '</font><br>' . $row['fat_mob'] . '</td>
<td style="font-size:10pt !important; text-align:center;">'.
$cprofile .'</td>
<td style="font-size:10pt !important; text-align:center;">' . $row['email_id'] .'<br><font color="green">' . $row['phone_no'] . '</font><br>' . $row['fb_id'] . '<br><font class="green">' . $row['twitter_id'] . '</font><br>' . $row['linkedin_id'] . '</td><td style="font-size:10pt !important; text-align:left;">SMS:<br><font color="green">Email:</font><br>FB:</td>
</tr></table>
<?php
include("\mpdf\mpdf.php");
$mpdf=new mPDF('','A4');
$keep_table_proportions = TRUE;
$mpdf->shrink_tables_to_fit=1;
$mpdf->setFooter('Details ::: ' . date("d/m/Y") . ' ::: {PAGENO} / {nb}');
$mpdf->WriteHTML($a);
$mpdf->Output('mytable.pdf', 'D');
exit;
Even after setting max width to 70pt, The Old details column takes around 25% of the page width due to which other columns are squeezed badly and look goes weird and also the footer is no more visible.
try the following :
<table cellpadding="5px" autosize="1" border="1" width="100%" style="overflow: wrap">
Then add appropriate widths to your th and td long with appropriate font size, say 8 to 10 pt.
Then, at the end, modify your code as follows:
include("\mpdf\mpdf.php");
$mpdf=new mPDF('','A4');
$mpdf->simpleTables = true;
$mpdf->packTableData = true;
$mpdf->keep_table_proportions = TRUE;
$mpdf->shrink_tables_to_fit=1;
$mpdf->setFooter('Birthday Details ::: ' . date("d/m/Y") . ' ::: {PAGENO} / {nb}');
$mpdf->WriteHTML($a);
$mpdf->Output('mytable.pdf', 'D');
exit;
This will lso improve the performance. Dont forget to upvote if this helps.
So I need to fetch data such as section, item names and subtotal of every section from my database and get the grand total of all the items.
I stumble upon the code below and modify it to my requirements.
The code works perfectly but I need to display more data like Item description, Qty, Price, status and so on.
The code below works and have no problem whatsoever but i need more data (description, qty, price and so on) to display in my table but I can't figure out how to do it.
The data I need to display is also in the same row where projectscostbreakdown_areaname, projectscostbreakdown_itemname and projectscostbreakdown_totalcost are.
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
while ( $row2 = $query->fetch() ) {
if ( empty($data[ $row2['projectscostbreakdown_areaname'] ]) ) {
$data[ $row2['projectscostbreakdown_areaname'] ]= array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
if ( empty( $data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] ) ) {
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] = array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ][] = $row2['projectscostbreakdown_totalcost'];
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
//while ( $data = $query->fetch() ) {
$numbering++;
$count++;
$class = ($count%2 == 0)? 'white': '#CCCCCC';
$sum = array_sum( $totalcost );
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">';
print_r($data2);
print '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody>
</table>';
?>
UPDATE
The output looks like this right now.
I need to include Description and Qty in the output but cant figure how to be done.
Section1
Item Name-----Description-----Qty-----Subtotal
item 1---------------------------------------------1000
item 2---------------------------------------------2000
----------------------------------Section Total: 3000
Section2
Item Name-----Description-----Qty-----Subtotal
item 3---------------------------------------------1000
----------------------------------Section Total: 1000
------------------------------------Grand Total: 4000
Complete code (more structured, fixed bugs):
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
$itemData = $query->fetchAll();
$query->execute();
while ($row2 = $query->fetch()) {
if (empty($data[$row2['projectscostbreakdown_areaname']]) ) {
$data[$row2['projectscostbreakdown_areaname']]= array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
if (empty($data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']])) {
$data[$row2['projectscostbreakdown_areaname']][ $row2['projectscostbreakdown_itemname']] = array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']]= array();
}
$data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']][] = $row2['projectscostbreakdown_totalcost'];
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
$count++;
echo $numbering.' ';
$class = ($count % 2 == 0) ? 'white' : '#CCCCCC';
$sum = array_sum($totalcost);
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">'.$itemData[$numbering]['projectscostbreakdown_itemdescription'].'</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$numbering++;
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody></table>';
?>
Basically, what I did (which might not be the best option but I couldn't think anything better) was I used $itemData = $query->fetchAll(); after executing $query->execute();. Now if we leave everything the same, table will be empty since pointer is at the last element. Therefore, we must execute again the same query by writing an additional $query->execute(); right after $itemData = $query->fetchAll();.
Now we have basically the same thing as in your example but with one additional variable $itemData with all information about items. To bring out description, quantity, etc. now we can use $itemData[$numbering]['projectscostbreakdown_itemdescription'] where $numbering stands for array's index number.
I want to print a class bill and i keep getting:
TCPDF ERROR: Wrong page number on setPage() function
Below is my code:
<?php
ob_start();
require_once '../includes/header.php';
require_once '../tcpdf/tcpdf.php';
require_once '../classes/InstitutionDetail.php';
require_once '../classes/ClassMembership.php';
require_once '../classes/Pupil.php';
require_once '../classes/Admission.php';
require_once '../classes/User.php';
require_once '../classes/Photo.php';
require_once '../classes/Bill.php';
require_once '../classes/Payments.php';
confirm_logged_in();
$institutionDetail = new InstitutionDetail();
$classMembership = new ClassMembership();
$pupil = new Pupil();
$admission = new Admission();
$user = new User();
$photo = new Photo();
$bill = new Bill();
$payment = new Payments();
$getUserDetails = $user->getUserByUsername($_SESSION["username"]);
$splitAccessPages = explode("//", $getUserDetails["access_pages"]);
for ($i = 0; $i < count($splitAccessPages); $i++) {
if (!in_array("print_class_bills", $splitAccessPages, TRUE)) {
redirect_to("logout_access.php");
}
}
//$getAcademicTerm = $academicTerm->getActivatedTerm();
//$get_academic_term = $getAcademicTerm["academic_year"] . "/" . $getAcademicTerm["term"];
if (!isset($_SESSION["chosen_term"], $_SESSION["selected_class_name"])) {
// redirect_to("student_bill.php");
$_SESSION["chosen_term"] = "";
$_SESSION["selected_class_name"] = "";
}
$getInstitutionDetail = $institutionDetail->getInstitutionDetails();
$getSchool_name = $getInstitutionDetail["school_name"];
$getSchoolMotor = $getInstitutionDetail["school_motor"];
$getPostalAddress = $getInstitutionDetail["postal_address"];
$getTelephoneNumbers = $getInstitutionDetail["telephone_1"] . " " . $getInstitutionDetail["telephone_2"] . " " . $getInstitutionDetail["telephone_3"];
class MYPDF extends TCPDF {
//Page header
public function Header() {
}
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-90);
// Set font
$this->SetFont('helvetica', '', 8);
// Page number
// date_default_timezone_set("Africa/Accra");
// $this->Cell(0, 10, date("d/m/Y h:i:sa") . " " . 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
$takeNote = "<strong><u>FOOTNOTES:</u></strong>";
$divSaparatefoot = '<div style="width:auto; background-color:mintcream; height:25px; border-bottom:3px solid #ddd;padding-bottom:3px;">'.'</div>';
// $horizontalLine = "<hr style=background:burlywood; height: 5px; />";
$space = "<p></p>";
$msg = "1. When <strong>Total Fees</strong> indicate <strong>credit</strong>, it means that, the school owes the student the said amount.";
$info = "2. All fees must be paid on or before the <strong>re-opening date</strong>.";
$bankNote = "<strong>Bankers:</strong>";
$company = "<strong><em>Software by ANIDROL GHANA:+233 26-764-2898 /+233 24-774-5156</em></strong>";
$institutionDetail = new InstitutionDetail();
$getInstitutionDetail = $institutionDetail->getInstitutionDetails();
$getBank_1 = "1. <strong>" . $getInstitutionDetail["bank_1"] . "</strong> Branch: <strong>" . $getInstitutionDetail["bank_1_branch"] . "</strong> Account Number: <strong>" . $getInstitutionDetail["bank_1_account_number"] . "<strong>";
$getBank_2 = "2. <strong>" . $getInstitutionDetail["bank_2"] . "</strong> Branch: <strong>" . $getInstitutionDetail["bank_2_branch"] . "</strong> Account Number: <strong>" . $getInstitutionDetail["bank_2_account_number"] . "<strong>";
$getBank_3 = "3. <strong>" . $getInstitutionDetail["bank_3"] . "</strong> Branch: <strong>" . $getInstitutionDetail["bank_3_branch"] . "</strong> Account Number: <strong>" . $getInstitutionDetail["bank_3_account_number"] . "<strong>";
$this->writeHTML($divSaparatefoot, true, 0, true, 0);
$this->writeHTML($takeNote, true, 0, true, 0);
$this->writeHTML($space, true, 0, true, 0);
$this->writeHTML($msg, true, 0, true, 0);
$this->writeHTML($info, true, 0, true, 0);
$this->writeHTML($space, true, 0, true, 0);
$this->writeHTML($bankNote, true, 0, true, 0);
$this->writeHTML($getBank_1, true, 0, true, 0);
$this->writeHTML($getBank_2, true, 0, true, 0);
$this->writeHTML($getBank_3, true, 0, true, 0);
$this->writeHTML($company, true, 0, true, 0, 'R');
}
}
$pdf = new MYPDF("", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set some language-dependent strings (optional)
if (#file_exists(dirname(__FILE__) . "/lang/eng.php")) {
require_once(dirname(__FILE__) . "/lang/eng.php");
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('times', '', 11);
$getClassStudentById = $classMembership->getClassStudentsById($_SESSION["chosen_term"], $_SESSION["selected_class_name"]);
foreach ($getClassStudentById as $value) {
$pdf->startPageGroup();
$pdf->AddPage();
$pdf->setJPEGQuality(75);
$getSingleBillAmount = $bill->getSingleBillingAmount($value["pupil_id"]);
$singleBillAmount = $getSingleBillAmount["billAmount"];
$getTermFees = $bill->getTermFees($value["pupil_id"], $_SESSION["chosen_term"]);
$getPTAAll = $bill->getPTAFeesAll($value["pupil_id"]);
// $termFeesOnly = number_format($getTermFees["termFees"], 2, ".", ",");
$getPTA = $bill->getPTAFees($value["pupil_id"], $_SESSION["chosen_term"]);
$termFees = number_format(($getTermFees["termFees"] + $getPTA["ptaFees"]), 2, ".", ",");
if ($termFees <= 0) {
if ($termFees == 0) {
$termFeesFormated = "";
} else {
$termFeesFormated = "GH¢" . str_replace("-", "", $termFees) . " Credit";
}
} else {
$termFeesFormated = "GH¢" . $termFees;
}
$getFeesPayable = $bill->getStudentAccount($value["pupil_id"]);
$getTotalFeesPaid = $bill->getTotalFeesPaid($value["pupil_id"]);
$getPTAFeesPaid = $bill->getPTAFeesPaid($value["pupil_id"]);
// $getBalance = number_format((($getFeesPayable["allFeesPayable"] + $singleBillAmount + $getPTAAll["ptaFeesAll"]) - ($getTotalFeesPaid["allFeesPaid"])), 2, ".", ",");
$getBalance = number_format((($getFeesPayable["allFeesPayable"] + $singleBillAmount + $getPTAAll["ptaFeesAll"]) - ($getTotalFeesPaid["allFeesPaid"] + $getPTAFeesPaid["ptaFeesPaid"] + $termFees)), 2, ".", ",");
if ($getBalance <= 0) {
if ($getBalance == 0) {
$balanceBroughtForward = "-";
} else {
$balanceBroughtForward = "GH¢" . str_replace("-", "", $getBalance) . " Credit";
}
} else {
$balanceBroughtForward = "GH¢" . $getBalance . " Debit";
}
// $totalFees = number_format(((($getFeesPayable["allFeesPayable"] - $getTotalFeesPaid["allFeesPaid"]) + $singleBillAmount) + $termFees), 2, ".", ",");
$totalFees = number_format((($getFeesPayable["allFeesPayable"] + $singleBillAmount + $getPTAAll["ptaFeesAll"] + $termFees) - ($getTotalFeesPaid["allFeesPaid"] + $getPTAFeesPaid["ptaFeesPaid"] + $termFees)), 2, ".", ",");
if ($totalFees <= 0) {
if ($totalFees == 0) {
$balanceCarriedForward = "-";
} else {
$balanceCarriedForward = "GH¢" . str_replace("-", "", $totalFees) . " Credit";
}
} else {
$balanceCarriedForward = "GH¢" . $totalFees;
}
// table
$getStudentPhoto = $photo->getPhotoById($value["pupil_id"]);
$studentPhoto = "../" . $getStudentPhoto["photo_url"];
$getLogoID = $photo->getSchoolLogoID();
$getSchoolLogo = $photo->getSchoolLogo($getLogoID["logo_id"]);
$schoolLogo = "../" . $getSchoolLogo["photo_url"];
$heading = "<span>GHANA EDUCATION SERVICE</span>"
. "<h1>" . $getSchool_name . "</h1>"
. "<span>" . $getPostalAddress . "</span><br />"
. "<span>" . $getTelephoneNumbers . "</span>";
$pdf->Image($studentPhoto, 155, 60, 35, 35, '', '', '', true, 150, '', false, false, 0, false, false, false);
$pdf->Image($schoolLogo, 5, 7, 34, 37, '', '', '', true, 150, '', false, false, 0, false, false, false);
$tbl_head_heading = '<table cellspacing = "0" cellpadding = "5">';
$tbl_foot_heading = '</table>';
$tbl_heading = '';
$tbl_heading .= '
<tbody>
<tr>
<td style="text-align: center; background-color: #666; color: #fff;" colspan="4">' . $heading . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_heading . $tbl_heading . $tbl_foot_heading, true, false, true, false, '');
$className ='<div style="width:auto; background-color:grey;">'.'<b>'. '<strong style="color:#fff; font-size:12px">'. htmlentities(strtoupper($_SESSION["chosen_term"] . " " . "Term Student Bill")) . '</strong>'.'</b>'.'</div>';
$pdf->writeHTML($className, true, 0, true, 0, 'C');
// $horizontalLineII = '<hr style="">'.'</hr>';
$divSaparate = '<div style="width:auto; background-color:mintcream; height:25px; border-bottom:3px solid #ddd;padding-bottom:3px;">'.'</div>';
$pdf->writeHTML($divSaparate);
//$pdf->writeHTML($horizontalLineII);
$headingSpace = "<div></div>";
$pdf->writeHTML($headingSpace, true, 0, true, 0);
//$horizontalLine = "<hr style='background-color:burlywood; height: 5px;'>"."</hr>";
$divSaparateLine = '<div style="width:auto; background-color:mintcream; height:25px; border-bottom:3px solid #ddd;padding-bottom:3px;">'.'</div>';
$getStudentData = $pupil->getPupilById($value["pupil_id"]);
$getStudentName = $getStudentData["other_names"] . " " . $getStudentData["family_name"];
$getStudentID = $getStudentData["pupil_id"];
$getGender = $getStudentData["sex"];
$getBoardingStatus = $value["boarding_status"];
$getClassName = $value["class_name"];
$tbl_head_title = '<table cellspacing = "10" cellpadding = "0" border = "0">';
$tbl_foot_title = '</table>';
$tbl_title = '';
$tbl_title .= '
<tbody>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Name:</strong></td>
<td style="text-align: left; font-weight:bold;margin:5px; border-bottom:1.5px solid #ddd;padding-bottom:3px;">' . $getStudentName . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>ID Number:</strong></td>
<td style="text-align: left; border-bottom:1.5px solid #ddd;padding-bottom:3px; width:100px;">' . $getStudentID . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%; "><strong>Gender:</strong></td>
<td style="text-align: left; border-bottom:1.5px solid #ddd;padding-bottom:3px; width:100px;">' . $getGender . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Status:</strong></td>
<td style="text-align: left; border-bottom:1.5px solid #ddd;padding-bottom:3px; width:100px;">' . $getBoardingStatus . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Class:</strong></td>
<td style="text-align: left; font-weight:bold; border-bottom:1.5px solid #ddd;padding-bottom:3px; width:100px;">' . $getClassName . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Balance b/f:</strong></td>
<td style="text-align: left;">' . $balanceBroughtForward . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Term Fees:</strong></td>
<td style="text-align: left;">' . $termFeesFormated . '</td>
</tr>
<tr style="color: #000;">
<td style="text-align: right; width: 20%;"><strong>Total Fees:</strong></td>
<td style="text-align: left;">' . $balanceCarriedForward . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_title . $tbl_title . $tbl_foot_title, FALSE, false, true, false, '');
$pdf->writeHTML($divSaparateLine, true, 0, true, 0);
// list of bill items
$tbl_head_description = '<table cellspacing = "2" cellpadding = "5" border = "0">';
$tbl_foot_description = '</table>';
$tbl_description = '';
$tbl_description .= '
<tbody>
<tr style="color: #000;">
<td style="width: 8.5%;"> </td>
<td style="width: 67%; text-align: left;">' . "<strong>BILL ITEMS</strong>" . '</td>
<td style="text-align: right; width: 16%;">' . "<strong>GH¢</strong>" . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_description . $tbl_description . $tbl_foot_description, FALSE, false, true, false, '');
$classBillItemsForStudent = $bill->getClassBillForStudent($value["class_name"], $_SESSION["chosen_term"]);
foreach ($classBillItemsForStudent as $classBillItemStudent) {
if ($getBoardingStatus === "Day Student") {
$schoolFees = $classBillItemStudent["day_amount"];
} else {
$schoolFees = $classBillItemStudent["boarding_amount"];
}
$tbl_head_item = '<table cellspacing = "1" cellpadding = "0" border = "0">';
$tbl_foot_item = '</table>';
$tbl_item = '';
$tbl_item .= '
<tbody>
<tr style="color: #000;">
<td style="width: 10%;"> </td>
<td style="width: 70%;">' . $classBillItemStudent["bill_item"] . '</td>
<td style="text-align: right; width: 10%;">' . number_format($schoolFees, 2, ".", ",") . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_item . $tbl_item . $tbl_foot_item, FALSE, false, true, false, '');
}
if ($getGender === "Male") {
$classBillItemsForMale = $bill->getClassBillForMale($value["class_name"], $_SESSION["chosen_term"]);
foreach ($classBillItemsForMale as $classBillItemMale) {
if ($getBoardingStatus === "Day Student") {
$schoolFeesMale = $classBillItemMale["day_amount"];
} else {
$schoolFeesMale = $classBillItemMale["boarding_amount"];
}
$tbl_head_item = '<table cellspacing = "1" cellpadding = "0" border = "0">';
$tbl_foot_item = '</table>';
$tbl_item = '';
$tbl_item .= '
<tbody>
<tr style="color: #000;">
<td style="width: 10%;"> </td>
<td style="width: 70%;">' . $classBillItemMale["bill_item"] . '</td>
<td style="text-align: right; width: 10%;">' . number_format($schoolFeesMale, 2, ".", ",") . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_item . $tbl_item . $tbl_foot_item, FALSE, false, true, false, '');
}
} else {
$classBillItemsForFemale = $bill->getClassBillForFemale($value["class_name"], $_SESSION["chosen_term"]);
foreach ($classBillItemsForFemale as $classBillItemFemale) {
if ($getBoardingStatus === "Day Student") {
$schoolFeesFemale = $classBillItemFemale["day_amount"];
} else {
$schoolFeesFemale = $classBillItemFemale["boarding_amount"];
}
$tbl_head_item = '<table cellspacing = "1" cellpadding = "0" border = "0">';
$tbl_foot_item = '</table>';
$tbl_item = '';
$tbl_item .= '
<tbody>
<tr style="color: #000;">
<td style="width: 10%;"> </td>
<td style="width: 70%;">' . $classBillItemFemale["bill_item"] . '</td>
<td style="text-align: right; width: 10%;">' . number_format($schoolFeesFemale, 2, ".", ",") . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_item . $tbl_item . $tbl_foot_item, FALSE, false, true, false, '');
//$get_term_from_session = $_SESSION["chosen_term"];
//$get_session_class = $_SESSION["selected_class_name"];
// $get_class_memebership = $classMembership ->getClassMembersByClassName($_SESSION["selected_class_name"]);
//
// if( $get_class_memebership){
//
// }
$getTotalBillForClass = $bill ->getTotalStudentCharges( $_SESSION["selected_class_name"],$_SESSION["chosen_term"]);
$tbl_head_itema = '<table cellspacing = "1" cellpadding = "0" border = "0">';
$tbl_foot_itema = '</table>';
$tbl_itema = '';
$tbl_itema.= '
<tbody>
<tr style="color: #000;">
<td style="width: 10%;"> </td>
<td style="width: 70%;">' . 'TOTAL:' . '</td>
<td style="text-align: right; width: 10%;">' . number_format($getTotalBillForClass, 2, ".", ",") . '</td>
</tr>
</tbody>';
$pdf->writeHTML($tbl_head_itema . $tbl_itema . $tbl_foot_itema, FALSE, false, true, false, '');
}
}
}
$pdf->lastPage();
ob_end_clean();
$pdf->Output();
Any time i try to generate a bill i keep getting that error and i dont know where i am wrong too...Can any body please help...