0

Trying to include a php file in public folder to the blade file, but that is not working:

Error:

View [../../public/pdf/index.php] not found. (View: C:\wamp\www\nih\app\views\rapport.blade.php)

rapport.blade.php

@extends('default')

@section('content')



<div class="jumbotron" >
<div class="container" >
<div class="row" >
<div class="col-lg-12" >


@include('../../public/pdf/index.php')

</div>
</div>
</div>
</div>


@stop

Index.php - Content

<form action='' method='Post'/>
Fra Dato: <input type="text" name="fraDato" value="<?php echo date('d-m-Y'); ?>" /> <br>
Til Dato: <input type="text" name="tilDato" value="<?php echo date('d-m-Y'); ?>"> <br> 
<input type="radio" name="hent" value="timesmaling">Times malinger<br>
<input type='submit' name='submit' value='Generer rapport'>

</form>



<?php

    require('mysql_table.php');

     $timezone = "Europe/Oslo";
     date_default_timezone_set($timezone);
     $format="%H%M%S";
    $strf=strftime($format);

     if(isset($_POST['submit']))

    {
        $fraDato1 = DateTime::createFromFormat('d-m-Y', $_REQUEST['fraDato']);
        $tilDato1 = DateTime::createFromFormat('d-m-Y', $_REQUEST['tilDato']);
        $fraDato = $fraDato1->format('Y-m-d');
        $tilDato = $tilDato1->format('Y-m-d');




    class PDF extends PDF_MySQL_Table
    {


    function Header()
    {
        //Title
        $this->SetFont('Arial','',18);
        $this->Cell(0,6,'Malinger/Oppgaver',0,1,'C');
        $this->Ln(10);
        //Ensure table header is output
        parent::Header();
    }
    }




    //Connect to database
    mysql_connect('localhost','root','');
    mysql_select_db('nih_bw');

    $pdf=new PDF();
    $pdf->AddPage();
    //First table: put all columns automatically

    if (isset($_POST['hent']))
    {

        if($_POST['hent'] == 'timesmaling')
        {
    $pdf->Table("SELECT measurements.title as Maling, routines.value as Verdi, DATE_FORMAT(routines.date, '%d/%m/%Y') as Dato, routines.time as Tid, pools.name as Basseng, emps.user_name as Ansatt
    FROM routines, measure_routine, measurements, pools, emps
    WHERE routines.id = measure_routine.routine_id
    AND measure_routine.measure_id = measurements.id
    AND (measurements.title  Like 'T_%') AND measure_routine.pool_id=pools.id AND routines.emp_id=emps.id AND Date between '".$fraDato."' and '".$tilDato."'
    ORDER BY routines.date, routines.time;");

    $pdf->Output($downloadfilename."$strf.pdf"); 
    header('Location: '.$downloadfilename."$strf.pdf");






       }



    }

    $prop=array('HeaderColor'=>array(255,150,100),
                'color1'=>array(210,245,255),
                'color2'=>array(255,255,210),
                'padding'=>2);

    }
    ?>
user3185936
  • 1,567
  • 6
  • 23
  • 44
  • possible duplicate of [laravel blade @include not working](http://stackoverflow.com/questions/21474638/laravel-blade-include-not-working) – MSadura Apr 01 '14 at 11:26

2 Answers2

0

Because it tries to include file as Blade template. Try to use the old good php include method:

<?php include('../../public/pdf/index.php') ?>
3472948
  • 801
  • 4
  • 15
neoascetic
  • 2,476
  • 25
  • 34
  • Thanks, that worked. But I am including some files with index.php but that returning some error(fpdf): https://www.dropbox.com/s/i9af32bj9mkfsp3/error.png – user3185936 Apr 01 '14 at 11:35
  • The funny thing is that when I go the path http://localhost/nih/public/pdf/index.php and run the file from there it works perfect, but not when I do it from the blade file. – user3185936 Apr 01 '14 at 11:55
  • Please paste the file content – neoascetic Apr 01 '14 at 11:56
  • Please check EDIT, its when I press the submit bottom in blade I get the error. – user3185936 Apr 01 '14 at 12:04
  • You have some not-trivial logic in your index file. Better approach is to move this logic to your Laravel app. You get error probably because of redirect (see `Location` header) - generated url to new PDF is not accessible – neoascetic Apr 01 '14 at 12:10
  • Hmm! Yes, it will be best to move the logic to laravel app. But that will be for difficult for me. The easiest will be to just include the php file and run it as a seperated file. The problem is that I am not understand why its getting error of the redirect. Because if I run the file directly in public it doesnt error me, but with that include i am getting error. – user3185936 Apr 01 '14 at 12:29
  • When I remove the header, it still error. So I am unsure if it's the header erroring. – user3185936 Apr 01 '14 at 13:26
  • You should change question or create new one, because your original question is answered :) – neoascetic Apr 01 '14 at 20:23
0

Please add FPDF PHP File.

require('fpdf.php');

Reference Link

GIPSSTAR
  • 2,050
  • 1
  • 25
  • 20