while sending bulk email i am finding error using codeigniter...I have attached my error part also...i need to find out solution.whether the id is passing are not need to check...In Model only showing error in function part ...I need to rectify that to get proper manner error part:
A PHP Error was encountered
Severity: Error
Message: Call to a member function get_user_by_id() on null
Filename: models/Report_model.php
Line Number: 264
My controller:
<?php
class Remindermail extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
$this->load->library(array('session', 'form_validation'));
$this->load->database();
$this->load->model('Gst_model');
$this->load->model('User_model');
$this->load->model('Report_model');
}
function sendReminderMail()
{
$details = $this->User_model->get_user_by_id($this->session->userdata('id'));
$data['id'] = $details[0]->id;
$data['vault_no'] = $details[0]->vault_no;
$vault_no = $data['vault_no'];
$Vault_decript = base64_encode($vault_no);
$this->db->where('vault_no', $vault_no);
$query=$this->db->get('client_mailing_details');
$client_details= $query->result();
$data['client_details'] = $client_details;
$client_name = $client_details[0]->client_name;
$client_mail = $client_details[0]->client_mail;
$client_pid = $client_details[0]->Provisional_ID;
$client_contact_no = $client_details[0]->Contact_no;
//post menthod
$this->load->model('Report_model');
$vendor_details = $this->Report_model->getNoUpdateVendor();
$data['vendor_details'] = $vendor_details;
//$Vault_decript = base64_encode($vault_no);
for ($i = 0; $i < count($vendor_details); ++$i) {
$ID_encript = base64_encode($vendor_details[$i]->VendorID);
$config = array(
'protocol' => 'sendmail',
'mailtype' => 'html',
'charset' => 'UTF-8',
);
$this->load->library('email', $config);
$this->email->set_newline("
");
$this->email->set_mailtype("html");
$message =
'<!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<table class="body" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: #f6f6f6;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f6f6f6">
<tbody>
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 13.3333px;"> </span></span></td>
<td class="container" style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; margin: 0 auto !important; max-width: 580px; padding: 10px; width: 580px;" valign="top" width="580">
<div class="content" style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;">
<table class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; box-shadow: 0px 2px 18px 0px rgba(0,0,0,2); width: 100%; background: #fff; border-radius: 3px;" border="0" width="100%">
<tbody>
<tr>
<td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;" valign="top">
<table style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
<p><img src="http://www.miisky.com/ci/GST.png" alt="" width="85" height="84" /> <strong>GSTN VENDOR UPDATION <img src="http://www.aarmsvaluechain.com/images/value-chain.png" alt="" width="98" height="84" /> </strong></p>
<p>Dear Sir / Madam,</p>
<p>As you are aware, the Government of India introduced Good and Service Tax ("GST"), was introduced in Aug 2016, and is poised to be implemented in July 2017. GST will subsume the existing indirect Taxes such as VAT, SERVICE TAX, CENVAT, ENTERTAINMENT TAX, ENTRY TAX etc. </p>
<p>As part of the GST regime, various state governments have initiated the GST enrollment process of existing VAT taxpayer registered with various State VAT departments. Accordingly, we would request you to confirm if you have completed the enrollment process and obtained the provisional ID from relevant State VAT department. In the event, the enrollment process is yet to commence in State in which you are registered as a VAT taxpayer, we would request you to confirm the receipt of the provisional ID at the earliest possible.</p>
<p>The process of enrollment and obtaining provisional IDs from State VAT department is provided on <a href="http://tutorial.gst.gov.in/video/module/index.html">http://tutorial.gst.gov.in/video/module/index.html</a>. </p>
<p>We have already have got the Provisional Registration Certificate and details of the same is provided below.</p>
<table border="4" cellpadding="5px" align="center">
<tbody>
<tr>
<th>Name of the Assesse</th>
<th>Provisional ID</th>
</tr>
<tr>
<td>'.$client_name.'</td>
<td>'.$client_pid.'</td>
</tr>
</tbody>
</table>
<div> </div>
<div>
<p align="center"><a style="display: inline-block; color: #ffffff; width: 250px; background-color: skyblue; border: solid 1px #00ff99; border-radius: 5px; box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.5); box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-transform: capitalize; border-color: #00ff99;" title="GSTN Number Updation" href="http://www.miisky.com/ci/index.php/Clientdoc/downloadDoc/'.$Vault_decript.'"><span style="color: #000000; font-family: Arial, Helvetica, sans-serif;">Click to view '.$client_name.' Documents</span></a></p>
</div>
<p>We would also request you to identify and ascertain the HSN (Harmonized System of Nomenclature) number of the products supplied to us under the Agreement. Under the model GST laws, HSN code of the product must be mentioned in the invoice issued by you.</p>
<p>Separately, with the introduction of GST and model GST laws, the existing agreement needs be amended to incorporate for fresh/ revised covenants and obligations considering GST laws, and regarding revised commercials, as the parties may mutually decide. Accordingly, discussions in this regard would be initiated in due course.</p>
<p>We request you to provide your Provisional id details as per the below format:</p>
<table style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: auto;" border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top; background-color: #00ff99; border-radius: 0px; text-align: center;" align="center" valign="top" bgcolor="#00ff99"><a style="display: inline-block; color: #ffffff; width: 500px; background-color: #00ff99; border: solid 1px #00ff99; border-radius: 5px; box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.5); box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-transform: capitalize; border-color: #00ff99;" title="GSTN Number Updation" href="http://www.miisky.com/ci/index.php/Vendorlink/vendorRecive/'.$ID_encript.'"><span style="color: #000000; font-family: Arial, Helvetica, sans-serif;">Click to update Vendor GSTN Number</span></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>We hereby authorize M/S. AARMS Value Chain Private Limited to collect and consolidate GST Registration details and request you to please share the details with them.</p>
<p>We look forward to your full support in smooth transition to the GST regime.</p>
<br />
<p>Best Regards,</p>
<p>'.$client_name.'</p><br>
<p>'.$client_contact_no.'</p>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
<div class="footer" style="clear: both; padding-top: 10px; text-align: center; width: 100%;">
<table style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-top: 10px; padding-bottom: 10px; font-size: 12px; color: #999999; text-align: center;" align="center" valign="top"><span style="color: #000000; font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 13.3333px;"><span class="apple-link" style="color: #000000; font-size: 12px; text-align: center;"><strong>Powered by:<a>AARMS value chain pvt ltd</a></strong></span> <br /><br /></span></span></td>
</tr>
<tr>
<td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-top: 10px; padding-bottom: 10px; font-size: 12px; color: #999999; text-align: center;" align="center" valign="top"><span style="color: #000000; font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 13.3333px;"> </span></span></td>
</tr>
</tbody>
</table>
</div>
<p><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 13.3333px;"> </span></span></p>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div id="_rc_sig"> </div>';
$mail_to = $vendor_details[$i]->VendorEmail;
$from_mail = $client_mail;
$from_name = $client_name;
$reply_to = $client_mail;
$subject = "Online GSTIN Updation!";
$this->load->library('email', $config);
$this->email->from($from_mail, $from_name);
$this->email->to($mail_to);
$this->email->cc($client_mail);
$this->email->bcc('innovations@miisky.com');
$this->email->subject($subject);
$this->email->message($message);
//$this->email->attach($file);
$this->email->send();
}
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Process Successfully executed!</div>');
redirect('Vendor_noupdate');
}
}
My Model:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Report_model extends CI_Model{
function __construct()
{
// Call the Model constructor
parent::__construct();
}
//read the department list from db
function getTotalvendor()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$sql = 'SELECT COUNT(*) as total_vendor FROM gst_vendormaster WHERE vault_no="'.$data['vault_no'].'" ';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function getUpdatedvendor()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$sql = 'SELECT COUNT(*) as updated_vendor FROM gst_vendor_location WHERE vault_no="'.$data['vault_no'].'"';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function getNoUpdateVendor()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$data['id'] = $details[0]->id;
$sql = 'SELECT gst_vendormaster.VendorCode, gst_vendormaster.VendorID, gst_vendormaster.VendorEmail, gst_vendormaster.VendorName
FROM gst_vendormaster
LEFT JOIN gst_vendor_location ON gst_vendormaster.VendorCode = gst_vendor_location.VendorCode
WHERE gst_vendor_location.id IS NULL AND gst_vendormaster.vault_no = "'.$data['vault_no'].'"';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function getTotalcustomer()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$sql = 'SELECT COUNT(*) as total_customer FROM gst_customermaster WHERE vault_no="'.$data['vault_no'].'" ';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function getUpdatedcustomer()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$sql = 'SELECT COUNT(*) as updated_customer FROM gst_customer_location WHERE vault_no="'.$data['vault_no'].'"';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function getNoUpdateCustomer()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('id'));
$data['vault_no'] = $details[0]->vault_no;
$sql = 'SELECT gst_customermaster.CustomerCode, gst_customermaster.CustomerID, gst_customermaster.Email, gst_customermaster.CustomerName
FROM gst_customermaster
LEFT JOIN gst_customer_location ON gst_customermaster.CustomerCode= gst_customer_location.CustomerCode
WHERE gst_customer_location.id IS NULL AND gst_customermaster.vault_no = "'.$data['vault_no'].'" ';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function get_all_vendor_list($vault_no)
{
$sql = 'SELECT * FROM `gst_vendormaster` where vault_no="'.$vault_no.'" ';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
function get_all_customer_list($vault_no)
{
$sql = 'SELECT * FROM `gst_customermaster` where vault_no="'.$vault_no.'"';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
}