i have following code in the controller file which check for post varible pdf and execute following code
if(isset($_POST['pdf']) && $_POST['pdf']=="pdf")
{
$this->load->model('voutput_model');
$final_view = $data['frmReport'];
$PDF_Name = "report.pdf";
$this->votput_model->pdf($PDF_Name,$final_view);
}
I have following code in model file
class Voutput_model extends CI_Model{
public function __construct()
{
parent::__construct();
$this->CI = get_instance();
}
public function pdf($file_name,$filecontents){
$this->pdf_path = $this->config->item('pdf_path');
$this->load->library('htmltopdf/Html2fpdf');
$file['Attach_path'] = $this->pdf_path.$file_name;
$this->html2fpdf->generate_pdf($file['Attach_path'],$filecontents,'Y');
}
}
while i am executing the code i am getting error as below:
Severity: Notice
Message: Undefined property: Voutput::$Voutput_model
Filename: controllers/voutput.php
Fatal error: Call to a member function pdf() on a non-object in
C:\xampp\htdocs\asset\application\controllers\voutput.php
You need to load model before use . Try this
$this->load->model('votput_model');
$this->votput_model->pdf($PDF_Name,$final_view);
Related
I created a codeigniter custom library(My_payment_gate_way_init) for my payment gateway.. but when i use my custom library function , controller(Billing) not passing parameters into the library it shows
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Billing::$My_payment_gate_way_init
Filename: controllers/Billing.php
Line Number: 576
that error occurs when i use
Controller
public function __construct()
{
parent::__construct();
$this->load->library('My_payment_gate_way_init');
}
function saveord(){
$ammount = $this->totlCost * 100;
$this->My_payment_gate_way_init->setTransactionAmountforPay($ammount);
}
library
class My_payment_gate_way_init
{
private $clientConfig;
private $initRequest;
private $transactionAmount;
private $redirect;
private $initResponse;
private $client;
private $CI;
function __construct()
{
$this->setTransactionAmountforPay();
}
function setTransactionAmountforPay($ammount=200){
// sets transaction-amounts details (all amounts are in cents)
$this->transactionAmount = new TransactionAmount();
$this->transactionAmount->setTotalAmount(0);
$this->transactionAmount->setServiceFeeAmount(0);
$this->transactionAmount->setPaymentAmount($ammount);
$this->transactionAmount->setCurrency("LKR");
$this->initRequest->setTransactionAmount($this->transactionAmount);
}
also it shows this error at bottom
Fatal error: Call to a member function setTransactionAmountforPay() on
null in
C:\xampp\htdocs\debug_online\application\controllers\Billing.php on
line 576
Make an object first before calling the function.
$this->My_payment_gate_way_init = new My_payment_gate_way_init();
$this->My_payment_gate_way_init->setTransactionAmountforPay($ammount);
I'm using codeigniter and trying to write a Helper class for loading dropdown dynamicly according to model name and the attribute which is the Column name for view.
function dropdown($Class,$Attribute)
{
$Output=NULL;
define("CLASSNAME", $Class."_model");
define("ATTRIBUTE", $Attribute);
$CI = get_Instance();
$CI->load->model(CLASSNAME);
$FullData=$CI->CLASSNAME->get();
foreach ($FullData as $Data)
{
$Output.='<option value="'.$Data->Id.'">'.$Data->ATTRIBUTE.'</option>';
}
return $Output;
}
But when I call it means i am getting this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: News::$CLASSNAME
Filename: helpers/component_helper.php
Line Number: 11
Fatal error: Call to a member function get() on a non-object in C:\xampp\test\application\helpers\component_helper.php on line 11
it seems that you may have missed a syntax
$CI = get_Instance();
use $CI =& get_Instance(); instead and check again if the issue is resolved.
[STDERR] PHP Fatal error: Call to undefined method Customer::isOwnStudents() in /upload/catalog/view/theme/Super_green/template/common/header.tpl on line 62
header.tpl looks like
<?php
if ($this->customer->isLogged()) {
if($this->customer->isOwnStudents()>0) echo $orderfood;
echo $language . $currency . $cart . $konto;`}
?>
class ModelAccountStudents extends Model {
public function isOwnStudents() {
$results = $this->getStudentses();
if(sizeof($results)>0) return true;
else return false;
}
What is wrong here in this code. I do not know why do I get this err.
From your code, it looks like $this->customer is an instance of Customer - you've defined the isOwnStudents() method for the ModelAccountStudents class, not the Customer class.
I'm new to PHP and Magento, I'm trying to delete a Customer from Magento and I get this error -
Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 30
At other times I get -
Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 15
The CustomerController.php file contains this code -
<?php
require('Mage/Adminhtml/controllers/CustomerController.php');
class Braintree_CustomerController extends Mage_Adminhtml_CustomerController
{
public function deleteAction()
{
$braintree = Mage::getModel('braintree/paymentMethod');
$customerId = $this->getRequest()->getParam('id');
if ($customerId)
{
$braintree->deleteCustomer($customerId);
}
parent::deleteAction();
}
public function massDeleteAction()
{
$customerIds = $this->getRequest()->getParam('customer');
if(is_array($customerIds))
{
$braintree = Mage::getModel('braintree/paymentMethod');
foreach ($customerIds as $customerId)
{
$braintree->deleteCustomer($customerId);
}
}
parent::massDeleteAction();
}
}
Change
$braintree = Mage::getModel('braintree/paymentMethod');
To
$braintree = Mage::getModel('braintree/paymentmethod');
Then rename
/app/code/local/Braintree/{Modulename}/Model/PaymentMethod.php
To
/app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php
Then change the class name by edit file /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php
Change
class Braintree_{Modulename}_Model_PaymentMethod ...
To
class Braintree_{Modulename}_Model_Paymentmethod ...
you shall not use camel case class names like paymentMethod!
$braintree = Mage::getModel('braintree/paymentMethod');
Rename your class to Paymentmethod.php, rename the class label inside the class file accordingly.
Then do a
$braintree = Mage::getModel('braintree/paymentmethod');
Mage::log(get_class(braintree);
if the result in the Mage::log is empty you made a mistake with you factory...
Good luck!
I followed the documentation on Models and I keep getting this error, any help would be appreciated.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Manage::$File
Filename: files/manage.php
Line Number: 14
Fatal error: Call to a member function get_files() on a non-object in /var/www/uisimulator/application/controllers/files/manage.php on line 14*
Here is my Model: - Located: application/models/files/file.php
class File extends CI_Model {
var $filename = '';
function __construct() {
parent::__construct();
}
// Return all config files
function get_files() {
$query = $this->db->get('config_files');
return $query->result();
}
function insert_file() {
$this->filename = $this->input->post('filename');
$this->db->insert('config_files', $this);
}
function update_file() {
$this->filename = $this->input->post('filename');
$this->db->update('config_files', $this, array('id' => $this->input->post('id'));
}
}
Here is my Controller: Location: application/controllers/files/manage.php
class Manage extends CI_Controller {
function __construct() {
parent::__construct();
}
public function index() {
$this->load->model('files/file', TRUE);
$config_files['query'] = $this->File->get_files();
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $configFiles);
// Load Footer
$this->load->view('footer');
}
}
Inside my view I have a simple loop to show the results:
<?php foreach ($configFiles as $file) : ?>
<li><?php echo $file['filename'];?></li>
<?php endforeach;?>
Try:
$this->load->model('files/file','', TRUE);
EDITED:
$data['configFiles'] = $this->File->get_files();
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $data);
This code result one record, but give me only fields from one table.
function listar_dados_produto($id)
{
$this->db->where('id',$id);
$query = $this->db->get('produtos');
return $query->result();
}
Note: I am using activerecord. The table produtos return their fields corectly, but i need one field
for another table named categorias.
Any reason you have passed TRUE as the second parameter in the $this->load->model method?
My understanding with CI is that the second parameter is to refer to your model by a different name, other than it's class.
It would appear you are naming your class a boolean, which is bound to cause some kind of error.
Try:
$this->load->model('files/file', NULL, TRUE);
//$data['configFiles'] = $this->File->get_files();
print_r($this->File->get_files());
exit;
// do you get any data?
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $data);