Eror libraries fpdf - codeigniter-3

I have an error fpdf
A PHP Error was encountered
Severity: Warning
Message: include_once(/home/u7639860/public_html/application/third_party/Fpdf/Pdf.php): failed to open stream: No such file or directory
Filename: libraries/Pdf.php
Line Number: 7
Backtrace:
File: /home/u7639860/public_html/application/libraries/Pdf.php
Line: 7
Function: _error_handler
File: /home/u7639860/public_html/application/libraries/Pdf.php
Line: 7
Function: include_once
File: /home/u7639860/public_html/application/controllers/Tb_permohonan.php
Line: 15
Function: library
File: /home/u7639860/public_html/index.php
Line: 316
Function: require_once
this my libraries
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pdf {
public function __construct() {
include_once APPPATH.'third_party/Fpdf/Pdf.php';
$pdf = new FPDF();
$pdf->AddPage();
$CI =& get_instance();
$CI->Pdf = $pdf;
}
}
?>
help me..

it's very simple because you only need to call one of the libraries
$this->load->library('Pdf');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pdf {
public function __construct() {
// include_once APPPATH.'third_party/Fpdf/Pdf.php';
$pdf = new FPDF();
$pdf->AddPage();
$CI =& get_instance();
$CI->Pdf = $pdf;
}
}
?>
Function include_once is deleted, it's run

Related

Zend : Error Occurs when create html file from zend phtml file for multiple employee

//controller function
function sendBulkMailAction(){
$template = "estimated-festival-bill-single.phtml";
foreach ($employeeArr as $profile_id => $employeeValue) {
$someData = array(); //here include some salary data
$model = new ViewModel($someData);
$model->setTemplate($template);
$htmlContent = "<!DOCTYPE html>\n\r<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\r<head>
<meta charset=\"utf-8\">
</head>
<body>"
. $this->getServiceLocator()->get('viewrenderer')->render($model)
. "</body>
</html>";
//create html file
//create pdf link from html by wkhtmlToPdf
//send this link via email to employee
}
}
//estimated-festival-bill-single.phtml
//simple code
<div> Employee Name</div>
<br>
<div><?php echo _get_salary_html(); ?></div>
<?php
function _get_salary_html(){
return "Salary Data";
}
?>
error show
Fatal error: Cannot redeclare _get_salary_html() (previously declared in G:\xampp\htdocs\ums\module\Hrm\view\hrm\salary-reports\estimated-salary-bill-single.phtml:9) in G:\xampp\htdocs\ums\module\Hrm\view\hrm\salary-reports\estimated-salary-bill-single.phtml on line 10
hints: when single employee its ok but for multiple employee show error
Because you are re-declaring function unknowingly. Add a condition around the function like below.
if (!function_exists('_get_salary_html')) {
function _get_salary_html() {
........
}
}

Call to a member function setId() on a non-object in magento

Call to a member function setId() on a non-object in
and here is my code
require_once '../app/Mage.php';
Mage::app();
$model = Mage::getModel('catelog/product');
for($id=1;$id<4;$id++)
echo "in loop";
// Mage::init();
try
{
$model->setId($id)->delete();
echo "Data deleted successfully.";
}
catch (Exception $e)
{
echo $e->getMessage();
}
how i solve this prob please tell me
Change
$model = Mage::getModel('catelog/product');
To
$model = Mage::getModel('catalog/product');
To delete a product:
$product = Mage::getModel('catalog/product')->load($productId);
$product->delete();

Zend pass variable from plugin to view

In plugin I try $this->view->menu = $menu; , but in view I try <?php var_dump($this->menu); ?> and get NULL
Maybe are solution to pass variable from plugin to view ?
you can use like below
First : Without using helpers or plugins do :
Zend_Layout::getMvcInstance()->assign('whatever', 'foo');
After this you can use the following in your layout:
<?php echo $this->layout()->whatever; ?>
This will print "foo".
OR
Second :
<?php
class My_Layout_Plugin extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMvcInstance();
$view = $layout->getView();
$view->whatever = 'foo';
}
}
then register this plugin with the front controller, e.g.
Zend_Controller_Front::getInstance()->registerPlugin(new My_Layout_Plugin());

PHPExcel error when opening downloaded file error "incorrect file format"

I'm creating an Excel report containing UTF-8 encoded data using PHPExcel on Zend. When I'm downloading and trying to open it in Excel it works on local environment but I'm getting the following Error: "Incorrect file format" from live sever/production. Any help / references would be appreciated.
here is a code i used to download xls file:
public function getCsv($data, $filename = false)
{
/**
* generate a file name using unixTimeStamp
* #var string $tmpfname
*/
if ($filename)
{
$tmpfile = "/tmp/".$filename. "-". date('Y-m-d_H:i:s') . ".csv";
$name = str_replace(' ','',$filename)."-".date('Y-m-d_H:i:s') . ".xls";
}
else
{
$tmpfile = "/tmp/report". "_". date('Y-m-d_H:i:s') . ".csv";
$name = "report-".date('Y-m-d_H:i:s') . ".xls";
}
/**
* open Temporary file name in write mode
* #var object $fp
*/
$fp = fopen($tmpfile, "w");
/**
* foreach datas write to csv
*/
foreach ($data as $fields)
fputcsv($fp, $fields, ',', '"');
/**
* close file
*/
fclose($fp);
try
{
$objReader = PHPExcel_IOFactory::createReader('CSV');
$objPHPExcel = $objReader->load($tmpfile);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
//set Header Content Type as application/csv
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=$name");
$objWriter->save('php://output');
}
catch (Exception $e)
{
echo $e->getMessage();
}
exit;
}
You must use this line before saving :
ob_end_clean();

Error in view file

I'm new to zend framework.I'm getting the following error when trying to view the page
Fatal error: Using $this when not in object context in D:\xampp\htdocs\neemjobs\application\views\scripts\register\index.phtml on line 1
class RegisterController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->pageTitle = "Zend_Form Example";
$this->view->bodyCopy = "<p >Please fill out this form.</p>";
$form = new forms_ContactForm();
$this->view->form = $form;
}
}
My View is
<?php echo $this->pageTitle ;?>
<?php echo $this->bodyCopy ;?>
This is totally correct (on my Zend Framework installation goes perfectly, I just don't understand "in which way" are you using the Form... but, anyway, it works, so the "bug" is not there...