Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "Ordination Credentials":
- // hack -jd
- include ('class.ezpdf.php');
- $pdf =& new Cezpdf('LETTER','landscape');
- $pdf->selectFont('./fonts/mtcorsva.afm');
- $pdf->ezSetMargins(30,1,30,1);
- extract($_GET);
- $query = "
- SELECT o.date_purchased,
- fd.template_fn,
- o.customers_name,
- op.orders_id,
- opa.orders_products_id,
- products_name,
- op.products_quantity,
- field_name,
- products_options_values
- FROM orders_products AS op
- JOIN orders AS o ON o.orders_id = op.orders_id
- JOIN fulfillment_doc_products AS fdp ON fdp.product_id = op.products_id
- JOIN fulfillment_docs AS fd ON fd.doc_id = fdp.doc_id
- JOIN orders_products_attributes AS opa ON opa.orders_products_id = op.orders_products_id
- RIGHT JOIN fulfillment_doc_fields AS fdf ON fdf.products_options_name = opa.products_options
- AND fdf.doc_products_id = fdp.doc_products_id
- WHERE op.orders_id
- BETWEEN $in
- AND $out
- AND fd.doc_id = $doc_id
- ORDER BY o.orders_id, products_name, opa.orders_products_id, field_name, products_options_values";
- $result = mysql_query(trim($query)) or die("Broke the interwebs.");
- while ($query_data = mysql_fetch_array($result)) {
- //Standard db output filtering and processing into multi-dimensional array as seen above
- $creds[$query_data['orders_products_id']][$query_data['field_name']] = sanitize_db_output($query_data['products_options_values']);
- $creds[$query_data['orders_products_id']]['order_number'] = $query_data['orders_id'];
- $creds[$query_data['orders_products_id']]['products_quantity'] = $query_data['products_quantity'];
- }
- $started = false;
- foreach( $creds as $opt ) {
- if($started) { $pdf->ezNewPage(); } //create new page
- $started = true;
- $name = ucwords(strtolower($opt['name']));
- foreach (array('-', '\'',' Mc') as $delimiter) {
- if (strpos($name, $delimiter) == true) {
- $name = implode($delimiter, array_map('ucfirst', explode($delimiter, $name)));
- }
- }
- //all caps
- foreach (array('Ii', 'Iii') as $delimiter) {
- if (strpos($name, $delimiter) == true) {
- $name = implode($delimiter, array_map('strtoupper', explode($delimiter, $name)));
- }
- }
- if(strpos($name, ',') !== false) {
- foreach (array(', Jr', ', Sr') as $delimiter) {
- if (strpos($name, $delimiter) == false) {
- $name=implode(" ", array_reverse(explode(',', $name)));
- }
- }
- }
- $day = $opt["date-day"];
- if (0<>$day) {
- if (in_array($day% 100, range(11,13))) {
- $day .= 'th';
- } else {
- switch ( $day % 10 ) {
- case 1: $day .= 'st'; break;
- case 2: $day .= 'nd'; break;
- case 3: $day .= 'rd'; break;
- default: $day .= 'th'; break;
- }
- }
- }
- $month = $opt["date-month"];
- $year = $opt["date-year"];
- $ordid = $opt["order_number"];
- //create date
- if (!isset($yname)) { $yname = "370"; }
- if (!isset($ydate)) { $ydate = "289"; }
- $pdf->ezSetY($yname); $pdf->ezText($name,28,array('left'=>-35, 'justification'=>'center'));
- $pdf->ezSetY($ydate); $pdf->ezText($day,17,array('left'=>-220, 'justification'=>'center'));
- $pdf->ezSetY($ydate); $pdf->ezText($month,17,array('left'=>40, 'justification'=>'center'));
- $pdf->ezSetY($ydate); $pdf->ezText($year,17,array('left'=>375, 'justification'=>'center'));
- $pdf->ezSetY(96); $pdf->ezText($ordid,12,array('left'=>505, 'justification'=>'center'));
- }
- $pdfcode = $pdf->output();
- $file = './tmp/PDF_ordinations.pdf';
- if (file_exists($fname)) { unlink($fname); } //start with new file
- if (!file_exists($dir)) { mkdir ($dir,0777); } //dir create if not there
- $fname = $file;
- $fp = fopen($fname,'w');
- fwrite($fp,$pdfcode);
- fclose($fp);
- header('Location:'.$fname);
- break;
Advertisement
Add Comment
Please, Sign In to add comment