<?php
    require_once ('../3rd_party/fpdf/fpdf.php');

    class blank_request_template extends FPDF
    {
        var $angle=0;

        private function Rotate($angle,$x=-1,$y=-1)
        {
            if($x==-1)
                $x=$this->x;
            if($y==-1)
                $y=$this->y;
            if($this->angle!=0)
                $this->_out('Q');
            $this->angle=$angle;
            if($angle!=0)
            {
                $angle*=M_PI/180;
                $c=cos($angle);
                $s=sin($angle);
                $cx=$x*$this->k;
                $cy=($this->h-$y)*$this->k;
                $this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
            }
        }

        protected function _endpage()
        {
            if($this->angle!=0)
            {
                $this->angle=0;
                $this->_out('Q');
            }
            parent::_endpage();
        }


        private function RotatedText($x,$y,$txt,$angle)        {
            //Text rotated around its origin
            $this->Rotate($angle,$x,$y);
            $this->Text($x,$y,$txt);
            $this->Rotate(0);
        }

        private function RotatedImage($file,$x,$y,$w,$h,$angle)
        {
            //Image rotated around its upper-left corner
            $this->Rotate($angle,$x,$y);
            $this->Image($file,$x,$y,$w,$h);
            $this->Rotate(0);
        }
        
        private function WordWrap(&$text, $maxwidth, $inConcatSymbol=null, &$highlightingArray=null)
        {
            // Determine if there is any data to work with or not
            if (trim($text)===''){
                // Return the empty array
                return 0;
            }

            // Figure out the length of a space in current font
            $space = $this->GetStringWidth(' ');
            
            // get the amount of lines 
            $lines = explode("\n", $text);
            
            // Init the string to return what should be used to match the highlight array.
            $text = '';
            
            // The line count that the currently working with string is for
            $count = 0;

            // Start looping through the string's endlines
            foreach ($lines as $line)
            {
                // Split up the words by spaces
                $words = preg_split('/ +/', $line);
                
                // Create a variable to hold the width of the current line. 
                // This takes into account the font.
                $width = 0;

                // Loop through all words in this line
                foreach ($words as $word)
                {
                    // Get the width of this current word 
                    $wordwidth = $this->GetStringWidth($word);
                    
                    // Determine if this word is more that the max width we can go to.
                    // This is for suuuuuuuuuuuuper long words or very tight spaces.
                    if ($wordwidth > $maxwidth)
                    {
                        // Word is too long, we need to cut it
                        for($i=0; $i<strlen($word); $i++)
                        {
                            $wordwidth = $this->GetStringWidth(substr($word, $i, 1));
                            if($width + $wordwidth <= $maxwidth)
                            {
                                $width += $wordwidth;
                                $text .= substr($word, $i, 1);
                            }
                            else
                            {
                                $width = $wordwidth;
                                $text = rtrim($text)."\n".substr($word, $i, 1);
                                $count++;
                            }
                        }
                    }
                    elseif($width + $wordwidth <= $maxwidth)
                    {
                        $width += $wordwidth + $space;
                        $text .= $word.' ';
                    }
                    else
                    {
                        $width = $wordwidth + $space;
                        $text = rtrim($text)."\n".$word.' ';
                        $count++;
                    }
                }
                $text = rtrim($text)."\n";
                $count++;
            }
            $text = rtrim($text);
            return $count;
        }
        
        private function highlightLocations($startingXOffset=0, $startingY=0, $cellHeight=5, $text='', $inConcatSymbol=null)
        {
            // Get the page number that we are on
            $currentPage=$this->page;
            
            // Determine if there is any reason to start this
            if (trim($text)=='' || $inConcatSymbol==null)
                return false;
            
            // Expand the lines on end line at first
            $lines = explode("\n", $text);
            
            // Set the variable determine if we are currently highlighting to no at first.
            $doHighlighting=false;

            // Set the fill color to yellow for highlighting
            $this->SetFillColor(255,255,0);

            // Set the variable to start at the line position for Y as what was passed in
            $currentLoopingYPos = $startingY;

            // Loop through the lines
            foreach ($lines as $line)
            {
                // Set a variable for the recombined string as nothing
                $recombinedString='';

                // Move to the line in Y now
                $this->SetY($currentLoopingYPos);
                
                // Determine if there was a delimiter on the line or if we are 
                // currently on highlighting.
                if (strpos($line,'*')!==false){
                    // Split this line on the delimiter passed in
                    $highlightSplit = explode($inConcatSymbol, $line);

                    // Loop through what we might have
                    for ($count=0; $count < count($highlightSplit); $count++) {
                        // Determine if we are already highlighting
                        if ($doHighlighting) {
                            // Get the current X position taking into account font size
                            $this->SetX($startingXOffset + $this->GetStringWidth($recombinedString)+1);
                            
                            // Get the current X position taking into account font size
                            $highlightStringWidth=$this->GetStringWidth($highlightSplit[$count]);

                            // This needs highlighting so try to overwrite what we have.
                             $this->Cell($highlightStringWidth,$cellHeight,"",0,0,'L',true);

                            // Determine if this is the last one or if there are more after this one
                            if ($count+1!=count($highlightSplit)){
                                // set as done highlighting 
                                $doHighlighting=false;
                            }
                        }
                        else {
                            // If there is only one segment left, then we are 
                            // done highlighting for this line.  Exit the loop.
                            if ($count+1==count($highlightSplit)){
                                // Break out of this loop
                                break;
                            }
                            
                            // set to do the highlighting on next round
                            $doHighlighting=true;
                        }

                        // Recombine the string
                        $recombinedString.= '*' . $highlightSplit[$count];
                    }
                }
                else if ($doHighlighting){
                    // Get the current X position at the beginning of the line
                    $this->SetX($startingXOffset+1);

                    // Get the width of the whole line for highlighting
                    $highlightStringWidth=$this->GetStringWidth($line);
                            
                    // This needs highlighting so try to overwrite what we have.
                    $this->Cell($highlightStringWidth,$cellHeight,"",0,0,'L',true);
                }
                
                // Move y to the next line
                $currentLoopingYPos+=$cellHeight;
            }

            // Get the page number that we are on
            $this->page=$currentPage;
            
            // Return to the position before highlighting started.
            //         TODO:  X doesn't work for some reason. Have to set it 
            //                after calling this method. Figure it out.
            $this->setX($startingXOffset);
            $this->setY($startingY);
            
            return true;
        }   
        
        function DocSetup(){
//            // Turn the auto pagebreak to on
//            $this->SetAutoPageBreak(true, 1);
            
            // Set the margins up
            $this->SetRightMargin(209 - $this->rMargin);
            $this->SetLeftMargin($this->lMargin+5);

            // Set the fill color to yellow for highlighting
            $this->SetFillColor(255,255,0);
        }
        
        private function getAppropriatePercentageToFitPage($image, $maxwidth, $maxHeight){
            // Get percentage to use.  Max widtrh is 180 and max height is 275.
            // Set at 100% at first
            $percentageToUse=1;

            // Determine if the width of the image is less than the width we have.
            if ($image[0]<$maxwidth){
                // Need to increase the image size.
                $percentageToUse=$image[0]/$maxwidth;
            }
            else {
                // Need to decrease the image size.
                $percentageToUse=$maxwidth/$image[0];
            }

            // Now determine if the percentage makes the other dimension too big
            if ($percentageToUse*$image[1]>$maxHeight){
                // Determine if the height of the image is less than the height we have.
                if ($image[1]<$maxHeight){
                    // Need to increase the image size.
                    $percentageToUse=$image[1]/$maxHeight;
                }
                else {
                    // Need to decrease the image size.
                    $percentageToUse=$maxHeight/$image[1];
                }
            }
            
            // Return whatever we figured out
            return $percentageToUse;
        }
        
        // Page header
        function Header($hexFillColor=null)
        {
            // Determine if they sent in a fill color
            if ($hexFillColor===null){
                // Just set the standard color
                $this->SetFillColor(255,255,255);
            }
            else {
                // Set the color passed in
                $this->SetFillColorHex($hexFillColor);
            }
            
            // Add the EES Logo
            $w=30;
            $this->Image('../images/logo_EES_trans.png',10,6,$w);

            // Set the title font to Arial bold 15
            $this->SetFont('Arial','B',15);

            // Move to the right
            $this->Cell(35);

            // Add a title cell with label
            $this->Cell(110,10,'          Blank Request Form          ',0,0,'C', true);

            // Move to the right
            $this->Cell(25);

            // Set the page number font to Arial italic 8
            $this->SetFont('Arial','I',8);

            // Add the Page number
            $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'L');

            // Add a Line break
            $this->SetY(20);
            
            // Create and add a line
            $this->SetLineWidth(0.01);
            $this->Line($this->lMargin-5, 20, $this->rMargin + 5, 20);
            
            // Create a line break
            $this->Ln(2);

            // Set the font to a normal font 
            $this->SetFont('Times','',11);
        }

        // Page footer
        function Footer($hexFillColor=null)
        {
            // Determine if they sent in a fill color
            if ($hexFillColor===null){
                // Just set the standard color
                $this->SetFillColor(255,255,255);
            }
            else {
                // Set the color passed in
                $this->SetFillColorHex($hexFillColor);
            }
            
            // Position at 1.5 cm from bottom
            $this->SetY(-15);
            
            // Set font to Arial italic 8
            $this->SetFont('Arial','I',8);
            
            // Add the Page number
            $this->Cell(190,10,'Page '.$this->PageNo().'/{nb}',0,1,'C');

            // Set the font to a normal font 
            $this->SetFont('Times','',11);
        }
        
        // Create the general task info
        function GeneralBlankInfo($assocBlank){
            // Working with 180 between margins.  3 from the left side.
            
            // Set the title font to Arial bold 15
            $this->SetFont('Arial','IB',12);

            // Add a title cell with label
            $this->Cell(180,10,'General Blank Information',0,1,'C');

            // Set the draw color to a neutral one
            $this->SetDrawColor(111,111,111);
            
            // Create and add a line
            $this->SetLineWidth(1);
            $this->Line($this->lMargin, $this->GetY(), $this->rMargin,  $this->GetY());
            
            // Add a Line break
            $this->ln(3);
            
            // Set the draw color to black
            $this->SetDrawColor(0);
            
            // Set line width to default
            $this->SetLineWidth(.01);
            
            //*** Data Row 1 ***//
            
            // Set the x to be at the beginning of the line
            $this->SetX($this->lMargin+3);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B',11);
            
            // Add a Task ID Label cell
            $this->Cell(25,5,'Task ID:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Add a Task ID cell
            $this->Cell(60,5,$assocBlank["TaskID"],1,0,'C');

            // Set the font to a normal font bolded
            $this->SetFont('Times','B');
            
            // Add a completes task Label cell
            $this->Cell(35,5,'Rush:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Determine if this is a rush job or not
            if ($assocBlank["Rush"]!=null &&
                $assocBlank["Rush"]==0){
                // Add a completes task cell
                $this->Cell(60,5,'NO',1,1,'C');
            }
            else {
                // Add a completes task cell
                $this->Cell(60,5,'YES',1,1,'C',true);
            }
            
            //*** Data Row 2 ***//
            
            // Create the two texts with carriage returns
            $taskTitle=htmlspecialchars_decode($assocBlank["Title"]);            
            $parentTitle=htmlspecialchars_decode($assocBlank["ParentTitle"]); 
            
            // Get the highest number of lines between the two
            $firstNOL=($this->WordWrap($taskTitle, 55)==0)?1:$this->WordWrap($taskTitle, 55);
            $secondNOL=($this->WordWrap($parentTitle, 55)==0)?1:$this->WordWrap($parentTitle, 55);
            $largestNOL=($firstNOL>$secondNOL)?$firstNOL:$secondNOL;

            // Get the current Y value
            $y=$this->GetY();
            
            // Set the x to be at the beginning of the line
            $this->SetX($this->lMargin+3);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B',11);
            
            // Add a Task ID Label cell
            $this->Cell(25,5*$largestNOL,'Task Title:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');

            // Add a Task ID cell
            $this->MultiCell(60,5*($largestNOL/$firstNOL),$taskTitle,1,'C');

            // Set the y back to what it started as and the x adjusted appropriately
            $this->SetY($y);
            $this->SetX($this->lMargin+88);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B');
            
            // Add a completes task Label cell
            $this->Cell(35,5*$largestNOL,'Parent Title:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Determine if there is a parent title
            if ($assocBlank["ParentTitle"]==null){
                // Add a completes task cell
                $this->Cell(60,5*$largestNOL,'NONE',1, 1,'C');
            }
            else {
                // Add a completes task cell
                $this->MultiCell(60,5*($largestNOL/$secondNOL),$parentTitle,1,'C');
            }
            
            // Add a Line break
            $this->ln(0);
            
            //*** Data Row 3 ***//
            
            // Create the customer name with carriage returns
            $companyName=htmlspecialchars_decode($assocBlank["CompanyName"]);            
            
            // Get the number of lines in the customer name
            $largestNOL=($this->WordWrap($companyName, 55)==0)?1:$this->WordWrap($companyName, 55);

            // Get the current Y value
            $y=$this->GetY();
            
            // Set the x to be at the beginning of the line
            $this->SetX($this->lMargin+3);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B',11);
            
            // Add a Customer Name Label cell
            $this->Cell(25,9*$largestNOL,'Customer:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');

            // Set the company color as highlight
            $this->SetFillColorHex($assocBlank["CompanyRowColor"]);
            
            // Add a Customer Name cell
            $this->MultiCell(60,9,$companyName,1,'C',true);

            // Set the fill color to yellow so they pay attention
            $this->SetFillColor(255,255,0);

            // Set the y back to what it started as and the x adjusted appropriately
            $this->SetY($y);
            $this->SetX($this->lMargin+88);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B');
            
            // Add a priority Label cell
            $this->Cell(35,9*$largestNOL,'Priority:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Determine what the expedite level is
            if ($assocBlank["Expedite"]==0){
                // Add a priority cell as normal
                $this->Cell(60,9*$largestNOL,'NORMAL',1,1,'C');
            }
            else {
                // Add a priority cell as expedite
                $this->Cell(60,9*$largestNOL,'EXPEDITE',1,1,'C',true);
            }
        }
        
        // Create the general task info
        function BlankSetup($assocBlank){
            // Working with 180 between margins.  3 from the left side.
            
            // Add a Line break
            $this->ln(15);
            
            // Set the title font to Arial bold 15
            $this->SetFont('Arial','IB',12);

            // Add a title cell with label
            $this->Cell(180,10,'Blank Setup Information',0,1,'C');

            // Set the draw color to a neutral one
            $this->SetDrawColor(111,111,111);
            
            // Create and add a line
            $this->SetLineWidth(1);
            $this->Line($this->lMargin, $this->GetY(), $this->rMargin,  $this->GetY());
            
            // Add a Line break
            $this->ln(3);
            
            // Set the draw color to black
            $this->SetDrawColor(0);
            
            // Set line width to default
            $this->SetLineWidth(.01);
            
            //*** Data Row 1 ***//
            
            // Set the x to be at the beginning of the line
            $this->SetX($this->lMargin+3);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B',11);
            
            // Add a machine Label cell
            $this->Cell(35,5,'Machine:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Determine if the name is NOT null.  If they are printing setup sheets, it should not be.
            if ($assocBlank["MachineName"]==null){
                // Set the fill color to red to denote something necessary for the programmer to add
                $this->SetFillColor(255,0,0);
                
                // Set the machine name to none
                $this->Cell(145,5,'NONE',1,1,'C', true);

                // Set the standard fill color back to yellow for highlighting
                $this->SetFillColor(255,255,0);
            }
            else {
                // Add a machine name cell and highlight it.
                $this->Cell(145,5,htmlspecialchars_decode($assocBlank["MachineName"]),1,1,'C');
            }

            // Add a Line break
            $this->ln(0);
            
            //*** Data Row 2 ***//
            
            // Set the x to be at the beginning of the line
            $this->SetX($this->lMargin+3);
            
            // Set the font to a normal font bolded
            $this->SetFont('Times','B',11);
            
            // Add a Programmer Label cell
            $this->Cell(35,5,'Programmer:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Add a Programmer cell
            $this->Cell(55,5,htmlspecialchars_decode($assocBlank["ProgrammerFirstName"] . ' ' . $assocBlank["ProgrammerLastName"]),1,0,'C');

            // Set the font to a normal font bolded
            $this->SetFont('Times','B');
            
            // Add a program checked by Label cell
            $this->Cell(35,5,'Checked By:',1);

            // Set the font to a normal font non-bolded
            $this->SetFont('Times','');
            
            // Add a program checked by cell
            $this->Cell(55,5,htmlspecialchars_decode($assocBlank["ProgramCheckedByFirstName"] . ' ' . $assocBlank["ProgramCheckedByLastName"]),1,1,'C');
        }
        
        function BlankSpecs($blankRow){
            // Working with 180 between margins.  3 from the left side.
            
            // Add a Line break
            $this->ln(15);
            
            // Set the title font to Arial bold 15
            $this->SetFont('Arial','IB',12);

            // Add a title cell with label
            $this->Cell(180,10,'Blank Specifications',0,1,'C');

            // Set the draw color to a neutral one
            $this->SetDrawColor(111,111,111);
            
            // Create and add a line
            $this->SetLineWidth(1);
            $this->Line($this->lMargin, $this->GetY(), $this->rMargin,  $this->GetY());
            
            // Add a Line break
            $this->ln(3);
            
            // Set the draw color to black
            $this->SetDrawColor(0);
            
            // Set line width to default
            $this->SetLineWidth(.01);
            
            // Determine if there were rows for the task blanks
            if ($blankRow != null){
                //*** Data Row 1 ***//

                // Set the x to be at the beginning of the line
                $this->SetX($this->lMargin+3);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);
            
                // Add a machine name cell and highlight it.
                $this->Cell(35,5,'Material:',1);

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Add a machine name cell and highlight it.
                $this->Cell(55,5,$blankRow["MaterialName"],1,0,'C');

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(35,5,'Type:',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Add a machine name cell and highlight it.
                $this->Cell(55,5,$blankRow["Type"],1,1,'C');

                //*** Data Row 2 ***//

                // Set the x to be at the beginning of the line
                $this->SetX($this->lMargin+3);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);
            
                // Add a machine name cell and highlight it.
                $this->Cell(35,5,'Cut Dimension:',1);

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Add a machine name cell and highlight it.
                $this->Cell(55,5,$blankRow["QuantityDimension"],1,0,'C');

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(35,5,'Blank Qty:',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Add a machine name cell and highlight it.
                $this->Cell(55,5,$blankRow["Quantity"],1,1,'C');

                //*** Data Row 3 ***//

                // Set the x to be at the beginning of the line
                $this->SetX($this->lMargin+3);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(15,5,'(X):',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Determine if it is precise or clean
                $defaultCut = 'ROUGH';
                $highlight=false;
                if ($blankRow["Dimension1Precise"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to red to denote important
                    $this->SetFillColor(255,0,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'PRECISE';
                }
                else if ($blankRow["Dimension1Clean"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to yellow so they pay attention
                    $this->SetFillColor(255,255,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'CLEAN';
                }

                // Add a machine name cell and highlight it.
                $this->Cell(45,5,$blankRow["Dimension1"] . ' ' . $defaultCut,1,0,'C',$highlight);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(15,5,'(Y):',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Determine if it is precise or clean
                $defaultCut = 'ROUGH';
                $highlight=false;
                if ($blankRow["Dimension2Precise"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to red to denote important
                    $this->SetFillColor(255,0,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'PRECISE';
                }
                else if ($blankRow["Dimension2Clean"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to yellow so they pay attention
                    $this->SetFillColor(255,255,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'CLEAN';
                }

                // Add a machine name cell and highlight it.
                $this->Cell(45,5,$blankRow["Dimension2"] . ' ' . $defaultCut,1,0,'C', $highlight);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(15,5,'(Z):',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Determine if it is precise or clean
                $defaultCut = 'ROUGH';
                $highlight=false;
                if ($blankRow["Dimension3Precise"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to red to denote important
                    $this->SetFillColor(255,0,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'PRECISE';
                }
                else if ($blankRow["Dimension3Clean"]==1){
                    // Set highlighting to true
                    $highlight=true;

                    // Set the fill color to yellow so they pay attention
                    $this->SetFillColor(255,255,0);

                    // Set the descriptor to annotate precise
                    $defaultCut = 'CLEAN';
                }

                // Add a machine name cell and highlight it.
                $this->Cell(45,5,$blankRow["Dimension3"] . ' ' . $defaultCut,1,1,'C', $highlight);

                //*** Data Row 4 ***//

                // Get the amount of lines that name takes
                $reason=htmlspecialchars_decode($blankRow["Reason"]);
                $largestNOL=($this->WordWrap($reason, 155)==0)?1:$this->WordWrap($reason, 155);

                // Set the x to be at the beginning of the line
                $this->SetX($this->lMargin+3);

                // Set the font to a normal font bolded
                $this->SetFont('Times','B',11);

                // Add a machine name cell and highlight it.
                $this->Cell(20,5*$largestNOL,'Reason:',1,0,'L');

                // Set the font to a normal font non-bolded
                $this->SetFont('Times','');

                // Get the current X and Y values
                $startingX=$this->GetX();
                $startingY=$this->GetY();

                // Highlight over the places that need it
                $this->highlightLocations($startingX, $startingY, 5, $reason, '*');

                // Set the x to be at the beginning of the line
                $this->SetX($this->lMargin+23);

                // Add a machine name cell and highlight it.
                $this->MultiCell(160,5,$reason,1,'L');

                // Add a Line break
                $this->ln(0);
            }
            else {
                // Set the fill color to red to denote something necessary for the programmer to add
                $this->SetFillColor(255,0,0);

                // Add a machine name cell and highlight it.
                $this->Cell(180,5,'NONE',1,1,'C', true);

                // Set the standard fill color back to yellow for highlighting
                $this->SetFillColor(255,255,0);
            }
        }
    }
?>