Link to home
Start Free TrialLog in
Avatar of woodwyn
woodwynFlag for United States of America

asked on

TCPDF ERROR: [Image] Unable to get image

Taking over an older website for someone I upgraded their backend db from SQL 2000 to 2016.  The web hosting server has not been modified, but now we are seeing a new error when trying to create a PDF report.  This worked before, so I don't think that suggestions I found online about cURL are accurate.  

"TCPDF ERROR: [Image] Unable to get image: ../../ban/main/ProductImages/HeaderImages/bbts_header.jpg"

Here's the entire content of Reports.php where I believe the issue is occurring.  I am not a PHP developer, but can typically support issues like this.  Please be specific with suggested solutions.  You  can search for header or logo to see the area where the issue most likely is occurring.  

<?php

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

class ReportsEntity extends Entity
{
    # Reports
    function getReportsList() {
        global $keyWebSubDomains;
        return NDatabase::getAllAssoc("SELECT convert(varchar(256),keyReport) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE

keyWebSubDomains = convert(uniqueidentifier,'$keyWebSubDomains') ORDER BY title");
    }
    function getReport($uid) {
#NDatabase::setDebug();        
        $report = NDatabase::getARow("SELECT convert(varchar(256),keyReport) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE

keyReport=convert(uniqueidentifier,'$uid')");
        return $report;
    }
    function setReport($uid, $params) {
#die(print_r($params));
        global $keyWebSubDomains;
        if (!empty($uid)) {
            NDatabase::query('UPDATE Reports SET title=?, stored_procedure=?, header_image=?, columns=?, execString=? WHERE convert(varchar(255),keyReport)=?',
                                    array($params['title'], $params['stored_procedure'], $params['header_image'], $params['columns'], $params['execString'], $uid));
        } else {
            $uid = Entity::getNUI();
            NDatabase::query('INSERT INTO Reports (keyWebSubDomains,title,stored_procedure,header_image,columns,execString) VALUES(convert(uniqueidentifier,?),?,?,?,?,?)',
                                    array($keyWebSubDomains, $params['title'], $params['stored_procedure'], $params['header_image'],  $params['columns'],  $params['execString']));
        }
        return $uid;
    }
    function deleteReport($uid) {
        NDatabase::query('DELETE FROM Reports WHERE keyReport = convert(uniqueidentifier,?)', array($uid));
        NDatabase::query('DELETE FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,?)', array($uid));
    }

    # Inputs
    function getInputsList($uid) {    
        return NDatabase::getAllAssoc("SELECT convert(varchar(256),keyInput) as keyInput, ltrim(rtrim(title)) as title, ltrim(rtrim(data_type)) as data_type, ltrim(rtrim(sp_variable)) as sp_variable,

is_required, sorting, ord FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,'$uid') ORDER BY ord");
    }
    function getInput($ind) {
        return NDatabase::getARow("SELECT convert(varchar(256),keyInput) as keyInput, convert(varchar(256),keyReport) as keyReport, ltrim(rtrim(title)) as title, ltrim(rtrim(data_type)) as

data_type, ltrim(rtrim(sp_variable)) as sp_variable, is_required, sorting, ord FROM ReportsInputs WHERE keyInput=convert(uniqueidentifier,'$ind')");
    }
    function setInput($uid, $ind, $params) {
        if (!empty($ind)) {
            NDatabase::query('UPDATE ReportsInputs SET title=?, data_type=?, sp_variable=?, is_required=?, sorting=?, ord=? WHERE convert(varchar(255),keyInput)=?',
                                    array($params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord'], $ind));
        } else {
            $ind = Entity::getNUI();
            NDatabase::query('INSERT INTO ReportsInputs (keyReport,title,data_type,sp_variable,is_required,sorting,ord) VALUES(convert(uniqueidentifier,?),?,?,?,?,?,?)',
                                    array($uid, $params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord']));
        }
        return $ind;
    }
    function deleteInput($ind) {
        NDatabase::query('DELETE FROM ReportsInputs WHERE keyInput = convert(uniqueidentifier,?)', array($ind));
    }


    # create report
    function createReport($cmd, $report, $params, $categories) {      
        global $keyWebSubDomains;
        $cKeyWebSubDomains = $keyWebSubDomains;
/*
EXEC EOLReportAssetUsage

@cKeyWebSubDomains,@dStartDate,@dEndDate,@cWebSubDomainsMenusKeys,@cDescription,@nIsPDF,@cSortBy1,@cSortBy2,@cSortBy3,@cSortBy4,@cSortBy5
EXEC EOLReportOrderHistory

@cKeyWebSubDomains,@dStartDate,@dEndDate,@cWebSubDomainsMenusKeys,@cOrderNumber,@cDescription,@nIsPDF,@cSortBy1,@cSortBy2,@cSortBy3,@cSortBy4,@cSortBy5      
EXEC EOLReportPostPortable

@cKeyWebSubDomains,@dStartDate,@dEndDate,@cWebSubDomainsMenusKeys,@cOrderNumber,@cDescription,@nIsPDF,@cSortBy1,@cSortBy2,@cSortBy3,@cSortBy4,@cSortBy5  
 
-- WKH '{0CD12A89-8AEA-4F80-AA3B-370D475B8C06}'
-- PCB '{8BAB3BAB-A22F-48A9-8ADF-CCC2ED70FBF7}'
-- woowdwyn '{92913C74-BAA9-4A5A-9703-C650D1B0694B}'
*/

        $values = $crits = array();
        $cWebSubDomainsMenusKeys = $cSortBy1 = $cSortBy2 = $cSortBy3 = $cSortBy4 = $cSortBy5 = '';
       
        $inputs = ReportsEntity::getInputsList($report['keyReport']);
        foreach($inputs as $input) {
            if ($input['data_type'] != 'Select') {
                $values[$input['sp_variable']] = $params[$input['keyInput']];
            } else {
                $select = $params[$input['keyInput']];
                if (is_array($select) && $input['sp_variable'] == '@cSortBy') {
                    foreach($select as $sel) {
                        if ($sel == '99') continue;
                       
                        if (empty($cSortBy1)) $cSortBy1 = $sel;
                        else if (empty($cSortBy2)) $cSortBy2 = $sel;
                        else if (empty($cSortBy3)) $cSortBy3 = $sel;
                        else if (empty($cSortBy4)) $cSortBy4 = $sel;
                        else if (empty($cSortBy5)) { $cSortBy5 = $sel; break; }
                    }
                } else {
                    $cSortBy1 = $params[$input['keyInput']];
                }
            }
        }
        $dStartDate =  isset($values['@dStartDate']) ? date('Y-m-d 00:00:01', strtotime($values['@dStartDate'])) : 'GETDATE()';
        $crits['Start Date'] =  date('m-d-Y', strtotime($dStartDate));
        $dEndDate = isset($values['@dEndDate']) ?  date('Y-m-d 23:59:59', strtotime($values['@dEndDate'])) : 'GETDATE()';
        $crits['End Date'] = date('m-d-Y', strtotime($dEndDate));
        $cOrderNumber = isset($values['@cOrderNumber']) ? $values['@cOrderNumber'] : '';
        if ($cOrderNumber) $crits['Order Number'] = $cOrderNumber;
        $cDescription = isset($values['@cDescription']) ? $values['@cDescription'] : '';
        if ($cOrderNumber) $crits['Description'] = $cDescription;
        $cCategory = isset($values['@cCategory']) ? $values['@cCategory'] : '';
        if ($cCategory) $crits['Category'] = $cCategory;
        $nAllOverlapCats = isset($values['@nAllOverlapCats']) ? $values['@nAllOverlapCats'] : '';
        if ($nAllOverlapCats) $crits['All Overlap Categories'] = $nAllOverlapCats;
        $n33Cube = isset($values['@n33Cube']) ? $values['@n33Cube'] : '';
        if ($n33Cube) $crits['33" Cube'] = $n33Cube;
        $n6TableSkirt = isset($values['@n6TableSkirt']) ? $values['@n6TableSkirt'] : '';
        if ($n6TableSkirt) $crits['6 Table Skirt'] = $n6TableSkirt;
        $n8TableSkirt = isset($values['@n8TableSkirt']) ? $values['@n8TableSkirt'] : '';
        if ($n8TableSkirt) $crits['8 Table Skirt'] = $n8TableSkirt;
        $nBanners = isset($values['@nBanners']) ? $values['@nBanners'] : '';
        if ($nBanners) $crits['Banners'] = $nBanners;
        $nFeatherLite = isset($values['@nFeatherLite']) ? $values['@nFeatherLite'] : '';
        if ($nFeatherLite) $crits['Featherlite'] = $nFeatherLite;
        $nHOP = isset($values['@nHOP']) ? $values['@nHOP'] : '';
        if ($nHOP) $crits['HOP'] = $nHOP;
        $nPipe8x7 = isset($values['@nPipe8x7']) ? $values['@nPipe8x7'] : '';
        if ($nPipe8x7) $crits['Pipe 8x7'] = $nPipe8x7;
        $nPipe8x10 = isset($values['@nPipe8x10']) ? $values['@nPipe8x10'] : '';
        if ($nPipe8x10) $crits['Pipe 8x10'] = $nPipe8x10;
        $nTableRunner = isset($values['@nTableRunner']) ? $values['@nTableRunner'] : '';
        if ($nTableRunner) $crits['Table Runner'] = $nTableRunner;
        $nIsPDF = $cmd == 'pdf' ? 1 : 0;

        if (!empty($categories)) {
            $cWebSubDomainsMenusKeys = implode(',', $categories);
        }
               

        $exec = trim($report['execString']);
        $execParams = explode('@', $exec);
        if (empty($exec) || $execParams == $exec) {
            $sp = trim($report['stored_procedure']);

            if ($sp == 'EOLReportOrderHistory') {
                $q = "EXEC $sp '$keyWebSubDomains','$dStartDate','$dEndDate','$cWebSubDomainsMenusKeys','$cOrderNumber','$cDescription',

$nIsPDF,'$cSortBy1','$cSortBy2','$cSortBy3','$cSortBy4','$cSortBy5'";
            }
            else if ($sp == 'EOLReportAssetUsage') {
                $q = "  DECLARE @nIsPDF TinyInt
                        SET @nIsPDF = 1
                        EXEC $sp '$keyWebSubDomains','$dStartDate','$dEndDate','$cWebSubDomainsMenusKeys','$cDescription',$nIsPDF,'$cSortBy1','$cSortBy2','$cSortBy3','$cSortBy4','$cSortBy5';
                    ";
            }
            else if ($sp == 'EOLReportPostPortable') {
                $q = "  DECLARE @nIsPDF TinyInt
                        SET @nIsPDF = 1
                        EXEC $sp '$keyWebSubDomains','$dStartDate','$dEndDate','$cWebSubDomainsMenusKeys','$cOrderNumber','$cDescription',

$nIsPDF,'$cSortBy1','$cSortBy2','$cSortBy3','$cSortBy4','$cSortBy5';
                    ";
            }
/*
            else if ($sp == 'EOLReportAssetUsageWithOverlaps') {
                $q = "  DECLARE @nIsPDF TinyInt
                        SET @nIsPDF = 7
            DECLARE @cTest TinyInt
            SET @cTest='OOOPS'
                        EXEC $sp '$keyWebSubDomains','$dStartDate','$dEndDate','$cWebSubDomainsMenusKeys','$cDescription','$cTest',

$nIsPDF,'$cSortBy1','$cSortBy2','$cSortBy3','$cSortBy4','$cSortBy5';
                    ";
            }
*/
        } else {
            $execParams = explode('@', $exec);
            $q = $execParams[0];
            $l = strlen($q);            
            unset($execParams[0]);
           
            foreach($execParams as $execParam) {
                $q .= ($l == strlen($q) ? ' ' : ',' );
                $execParam = str_replace(",", "", $execParam);
               
               
                if ($execParam == 'nIsPDF') {
                    $q .= "$" . $execParam;
                } else {
                    $q .= "'$$execParam'";
                }
            }
        }  
        eval ("\$q = \"$q\";");
#die($q);            
       
        $_SESSION["SP"] = $q;
        $data = NDatabase::getOne($q);
        if (!$data)
            return 'No records found.';      
           
        $data = NDatabase::getAllAssoc($q);
#echo "<pre>"; die(print_r($data));
        if (is_array($data)) {
            $filename = trim($report['title']) . '_' . time();
            $parts = explode("/", $_SERVER['PHP_SELF']);
            $subDomain = $parts[count($parts) - 3];
            $main = $parts[count($parts) - 2];
            $uploaddir = $subDomain .'/'. $main . '/ProductImages/Reports/';
           
            $_logo = '../../' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];
            $logo = file_exists($_logo) ? $_logo : '';
            $_ss = explode('.', $report['header_image']);
            $ext = $_ss[ count($_ss)-1 ];
           
            $_SESSION['title'] = $title = trim($report['title']);
            $_SESSION['logo'] = $logo;
            $_SESSION['ext'] = strtoupper($_ss[ count($_ss)-1 ]);
           
            if ($cmd == 'pdf') {    
                return ReportsEntity::createPDF($filename.'.pdf', $uploaddir, $data, $report, $logo, $crits);
            } else {
                return ReportsEntity::createCSV($filename.'.csv', $uploaddir, $data);
            }
        }
    }      

    # to CSV
    function createCSV($filename, $path, $data) {
        $file_csv = '../../' . $path . $filename;
#echo $file_csv."<br>";
        $fp = fopen($file_csv, 'w');
        $row = 0;
        foreach($data as $d) {
            $str = '';
            if ($row == 0) {
                $headers = array_keys($d);
                foreach ($headers as $header) { $str .= $header.","; }                
                fwrite($fp, $str . PHP_EOL);
                $str = '';
                $row++;
            }
            foreach ($d as $v) {
#                $str .= "'".addslashes($v)."',";
                $str .= "$v,";
            }
            fwrite($fp, $str . PHP_EOL);
        }
        fclose($fp);
       
        return (file_exists($file_csv)) ? $filename : 'File not exists. Please connect to admins.';
    }

    # to PDF
    function createPDF($filename, $path, $data, $report, $logo, $crits) {        
        $file_pdf = '../../' . $path . $filename;        
        $title = trim($report['title']);
       
#        $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('DS6 Team');
        $pdf->SetTitle($title);
        $pdf->SetSubject($title);
        $pdf->SetKeywords('TCPDF, PDF, report');

#        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
#        $pdf->SetFont('helvetica', 'B', 24);
#        $pdf->SetHeaderData($logo, PDF_HEADER_LOGO_WIDTH, $report['title'], " Created on ".date('F d, Y'));
#        $pdf->SetHeaderData($logo);

        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

        // set margins
#        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
        $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);

        $pdf->SetFont('dejavusans', '', 8);
        $pdf->AddPage();
        $y = $pdf->GetY();  
        $pdf->SetY( $y-7, true );        

// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)
       
        $text = '';
        $substring='1969';
        foreach($crits as $title => $value) {
            if (strpos($value, $substring) !== false) {
                $value="";
            }
            $text .= "<tr><td>&nbsp;&nbsp;$title:&nbsp;&nbsp;$value</td></tr>";
        }

        $html .= "<table style='width:100%; cellspacing='0'> <tr><td><b>Report Criteria</b></td></tr>$text</table><br><br>";

#echo "<br>".$html;        
#die();
       
#        $y = $pdf->GetY();
#        $pdf->SetY( $y+2, true );        


        $headers = array_keys($data[0]);
        $width = 0;
        if (!empty($report['columns'])) {
            $cols = strpos($report['columns'], ';') !== false ? explode(';', $report['columns']) : $report['columns'];
            if (is_array($cols)) {
                foreach($cols as $col) {
                    $_col = explode(':', $col);
                    $columns[$_col[0]] =$_col[1];
                    $width = $width + (int)$_col[1];
                }
            } else {
                $_col = explode(':', $cols);
                $columns[$_col[0]] = $_col[1];
                $width = $width + (int)$_col[1];
            }      
        }
#die(print_r($columns));
       
        $count_h = count($headers);
        $count_c = count($columns);
        $const_width = ceil((982 - $width) / ($count_h - $count_c));
#die("$const_width = (982 - $width) / ($count_h - $count_c)");
       
        $html .= '<table style="width:100%;" cellspacing="0">';
       
        $html .= '<tr>';
        $k = 1;
        foreach($headers as $header) {
            $col_width = isset($columns[$header]) ? $columns[$header] : $const_width;
                   
            $hd = ucwords($header);
            $h = split(",", substr( preg_replace("/([A-Z])/", ',\\1', $hd), 1 ));
            $header = implode(' ', $h);
           
            $html .= '<td bgcolor="#eee" align="left" width="'.$col_width.'" height="32" vertical-align="middle"><b>'.$header.'</b></td>';
            $k++;
        }
        $html .= '</tr>';
       
        foreach( $data as $dat ) {
            $html .= '<tr>';
            foreach($dat as $d) {
                $html .= "<td style='word-wrap:break-word;'>$d</td>";
            }
            $html .= '</tr>';
        }        
        $html .= '</table>';

        $pdf->writeHTML($html, true, false, true, false, '');
        $pdf->lastPage();
        $pdf->Output($file_pdf, 'F');

        return (file_exists($file_pdf)) ? $filename : 'File not exists. Please connect to admins.';
    }
   
}

class MYPDF extends TCPDF {

    //Page header
    public function Header() {
        // Logo
        $this->Image($_SESSION['logo'], 5, 5, 40, '', $_SESSION['ext'], '', 'T', false, 72, 'L', false, false, 0, false, false, false);
       
        // Title
        $this->SetFont('helvetica', '', 16);
        $this->Cell(10, 15, "       ", 0, false, 'L', 0, '', 0, false, 'M', 'M');
        $this->Cell(180, 15, $_SESSION['title'], 0, false, 'L', 0, '', 0, false, 'T', 'M');
        $this->SetFont('helvetica', 'i', 12 );
        $this->Cell(0, 15, "Created on ".date('F d, Y'), 0, false, 'R', 0, '', 0, false, 'T', 'M');
       
        $this->Line( 10, 17, $this->getPageWidth() - 10, 17 );
    }
}
?>
ASKER CERTIFIED SOLUTION
Avatar of NerdsOfTech
NerdsOfTech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of woodwyn

ASKER

I can successfully navigate to the image using the URL for the image:

http://mydomain.com/ban/main/ProductImages/HeaderImages/bbts_header.jpg
Ok great. So, what is the relative path to this image from the script?

(the script is going UP two directories from the script "../../" then going through the directories from that level)

../../ban/main/ProductImages/HeaderImages/bbts_header.jpg

Being that the "ban" folder is at the root directory, the script is coded as being two directories deep.

e.g. http://mydomain.com/1/2/script.php 
(if it was two levels deep, the script would work as is.)

Since it is not two levels deep, where is this script located?


So is it one level deep?:
e.g. http://mydomain.com/1/script.php
$_logo = '../' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];

Open in new window


Or on the root directory level?:
e.g. http://mydomain.com/script.php
$_logo = $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];

Open in new window


Or 3 levels deep?:
e.g. http://mydomain.com/1/2/3/script.php 
$_logo =  '../../..' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];

Open in new window


etc.
Avatar of woodwyn

ASKER

Hope this helps.  

http://mydomain.com/ban/main/report_build.php?  Is the URL when I get the error.  This directs us back up two folder levels, but the Reports.php file is two levels back down, basically at http://mydomain.com/application/entity/reports.php.

The content of report_build.php page is
<?php
//load file which contain including Smarty, PEAR and other required libraries
require_once "../../sub_report_build.php";
?>

The content of sub_report_build.php is
<?php

//load file which contain including Smarty, PEAR and other required libraries
require_once "_loader.php";
if(!UserEntity::checkRoles($user_id, array("GA","RU","DA"))) {
    $Msgr->sendMessage("login.php", $Msgr->GetMessage('login_need'));
    General::Redirect("login.php");      
}


$uid = http_request('uid');

$cmd = http_request('cmd');
if (!isset($cmd) || empty($cmd)) $cmd = 'params';

$response = http_request('input');
NTemplate::assign("response", $response);

$rep_cats = http_request('rep_cats');

$report_link_pdf = http_request('report_link_pdf');
$report_link_csv = http_request('report_link_csv');

$errors = array();

loadEntity('user');
loadEntity('reports');

# the method doesn't return data for USER ?????????????????????
#$report = ReportsEntity::getReport($uid);

$reports = ReportsEntity::getReportsList();
foreach($reports as $report) {
    if ($report['keyReport'] == $uid) {
        NTemplate::assign("report", $report);
        break;
    }
}

$inputs = ReportsEntity::getInputsList($uid);
foreach($inputs as $key => $input) {

    if ($input['data_type'] == 'Select' && !empty($input['sorting'])) {
        $sort = array();
        $sorts = explode(';', $input['sorting']);
        $resp_ar = isset($response) ? $response[$input['keyInput']] : array();

        foreach ($sorts as $kid=>$sid) {
            $select = "<select name='input[".$input['keyInput']."][]' style='width:146px;'>";
            if ($input['is_required'] == 0)
                $select .= "<option value='99'".(!isset($response) ? " selected='selected'" : '')."> </option>";

            foreach ($sorts as $k=>$s) {
                if (!isset($response))
                    $select .= "<option value='$s'".($k==0 && $input['is_required'] == 1 ? 'selected="selected"' : '').">$s</option>";
                else
                    $select .= "<option value='$s'".($resp_ar[$kid] == $s ? 'selected="selected"' : '').">$s</option>";
            }
            $select .= "</select>";

            $sort[$input['title']." ".($kid+1)] = "$select";
        }

        $inputs[$key]['sorting'] = $sort;
    }
}
#echo "<pre>"; die(print_r($inputs));
NTemplate::assign("inputs", $inputs);

if (isset($response)) {
    foreach ($inputs as $input) {
        if ( $input['is_required'] == 1 && empty( $response[$input['keyInput']] ) ) {
            $errors[] = $input['title'].' value cannot be blank';
        }
    }
}

$categories = array();
$role = UserEntity::getRoles($user_id);
#die("$user_id, $role");
if (UserEntity::getMenuLimitSetting() == 1) {
    global $keyWebSubDomains;
    $sub_left_menu = ItemEntity::getViewCategories($keyWebSubDomains);
#echo "<pre>";print_r($sub_left_menu);echo "</pre>";            
   
    $user_id = NSession::get("user_id");
    $access_left_menu = UserEntity::getAccessCategories($user_id);
#echo "<pre>";print_r($access_left_menu);echo "</pre>";            

    $idx = 0;
    foreach ($sub_left_menu as $item) {
        if ( ($role == 'RU' && in_array($item['keyWebSubDomainsMenus'], $access_left_menu)) || $role !== 'RU') {
            $checked = in_array($item['keyWebSubDomainsMenus'], $rep_cats) ? '1' : '0';
            $categories[] = array(
                        "key" => $item['keyWebSubDomainsMenus'],
                        "parent" => $item['keyWebSubDomainsMenusParent'],
                        'name' => $item['LeftMenuHeader'],
                        'checked' => $checked,
                        'level' => $item['level'],
                        'idx' => $idx
                    );
            $idx++;
        }
    }
}
NTemplate::assign("categories", $categories);


# create a Report
NTemplate::assign("build_response", '');

if (empty($errors) && $cmd != 'params') {
    loadEntity('domain');
    $keyWebSubDomains = DomainEntity::getSubDomainKey();
    $filename = ReportsEntity::createReport($cmd, $report, $response, $rep_cats);
   
    if (strpos($filename, '.csv') > 0 || strpos($filename, '.pdf') > 0) {
        $parts = explode("/", $_SERVER['PHP_SELF']);
        $link = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $parts[count($parts) - 3] . '/' . $parts[count($parts) - 2] . '/ProductImages/Reports/' . $filename;
        if ($cmd == 'pdf')
            $report_link_pdf = $link;
        else
            $report_link_csv = $link;
    }
    else {
        NTemplate::assign("build_response", $filename);
    }
}
NTemplate::assign("report_link_pdf", $report_link_pdf);
NTemplate::assign("report_link_csv", $report_link_csv);


NTemplate::assign("title", $report['title']);
NTemplate::assign("uid", $uid);
NTemplate::assign("cmd", $cmd);
NTemplate::assign("errors", $errors);
NTemplate::display("sub_report_build.tpl");

?>
Where is reports.php referenced/included (it seems as if it isn't)?
Avatar of woodwyn

ASKER

$_logo = '../../' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];

I don't think this train of thought is productive.  I have tried changing the relative path to ../, ../../, ../../../ and ../../../../.  I have also tried entering the actual URL of the image instead of a relative path,
 $_logo = 'http://mydomain.com/ban/main/ProductImages/HeaderImages/bbts_header.jpg';

I'm not sure if that is the right syntax for that, but it doesn't work either.  

I think the issue is not in the relative path.  It worked up until a couple of weeks ago and this type of relative path works in other areas of the website.  I believe the issue is based around PDFs loading images.
Could it be a permissions issue with the files or folders involved? How are these files and folders CHMOD'd?
Avatar of woodwyn

ASKER

It's not a permissions issue.  The images are accessed in other areas of the sites, but it the PDFs are no longer able to access the images.
Thanks for trying the exact path as that was going to be my next question.

Check the TCPDF cache folder permissions.

Also, double check permissions on the files and folders as TCPDF accesses files as an anonymous user.

Check php.ini allow_url_fopen = On; allow_url_include = On;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial