0) { $moneystr = getwords($milval) . " Million"; } // handle the thousands $workval = $numval - ($milval * 1000000); // get rid of millions $thouval = (integer)($workval / 1000); if($thouval > 0) { $workword = getwords($thouval); if ($moneystr == "") { $moneystr = $workword . " Thousand"; }else{ $moneystr .= " " . $workword . " Thousand"; } } // handle all the rest of the dollars $workval = $workval - ($thouval * 1000); // get rid of thousands $tensval = (integer)($workval); if ($moneystr == ""){ if ($tensval > 0){ $moneystr = getwords($tensval); }else{ $moneystr = "Zero"; } }else // non zero values in hundreds and up { $workword = getwords($tensval); $moneystr .= " " . $workword; } // plural or singular 'dollar' $workval = (integer)($numval); if ($workval == 1){ $moneystr .= " Dollar And "; }else{ $moneystr .= " Dollars And "; } // do the cents - use printf so that we get the // same rounding as printf $workstr = sprintf("%3.2f",$numval); // convert to a string $intstr = substr($workstr,strlen - 2, 2); $workint = (integer)($intstr); if ($workint == 0){ $moneystr .= "Zero"; }else{ $moneystr .= getwords($workint); } if ($workint == 1){ $moneystr .= " Cent"; }else{ $moneystr .= " Cents"; } // done return $moneystr; } //************************************************************* // this function creates word phrases in the range of 1 to 999. // pass it an integer value //************************************************************* function getwords($workval) { $numwords = array( 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine", 10 => "Ten", 11 => "Eleven", 12 => "Twelve", 13 => "Thirteen", 14 => "Fourteen", 15 => "Fifteen", 16 => "Sixteen", 17 => "Seventeen", 18 => "Eighteen", 19 => "Nineteen", 20 => "Twenty", 30 => "Thirty", 40 => "Forty", 50 => "Fifty", 60 => "Sixty", 70 => "Seventy", 80 => "Eighty", 90 => "Ninety"); // handle the 100's $retstr = ""; $hundval = (integer)($workval / 100); if ($hundval > 0){ $retstr = $numwords[$hundval] . " Hundred"; } // handle units and teens $workstr = ""; $tensval = $workval - ($hundval * 100); // dump the 100's // do the teens if (($tensval < 20) && ($tensval > 0)) { $workstr = $numwords[$tensval]; // got to break out the units and tens } else { $tempval = ((integer)($tensval / 10)) * 10; // dump the units $workstr = $numwords[$tempval]; // get the tens $unitval = $tensval - $tempval; // get the unit value if ($unitval > 0){ $workstr .= " " . $numwords[$unitval]; } } // join the parts together if ($workstr != "") { if ($retstr != "") { $retstr .= " " . $workstr; } else { $retstr = $workstr; } } return $retstr; } function UT_generatePDF($src, $filename="", $param="", $PDF_HEADER_LOGO="") { /**** PDF Setup ****/ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Unitech Corporation Limited'); $pdf->SetTitle($currTitle); $pdf->SetSubject($currTitle); $pdf->SetKeywords('Unitech Corporation Limited - ' . $currTitle); $pdf->setPageUnit("px"); $pdf->SetAutoPageBreak(true, 90); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(30, 20, -1); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('dejavusans', '', 10); //$pdf->SetFont('stsongstdlight', '', 9); //$pdf->SetFont('stsongstdlight', '', 9); // add a page $pdf->AddPage(); $pdf->writeHTML($src, true, false, true, false, ''); if ($param == "") { if ($filename == "") { $pdf->Output(mktime(), 'I'); } else { $pdf->Output($filename, 'D'); } } else { if ($filename == "") { $pdf->Output(mktime(), $param); } else { $pdf->Output($filename, $param); } } return ($filename); } ?>