EllisLab text mark
Advanced Search
     
CI newbie needs help with page not rendering after process is sent through more then 2 functions
Posted: 05 November 2012 02:21 AM   [ Ignore ]
Joined: 2012-11-05
8 posts

Hi I’m relatively new to CI and I’ve run across this issue a couple times.

the task i’m working on loads a main index, when a link is clicked a popup which is used to gather filters to display a view appears. once it is submitted another view with a form appears. on submission of this form it does several inserts into databases and then redirected to a generatePDF function. after output of the pdf another database insert is done and its redirected back to the index.

the redirects are all done with

$this->function($data); 

I’ve checked all the databases and all the info is there that should of been inserted, and the pdf file is in the files folder but all it renders is a blank page.  I placed a echo statement at the very end of my index and it echos the page image that should of displayed. So I know its getting there, just unsure why it won’t render.

In other cases when this has happened if I placed a return; after it It would work but even that isn’t working this time.

Any help would be greatly appreciated.

 

 
Posted: 05 November 2012 02:22 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

Show your code.

 
Posted: 05 November 2012 02:30 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts
function createNewa()
 
{
  $data[
'text'$this->lang->language;
  
$data['storevis''hidden';
  
$data['agentvis''hidden';
  
$data['billvis''hidden';
  
$data['projvis''hidden';


  
$filters['facilityTypeID'6;
  
$billtos $this->Warehouses->getAll($filters);
  
  
$data['billtos'][0] "Select Bill to Facility";
  foreach(
$billtos as $billto)
   
$data['billtos'][$billto['warehouseID']] $billto['name'];
   
  
$stores $this->companyProjectsMembers->getStores2();
  
  
$data['stores'][0] "Select A Store";
  foreach(
$stores as $store)
  
{
   
if(strlen($store['storeID']) == 0)
    
$meas = -1;
   else
    
$meas strlen($store['storeID']);
    
   
$data['stores'][$store['storeID']] $store['storeID'].' '.str_repeat(' '10-$meas).' '.$store['name'].' '.str_repeat(' ',30-strlen($store['name'])-1).' '.str_repeat('-'2).' '.$store['city'].', '.$store['state'];
  
}
  
  $rules[
'storeID'"trim|greater_than[0]|required";
  
  
$this->validation->set_rules($rules);
  
$this->validation->set_fields('',''$stores);
  
  if(
$_POST['process'== '1' && $this->validation->run())
  
{

   $store 
$this->companyProjectsMembers->storesStoreInfo($_POST['storeID']);
   
$agents $this->companyProjectsMembers->getAgents2();
   for(
$x=0$x<count($agents); $x++)
   

    $agents[$x][
'mileage'number_format(round($this->_calcDist($agents[$x]['Latitude']$agents[$x]['Longitude']$store[0]['Latitude']$store[0]['Longitude']),2),2,".","");    
   
}
   
foreach($agents as $key => $row)
   
{
    $mileage[$key] 
$row['mileage'];
    
$id[$key] $row['agentID'];
   
}

   array_multisort
($mileageSORT_ASC$idSORT_ASC,  $agents);
   
   
$data['agents'][0] "Select a Agent";
   foreach(
$agents as $agent)
   
{
    
if(strlen($agent['agentID']) == 0)
     
$meas = -1;
    else
     
$meas strlen($agent['agentID']);
    
    
$data['agents'][$agent['ID']] $agent['agentID'].' '.str_repeat('&nbsp;'10-$meas).' '.$agent['name'].' '.str_repeat('&nbsp;',50-strlen($agent['name'])-1).' '.str_repeat('-'2).' '.$agent['mileage'];
   
}
   
   $data[
'storevis''';
   
$data['agentvis''';
   
$data['billvis''';
   
$data['projvis''';
   
$data['sselected'$_POST['sselected'];
   
$data['mselected'$_POST['mselected'];

  
}
   
  $housingData[
'contents'$this->load->view('/reviewProjects/createNewa'$datatrue);
  
$housingData['text'$this->lang->language;
  
$this->load->view('/housing/blank'$housingData);
 
}
 
function _validProjName($str)
 
{
  
  
if ($this->companyProjects->nameExists($str))
  
{
   
return false;
  
}

  
return true;
 

there is more but its a few thousand lines in total

 
Posted: 05 November 2012 02:33 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts
function createNew()
 
{

  $data[
'text'$this->lang-language;
  
set_time_limit(0);
  if(!empty(
$_POST['projName']))
   
$name $this->_validProjName($_POST['projName']);
   
  if(
$name == '0'){
  
echo '<br>false';
   
$data['message'"The selected project name already exists please select a different one!";}
  
  $agentID 
$this->companyProjectsMembers->getAgentIDByID($_POST['ID']);
  
$agentInfo $this->companyProjectsMembers->agentsAgentInfo($agentID['agentID']);
  
$storeInfo $this->companyProjectsMembers->storesStoreInfo($_POST['storeID']);  
  
$data['billInfo'$this->Warehouses->getInfo($_POST['warehouseID']);
  
$data['agent'$agentInfo[0];
  
$data['store'$storeInfo[0];
  
$data['projName'$_POST['projName'];
  
$data['orderNum'$_POST['orderNum'];
  
$data['ID'$agentInfo[0]['ID'];
  
$data['storeID'$storeInfo[0]['storeID'];
  
$data['projectName'$_POST['projName'];
  
$data['orderNumber'$_POST['orderNum'];
  
$data['warehouseID'$_POST['warehouseID'];
  
  if(
$_POST['process'== '1')
  
{

   
if($_POST['projname'!= '')
   
{

    $name1 
$this->_validProjName($_POST['projname']);

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

    $data[
'message'"The selected project name already exists please select a different one!";
   
}
   $data[
'projName'$_POST['projname'];
  
}
  
  
if($_POST['process'== '2')
  
{   
   
if($_POST['projname'!= '')
   
{
    $exists 
$this->companyProjects->nameExists($_POST['projname']);
    
    if(
count($exists) > )
    
{
     $data[
'message'"Your selected name already exists.<br>Please choose a different name.";
    
}
    
if(count($exists) == 0)
    
{
     $pdata[
'name'$_POST['projname'];
     
$pdata['companyID'$this->userInfo['companyID'];
     
$pdata['OrderNo'$_POST['orderNum'];
     
$pdata['billName'$_POST['billName'];
     
$pdata['billAddress'$_POST['billAddress'];
     
$pdata['billCity'$_POST['billCity'];
     
$pdata['billState'$_POST['billState'];
     
$pdata['billZip'$_POST['billZip'];
     
$pdata['billPO'$_POST['billtoPoNum'];
     
$pdata['billEmail'$_POST['billEmail'];
     
$pdata['originPickup'$_POST['pickDateTime'];
     
$pdata['originShipper'$_POST['shipper'];
     
$pdata['originAddress1'$_POST['sAddress1'];
     
$pdata['originAddress2'$_POST['sAddress2'];
     
$pdata['originCity'$_POST['sCity'];
     
$pdata['originState'$_POST['sState'];
     
$pdata['originZip'$_POST['sZip'];
     
$pdata['originContact'$_POST['sContact'];
     
$pdata['originPhone'$_POST['sPhone'];
     
$pdata['numMen'$_POST['numMen'];
     
$pdata['numStraight'$_POST['numStrTrucks'];
     
$pdata['numTrailer'$_POST['numTractorTrk'];
     
$pdata['liftGate'$_POST['liftGate'];
     
$pdata['blanket'$_POST['BnS'];
     
$pdata['furniture'$_POST['furnDolly'];
     
$pdata['appliance'$_POST['appDolly'];
     
$pdata['palletJack'$_POST['palletJack'];
     
$pdata['insidePickup'$_POST['inPickup'];
     
$pdata['dockPickup'$_POST['dockPickup'];
     
$pdata['dockDel'$_POST['DockDel'];
     
$pdata['insideDel'$_POST['inDel'];
     
$pdata['unpack'$_POST['unpack'];
     
$pdata['debrisRem'$_POST['debRem'];
     
$pdata['setup'$_POST['setupAssem'];
     
$pdata['packingMat'$_POST['packMat'];
     
$pdata['jBar'$_POST['jBar'];
     
$pdata['originInst'$_POST['originInst'];
     
$pdata['destInst'$_POST['destInst'];
     
$pdata['descr1'$_POST['descr1'];
     
$pdata['descr2'$_POST['descr2'];
     
$pdata['descr3'$_POST['descr3'];
     
$pdata['inventoryNote1'$_POST['inven1'];
     
$pdata['inventoryNote2'$_POST['inven2'];
     
$pdata['inventoryNote3'$_POST['inven3'];
     
$pdata['inventoryNote4'$_POST['inven4'];
     
$pdata['image1'$_POST['img1'];
     
$pdata['image2'$_POST['img2'];
     
$pdata['image3'$_POST['img3'];
     
$pdata['notes'$_POST['notes'];
     
     
$projectID $this->companyProjects->createProject($pdata);
     
     if(!empty(
$_POST['agentNum']) && !empty($_POST['destName']))
     
{
      
      $assignData[
'agentID'$_POST['agentNum'];
      
$assignData['storeID'$_POST['destName'];
      
$assignData['companyProjectsID'$projectID;
      
$assignData['companyID'$storeInfo[0]['companyID'];
      
      
$this->companyProjectsMembers->addMembersToProject($assignData);

      
$aExists $this->companyProjectsMembers->agentExists($_POST['agentNum']$projectID);
      
$aaExists $this->companyProjectsMembers->agentExistsWithNoProject($_POST['agentNum']);
      if(
count($aaExists) > 0)
      
{
       $aData[
'projectID'$projectID;
       
$this->companyProjectsMembers->updateAgents($aaExists['ID']$aData);
      
 
Posted: 05 November 2012 02:34 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts

    if(count($aExists) == 0 && count($aaExists) == 0)
    {
    $agentInfo = $this->companyProjectsMembers->agentsAgentInfo($_POST[‘agentNum’]);
    $agent = $agentInfo[0];

      $aData[‘agentID’] = $agent[‘agentID’];
      $aData[‘companyID’] = $agent[‘companyID’];
      $aData[‘projectID’] = $projectID;
      $aData[‘name’] = $agent[‘name’];
      $aData[‘address1’] = $agent[‘address1’];
      $aData[‘city’] = $agent[‘city’];
      $aData[‘state’] = $agent[‘state’];
      $aData[‘zip’] = $agent[‘zip’];
      $aData[‘postalCode’] = $agent[‘postalCode’];
      $aData[‘country’] = $agent[‘country’];
      $aData[‘phone’] = $agent[‘phone’];
      $aData[‘contact’] = $agent[‘contact’];
      $aData[‘email’] = $agent[‘email’];
      $aData[‘companyCategoryID’] = $agent[‘companyCategoryID’];
      $aData[‘Latitude’] = $agent[‘Latitude’];
      $aData[‘Longitude’] = $agent[‘Longitude’];       
       
      $this->companyProjectsMembers->insertAgentsTable($aData);   
   
    }

    $sExists = $this->companyProjectsMembers->agentExists($_POST[‘destName’], $projectID);
    $ssExists = $this->companyProjectsMembers->agentExistsWithNoProject($_POST[‘destName’]);
    if(count($ssExists) > 0)
    {
    $sData[‘projectID’] = $projectID;
    $this->companyProjectsMembers->updateStores($ssExists[‘ID’], $sData);
    }
       
    if(count($sExists) == 0 && count($ssExists) == 0)
    {
    $storeInfo = $this->companyProjectsMembers->storesStoreInfo($_POST[‘destName’]);
   
    $store = $storeInfo[0];

      $sData[‘storeID’] = $store[‘storeID’];
      $sData[‘companyID’] = $store[‘companyID’];
      $sData[‘projectID’] = $projectID;
      $sData[‘name’] = $store[‘name’];
      $sData[‘address1’] = $store[‘address1’];
      $sData[‘city’] = $store[‘city’];
      $sData[‘state’] = $store[‘state’];
      $sData[‘zip’] = $store[‘zip’];
      $sData[‘postalCode’] = $store[‘postalCode’];
      $sData[‘country’] = $store[‘country’];
      $sData[‘phone’] = $store[‘phone’];
      $sData[‘contact’] = $store[‘contact’];
      $sData[‘email’] = $store[‘email’];
      $sData[‘companyCategoryID’] = $store[‘companyCategoryID’];
      $sData[‘Latitude’] = $store[‘Latitude’];
      $sData[‘Longitude’] = $store[‘Longitude’];       
       
      $this->companyProjectsMembers->insertStoresTable($sData);   
   
    }

    $filters[‘agentID’] = $_POST[‘agentNum’];
    $filters[‘storeID’] = $_POST[‘destName’];   
    $filters[‘notification’] = “Project name ” . $_POST[‘projname’] . ” was successfully created.”;
    $maxID = ‘’;

    $this->createAgentPDF($maxID, $projectID, $filters);
    }
    $data[‘notification’] = “Project name ” . $_POST[‘projname’] . ” was successfully created.”;
    $this->index($data);
  } 
  }
  }
  $housingData[‘contents’] = $this->load->view(’/reviewProjects/createNew’, $data, true);
  $housingData[‘text’] = $this->lang->language;
  $this->load->view(’/housing/blank’, $housingData);
  //$this->load->view(’/labelTemplates/pageHousing’, $data);
}

 
Posted: 05 November 2012 02:36 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts

this is at the end of the pdf function

$filename './uploads/rfs/'.$agent['agentID'].'_'.$projectID.'.pdf';
    
$fileInfo[$i]['fileName'$agent['agentID'].'_'.$projectID.'.pdf';
    
$fileInfo[$i]['size'filesize($fileInfo[$i]['fileName']);
    
$fileInfo[$i]['locationType''agentPDF';
    
$fileInfo[$i]['locationID'$agent['companyID'].$projectID;
    
$pagesInfo[$agent['agentID']]['pages'$a;

    
$file[] $this->pdf->output($filename'F');

    
$i++;
   

   $aaData[
'attachments''Y';
   foreach(
$agents as $agent)
   
{
    $this
->companyProjectsMembers->updateAgents($agent['ID']$aaData);
    
$notification $pagesInfo[$agent['agentID']]['pages'" pages for "$agent['name'"<br/>" $notification;
   
}
   
foreach($fileInfo as $file)
    
$this->Files->insert($file);
    
   if(
$filters['notification'!= '')
    
$notification0 $filters['notification'];
    
   
$notification1 "The following were successfully generated!"
   
$data['notification'$notification0.'<br>'.$notification1.'<br>'.$notification;
   
   if(
count($filters) > 0)
   
{
    $this
->index($data);
    
   
}     
   
else
   
{
    $this
->importStoreAgentAssignments($data);
   
 
Posted: 05 November 2012 02:40 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts

to make more sense of this the createNewa is the popup. its redirected through post to the createNew function which near the bottom has the

$this->createAgentPDF(); 

redirect.  then at the bottom of the pdf in the if statement is the redirect back to the index.

 
Posted: 05 November 2012 02:51 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts

this is the image of the echo at the end of the index function.  but it wont render through the load->view

 
Posted: 06 November 2012 12:51 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2012-11-05
8 posts

Solved.