Solved

using post to write PDF

Posted on 2008-06-11
42
830 Views
Last Modified: 2012-08-14
Hello I'm trying to a post var that looks like this and split it so i get the name and data out in to cells... This is out of flash and is used for three other things in there which is why i thought I could just use this single var..... Thanks for the help on this... it's one of my weak areas... thanks again...
jeremyBass


here is what the var is
$_POST["dataArray"]   =
{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}

so the cell should look something like this:

em_data_rec_v
      na
em_data_rec_d
      na
em_data_rec_di
      na
appstate_cb
      na
Job_Pick`0
      Unit Secretary Medical Unit
Job_Pick`1
      UNIT SECRETARY - SURGICAL UNIT
row|0
      employer
            asdf
      address
            asdf
      phone
            asdf
      supervisor
            asdf
      contact
            false
      wage
            asdf
      duties
            asdf
      from
            Thu Jun 5 00:00:00 GMT-0700 2008
      to
            Fri Jun 13 00:00:00 GMT-0700 2008
      reason
            asdf
row|1
      employer
            new Employee
      address
            asdf
      phone
            asdf
      supervisor
            asdf
      contact
            false
      wage
            asdf
      duties
            asdf
      from
            Mon Jun 9 00:00:00 GMT-0700 2008
      to
            Mon Jun 2 00:00:00 GMT-0700 2008
      reason
            asdf


<?php

//============================================================+

// File name   : example_011.php

// Begin       : 2008-03-04

// Last Update : 2008-05-28

// 

// Description : Example 011 for TCPDF class

//               Colored Table

// 

// Author: Nicola Asuni

// 

// (c) Copyright:

//               Nicola Asuni

//               Tecnick.com s.r.l.

//               Via Della Pace, 11

//               09044 Quartucciu (CA)

//               ITALY

//               www.tecnick.com

//               info@tecnick.com

//============================================================+
 

/**

 * Creates an example PDF TEST document using TCPDF

 * @package com.tecnick.tcpdf

 * @abstract TCPDF - Example: Colored Table

 * @author Nicola Asuni

 * @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - v - info@tecnick.com

 * @link http://tcpdf.org

 * @license http://www.gnu.org/copyleft/lesser.html LGPL

 * @since 2008-03-04

 */

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');
 
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file

	function LoadData($file) {

		//Read file lines

		$lines=file($file);

		$data=array();

		foreach($lines as $line)

		$data[]=explode(',',chop($_POST["dataArray"]));

		return $data;

	}

	

	//Colored table

	function ColoredTable($header,$data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);

			$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);

			$this->Ln();

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital','Area (sq km)','Pop. (thousands)');
 

//Data loading

$data=$pdf->LoadData('../cache/table_data_demo.txt');
 

// print colored table

$pdf->ColoredTable($header,$data);
 
 

// ---------------------------------------------------------
 

//Close and output PDF document

//$pdf->Output("example_011.pdf", "I");
 
 

//$sendTo = "*@roadrunner.com";

//$subject = "My Flash site reply";

//

//// variables are sent to this PHP page through

//// the POST method.  $_POST is a global associative array

//// of variables passed through this method.  From that, we

//// can get the values sent to this page from Flash and

//// assign them to appropriate variables which can be used

//// in the PHP mail() function.

//

//

//// header information not including sendTo and Subject

//// these all go in one variable.  First, include From:

//$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";

//// next include a replyto

//$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

//// often email servers won't allow emails to be sent to

//// domains other than their own.  The return path here will

//// often lift that restriction so, for instance, you could send

//// email to a hotmail account. (hosting provider settings may vary)

//// technically bounced email is supposed to go to the return-path email

//$headers .= "Return-path: " . $_POST["email"];

//

//// now we can add the content of the message to a body variable

//$message = Output("example_011.pdf", "I");

//

//

//// once the variables have been defined, they can be included

//// in the mail function call which will send you an email

//mail($sendTo, $subject, $message, $headers);

////============================================================+

//// END OF FILE                                                 

////============================================================+

// file that loads phpmailer and your smtp config info

// you set this up if you follow the phpmailer tutorial.

//require_once('lib/mailconfig.php');    
 

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/*/*/*/*/html/*/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("X@roadrunner.com", "John Doe");

$mail->From     = "nowens@sjrmc.org";

$mail->FromName = 'X';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}
 

if(!$mail->Send()) {

  echo 'Failed to send mail';

} else {

  echo 'Mail sent';

}

 
 
 
 
 

?>

Open in new window

0
Comment
Question by:jeremyBass26
  • 25
  • 16
42 Comments
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21817487
I'm surprised thatthis has gotten nothing... i think it's clear what i need... just a how to is what i am looking for not for some one to write it all.... anyways, an FYI... I will be out after 4pm PST and will be gone for my son's surgery for the next four days... so I will not be able to do much if any thing...
thanks again...
jeremyBass
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21849850
Does any body have any idea on this....

try it many ways.... Can't some one help out on this?

$string = split('[,]', $_POST["dataArray"]);

$length = count($string) / 2;
 
 
 
 

		$lines=file($file);

		$data=array();

		foreach($lines as $line)

		for ($i = 0; $i< $length; $i++) {

    array_push($data, array_splice($string, i*2, 2));

}

		return $data;

Open in new window

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21851108
Hello.

Just got the message. Looking into it, so please don't panic!!!!
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21851248
Ok.

The following script only splits the data up. Nothing more.

The data is all held in $a_Data.

The data is ...

Array
(
    [em_data_rec_v] => na
    [em_data_rec_d] => na
    [em_data_rec_di] => na
    [appstate_cb] => na
    [Job_Pick] => Array
        (
            [0] => Unit Secretary Medical Unit
            [1] => UNIT SECRETARY - SURGICAL UNIT
        )

    [0] => Array
        (
            [row] => 0
            [employer] => asdf
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Thu Jun 5 00:00:00 GMT-0700 2008
            [to] => Fri Jun 13 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

    [1] => Array
        (
            [row] => 1
            [employer] => new Employee
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Mon Jun 9 00:00:00 GMT-0700 2008
            [to] => Mon Jun 2 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

)

<?php
 

// Prepare the data.

$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary 
 

Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL 
 

UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 
 

00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new 
 

Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 
 

2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';
 

// Prepare the results.

$a_Data = array();
 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));
 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}
 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}
 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}
 

print_r($a_Data);

Open in new window

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21851261
Oh sorry. There aren't any line breaks in the first few lines.

Here it is ...
<?php
 

// Prepare the data.

$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';
 

// Prepare the results.

$a_Data = array();
 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));
 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}
 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}
 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}
 

print_r($a_Data);

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21851604
Hello, Thanks for the hand on this... So putting what you suggested i get...

////////////////////////////////////////////////////
/////////****From hard code /// don't get to see output on dynamic from form... only output
////////////////////////////////////////////////////
Array ( [em_data_rec_v] => na [em_data_rec_d] => na [em_data_rec_di] => na [appstate_cb] => na [Job_Pick] => Array ( [0] => Unit Secretary Medical Unit [1] => UNIT SECRETARY - SURGICAL UNIT ) [0] => Array ( [row] => 0 [employer] => asdf [address] => asdf [phone] => asdf [supervisor] => asdf [contact] => false [wage] => asdf [duties] => asdf [from] => Thu Jun 5 00:00:00 GMT-0700 2008 [to] => Fri Jun 13 00:00:00 GMT-0700 2008 [reason] => asdf ) [1] => Array ( [row] => 1 [employer] => new Employee [address] => asdf [phone] => asdf [supervisor] => asdf [contact] => false [wage] => asdf [duties] => asdf [from] => Mon Jun 9 00:00:00 GMT-0700 2008 [to] => Mon Jun 2 00:00:00 GMT-0700 2008 [reason] => asdf ) ) Mail sentresponse=passed&response=passedresponse=passed&response=passed



Now if I delete off the
$_POST['dataArray'] = '{em_data_rec_v:na},{...

and run the file... I get nothing... I know the post is getting over there... sooo.... I don't know lol...



And I get the PDF... but spotty with the values being place into rows and ... I'm really in an area of php that Ive not really done before, doing the cells and rows, and creating the PDF... right over my head....

I'm aiming at an output of a PDF, one that has each item and value in separate "tables" so then can be styled... make it look like a real application...


I think I'm fallowing what you are doing... I have to read up more on keys? ? ~  joys of learning...  Thanks for the hand on this...

jeremyBass

<?php

//============================================================+

// File name   : example_011.php

// Begin       : 2008-03-04

// Last Update : 2008-05-28

// 

// Description : Example 011 for TCPDF class

//               Colored Table

// 

// Author: Nicola Asuni

// 

// (c) Copyright:

//               Nicola Asuni

//               Tecnick.com s.r.l.

//               Via Della Pace, 11

//               09044 Quartucciu (CA)

//               ITALY

//               www.tecnick.com

//               info@tecnick.com

//============================================================+
 

/**

 * Creates an example PDF TEST document using TCPDF

 * @package com.tecnick.tcpdf

 * @abstract TCPDF - Example: Colored Table

 * @author Nicola Asuni

 * @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - v - info@tecnick.com

 * @link http://tcpdf.org

 * @license http://www.gnu.org/copyleft/lesser.html LGPL

 * @since 2008-03-04

 */

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');
 

 

// Prepare the results.

$a_Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));

 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}

 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}

 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}

 

print_r($a_Data);
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 
 
 

	

	//Colored table

	function ColoredTable($header,$a_Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($a_Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$this->Ln();

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 
 
 

// print colored table

$pdf->ColoredTable($header,$a_Data);
 
 

// ---------------------------------------------------------
 
 
 

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/*u/dou*n/html/Core/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("abass3@roadrunner.com", "John Doe");

$mail->From     = "n*@sjrmc.org";

$mail->FromName = 'SJRMC  Personnel Department';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}

$dataResponse_1 = "passed";

if(!$mail->Send()) {

  echo 'response=error';

  echo 'response=passed';

} else {

  echo 'Mail sent';

  echo 'response=passed';

  

print("&response=$dataResponse_1");

}

  echo 'response=passed';

print("&response=$dataResponse_1");
 
 
 

?>

Open in new window

example-011-FROM-HARD-CODE-POST.pdf
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21851632
Here is what the flash file is out putting via the POST.... incase this would drastically change things... I forgot that there has been some changes... didn't look like they are to different then the example but ... thought this wouldn't hurt...



FULL POST FROM FLASH
{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21851640
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21851713
also one more thing... if it would make the solution better... i can change the null values from "" to " " or "na"...

ie
{street:}

to
{street: } etc...
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21852549
Hello, so I made another pass... it was my idea to search the POST for the patterns and split them... I tried a very rough cut... but it didn't work... my be there is something to build off of... ?

Still can't post from the flash... or more to the point Im not seeing the post data in the PDF... ideas?

Thanks for the help...

<?php

//============================================================+

// File name   : example_011.php

// Begin       : 2008-03-04

// Last Update : 2008-05-28

// 

// Description : Example 011 for TCPDF class

//               Colored Table

// 

// Author: Nicola Asuni

// 

// (c) Copyright:

//               Nicola Asuni

//               Tecnick.com s.r.l.

//               Via Della Pace, 11

//               09044 Quartucciu (CA)

//               ITALY

//               www.tecnick.com

//               info@tecnick.com

//============================================================+
 

/**

 * Creates an example PDF TEST document using TCPDF

 * @package com.tecnick.tcpdf

 * @abstract TCPDF - Example: Colored Table

 * @author Nicola Asuni

 * @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - v - info@tecnick.com

 * @link http://tcpdf.org

 * @license http://www.gnu.org/copyleft/lesser.html LGPL

 * @since 2008-03-04

 */

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');

$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';
 
 

$pattern_NnV='/(?<name>\w+):(?<value>\w+)/';// $_NnV[0][0] should be '{em_data_rec_v:na}'

$pattern_job='/(?<name>\w+)|(?<value>\w+)/';

$pattern_PASTjob='/?<name>\w+|?<value>\w+,/';//////don't even know if itll work...

$search= $_POST['dataArray']

$matches_NnV = array();

$matches_job) = array();

$matches_PASTjob = array();

$NnV=preg_match_all($pattern_NnV,$search,$matches_NnV);

$job=preg_match_all($pattern_job,$search,$matches_job);

$PASTjob=preg_match_all($pattern_PASTjob,$search,$matches_PASTjob);
 
 

 

// Prepare the results.

$a_Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));
 

for (i=0; $i<$a_Split1.length; i++) {

 

 if ($NnV == $a_Split1){ // name:value pairs.

 list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

 } elseif ($job == $a_Split1) { // use name[x]=value.

 list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

 } elseif ($PASTjob == $a_Split1) { //multiple name|value pairs joined by ,

 $a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

}
 

 

print_r($a_Data);
 
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 
 
 

	

	//Colored table

	function ColoredTable($header,$a_Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($a_Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$this->Ln();

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 
 
 

// print colored table

$pdf->ColoredTable($header,$a_Data);
 
 

// ---------------------------------------------------------
 

//Close and output PDF document

//$pdf->Output("example_011.pdf", "I");
 
 

//$sendTo = "abass3@roadrunner.com";

//$subject = "My Flash site reply";

//

//// variables are sent to this PHP page through

//// the POST method.  $_POST is a global associative array

//// of variables passed through this method.  From that, we

//// can get the values sent to this page from Flash and

//// assign them to appropriate variables which can be used

//// in the PHP mail() function.

//

//

//// header information not including sendTo and Subject

//// these all go in one variable.  First, include From:

//$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";

//// next include a replyto

//$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

//// often email servers won't allow emails to be sent to

//// domains other than their own.  The return path here will

//// often lift that restriction so, for instance, you could send

//// email to a hotmail account. (hosting provider settings may vary)

//// technically bounced email is supposed to go to the return-path email

//$headers .= "Return-path: " . $_POST["email"];

//

//// now we can add the content of the message to a body variable

//$message = Output("example_011.pdf", "I");

//

//

//// once the variables have been defined, they can be included

//// in the mail function call which will send you an email

//mail($sendTo, $subject, $message, $headers);

////============================================================+

//// END OF FILE                                                 

////============================================================+

// file that loads phpmailer and your smtp config info

// you set this up if you follow the phpmailer tutorial.

//require_once('lib/mailconfig.php');    
 

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/d/o/u/dougbarton/html/Core/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("abass3@roadrunner.com", "John Doe");

$mail->From     = "nowens@sjrmc.org";

$mail->FromName = 'SJRMC  Personnel Department';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}

$dataResponse_1 = "passed";

if(!$mail->Send()) {

  echo 'response=error';

  echo 'response=passed';

} else {

  echo 'Mail sent';

  echo 'response=passed';

  

print("&response=$dataResponse_1");

}
 
 
 
 

?>

Open in new window

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21853522
I would STRONGLY recommend learning about serializing data.

This provides a standard way to encode and decode data.

If your data in flash is in an array, then does it have a JSON encoding facility?

Run the standalone snippet below to see JSON encoding/decoding in action.




To see if you are getting the POST ...

<?php
var_dump($_POST);
exit;
// the rest of your php script goes here. The above lines are a debug only - can be removed once you actually get $_POST populated correctly.




The output from the snippet is ...

This is the original value held in $_POST["dataArray"].
{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}

This is the data extracted from $_POST["dataArray"] as an array.
Array
(
    [em_data_rec_v] => na
    [em_data_rec_d] => na
    [em_data_rec_di] => na
    [appstate_cb] => na
    [Job_Pick] => Array
        (
            [0] => Unit Secretary Medical Unit
            [1] => UNIT SECRETARY - SURGICAL UNIT
        )

    [0] => Array
        (
            [row] => 0
            [employer] => asdf
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Thu Jun 5 00:00:00 GMT-0700 2008
            [to] => Fri Jun 13 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

    [1] => Array
        (
            [row] => 1
            [employer] => new Employee
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Mon Jun 9 00:00:00 GMT-0700 2008
            [to] => Mon Jun 2 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

)


This is the array converted to a JSON string.
{"em_data_rec_v":"na","em_data_rec_d":"na","em_data_rec_di":"na","appstate_cb":"na","Job_Pick":["Unit Secretary Medical Unit","UNIT SECRETARY - SURGICAL UNIT"],"0":{"row":"0","employer":"asdf","address":"asdf","phone":"asdf","supervisor":"asdf","contact":"false","wage":"asdf","duties":"asdf","from":"Thu Jun 5 00:00:00 GMT-0700 2008","to":"Fri Jun 13 00:00:00 GMT-0700 2008","reason":"asdf"},"1":{"row":"1","employer":"new Employee","address":"asdf","phone":"asdf","supervisor":"asdf","contact":"false","wage":"asdf","duties":"asdf","from":"Mon Jun 9 00:00:00 GMT-0700 2008","to":"Mon Jun 2 00:00:00 GMT-0700 2008","reason":"asdf"}}

This is the JSON string converted to an array.
Array
(
    [em_data_rec_v] => na
    [em_data_rec_d] => na
    [em_data_rec_di] => na
    [appstate_cb] => na
    [Job_Pick] => Array
        (
            [0] => Unit Secretary Medical Unit
            [1] => UNIT SECRETARY - SURGICAL UNIT
        )

    [0] => Array
        (
            [row] => 0
            [employer] => asdf
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Thu Jun 5 00:00:00 GMT-0700 2008
            [to] => Fri Jun 13 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

    [1] => Array
        (
            [row] => 1
            [employer] => new Employee
            [address] => asdf
            [phone] => asdf
            [supervisor] => asdf
            [contact] => false
            [wage] => asdf
            [duties] => asdf
            [from] => Mon Jun 9 00:00:00 GMT-0700 2008
            [to] => Mon Jun 2 00:00:00 GMT-0700 2008
            [reason] => asdf
        )

)


What I'm trying to show is that if you can provide the data in JSON encoded form, to get the data into an array in PHP is as simple as ...

$a_Data = json_decode($_POST['data'], True);

where $_POST['data'] points to the JSON encoded data.

Once we can get the data to PHP, we can move on. Until then, don't worry about the PDF.
<?php

 

// Prepare the data.

$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';

 

// Prepare the results.

$a_Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));

 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}

 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}

 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}

 

echo 'This is the original value held in $_POST["dataArray"].', PHP_EOL, $_POST['dataArray'], PHP_EOL, PHP_EOL;

echo 'This is the data extracted from $_POST["dataArray"] as an array.', PHP_EOL;

print_r($a_Data);

echo PHP_EOL, PHP_EOL;

echo 'This is the array converted to a JSON string.', PHP_EOL, json_encode($a_Data), PHP_EOL, PHP_EOL;

echo 'This is the JSON string converted to an array.', PHP_EOL;

print_r(json_decode(json_encode($a_Data), True));

echo PHP_EOL, PHP_EOL;

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21858921
I would STRONGLY recommend learning about serializing data.
////////I will do this asap

If your data in flash is in an array, then does it have a JSON encoding facility?
/////// sort of... I think... may-be not... would this be helpful?.... if you'd like to see the code for the form it can be viewed here:
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/ActionScript/Q_23486958.html

Run the standalone snippet below to see JSON encoding/decoding in action.
//////////////////////////
So i ran you suggestion... and got the out put and the JSON conversions... I think I'm started to see where your going with this...

but with,  var_dump($_POST);
exit;
 I can't run it from flash as I don't see the page, and no PDF gets emailed to me...  I think I need to create an out put so that I just get the post data in the PDF so it gets emailed for testing?...  Any ideas on that... ?


This is the data that is being posted from flash (look to below)  This is the complete list but it is dynamic and will change, which is why i was think about the :

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$pattern_NnV='/(?<name>\w+):(?<value>\w+)/';// $_NnV[0][0] should be '{em_data_rec_v:na}'
$pattern_job='/(?<name>\w+)|(?<value>\w+)/';
$pattern_PASTjob='/?<name>\w+|?<value>\w+,/';//////don't even know if itll work...
$search= $_POST['dataArray']
$matches_NnV = array();
$matches_job) = array();
$matches_PASTjob = array();
$NnV=preg_match_all($pattern_NnV,$search,$matches_NnV);
$job=preg_match_all($pattern_job,$search,$matches_job);
$PASTjob=preg_match_all($pattern_PASTjob,$search,$matches_PASTjob);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////
///the flash data......
/////////////////////
{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}



In short I'm open to what ever... this is a learning thing as the job it's self got a long extension so all is good for the time.... Let me know what you need me to do or anything... thanks again for the help

<?php

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');

// Prepare the data.

$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';

 

// Prepare the results.

$a_Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST['dataArray'], '{}'));

 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}

 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}

 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}

 

echo 'This is the original value held in $_POST["dataArray"].', PHP_EOL, $_POST['dataArray'], PHP_EOL, PHP_EOL;

echo 'This is the data extracted from $_POST["dataArray"] as an array.', PHP_EOL;

print_r($a_Data);

echo PHP_EOL, PHP_EOL;

echo 'This is the array converted to a JSON string.', PHP_EOL, json_encode($a_Data), PHP_EOL, PHP_EOL;

echo 'This is the JSON string converted to an array.', PHP_EOL;

print_r(json_decode(json_encode($a_Data), True));

echo PHP_EOL, PHP_EOL;
 
 
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 
 
 

	

	//Colored table

	function ColoredTable($header,$a_Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($a_Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$this->Ln();

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 
 
 

// print colored table

$pdf->ColoredTable($header,$a_Data);
 

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/d/o/u/dougbarton/html/Core/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("dbjeremy@cableone.net", "John Doe");

$mail->From     = "nowens@sjrmc.org";

$mail->FromName = 'SJRMC  Personnel Department';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}

$dataResponse_1 = "passed";

if(!$mail->Send()) {

  echo 'response=error';

  echo 'response=passed';

} else {

  echo 'Mail sent';

  echo 'response=passed';

  

print("&response=$dataResponse_1");

}
 

//dbjeremy@cableone.net

//abass3@roadrunner.com
 
 

?>

Open in new window

example-011.pdf
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21859548
Hello, so quick question on top of all this... serializing data would be helpful in doing the validation part, (there is going to be a passing of a array of the error-ed values back to flash stopping the PDF creation and mail)... I'm thinking I'm getting that out of all I have been reading... tough when Google is your handbook lol...
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21863624
http://docs.php.net/manual/en/ is THE manual.

Try this ...

<?php
file_put_contents('./post.txt', var_export($_POST, True));
exit;
// The rest of the script.



Again, this is only a debug. You won't get anything on the screen or a PDF. But the server should create a new file called post.txt which you can open in your browser.

Also, use Firefox with Firebug to see what communications take place. Not sure if net traffic is read for Flash.
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21867476
Sorry for the delay, I just got a new system and so i was down...

this
file_put_contents('./post.txt', var_export($_POST, True));
exit;


Outputs....
array (
  'dataArray' => '{name:value},{jobs_picks:{Job_Pick`0|Medical Transcriptionist Health Information Services}}',
)

I tried firebug... but it doesn't show the post, just the head, but it does show the net calls.... I'll try fiddler... see if that picks it up...


I am a little unsure why none of the other values are there... um.. and where to go from here... shoot what would you suggest?
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21870475
The values not being present is the responsibility of the client. In this case the Flash app. That's not in my skillset. Sorry.

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21871191
But that's the thing... They are being sent... I can even trace them out.... thats where I get that list from

http://www.experts-exchange.com/Q_23486958.html#a21858921

I'm not sure what the deals is... but for now can we work off this:


$_POST['dataArray'] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose}';

It's a good cross of what I need... I'll do testing and what not on the flash part on the side... this is the important thing at the moment to me...

The way I think it needs to work is that sort and pull data based on a pattern to over come the variable ordering of the data packages... so I'd just have to run through them all to get the tables of the data packages... thanks again for the help... I learn tons be going through this... sharpin the knife ah :-)
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21871579
ok... just got the post back... not sure what it was... I think i had a typo... i just couldn't see it... lol... retyped it out...

the contents :-)
'{name:value},{Applacation Date:Wed Jun 25 20:08:59 GMT-0700 2008},{emps_grd:{row|0,employer|Employer 3,address|,phone|,supervisor|,contact|,wage|,duties|,from|,to|,reason|},{row|1,employer|Employer 2,address|,phone|,supervisor|,contact|,wage|,duties|,from|,to|,reason|},{row|2,employer|Contact,address|,phone|,supervisor|,contact|,wage|,duties|,from|,to|,reason|}},{jobs_picks:{Job_Pick`NaN|undefined}},{name_title:Pick},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:Pick},{evenings:Pick},{nights:Pick},{high_school_from:undefined},{high_school_to:undefined},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:undefined},{college2_to:undefined},{college2_when:undefined},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:},{firstname:},{middlename:},{suffix:},{ssn:},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:},{part_time:},{temp:},{on_call:},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:},{avaiable_thru:},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:},{skill_accounting:},{skill_insure_bill:},{skill_credit_collect:},{skill_switchborad:},{skill_cashier:},{skill_10key:},{skill_invoicing:},{skill_reception:},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:},{skill_maintencraft_pl:},{skill_maintencraft_co:},{skill_maintencraft_pt:},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_N:},{rotate_shifts_N:},{weekends_N:},{relativeemplo_N:},{high_school_did_atend_N:},{college_did_atend_N:},{college2_did_atend_N:},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}'

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21871604
this is old looking out put... check pdf


up to date
<?php

//file_put_contents('./post.txt', var_export($_POST["dataArray"], True));

//$dataResponse = "passed";

//if($a_Data == $a_Data) {

//	print("&response=error");

//} else {

//	print("&response=passed");

//}

//exit;

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');
 

// Prepare the results.

$a_Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST["dataArray"], '{}'));

 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$a_Data[$s_Key] = $s_Value;

	}

 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$a_Data[$s_Key1][$s_Key2] = $s_Value;

	}

 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$a_Data[] = $a_Split3;

	}

 

echo 'This is the original value held in $_POST["dataArray"].', PHP_EOL, $_POST["dataArray"], PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the data extracted from $_POST["dataArray"] as an array.', PHP_EOL,'<br/><br/>';

print_r($a_Data);

echo PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the array converted to a JSON string.', PHP_EOL, json_encode($a_Data), PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the JSON string converted to an array.', PHP_EOL,'<br/><br/>';

print_r(json_decode(json_encode($a_Data), True));

echo PHP_EOL, PHP_EOL,'<br/><br/>';
 
 
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 
 
 

	

	//Colored table

	function ColoredTable($header,$a_Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($a_Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$this->Ln();

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 
 
 

// print colored table

$pdf->ColoredTable($header,$a_Data);
 

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/*/*/*/*/html/Core/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("abass3@roadrunner.com", "John Doe");

$mail->From     = "n*@sjrmc.org";

$mail->FromName = 'SJRMC  Personnel Department';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}

$dataResponse_1 = "passed";

if(!$mail->Send()) {

	print("&response=error");

} else {

	print("&response=passed");

}
 
 
 
 

?>

Open in new window

example-011.pdf
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21871796
Ok so i have made some more laps, well skips... check PDF :-)

Still need to run through what you were talking about but I'l closer lol

up to data code
<?php

//file_put_contents('./post.txt', var_export($_POST["dataArray"], True));

//$dataResponse = "passed";

//if($a_Data == $a_Data) {

//	print("&response=error");

//} else {

//	print("&response=passed");

//}

//exit;

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');
 

// Prepare the data.

//$_POST['dataArray'] = '{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}';

 

// Prepare the results.

$Data = array();

 

// Split on the , where it is },{

$a_Split1 = explode('},{', trim($_POST["dataArray"], '{}'));

 

// The first 4 entries are name:value pairs.

for ($i = 0 ; $i < 4 ; ++$i)

	{

	list($s_Key, $s_Value) = explode(':', $a_Split1[$i]);

	$Data[$s_Key] = $s_Value;

	}

 

// The next 2 rows use name[x]=value.

for ($i = 4 ; $i < 6 ; ++$i)

	{

	list($s_Keys, $s_Value) = explode('|', $a_Split1[$i]);

	list($s_Key1, $s_Key2) = explode('`', $s_Keys);

	$Data[$s_Key1][$s_Key2] = $s_Value;

	}

 

// The next 2 rows are essentially multiple name|value pairs joined by ,

for ($i = 6 ; $i < 8 ; ++$i)

	{

	$a_Split3 = array();

	$a_Split2 = explode(',', $a_Split1[$i]);

	foreach($a_Split2 as $s_Pair)

		{

		list($s_Key, $s_Value) = explode('|', $s_Pair);

		$a_Split3[$s_Key] = $s_Value;

		}

	$Data[] = $a_Split3;

	}

 

echo 'This is the original value held in $_POST["dataArray"].', PHP_EOL, $_POST["dataArray"], PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the data extracted from $_POST["dataArray"] as an array.', PHP_EOL,'<br/><br/>';

print_r($Data);

echo PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the array converted to a JSON string.', PHP_EOL, json_encode($Data), PHP_EOL, PHP_EOL,'<br/><br/>';

echo 'This is the JSON string converted to an array.', PHP_EOL,'<br/><br/>';

print_r(json_decode(json_encode($a_Data), True));

echo PHP_EOL, PHP_EOL,'<br/><br/>';
 
 
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 

function MultiRow($left, $right) {

		//MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0)

		

		$page_start = $this->getPage();

		$y_start = $this->GetY();

		

		// write the left cell

		$this->MultiCell(40, 0, $left, 1, 'R', 0, 2, 0 ,0, true, 0);

		

		$page_end_1 = $this->getPage();

		$y_end_1 = $this->GetY();

		

		$this->setPage($page_start);

		

		// write the right cell

		$this->MultiCell(0, 0, $right, 1, 'J', 0, 1, $this->GetX() ,$y_start, true, 0);

		

		$page_end_2 = $this->getPage();

		$y_end_2 = $this->GetY();

		

		// set the new row position by case

		if (max($page_end_1,$page_end_2) == $page_start) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 == $page_end_2) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 > $page_end_2) {

			$ynew = $y_end_1;

		} else {

			$ynew = $y_end_2;

		}

		

		$this->setPage(max($page_end_1,$page_end_2));

		$this->SetXY($this->GetX(),$ynew);

	}

	
 

	

	//Colored table

	function ColoredTable($header,$Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

		$this->Cell(0,12,"Example 001",1,1,'C');

		

		

	}

	

	

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 

$text =  $_POST["dataArray"];
 

for ($i=0; $i<1; $i++) {

	$pdf->MultiRow("Row ".($i+1), $text."\n");

}

// print colored table

//$pdf->ColoredTable($header,$Data);
 
 
 
 
 
 
 

////////////////////////////////

/////////EMAIL AREA

//////////////////////////////

// create your pdf file. maybe give it a unique filename.

$filename = "example_011.pdf";

// use for Upload folder >>>>>>>>>>>>>>>>>

$pdf->Output("/home/content/*/dougbarton/html/Core/uploads/apps/" . $filename,"F"); 

$pdf->Output($filename, "F");  

$mail = new PHPMailer();

$mail->MsgHTML($body);

$mail->AddAddress("abass3@roadrunner.com", "John Doe");

$mail->From     = "n*@sjrmc.org";

$mail->FromName = 'SJRMC  Personnel Department';

$mail->Subject  =  'Employment Application CC';

$mail->Body     =  'Thank you for submiting your application. REPLACE TEXT';

 

if(!$mail->AddAttachment("example_011.pdf"))	{

    echo "There was a problem attaching the pdf.";

    echo $mailer->ErrorInfo;

}

$dataResponse_1 = "passed";

if(!$mail->Send()) {

	print("&response=error");

} else {

	print("&response=passed");

}
 

//dbjeremy@cableone.net

//abass3@roadrunner.com
 
 

?>

Open in new window

example-011.pdf
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 40

Expert Comment

by:RQuadling
ID: 21872877
It looks like the format has changed in the data. I'll need a little while to check this out. Having a standardised format (JSON would be ideal) is well worth hunting down in your actionscript (I assume that's what you are using).
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21872879
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21875937
Well... I did not change the way the data has been formed; though the solution can not be based of position, only by pattern... but I would be more then happy to format the output data any which way, but I can not add a class to the file, it is all ready 177kb, I am trying hard to get that down lower then it is... not higher It was at 200kb to start before 2 rounds of refactoring... but since it is my code forming all that, I can have it out put any way that would help this solution come to fruition.... just let me know.... I will work with you not against you....Thank you again for the hand on this& Im learning grips&
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21878699
If you look at the data you supplied in the question ...

{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:na},{Job_Pick`0|Unit Secretary Medical Unit},{Job_Pick`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}


Now, in the last message with data it is ...

{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}



As you can see, quite different.

Are you creating this data as a string, or is this a built in call within the flash environment?

I'll give it another go. I'm at home at the moment and in the middle of watching Heroes, so later.
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21879469
Well I know that... lol... but I said that the data sets would switch position and that the first was only an example... they are uniformed to a point so thats why the comment about them basicly begin the same... sorry i should have been more clear from the start....

anyways

Are you creating this data as a string
/////////
yes i whave a switch case that runs through all components and adds them to an array, then I post the array to the php using loadAndSend so that I can get a valdation process in the php the makes the PDF and mails it... right now it's responds to the flash with passed or error... but in the end i thought that I could pass an array back to a function so i can highlight the errored areas... that is about it... I'm in meetings for the next few hours... but i'll be back soon :) thanks again for the help here....
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21879868
Based on the format of the large example of data, the following script splits it into a usable PHP array.

The script produces an array like this ...

array (
  'name' => 'value',
  'Applacation Date' => 'Mon Jun 23 17:36:26 GMT-0700 2008',
  'emps_grd' =>
  array (
    0 =>
    array (
      'row' => '0',
      'employer' => 'asdfasdf',
      'address' => 'asdfasdf',
      'phone' => 'asdf',
      'supervisor' => 'asdf',
      'contact' => 'false',
      'wage' => '',
      'duties' => '',
      'from' => 'Mon Jun 2 00:00:00 GMT-0700 2008',
      'to' => '',
      'reason' => '',
    ),
    1 =>
    array (
      'row' => '1',
      'employer' => 'new Employee',
      'address' => 'asdfasdf',
      'phone' => '',
      'supervisor' => 'asdfadf',
      'contact' => 'false',
      'wage' => 'asdfasdf',
      'duties' => '',
      'from' => 'Tue Jun 3 00:00:00 GMT-0700 2008',
      'to' => 'Thu Jun 19 00:00:00 GMT-0700 2008',
      'reason' => '',
    ),
  ),
  'jobs_picks' =>
  array (
    0 =>
    array (
      'Job_Pick`0' => 'CNA - MEDICAL UNIT',
    ),
    1 =>
    array (
      'Job_Pick`1' => 'Unit Secretary / CNA Mental Health Center',
    ),
    2 =>
    array (
      'Job_Pick`2' => 'CREDIT COUNSELOR',
    ),
    3 =>
    array (
      'Job_Pick`3' => 'UNIT SECRETARY - ICU/PCU',
    ),
    4 =>
    array (
      'Job_Pick`4' => 'CNA - SURGICAL UNIT',
    ),
    5 =>
    array (
      'Job_Pick`5' => 'CNA - SURGICAL UNIT',
    ),
  ),
  'name_title' => 'Mr',
  'urstate' => 'Choose',
  'primphonetype' => 'Choose',
  'altphonetype' => 'Choose',
  'emerg_contype' => 'Choose',
  'days' => '3rd',
  'evenings' => '1st',
  'nights' => '2nd',
  'high_school_from' => 'Mon Jun 9 00:00:00 GMT-0700 2008',
  'high_school_to' => 'Tue Jun 17 00:00:00 GMT-0700 2008',
  'high_school_when' => 'undefined',
  'prev_emplofrom' => 'undefined',
  'prev_emploto' => 'undefined',
  'skill_medterm_date' => 'undefined',
  'college_from' => 'undefined',
  'college_to' => 'undefined',
  'college_when' => 'undefined',
  'college2_from' => 'Tue Jun 10 00:00:00 GMT-0700 2008',
  'college2_to' => 'Tue Jun 17 00:00:00 GMT-0700 2008',
  'college2_when' => 'Thu Jun 19 00:00:00 GMT-0700 2008',
  'college3_from' => 'undefined',
  'college3_to' => 'undefined',
  'college3_when' => 'undefined',
  'college4_from' => 'undefined',
  'college4_to' => 'undefined',
  'college4_when' => 'undefined',
  'current_ed_completdate' => 'undefined',
  'license_xdate' => 'undefined',
  'license2_xdate' => 'undefined',
  'em_data_rec_brith' => 'undefined',
  'lastname' => 'Dude',
  'firstname' => 'Man',
  'middlename' => 'Hit',
  'suffix' => 'sr',
  'ssn' => '5946565632',
  'street' => false,
  'city' => false,
  'zip' => false,
  'primphone' => false,
  'altphone' => false,
  'email' => false,
  'emerg_con' => false,
  'emerg_connumber' => false,
  'learnabout_job_othertxt' => false,
  'relative_name' => false,
  'relative_rela' => false,
  'undefined' => 'undefined',
  'high_school_name' => false,
  'high_school_loca' => false,
  'college_name' => false,
  'college_loca' => false,
  'college2_name' => false,
  'college2_loca' => false,
  'college3_name' => false,
  'college3_loca' => false,
  'college4_name' => false,
  'college4_loca' => false,
  'college_major' => false,
  'college2_major' => false,
  'college3_major' => false,
  'college4_major' => false,
  'current_ed_name' => false,
  'current_ed_loca' => false,
  'current_ed_study' => false,
  'license_type' => false,
  'license_number' => false,
  'license_state' => false,
  'license2_type' => false,
  'license2_number' => false,
  'license2_state' => false,
  'skill_typn_wpm' => false,
  'skill_medterm_school' => false,
  'skill_monitors_type' => false,
  'leg_othername_1' => false,
  'leg_othername_2' => false,
  'leg_othername_3' => false,
  'leg_othername_4' => false,
  'leg_able_work_note' => false,
  'leg_convic_note' => false,
  'em_data_rec_notes' => false,
  'digitalsign' => false,
  'full_time' => 'yes',
  'part_time' => 'Yes',
  'temp' => false,
  'on_call' => 'Yes',
  'avaiable_mon' => false,
  'avaiable_tus' => false,
  'avaiable_wed' => 'Yes',
  'avaiable_thru' => 'Yes',
  'avaiable_fri' => false,
  'avaiable_sat' => false,
  'avaiable_sun' => 'Yes',
  'ssnoptout' => false,
  'learnabout_job_ad' => false,
  'learnabout_job_friend' => false,
  'learnabout_job_other' => false,
  'skill_typn' => false,
  'skill_dataentry' => false,
  'skill_medterm' => false,
  'skill_medtrans' => 'Yes',
  'skill_accounting' => 'Yes',
  'skill_insure_bill' => 'Yes',
  'skill_credit_collect' => 'Yes',
  'skill_switchborad' => false,
  'skill_cashier' => false,
  'skill_10key' => 'Yes',
  'skill_invoicing' => false,
  'skill_reception' => 'Yes',
  'skill_floorcare_man' => false,
  'skill_floorcare_mac' => false,
  'skill_dishman' => false,
  'skill_dishindus' => false,
  'skill_linen' => false,
  'skill_sterilizer' => false,
  'skill_autoclave' => false,
  'skill_sewing' => false,
  'skill_maintengen' => false,
  'skill_maintencraft' => false,
  'skill_maintencraft_el' => 'Yes',
  'skill_maintencraft_pl' => 'Yes',
  'skill_maintencraft_co' => 'Yes',
  'skill_maintencraft_pt' => 'Yes',
  'skill_steriletechique' => false,
  'skill_vitalsigns' => false,
  'skill_charting' => false,
  'skill_pre_opprep' => false,
  'skill_isolation' => false,
  'skill_cateterization' => false,
  'skill_coronarycare' => false,
  'skill_intensive' => false,
  'skill_monitors' => false,
  'skill_orthopedic' => false,
  'skill_pediatic' => false,
  'skill_obstertrics' => false,
  'skill_medical' => false,
  'skill_surgical' => false,
  'skill_geriatric' => false,
  'skill_oncology' => false,
  'skill_family_homecare' => false,
  'em_data_rec_w' => false,
  'em_data_rec_b' => false,
  'em_data_rec_h' => false,
  'em_data_rec_a' => false,
  'em_data_rec_a_i' => false,
  'em_data_rec_v' => false,
  'em_data_rec_d' => false,
  'em_data_rec_di' => false,
  'appstate_cb' => false,
  'drugtest' => false,
  'digital_agree' => false,
  'Em_HIS_Con_Y' => 'Yes',
  'rotate_shifts_N' => 'No',
  'weekends_Y' => 'Yes',
  'relativeemplo_N' => false,
  'high_school_did_atend_N' => 'No',
  'college_did_atend_Y' => 'Yes',
  'college2_did_atend_Y' => 'Yes',
  'college3_did_atend_N' => false,
  'college4_did_atend_N' => false,
  'current_ed_N' => false,
  'licensed_N' => false,
  'app4license_N' => false,
  'leg_othername_N' => false,
  'leg_able_work_N' => false,
  'leg_visa_N' => false,
  'em_data_rec_sex_M' => false,
  'leg_convic_N' => false,
  '_18_N' => false,
  'prev_emplo_N' => false,
)
<?php
 

// Prepare the data.

$_POST['dataArray'] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}';
 

/*

{name:value},{emps_grd:{row|0,employer|asdfasdf,reason|},{row|1,employer|new Employee,address|asdfasdf,reason|}},

*/
 

function splitData(array $a_Data)

	{

	static $i_Level = 0;
 

	++$i_Level;
 

	$a_Results = array();
 

	foreach($a_Data as $s_Entry)

		{

		switch($i_Level)

			{

			case 1 :

				$s_Entry = substr($s_Entry, 1, -1);

				$i_SplitPos = strpos($s_Entry, ':');

				$s_Key = substr($s_Entry, 0, $i_SplitPos);

				$s_Value = substr($s_Entry, 1 + $i_SplitPos);

				break;

			case 2 :

				$a_Results[] = splitData(explode(',', $s_Entry));

				break;

			case 3:

				list($s_Key, $s_Value) = explode('|', $s_Entry);

				break;

			}
 

		if ('{' === $s_Value{0})

			{

			$a_Results[$s_Key] = splitData(preg_split('`(?:}),(?:{)`', substr($s_Value, 1, -1)));

			}

		else

			{

			if (2 !== $i_Level)

				{

				$a_Results[$s_Key] = $s_Value;

				}

			}

		}
 

	--$i_Level;
 

	return $a_Results;

	}
 

preg_match_all( '`({[^{},]*?:{.*?}}|{[^{},]*?:.*?})`sim', $_POST['dataArray'], $a_Matches);
 

$a_Data = splitData($a_Matches[1]);
 

var_export($a_Data);

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21881100
Heck I must be super slow today... but I'm having the damnest time getting the stuff out of the array you built... great work there by the way... I think I need to read more but I'm seeing what you are doing... thanks for the help i'm learning alot on this...  so was trying to get the data out using anything I know... got the right number of rows but never the data...

for ($i=0; $i<count($a_Data); $i++) {
      $pdf->MultiRow("Row ".($i+1), $a_Data[i]."\n");
      echo '1111111111111111111in $a_Data.',$a_Data[i],'<br/><br/>';
}

and so on... not sure what to do there...

the thought was it'd look kind like what you were said the array was set up it's self... I put a text file showing what it may look like... so I was thinkin that may-be... the case swicth would need to be used to do this?  ???  thats my though on this at this point, but I'll wait to do anything as I want to read up on what you did... may-be you'll have a grand idea like the last little jewel... it's funny i think one of my major issues is that i'm learning actionscript (which pretty good with) javascript, php and asp at the same time... anyways ... thanks for the help here.....








// Prepare the data.

$_POST["dataArray"] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}';

 

/*

{name:value},{emps_grd:{row|0,employer|asdfasdf,reason|},{row|1,employer|new Employee,address|asdfasdf,reason|}},

*/
 

function splitData(array $a_Data)

	{

	static $i_Level = 0;

 

	++$i_Level;

 

	$a_Results = array();

 

	foreach($a_Data as $s_Entry)

		{

		switch($i_Level)

			{

			case 1 :

				$s_Entry = substr($s_Entry, 1, -1);

				$i_SplitPos = strpos($s_Entry, ':');

				$s_Key = substr($s_Entry, 0, $i_SplitPos);

				$s_Value = substr($s_Entry, 1 + $i_SplitPos);

				break;

			case 2 :

				$a_Results[] = splitData(explode(',', $s_Entry));

				break;

			case 3:

				list($s_Key, $s_Value) = explode('|', $s_Entry);

				break;

			}

 

		if ('{' === $s_Value{0})

			{

			$a_Results[$s_Key] = splitData(preg_split('`(?:}),(?:{)`', substr($s_Value, 1, -1)));

			}

		else

			{

			if (2 !== $i_Level)

				{

				$a_Results[$s_Key] = $s_Value;

				}

			}

		}

 

	--$i_Level;

 

	return $a_Results;

	}

 

preg_match_all( '`({[^{},]*?:{.*?}}|{[^{},]*?:.*?})`sim', $_POST["dataArray"], $a_Matches);

 

$a_Data = splitData($a_Matches[1]);

 

var_export($a_Data);
 

echo '333333333333333333333333333333333333333333333333333333333in $_POST["dataArray"].',var_export($a_Data),'<br/><br/>';
 

echo 'This is the original value held in $_POST["dataArray"].', PHP_EOL, $_POST["dataArray"], PHP_EOL, PHP_EOL,'<br/><br/>';

//echo 'This is the data extracted from $_POST["dataArray"] as an array.', PHP_EOL,'<br/><br/>';

//print_r($a_Data);

//echo PHP_EOL, PHP_EOL,'<br/><br/>';

//echo 'This is the array converted to a JSON string.', PHP_EOL, json_encode($a_Data), PHP_EOL, PHP_EOL,'<br/><br/>';

//echo 'This is the JSON string converted to an array.', PHP_EOL,'<br/><br/>';

//print_r(json_decode(json_encode($a_Data), True));

//echo PHP_EOL, PHP_EOL,'<br/><br/>';
 
 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

	

	//Load table data from file
 

		//Read file lines

		
 

function MultiRow($left, $right) {

		//MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0)

		

		$page_start = $this->getPage();

		$y_start = $this->GetY();

		

		// write the left cell

		$this->MultiCell(40, 0, $left, 1, 'R', 0, 2, 0 ,0, true, 0);

		

		$page_end_1 = $this->getPage();

		$y_end_1 = $this->GetY();

		

		$this->setPage($page_start);

		

		// write the right cell

		$this->MultiCell(0, 0, $right, 1, 'J', 0, 1, $this->GetX() ,$y_start, true, 0);

		

		$page_end_2 = $this->getPage();

		$y_end_2 = $this->GetY();

		

		// set the new row position by case

		if (max($page_end_1,$page_end_2) == $page_start) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 == $page_end_2) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 > $page_end_2) {

			$ynew = $y_end_1;

		} else {

			$ynew = $y_end_2;

		}

		

		$this->setPage(max($page_end_1,$page_end_2));

		$this->SetXY($this->GetX(),$ynew);

	}

	
 

	

	//Colored table

	function ColoredTable($header,$a_Data) {

		//Colors, line width and bold font

		$this->SetFillColor(255,0,0);

		$this->SetTextColor(255);

		$this->SetDrawColor(128,0,0);

		$this->SetLineWidth(.3);

		$this->SetFont('','B');

		//Header

		$w=array(40,35,40,45);

		for($i=0;$i<count($header);$i++)

		$this->Cell($w[$i],7,$header[$i],1,0,'C',1);

		$this->Ln();

		//Color and font restoration

		$this->SetFillColor(224,235,255);

		$this->SetTextColor(0);

		$this->SetFont('');

		//Data

		$fill=0;

		foreach($a_Data as $row) {

			$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);

			$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

			$fill=!$fill;

		}

		$this->Cell(array_sum($w),0,'','T');

		$this->Cell(0,12,"Example 001",1,1,'C');

		

		

	}

	

	

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

//Data loading..................don't need this.. using 

$text =  var_export($a_Data);
 

for ($i=0; $i<count($a_Data); $i++) {

	$pdf->MultiRow("Row ".($i+1), $a_Data[i]."\n");

	echo '1111111111111111111in $a_Data.',$a_Data[i],'<br/><br/>';

}

// print colored table

$pdf->ColoredTable($header,$a_Data);

Open in new window

tableStructure.txt
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21882198
for($i_Counter = 0, $i_Max = count($a_Array) ; $i_Counter < $i_Max ; ++$i_Counter)
 {
 echo $a_Array[$i_Counter], PHP_EOL;
 }

The above code only works with numeric indicies.

As the array is a name/value pair (in PHP terms an associative array), you need to use ...

foreach($a_Array as $s_Key => $m_Value)
 {
 // Is $m_Value an array?
 if (is_array($m_Value))
   {
   foreach($m_Value as $s_SubKey => $m_SubValue)
    {
    echo "a_Array[$s_Key][$s_SubKey] = $m_SubValue", PHP_EOL;
    }
   }
 else
  {
  echo "a_Array[$s_Key] = $m_Value", PHP_EOL;
  }
 }


sort of thing.

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21882310
Rock on... this is what i came out with ....


foreach($a_Data  as $s_Key => $m_Value)
 {
 // Is $m_Value an array?
 if (is_array($m_Value))
   {
   foreach($m_Value as $s_SubKey => $m_SubValue)
    {
      $pdf->MultiRow("$s_Key - $s_SubKey".($i+1), $m_SubValue."\n\n");
    }
   }
 else
  {
  $pdf->MultiRow("$s_Key".($i+1), $m_Value."\n\n");
  }
 }

there are still arrays for the ?subValue?

so would it be like this..... I not getting it to work ... but may-be you know what i was tring to do.... basicaly drill down the same way...
foreach($a_Data  as $s_Key => $m_Value)
 {
 // Is $m_Value an array?
 if (is_array($m_Value))
   {
   foreach($m_Value as $s_SubKey => $m_SubValue)
    {
      $pdf->MultiRow("$s_Key - $s_SubKey".($i+1), foreach($m_SubValue  as $s_Key => $m_Value)
 {
 // Is $m_Value an array?
 if (is_array($m_Value))
   {
   foreach($m_Value as $s_SubKey => $m_SubValue)
    {
      $pdf->MultiRow("$s_Key - $s_SubKey".($i+1), $m_SubValue."\n\n");
    }
   }
 else
  {
  $pdf->MultiRow("$s_Key".($i+1), $m_Value."\n\n");
  }
 }
."\n\n");
    }
   }
 else
  {
  $pdf->MultiRow("$s_Key".($i+1), $m_Value."\n\n");
  }
 }
example-011.pdf
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21882505
So an recursive approach is needed.

Can you tell me the PDF calls you need to create a table within a table or do you want to have it looking like this ...

[key] [value]
[key] [key] [value]
[key] [key] [key] [value]

sort of thing?

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21882635
these are the only table calls i could find...

/////////////////////////////////////////
////////////////////////////////////////
/**
* @var HTML PARSER: true in case of ordered list (OL), false otherwise.
* @access protected
*/
var $listordered = false;

/**
* @var HTML PARSER: count list items.
* @access protected
*/
var $listcount = 0;

/**
* @var HTML PARSER: size of table border.
* @access protected
*/
var $tableborder = 0;

/**
* @var HTML PARSER: 'th' or 'td' ath the beginning of HTML cell.
* @access protected
*/
var $tdbegin = false;

/**
* @var HTML PARSER: table width.
* @access protected
*/
var $tdwidth = 0;

/**
* @var HTML PARSER: table height.
* @access protected
*/
var $tdheight = 0;

/**
* @var HTML PARSER: table align.
* @access protected
*/
var $tdalign = "L";

////////////////////////////////////////////////////////
//////////////////////////////////////////////////////

I'm looking to end up with a structure like
----------------
| name | value |
----------------

--------------------------------------------------------
| Applacation Date | Mon Jun 23 17:36:26 GMT-0700 2008 |
--------------------------------------------------------

------------------------------------------------------------
| emps_grd | 0          |                                  |
|          | row        | 0                                |
|          | employer   | asdfasdf                         |
|          | address    | asdfasdf                         |
|          | phone      | asdfasdf                         |
|          | supervisor | asdfasdf                         |
|          | contact    | 208-208-9999                     |
|          | wage       | 99.99                            |
|          | duties     | asdfasdf                     |
|          | from       | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | to         | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | reason     | asdfasdf                         |
------------------------------------------------------------
| emps_grd | 1          |                                  |
|          | row        | 1                                |
|          | employer   | asdfasdf                         |
|          | address    | asdfasdf                         |
|          | phone      | asdfasdf                         |
|          | supervisor | asdfasdf                         |
|          | contact    | 208-208-9999                     |
|          | wage       | 99.99                            |
|          | duties     | asdfasdf                     |
|          | from       | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | to         | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | reason     | asdfasdf                         |
------------------------------------------------------------
| emps_grd | 2          |                                  |
|          | row        | 2                                |
|          | employer   | asdfasdf                         |
|          | address    | asdfasdf                         |
|          | phone      | asdfasdf                         |
|          | supervisor | asdfasdf                         |
|          | contact    | 208-208-9999                     |
|          | wage       | 99.99                            |
|          | duties     | asdfasdf                     |
|          | from       | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | to         | Mon Jun 2 00:00:00 GMT-0700 2008 |
|          | reason     | asdfasdf                         |
------------------------------------------------------------

----------------------------------------------------------
| jobs_picks |                                           |
----------------------------------------------------------
| Job_Pick`0 | CNA - MEDICAL UNIT                        |
----------------------------------------------------------
| Job_Pick`1 | Unit Secretary / CNA Mental Health Center |
----------------------------------------------------------
| Job_Pick`2 | CREDIT COUNSELOR                          |
----------------------------------------------------------
| Job_Pick`3 | UNIT SECRETARY - ICU/PCU                  |
----------------------------------------------------------
| Job_Pick`4 | CNA - SURGICAL UNIT                       |
----------------------------------------------------------
| Job_Pick`5 | CNA - SURGICAL UNIT                       |
----------------------------------------------------------

-------------------
| name_title | Mr |
-------------------

--------------------
| urstate | Choose |
--------------------

--------------------------
| primphonetype | Choose |
--------------------------

etc............




I think that would be the

[key] [value]
[key] [value]

[key]
    [key] [value]
    [key] [value]

[key]
     [key]
          [key] [value]
     [key]
          [key] [value]






????? I think that is what it would be....

here is the whole list...
class TCPDF {

		

		// protected or Protected properties
 

		/**

		* @var current page number

		* @access protected

		*/

		var $page;

		

		/**

		* @var current object number

		* @access protected

		*/

		var $n;
 

		/**

		* @var array of object offsets

		* @access protected

		*/

		var $offsets;
 

		/**

		* @var buffer holding in-memory PDF

		* @access protected

		*/

		var $buffer;
 

		/**

		* @var array containing pages

		* @access protected

		*/

		var $pages;
 

		/**

		* @var current document state

		* @access protected

		*/

		var $state;
 

		/**

		* @var compression flag

		* @access protected

		*/

		var $compress;
 

		/**

		* @var default page orientation (P = Portrait, L = Landscape)

		* @access protected

		*/

		var $DefOrientation;
 

		/**

		* @var current page orientation (P = Portrait, L = Landscape)

		* @access protected

		*/

		var $CurOrientation;
 

		/**

		* @var array indicating page orientation changes

		* @access protected

		*/

		var $OrientationChanges;
 

		/**

		* @var scale factor (number of points in user unit)

		* @access protected

		*/

		var $k;
 

		/**

		* @var width of page format in points

		* @access protected

		*/

		var $fwPt;
 

		/**

		* @var height of page format in points

		* @access protected

		*/

		var $fhPt;
 

		/**

		* @var width of page format in user unit

		* @access protected

		*/

		var $fw;
 

		/**

		* @var height of page format in user unit

		* @access protected

		*/

		var $fh;
 

		/**

		* @var current width of page in points

		* @access protected

		*/

		var $wPt;
 

		/**

		* @var current height of page in points

		* @access protected

		*/

		var $hPt;
 

		/**

		* @var current width of page in user unit

		* @access protected

		*/

		var $w;
 

		/**

		* @var current height of page in user unit

		* @access protected

		*/

		var $h;
 

		/**

		* @var left margin

		* @access protected

		*/

		var $lMargin;
 

		/**

		* @var top margin

		* @access protected

		*/

		var $tMargin;
 

		/**

		* @var right margin

		* @access protected

		*/

		var $rMargin;
 

		/**

		* @var page break margin

		* @access protected

		*/

		var $bMargin;
 

		/**

		* @var cell internal padding

		* @access protected

		*/

		var $cMargin;
 

		/**

		* @var current horizontal position in user unit for cell positioning

		* @access protected

		*/

		var $x;
 

		/**

		* @var current vertical position in user unit for cell positioning

		* @access protected

		*/

		var $y;
 

		/**

		* @var height of last cell printed

		* @access protected

		*/

		var $lasth;
 

		/**

		* @var line width in user unit

		* @access protected

		*/

		var $LineWidth;
 

		/**

		* @var array of standard font names

		* @access protected

		*/

		var $CoreFonts;
 

		/**

		* @var array of used fonts

		* @access protected

		*/

		var $fonts;
 

		/**

		* @var array of font files

		* @access protected

		*/

		var $FontFiles;
 

		/**

		* @var array of encoding differences

		* @access protected

		*/

		var $diffs;
 

		/**

		* @var array of used images

		* @access protected

		*/

		var $images;
 

		/**

		* @var array of links in pages

		* @access protected

		*/

		var $PageLinks;
 

		/**

		* @var array of internal links

		* @access protected

		*/

		var $links;
 

		/**

		* @var current font family

		* @access protected

		*/

		var $FontFamily;
 

		/**

		* @var current font style

		* @access protected

		*/

		var $FontStyle;

		

		/**

		* @var current font ascent (distance between font top and baseline)

		* @access protected

		* @since 2.8.000 (2007-03-29)

		*/

		var $FontAscent;

		

		/**

		* @var current font descent (distance between font bottom and baseline)

		* @access protected

		* @since 2.8.000 (2007-03-29)

		*/

		var $FontDescent;
 

		/**

		* @var underlining flag

		* @access protected

		*/

		var $underline;
 

		/**

		* @var current font info

		* @access protected

		*/

		var $CurrentFont;
 

		/**

		* @var current font size in points

		* @access protected

		*/

		var $FontSizePt;
 

		/**

		* @var current font size in user unit

		* @access protected

		*/

		var $FontSize;
 

		/**

		* @var commands for drawing color

		* @access protected

		*/

		var $DrawColor;
 

		/**

		* @var commands for filling color

		* @access protected

		*/

		var $FillColor;
 

		/**

		* @var commands for text color

		* @access protected

		*/

		var $TextColor;
 

		/**

		* @var indicates whether fill and text colors are different

		* @access protected

		*/

		var $ColorFlag;
 

		/**

		* @var word spacing

		* @access protected

		*/

		var $ws;
 

		/**

		* @var automatic page breaking

		* @access protected

		*/

		var $AutoPageBreak;
 

		/**

		* @var threshold used to trigger page breaks

		* @access protected

		*/

		var $PageBreakTrigger;
 

		/**

		* @var flag set when processing footer

		* @access protected

		*/

		var $InFooter;
 

		/**

		* @var zoom display mode

		* @access protected

		*/

		var $ZoomMode;
 

		/**

		* @var layout display mode

		* @access protected

		*/

		var $LayoutMode;
 

		/**

		* @var title

		* @access protected

		*/

		var $title;
 

		/**

		* @var subject

		* @access protected

		*/

		var $subject;
 

		/**

		* @var author

		* @access protected

		*/

		var $author;
 

		/**

		* @var keywords

		* @access protected

		*/

		var $keywords;
 

		/**

		* @var creator

		* @access protected

		*/

		var $creator;
 

		/**

		* @var alias for total number of pages

		* @access protected

		*/

		var $AliasNbPages;
 

		/**

		* @var right-bottom corner X coordinate of inserted image

		* @since 2002-07-31

		* @author Nicola Asuni

		* @access protected

		*/

		var $img_rb_x;
 

		/**

		* @var right-bottom corner Y coordinate of inserted image

		* @since 2002-07-31

		* @author Nicola Asuni

		* @access protected

		*/

		var $img_rb_y;
 

		/**

		* @var image scale factor

		* @since 2004-06-14

		* @author Nicola Asuni

		* @access protected

		*/

		var $imgscale = 1;
 

		/**

		* @var boolean set to true when the input text is unicode (require unicode fonts)

		* @since 2005-01-02

		* @author Nicola Asuni

		* @access protected

		*/

		var $isunicode = false;
 

		/**

		* @var PDF version

		* @since 1.5.3

		* @access protected

		*/

		var $PDFVersion = "1.5";

		

		

		// ----------------------

		

		/**

		 * @var Minimum distance between header and top page margin.

		 * @access protected

		 */

		var $header_margin;

		

		/**

		 * @var Minimum distance between footer and bottom page margin.

		 * @access protected

		 */

		var $footer_margin;

		

		/**

		 * @var original left margin value

		 * @access protected

		 * @since 1.53.0.TC013

		 */

		var $original_lMargin;

		

		/**

		 * @var original right margin value

		 * @access protected

		 * @since 1.53.0.TC013

		 */

		var $original_rMargin;

			

		/**

		 * @var Header font.

		 * @access protected

		 */

		var $header_font;

		

		/**

		 * @var Footer font.

		 * @access protected

		 */

		var $footer_font;

		

		/**

		 * @var Language templates.

		 * @access protected

		 */

		var $l;

		

		/**

		 * @var Barcode to print on page footer (only if set).

		 * @access protected

		 */

		var $barcode = false;

		

		/**

		 * @var If true prints header

		 * @access protected

		 */

		var $print_header = true;

		

		/**

		 * @var If true prints footer.

		 * @access protected

		 */

		var $print_footer = true;

		

		/**

		 * @var Header width (0 = full page width).

		 * @access protected

		 */

		var $header_width = 0;

		

		/**

		 * @var Header image logo.

		 * @access protected

		 */

		var $header_logo = "";

		

		/**

		 * @var Header image logo width in mm.

		 * @access protected

		 */

		var $header_logo_width = 30;

		

		/**

		 * @var String to print as title on document header.

		 * @access protected

		 */

		var $header_title = "";

		

		/**

		 * @var String to print on document header.

		 * @access protected

		 */

		var $header_string = "";

		

		/**

		 * @var Default number of columns for html table.

		 * @access protected

		 */

		var $default_table_columns = 4;

		

		

		// variables for html parser

		

		/**

		 * @var HTML PARSER: store current link.

		 * @access protected

		 */

		var $HREF;

		

		/**

		 * @var HTML PARSER: store font list.

		 * @access protected

		 */

		var $fontList;

		

		/**

		 * @var HTML PARSER: true when font attribute is set.

		 * @access protected

		 */

		var $issetfont;

		

		/**

		 * @var HTML PARSER: array of foreground colors

		 * @access protected

		 */

		var $fgcolor;

		

		/**

		 * @var HTML PARSER: true in case of ordered list (OL), false otherwise.

		 * @access protected

		 */

		var $listordered = false;

		

		/**

		 * @var HTML PARSER: count list items.

		 * @access protected

		 */

		var $listcount = 0;

		

		/**

		 * @var HTML PARSER: size of table border.

		 * @access protected

		 */

		var $tableborder = 0;

		

		/**

		 * @var HTML PARSER: 'th' or 'td' ath the beginning of HTML cell.

		 * @access protected

		 */

		var $tdbegin = false;

		

		/**

		 * @var HTML PARSER: table width.

		 * @access protected

		 */

		var $tdwidth = 0;

		

		/**

		 * @var HTML PARSER: table height.

		 * @access protected

		 */

		var $tdheight = 0;

		

		/**

		 * @var HTML PARSER: table align.

		 * @access protected

		 */

		var $tdalign = "L";

		

		/**

		 * @var HTML PARSER: array of background colors

		 * @access protected

		 */

		var $bgcolor;

		

		/**

		 * @var Store temporary font size in points.

		 * @access protected

		 */

		var $tempfontsize = 10;

		

		/**

		 * @var Bold font style status.

		 * @access protected

		 */

		var $b;

		

		/**

		 * @var Underlined font style status.

		 * @access protected

		 */

		var $u;

		

		/**

		 * @var Italic font style status.

		 * @access protected

		 */

		var $i;

		

		/**

		 * @var Line through font style status.

		 * @access protected

		 * @since 2.8.000 (2008-03-19)

		 */

		var $d;

		

		/**

		 * @var spacer for LI tags.

		 * @access protected

		 */

		var $lispacer = "";

		

		/**

		 * @var default encoding

		 * @access protected

		 * @since 1.53.0.TC010

		 */

		var $encoding = "UTF-8";

		

		/**

		 * @var PHP internal encoding

		 * @access protected

		 * @since 1.53.0.TC016

		 */

		var $internal_encoding;

				

		/**

		 * @var store previous font family

		 * @access protected

		 * @since 1.53.0.TC017

		 */

		var $prevFontFamily;

		

		/**

		 * @var store previous font style

		 * @access protected

		 * @since 1.53.0.TC017

		 */

		var $prevFontStyle;

		

		/**

		 * @var indicates if the document language is Right-To-Left

		 * @access protected

		 * @since 2.0.000

		 */

		var $rtl = false;

		

		/**

		 * @var used to force RTL or LTR string inversion

		 * @access protected

		 * @since 2.0.000

		 */

		var $tmprtl = false;

		

		// --- Variables used for document encryption:

		

		/**

		 * Indicates whether document is protected

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $encrypted;

		

		/**

		 * U entry in pdf document

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $Uvalue;

		

		/**

		 * O entry in pdf document

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $Ovalue;

		

		/**

		 * P entry in pdf document

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $Pvalue;

		

		/**

		 * encryption object id

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $enc_obj_id;

		

		/**

		 * last RC4 key encrypted (cached for optimisation)

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $last_rc4_key;

		

		/**

		 * last RC4 computed key

		 * @access protected

		 * @since 2.0.000 (2008-01-02)

		 */

		var $last_rc4_key_c;

		

		// --- bookmark ---

		

		/**

		 * Outlines for bookmark

		 * @access protected

		 * @since 2.1.002 (2008-02-12)

		 */

		var $outlines = array();

		

		/**

		 * Outline root for bookmark

		 * @access protected

		 * @since 2.1.002 (2008-02-12)

		 */

		var $OutlineRoot;

		

		

		// --- javascript and form ---

		

		/**

		 * javascript code

		 * @access protected

		 * @since 2.1.002 (2008-02-12)

		 */

		var $javascript = "";

		

		/**

		 * javascript counter

		 * @access protected

		 * @since 2.1.002 (2008-02-12)

		 */

    var $n_js;

    

		/**

		 * line trough state

		 * @access protected

		 * @since 2.8.000 (2008-03-19)

		 */

    var $linethrough;

        

		/**

		 * ID of html tags with bgcolor attribute

		 * @access protected

		 * @since 2.9.000 (2008-03-25)

		 */

    var $bgtag;

    

    // --- Variables used for User's Rights ---

    // See PDF reference chapter 8.7 Digital Signatures

        

		/**

		 * If true enables user's rights on PDF reader

		 * @access protected

		 * @since 2.9.000 (2008-03-26)

		 */

    var $ur;

        

		/**

		 * Names specifying additional document-wide usage rights for the document.

		 * @access protected

		 * @since 2.9.000 (2008-03-26)

		 */

    var $ur_document;

        

		/**

		 * Names specifying additional annotation-related usage rights for the document.

		 * @access protected

		 * @since 2.9.000 (2008-03-26)

		 */

    var $ur_annots;

        

		/**

		 * Names specifying additional form-field-related usage rights for the document.

		 * @access protected

		 * @since 2.9.000 (2008-03-26)

		 */

    var $ur_form;

        

		/**

		 * Names specifying additional signature-related usage rights for the document.

		 * @access protected

		 * @since 2.9.000 (2008-03-26)

		 */

    var $ur_signature;

    

    /**

		 * Dot Per Inch Document Resolution (do not change)

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $dpi = 72;

		

		/**

		 * Indicates whether a new page group was requested

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $newpagegroup;

		

		/**

		 * Contains the number of pages of the groups

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $pagegroups;

		

		/**

		 * Contains the alias of the current page group

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $currpagegroup; 

		

		/**

		 * Restrict the rendering of some elements to screen or printout.

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $visibility="all";

		

		/**

		 * Print visibility.

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $n_ocg_print;

		

		/**

		 * View visibility.

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $n_ocg_view;

		

		/**

		 * Array of transparency objects and parameters.

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $extgstates;

		

		/**

		 * Set the default JPEG compression quality (1-100)

		 * @access protected

		 * @since 3.0.000 (2008-03-27)

		 */

		var $jpeg_quality;

		

		/**

		 * Colspan attribute value for the current HTML cell.

		 * @access protected

		 * @since 3.0.011 (2008-05-23)

		 */

		var $tdcolspan = 1;

Open in new window

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21882680
Try this. I've added a LOT of comments to the code. Please read them carefully and ask if you don't understand any.

I've also attached the debug.log file that the code below produces (if you leave the DEBUG lines uncommented that is).
<?php

// This dummy PDF class is used to allow $o_PDF->MultiRow() to function.

class dummyPDF

	{

	public function MultiRow()

		{

		// Get the parameters.

		$a_Params = func_get_args();
 

		// DEBUG : Uncomment the next line to create a debug log file.

		file_put_contents('./debug.log', implode(' | ', $a_Params) . PHP_EOL, FILE_APPEND);

		}

	}
 

function splitData(array $a_Data)

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;
 

 	// We are in a new level.

	++$i_Level;
 

 	// This levels results start life as an empty array.

	$a_Results = array();
 

 	// Iterate the supplied data to this level.

	foreach($a_Data as $s_Entry)

		{

		// Different levels have different formatting.

		switch($i_Level)

			{

			// Level 1 is {name:value} (even if value is an array).

			case 1 :

				$s_Entry = substr($s_Entry, 1, -1);

				$i_SplitPos = strpos($s_Entry, ':');

				$s_Key = substr($s_Entry, 0, $i_SplitPos);

				$s_Value = substr($s_Entry, 1 + $i_SplitPos);

				break;

			// Level 2 is where value is {name|value},{name|value},{name|value},{name|value}

			case 2 :

				$a_Results[] = splitData(explode(',', $s_Entry));

				break;

			// Level 3 is name|value

			case 3:

				list($s_Key, $s_Value) = explode('|', $s_Entry);

				break;

			}
 

		// If the value starts with a { it needs further refinement so call this function recursively.

		if (isset($s_Value) && (strlen($s_Value) > 0) && ('{' === $s_Value{0}))

			{

			$a_Results[$s_Key] = splitData(preg_split('`(?:}),(?:{)`', substr($s_Value, 1, -1)));

			}

		else

			{

			// Level 2 is not data generating.

			if (2 !== $i_Level)

				{

				// Store the results.

				$a_Results[$s_Key] = $s_Value;

				}

			}

		}
 

 	// We have finished with this level.

	--$i_Level;
 

 	// Return the results for this level.

	return $a_Results;

	}
 

function dataToPDF($o_PDF, array $a_Data, array $a_Keys = array())

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;
 

 	// We are in a new level.

	++$i_Level;
 

	// Iterate the supplied data array.

	foreach($a_Data as $s_Key => $m_Values)

		{

		// If the data is an array then call this function recursively.

		if (is_array($m_Values))

			{

			// Store the current key at the current level.

			$a_Keys[$i_Level] = $s_Key;
 

			// Call this function recursively with the PDF object we received,

			// the array of values and the accumulated keys.

			dataToPDF($o_PDF, $m_Values, $a_Keys);

			}

		else

			{

			// Remove any accumulated keys for this level

			unset($a_Keys[$i_Level]);
 

			// Generate a parameter array containing any supplied keys,

			// the current key and the current value.

			$a_Params = $a_Keys;

			$a_Params[] = $s_Key;

			$a_Params[] = $m_Values;
 

			// Call the PDF object to add a MultiRow with the array of parameters.

			call_user_func_array(array($o_PDF, 'MultiRow'), $a_Params);

			}

		}
 

 	// We have finished with this level.

	--$i_Level;

	}
 

// Prepare the data.

// This will come in from your script.

$_POST['dataArray'] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}';
 

// Convert the long string into an array.

preg_match_all( '`({[^{},]*?:{.*?}}|{[^{},]*?:.*?})`sim', $_POST['dataArray'], $a_Matches);
 

// Convert the simple array into a nested array.

$a_Data = splitData($a_Matches[1]);
 

// Remove any log file.

@unlink('./debug.log');
 

// DEBUG : Uncomment the next line to create a debug log file.

file_put_contents('./debug.log', var_export($a_Data, True) . PHP_EOL, FILE_APPEND);
 
 

// Create a dummy PDF object as I need the rest of the code to work with a PDF object.

$o_PDF = new dummyPDF();
 

// Convert the complex nested array into a PDF document.

dataToPDF($o_PDF, $a_Data);

Open in new window

debug.log
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21882843
wow...  well i only thing i'm not getting on this is the dummy pdf... could you explain that thought... I seems to me that $o_PDF is the PDF? or what gets passed to the ... um... no this area confuses me... sorry...
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21883801
The dummyPDF class exists for testing purposes.

From your perspective, change ...

$o_PDF = new dummyPDF();

to

$o_PDF = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);

Oh. You will probably need to change all the $o_PDF to $PDF.

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21886790
Ok so your probly going to think i'm and idiot on this, but I have went round and round and keep running in to the same issue...

I'f not sure why.... I thought to make it fit in all i'd have to move the like peices into position, but that didn't seem to work, also try it from scrach ( bet you can guess how that went lol)... anyways.... I made the $o_PDF to $PDF changes, $o_PDF = new dummyPDF(); change, corrected the redefined function errors, ect... and the best i'v gotten is...

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/content/d/o/u/dougbarton/html/Core_files/PDFgenerator/tcpdf_php4/examples/example_011.php on line 111

which refers to

// Call the PDF object to add a MultiRow with the array of parameters.
call_user_func_array(array($PDF, 'MultiRow'), $a_Params);


Where am I going wrong?  thanks again for all the help...

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');
 

// Prepare the data.

$_POST["dataArray"] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}';

 

 

 

 

 

 function splitData(array $a_Data)

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;

 

 	// We are in a new level.

	++$i_Level;

 

 	// This levels results start life as an empty array.

	$a_Results = array();

 

 	// Iterate the supplied data to this level.

	foreach($a_Data as $s_Entry)

		{

		// Different levels have different formatting.

		switch($i_Level)

			{

			// Level 1 is {name:value} (even if value is an array).

			case 1 :

				$s_Entry = substr($s_Entry, 1, -1);

				$i_SplitPos = strpos($s_Entry, ':');

				$s_Key = substr($s_Entry, 0, $i_SplitPos);

				$s_Value = substr($s_Entry, 1 + $i_SplitPos);

				break;

			// Level 2 is where value is {name|value},{name|value},{name|value},{name|value}

			case 2 :

				$a_Results[] = splitData(explode(',', $s_Entry));

				break;

			// Level 3 is name|value

			case 3:

				list($s_Key, $s_Value) = explode('|', $s_Entry);

				break;

			}

 

		// If the value starts with a { it needs further refinement so call this function recursively.

		if (isset($s_Value) && (strlen($s_Value) > 0) && ('{' === $s_Value{0}))

			{

			$a_Results[$s_Key] = splitData(preg_split('`(?:}),(?:{)`', substr($s_Value, 1, -1)));

			}

		else

			{

			// Level 2 is not data generating.

			if (2 !== $i_Level)

				{

				// Store the results.

				$a_Results[$s_Key] = $s_Value;

				}

			}

		}

 

 	// We have finished with this level.

	--$i_Level;

 

 	// Return the results for this level.

	return $a_Results;

	}

 

function dataToPDF($PDF, array $a_Data, array $a_Keys = array())

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;

 

 	// We are in a new level.

	++$i_Level;

 

	// Iterate the supplied data array.

	foreach($a_Data as $s_Key => $m_Values)

		{

		// If the data is an array then call this function recursively.

		if (is_array($m_Values))

			{

			// Store the current key at the current level.

			$a_Keys[$i_Level] = $s_Key;

 

			// Call this function recursively with the PDF object we received,

			// the array of values and the accumulated keys.

			dataToPDF($PDF, $m_Values, $a_Keys);

			}

		else

			{

			// Remove any accumulated keys for this level

			unset($a_Keys[$i_Level]);

 

			// Generate a parameter array containing any supplied keys,

			// the current key and the current value.

			$a_Params = $a_Keys;

			$a_Params[] = $s_Key;

			$a_Params[] = $m_Values;

 

			// Call the PDF object to add a MultiRow with the array of parameters.

			call_user_func_array(array($PDF, 'MultiRow'), $a_Params);

			

			}

		}

 

 	// We have finished with this level.

	--$i_Level;

	}

 

// Prepare the data.

// This will come in from your script.
 
 

// Convert the long string into an array.

preg_match_all( '`({[^{},]*?:{.*?}}|{[^{},]*?:.*?})`sim', $_POST['dataArray'], $a_Matches);

 

// Convert the simple array into a nested array.

$a_Data = splitData($a_Matches[1]);

 dataToPDF($PDF, $a_Data);

// Remove any log file.

@unlink('./debug.log');

 

// DEBUG : Uncomment the next line to create a debug log file.

//file_put_contents('./debug.log', var_export($a_Data, True) . PHP_EOL, FILE_APPEND);

 

// extend TCPF with custom functions

class MYPDF extends TCPDF {
 

function MultiRow($left, $right) {

		//MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0)

		

		$a_Params = func_get_args();

		// DEBUG : Uncomment the next line to create a debug log file.

		//file_put_contents('./debug.log', implode(' | ', $a_Params) . PHP_EOL, FILE_APPEND);

		

		$page_start = $this->getPage();

		$y_start = $this->GetY();

		

		// write the left cell

		$this->MultiCell(40, 0, $left, 1, 'R', 0, 2, 0 ,0, true, 0);

		

		$page_end_1 = $this->getPage();

		$y_end_1 = $this->GetY();

		

		$this->setPage($page_start);

		

		// write the right cell

		$this->MultiCell(0, 0, $right, 1, 'J', 0, 1, $this->GetX() ,$y_start, true, 0);

		

		$page_end_2 = $this->getPage();

		$y_end_2 = $this->GetY();

		

		// set the new row position by case

		if (max($page_end_1,$page_end_2) == $page_start) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 == $page_end_2) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 > $page_end_2) {

			$ynew = $y_end_1;

		} else {

			$ynew = $y_end_2;

		}

		

		$this->setPage(max($page_end_1,$page_end_2));

		$this->SetXY($this->GetX(),$ynew);

	}

}
 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 
 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");
 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 

//set some language-dependent strings

$pdf->setLanguageArray($l); 
 

//initialize document

$pdf->AliasNbPages();
 

// add a page

$pdf->AddPage();
 

// ---------------------------------------------------------
 

// set font

$pdf->SetFont("vera", "", 12);
 

//Column titles

$header=array('something','Capital');
 

  
 
 

$pdf->MultiRow("Row ".($i+1), $a_Data."\n"); 

Open in new window

0
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
ID: 21888282
Uh?

Are you sure you are on PHP5?

The error contains ...

/home/content/d/o/u/dougbarton/html/Core_files/PDFgenerator/tcpdf_ >>>>> php4 <<<<< /examples/example_011.php

php4.

See http://docs.php.net/manual/en/language.pseudo-types.php#language.types.callback and look at example #1 Type 3.

This is pretty basic stuff.


Ah! You flip chart! You are calling my functions without having first created the PDF instance!

Try this. You can't talk to an instance without first creating it. Not like scalar variables which are created on demand.


<?php

require("../PHPMailer_v2.0.0/class.phpmailer.php");

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');

 

function splitData(array $a_Data)

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;

 

 	// We are in a new level.

	++$i_Level;

 

 	// This levels results start life as an empty array.

	$a_Results = array();

 

 	// Iterate the supplied data to this level.

	foreach($a_Data as $s_Entry)

		{

		// Different levels have different formatting.

		switch($i_Level)

			{

			// Level 1 is {name:value} (even if value is an array).

			case 1 :

				$s_Entry = substr($s_Entry, 1, -1);

				$i_SplitPos = strpos($s_Entry, ':');

				$s_Key = substr($s_Entry, 0, $i_SplitPos);

				$s_Value = substr($s_Entry, 1 + $i_SplitPos);

				break;

			// Level 2 is where value is {name|value},{name|value},{name|value},{name|value}

			case 2 :

				$a_Results[] = splitData(explode(',', $s_Entry));

				break;

			// Level 3 is name|value

			case 3:

				list($s_Key, $s_Value) = explode('|', $s_Entry);

				break;

			}

 

		// If the value starts with a { it needs further refinement so call this function recursively.

		if (isset($s_Value) && (strlen($s_Value) > 0) && ('{' === $s_Value{0}))

			{

			$a_Results[$s_Key] = splitData(preg_split('`(?:}),(?:{)`', substr($s_Value, 1, -1)));

			}

		else

			{

			// Level 2 is not data generating.

			if (2 !== $i_Level)

				{

				// Store the results.

				$a_Results[$s_Key] = $s_Value;

				}

			}

		}

 

 	// We have finished with this level.

	--$i_Level;

 

 	// Return the results for this level.

	return $a_Results;

	}

 

function dataToPDF($PDF, array $a_Data, array $a_Keys = array())

	{

	// We need to track levels so use a static variable.

	static $i_Level = 0;

 

 	// We are in a new level.

	++$i_Level;

 

	// Iterate the supplied data array.

	foreach($a_Data as $s_Key => $m_Values)

		{

		// If the data is an array then call this function recursively.

		if (is_array($m_Values))

			{

			// Store the current key at the current level.

			$a_Keys[$i_Level] = $s_Key;

 

			// Call this function recursively with the PDF object we received,

			// the array of values and the accumulated keys.

			dataToPDF($PDF, $m_Values, $a_Keys);

			}

		else

			{

			// Remove any accumulated keys for this level

			unset($a_Keys[$i_Level]);

 

			// Generate a parameter array containing any supplied keys,

			// the current key and the current value.

			$a_Params = $a_Keys;

			$a_Params[] = $s_Key;

			$a_Params[] = $m_Values;

 

			// Call the PDF object to add a MultiRow with the array of parameters.

			call_user_func_array(array($PDF, 'MultiRow'), $a_Params);

			

			}

		}

 

 	// We have finished with this level.

	--$i_Level;

	}

 

// Prepare the data.

// This would normally come in from your flash.

$_POST["dataArray"] = '{name:value},{Applacation Date:Mon Jun 23 17:36:26 GMT-0700 2008},{emps_grd:{row|0,employer|asdfasdf,address|asdfasdf,phone|asdf,supervisor|asdf,contact|false,wage|,duties|,from|Mon Jun 2 00:00:00 GMT-0700 2008,to|,reason|},{row|1,employer|new Employee,address|asdfasdf,phone|,supervisor|asdfadf,contact|false,wage|asdfasdf,duties|,from|Tue Jun 3 00:00:00 GMT-0700 2008,to|Thu Jun 19 00:00:00 GMT-0700 2008,reason|}},{jobs_picks:{Job_Pick`0|CNA - MEDICAL UNIT},{Job_Pick`1|Unit Secretary / CNA Mental Health Center},{Job_Pick`2|CREDIT COUNSELOR},{Job_Pick`3|UNIT SECRETARY - ICU/PCU},{Job_Pick`4|CNA - SURGICAL UNIT},{Job_Pick`5|CNA - SURGICAL UNIT}},{name_title:Mr},{urstate:Choose},{primphonetype:Choose},{altphonetype:Choose},{emerg_contype:Choose},{days:3rd},{evenings:1st},{nights:2nd},{high_school_from:Mon Jun 9 00:00:00 GMT-0700 2008},{high_school_to:Tue Jun 17 00:00:00 GMT-0700 2008},{high_school_when:undefined},{prev_emplofrom:undefined},{prev_emploto:undefined},{skill_medterm_date:undefined},{college_from:undefined},{college_to:undefined},{college_when:undefined},{college2_from:Tue Jun 10 00:00:00 GMT-0700 2008},{college2_to:Tue Jun 17 00:00:00 GMT-0700 2008},{college2_when:Thu Jun 19 00:00:00 GMT-0700 2008},{college3_from:undefined},{college3_to:undefined},{college3_when:undefined},{college4_from:undefined},{college4_to:undefined},{college4_when:undefined},{current_ed_completdate:undefined},{license_xdate:undefined},{license2_xdate:undefined},{em_data_rec_brith:undefined},{lastname:Dude},{firstname:Man},{middlename:Hit},{suffix:sr},{ssn:5946565632},{street:},{city:},{zip:},{primphone:},{altphone:},{email:},{emerg_con:},{emerg_connumber:},{learnabout_job_othertxt:},{relative_name:},{relative_rela:},{undefined:undefined},{undefined:undefined},{undefined:undefined},{undefined:undefined},{high_school_name:},{high_school_loca:},{college_name:},{college_loca:},{college2_name:},{college2_loca:},{college3_name:},{college3_loca:},{college4_name:},{college4_loca:},{college_major:},{college2_major:},{college3_major:},{college4_major:},{current_ed_name:},{current_ed_loca:},{current_ed_study:},{license_type:},{license_number:},{license_state:},{license2_type:},{license2_number:},{license2_state:},{skill_typn_wpm:},{skill_medterm_school:},{skill_monitors_type:},{leg_othername_1:},{leg_othername_2:},{leg_othername_3:},{leg_othername_4:},{leg_able_work_note:},{leg_convic_note:},{undefined:undefined},{undefined:undefined},{em_data_rec_notes:},{digitalsign:},{full_time:yes},{part_time:Yes},{temp:},{on_call:Yes},{avaiable_mon:},{avaiable_tus:},{avaiable_wed:Yes},{avaiable_thru:Yes},{avaiable_fri:},{avaiable_sat:},{avaiable_sun:Yes},{ssnoptout:},{learnabout_job_ad:},{learnabout_job_friend:},{learnabout_job_other:},{skill_typn:},{skill_dataentry:},{skill_medterm:},{skill_medtrans:Yes},{skill_accounting:Yes},{skill_insure_bill:Yes},{skill_credit_collect:Yes},{skill_switchborad:},{skill_cashier:},{skill_10key:Yes},{skill_invoicing:},{skill_reception:Yes},{skill_floorcare_man:},{skill_floorcare_mac:},{skill_dishman:},{skill_dishindus:},{skill_linen:},{skill_sterilizer:},{skill_autoclave:},{skill_sewing:},{skill_maintengen:},{skill_maintencraft:},{skill_maintencraft_el:Yes},{skill_maintencraft_pl:Yes},{skill_maintencraft_co:Yes},{skill_maintencraft_pt:Yes},{skill_steriletechique:},{skill_vitalsigns:},{skill_charting:},{skill_pre_opprep:},{skill_isolation:},{skill_cateterization:},{skill_coronarycare:},{skill_intensive:},{skill_monitors:},{skill_orthopedic:},{skill_pediatic:},{skill_obstertrics:},{skill_medical:},{skill_surgical:},{skill_geriatric:},{skill_oncology:},{skill_family_homecare:},{em_data_rec_w:},{em_data_rec_b:},{em_data_rec_h:},{em_data_rec_a:},{em_data_rec_a_i:},{em_data_rec_v:},{em_data_rec_d:},{em_data_rec_di:},{appstate_cb:},{drugtest:},{digital_agree:},{Em_HIS_Con_Y:Yes},{rotate_shifts_N:No},{weekends_Y:Yes},{relativeemplo_N:},{high_school_did_atend_N:No},{college_did_atend_Y:Yes},{college2_did_atend_Y:Yes},{college3_did_atend_N:},{college4_did_atend_N:},{current_ed_N:},{licensed_N:},{app4license_N:},{leg_othername_N:},{leg_able_work_N:},{leg_visa_N:},{em_data_rec_sex_M:},{leg_convic_N:},{_18_N:},{prev_emplo_N:}';
 

// Convert the long string into an array.

preg_match_all( '`({[^{},]*?:{.*?}}|{[^{},]*?:.*?})`sim', $_POST['dataArray'], $a_Matches);

 

// Convert the simple array into a nested array.

$a_Data = splitData($a_Matches[1]);
 

// Remove any log file.

@unlink('./debug.log');

 

// DEBUG : Uncomment the next line to create a debug log file.

file_put_contents('./debug.log', var_export($a_Data, True) . PHP_EOL, FILE_APPEND);

 

// extend TCPF with custom functions

class MYPDF extends TCPDF {

 

function MultiRow($left, $right) {

		//MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0)

		

		$a_Params = func_get_args();

		// DEBUG : Uncomment the next line to create a debug log file.

		//file_put_contents('./debug.log', implode(' | ', $a_Params) . PHP_EOL, FILE_APPEND);

		

		$page_start = $this->getPage();

		$y_start = $this->GetY();

		

		// write the left cell

		$this->MultiCell(40, 0, $left, 1, 'R', 0, 2, 0 ,0, true, 0);

		

		$page_end_1 = $this->getPage();

		$y_end_1 = $this->GetY();

		

		$this->setPage($page_start);

		

		// write the right cell

		$this->MultiCell(0, 0, $right, 1, 'J', 0, 1, $this->GetX() ,$y_start, true, 0);

		

		$page_end_2 = $this->getPage();

		$y_end_2 = $this->GetY();

		

		// set the new row position by case

		if (max($page_end_1,$page_end_2) == $page_start) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 == $page_end_2) {

			$ynew = max($y_end_1, $y_end_2);

		} elseif ($page_end_1 > $page_end_2) {

			$ynew = $y_end_1;

		} else {

			$ynew = $y_end_2;

		}

		

		$this->setPage(max($page_end_1,$page_end_2));

		$this->SetXY($this->GetX(),$ynew);

	}

}

 

// create new PDF document

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 

$pdf->SetProtection(array('print')); 

 

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor("Nicola Asuni");

$pdf->SetTitle("TCPDF Example 011");

$pdf->SetSubject("TCPDF Tutorial");

$pdf->SetKeywords("TCPDF, PDF, example, test, guide");

 

// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

 

// 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 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 image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 

 

//set some language-dependent strings

$pdf->setLanguageArray($l); 

 

//initialize document

$pdf->AliasNbPages();

 

// add a page

$pdf->AddPage();

 

// ---------------------------------------------------------

 

// set font

$pdf->SetFont("vera", "", 12);

 

//Column titles

$header=array('something','Capital');

 

  

dataToPDF($pdf, $a_Data);

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21888385
yep for sure... that is what i get for only getting 4 hours of sleep... So I have a few more questions around this and I think i'll have the base down and understood...

there is a wierd result where the are huge gap for some odd reason...  not sure at all on that... it showed up well i was creating the rows by count... and like a fool i made a few changes at the same time and boom it was fix with out knowing why... lol...

and the other thing is how do it end the mulitcell and start a new one after the last "node"... is this something that would be like:

foreach(i = 0; i < $i_Level.length; i++ )
if ($i_Level == 0) {
                  open table if new
            } elseif ($i_Level[i]-1 => $i_Level[i]) {
                  end of the chain close table
            } else {
                  end
            }
}

end up with the so i can move the around.... free from each other?

??? what do you think?
example-011.pdf
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21889926
ok so I was trying to work it out... and noticed something a raey...
I'm getting emps_grd 0 repeted... same with the job picks... I think it's just telling my the level?  it's in the current pdf... not to shure what to do about that?

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21895007
I thought Multi-Cell allowed for multiple cells. Obviously not. I don't know your PDF class. It is not how I would do it and so that is for another answer.

The issue is now just a rendering issue.

If you can create real tables, then I would use each of the emp records as a mini table (again,another question).

You are nearly there.

Can you create cells in the PDF to the equivalent in HTML of ...

<td colspan="10">....</td>

If so, you need to have enough columns for the emp rows and all the other rows use x columns.
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21895574
*sigh* I don't know i see to options

////////////////////////////////////////////////////////////////////
//////////// 1

"I thought Multi-Cell allowed for multiple cells. Obviously not. I don't know your PDF class. It is not how I would do it and so that is for another answer."

Well I know that I need to stay with the class I have (it's part of the cms Im working with).... It's just that I didn't think that pulling the data was going to be as involved as it has been... This question was just suppose to be mostly to make tables out of the parts... I'd be more the happy to Accept as Solution and start a new question...



////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// 2    --- seems like the easies way
What I want is the "data pockets" as tables them selves... thats why I thought the mulity cell would work.. It'd be opened and closed for each "data set"

http://www.experts-exchange.com/Q_23486958.html#a21882635


"Can you create cells in the PDF to the equivalent in HTML of ..."

Yes.... could we just work it out that way... Get the "data parts" (what have you) into tables? I know I can get the rest... It's just your way of handling the data is still a little foreign to me, I what not had enough time to full get it yet...


Let me know, I just need to finish this off... and you have been a real big help... I had no clue that the data part of this was as hard as it is... thank you so much for sticking it out with me...


Here is an HTML example:  

<?php 

//============================================================+ 

// File name   : example_021.php 

// Begin       : 2008-03-04 

// Last Update : 2008-05-28 

//  

// Description : Example 021 for TCPDF class 

//               WriteHTML text flow 

//  

// Author: Nicola Asuni 

//  

// (c) Copyright: 

//               Nicola Asuni 

//               Tecnick.com s.r.l. 

//               Via Della Pace, 11 

//               09044 Quartucciu (CA) 

//               ITALY 

//               www.tecnick.com 

//               info@tecnick.com 

//============================================================+ 
 

/** 

 * Creates an example PDF TEST document using TCPDF 

 * @package com.tecnick.tcpdf 

 * @abstract TCPDF - Example: WriteHTML text flow. 

 * @author Nicola Asuni 

 * @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com 

 * @link http://tcpdf.org 

 * @license http://www.gnu.org/copyleft/lesser.html LGPL 

 * @since 2008-03-04 

 */ 
 

require_once('../config/lang/eng.php'); 

require_once('../tcpdf.php'); 
 

// create new PDF document 

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);  
 

// set document information 

$pdf->SetCreator(PDF_CREATOR); 

$pdf->SetAuthor("Nicola Asuni"); 

$pdf->SetTitle("TCPDF Example 021"); 

$pdf->SetSubject("TCPDF Tutorial"); 

$pdf->SetKeywords("TCPDF, PDF, example, test, guide"); 
 

// set default header data 

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); 
 

// 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 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 image scale factor 

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);  
 

//set some language-dependent strings 

$pdf->setLanguageArray($l);  
 

//initialize document 

$pdf->AliasNbPages(); 
 

// add a page 

$pdf->AddPage(); 
 

// --------------------------------------------------------- 
 

// set font 

$pdf->SetFont("dejavusans", "", 9); 
 

// create some HTML content 

$htmlcontent = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. <em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> <em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em><br /><br /><b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i> -&gt; &nbsp;&nbsp; <b>A</b> + <b>B</b> = <b>C</b> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>B</i> = <i>A</i> &nbsp;&nbsp; -&gt; &nbsp;&nbsp; <i>C</i> - <i>A</i> = <i>B</i><br /><br /><b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u>"; 
 

// output the HTML content 

$pdf->writeHTML($htmlcontent, true, 0, true, 0); 
 

// reset pointer to the last page 

$pdf->lastPage(); 
 

// --------------------------------------------------------- 
 

//Close and output PDF document 

$pdf->Output("example_021.pdf", "I"); 
 

//============================================================+ 

// END OF FILE                                                  

//============================================================+ 

?> 

Open in new window

0
 
LVL 4

Author Closing Comment

by:jeremyBass26
ID: 31466408
I guess you would like me to put this back up as a new question to finish this?... Anyways... thank you for your help, I see i have much to learn on this ... I hope you will sick with me on taking what you were showing me and maing it in to sperat HTML tables... thanks again.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now