diff --git a/app/Config/Boot/production.php b/app/Config/Boot/production.php index 1241907..314d630 100644 --- a/app/Config/Boot/production.php +++ b/app/Config/Boot/production.php @@ -7,7 +7,7 @@ | Don't show ANY in production environments. Instead, let the system catch | it and display a generic error message. */ -ini_set('display_errors', '0'); +ini_set('display_errors', '1'); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); /* diff --git a/app/Config/Email.php b/app/Config/Email.php index d9ca142..bd92839 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -33,7 +33,7 @@ class Email extends BaseConfig * * @var string */ - public $protocol = 'mail'; + public $protocol = 'smtp'; /** * The server path to Sendmail. @@ -47,35 +47,35 @@ class Email extends BaseConfig * * @var string */ - public $SMTPHost; + public $SMTPHost='smtp.googlemail.com'; /** * SMTP Username * * @var string */ - public $SMTPUser; + public $SMTPUser='celine.forworkinphp96@gmail.com'; /** * SMTP Password * * @var string */ - public $SMTPPass; + public $SMTPPass='phpmailer96'; /** * SMTP Port * * @var integer */ - public $SMTPPort = 25; + public $SMTPPort = 465; /** * SMTP Timeout (in seconds) * * @var integer */ - public $SMTPTimeout = 5; + public $SMTPTimeout = 60; /** * Enable persistent SMTP connections @@ -89,7 +89,7 @@ class Email extends BaseConfig * * @var string */ - public $SMTPCrypto = 'tls'; + public $SMTPCrypto = 'ssl'; /** * Enable word-wrap @@ -110,7 +110,7 @@ class Email extends BaseConfig * * @var string */ - public $mailType = 'text'; + public $mailType = 'html'; /** * Character set (utf-8, iso-8859-1, etc.) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f0bc737..4b90374 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -43,7 +43,9 @@ $routes->match(['get','post'],'donation_data','Dashboard::donation_data_upload') $routes->match(['get','post'],'donor_register','My_controller::donor_register'); $routes->match(['get'],'fetch_donor_id','Dashboard::fetch_donor_id'); +$routes->match(['get'],'fetch_cause_name','Dashboard::fetch_cause_name'); $routes->match(['get','post'],'add_donation_cause','Dashboard::add_donation_cause'); +$routes->match(['get'],'htmlToPDF','PdfController::htmlToPDF'); // $routes->add('register','Donation::register'); // $routes->add('list','Donation::edit_view'); // $routes->add('store','Home::store'); diff --git a/app/Controllers/Dashboard.php b/app/Controllers/Dashboard.php index 2791dc6..0bdd394 100644 --- a/app/Controllers/Dashboard.php +++ b/app/Controllers/Dashboard.php @@ -6,6 +6,7 @@ use App\Models\Transaction_model; use App\Models\Donation_data_model; use App\Models\My_model; use App\Models\Donation_cause; +use App\Models\Donor_model; class Dashboard extends BaseController { @@ -28,8 +29,8 @@ class Dashboard extends BaseController return redirect()->to(base_url()); } - $name= session()->get('logged_user'); - $data['userdata']=$this->dModel->getLoggedInUserData($name); + $id= session()->get('logged_user'); + $data['userdata']=$this->dModel->getLoggedInUserData($id); echo view('templates/header',$data); echo view('dashboard'); echo view('templates/footer'); @@ -49,7 +50,8 @@ class Dashboard extends BaseController } $name= session()->get('logged_user'); - $data['donor']=$this->MyModel->fetch_donor_id(); + //$data['donor']=$this->MyModel->fetch_donor_id(); + //$data2['donor']=$this->MyModel->fetch_donor_id(); echo view('templates/header'); echo view('receipts'); echo view('templates/footer'); @@ -59,6 +61,12 @@ class Dashboard extends BaseController echo $this->MyModel->fetch_donor_id(); + } + function fetch_cause_name() + { + + echo $this->dcModel->fetch_cause_name(); + } public function generate_receipts() @@ -81,7 +89,8 @@ class Dashboard extends BaseController ]; $model->save($receiptData); - return redirect()->to(base_url().'/Dashboard'); + + return redirect()->to(base_url().'/Dashboard/last_receipt/'); } public function all_receipt() { @@ -120,6 +129,59 @@ class Dashboard extends BaseController echo view('templates/footer'); } + function last_receipt() + { + // admin data + $dmodel = new Donor_model(); + $id= session()->get('logged_user'); + $admin_data=$dmodel->find($id); + // last receipt data + $receipt_data=$this->rModel->last_receipt(); + //print_r($receipt_data); + foreach($receipt_data as $key){ $key['receipt_id']; $key['donor_id'];} + //donation cause + $causemodel = new Donation_cause(); + $cause_id=$key['receipt_id']; + $cause_data=$causemodel->find($cause_id); + // donor data + $model = new My_model(); + $donor_id=$key['donor_id']; + $Donor_data=$model->find($donor_id); + // array for receipt + $data= [ 'donordata'=>$Donor_data , 'admindata' =>$admin_data , 'receipt'=>$receipt_data ,'causedata'=>$cause_data ]; + + echo view('templates/header'); + echo view('pdf_view',$data); + echo view('templates/footer'); + } + + function view_receipt($receiptid) + { + // admin data + $dmodel = new Donor_model(); + $id= session()->get('logged_user'); + $admin_data=$dmodel->find($id); + // receipt data + $rmodel = new Receipt_model(); + $receipt_id=$receiptid; + $receipt_data=$rmodel->find($receipt_id); + $donorid = $receipt_data['donor_id']; + $causeid = $receipt_data['cause_name']; + // donation cause + $causemodel = new Donation_cause(); + $cause_id=$causeid; + $cause_data=$causemodel->find($cause_id); + // donor data + $model = new My_model(); + $donor_id=$donorid; + $Donor_data=$model->find($donor_id); + // array for receipt + $data= [ 'donordata'=>$Donor_data , 'admindata' =>$admin_data , 'receipt'=>$receipt_data , 'causedata'=>$cause_data]; + + echo view('templates/header'); + echo view('view_receipt',$data); + echo view('templates/footer'); + } public function transaction() { $data = []; @@ -266,7 +328,7 @@ class Dashboard extends BaseController return redirect()->to(base_url()); } - $name= session()->get('logged_user'); + $data['donationcause']=$this->dcModel->all_donation_cause(); echo view('templates/header',$data); echo view('add_donation_cause'); @@ -287,7 +349,28 @@ class Dashboard extends BaseController ]; $model->save($donationCause); - return $this->donation_cause(); - + return redirect()->to(base_url()."/Dashboard/donation_cause"); + } + function edit_donation_cause($id) + { + if(!session()->has('logged_user')) + { + return redirect()->to(base_url()); + } + $model = new Donation_cause(); + $donation_cause=$model->find($id); + $data= [ 'post'=>$donation_cause ]; + + if($this->request->getMethod() == 'post') + { + $model = new Donation_cause(); + $_POST['id'] = $id; + $model->save($_POST); + return redirect()->to(base_url()."/Dashboard/donation_cause"); + } + echo view('templates/header',$data); + echo view('donation_cause_edit'); + echo view('templates/footer'); + } } \ No newline at end of file diff --git a/app/Controllers/PdfController.php b/app/Controllers/PdfController.php new file mode 100644 index 0000000..c8492c7 --- /dev/null +++ b/app/Controllers/PdfController.php @@ -0,0 +1,64 @@ +find($receipt_id); + $data= [ 'post'=>$receipt_data ]; + // $html = view('pdf_view',$data); + // $dompdf->loadHtml($html); + $dompdf = new \Dompdf\Dompdf(); + $dompdf->loadHtml(view('pdf_view',$data)); + $dompdf->setPaper('A4', 'landscape'); + $dompdf->render(); + $dompdf->stream(); + } + function download_receipt($receiptid) + { + // admin data + $dmodel = new Donor_model(); + $id= session()->get('logged_user'); + $admin_data=$dmodel->find($id); + // receipt data + $rmodel = new Receipt_model(); + $receipt_id=$receiptid; + $receipt_data=$rmodel->find($receipt_id); + $donorid = $receipt_data['donor_id']; + $causeid = $receipt_data['cause_name']; + // donation cause + $causemodel = new Donation_cause(); + $cause_id=$causeid; + $cause_data=$causemodel->find($cause_id); + // donor data + $model = new My_model(); + $donor_id=$donorid; + $Donor_data=$model->find($donor_id); + // array for receipt + $data= [ 'donordata'=>$Donor_data , 'admindata' =>$admin_data , 'receipt'=>$receipt_data , 'causedata'=>$cause_data]; + + $dompdf = new \Dompdf\Dompdf(); + $dompdf->loadHtml(view('download_receipt',$data)); + $dompdf->setPaper('A4', 'portrait'); + $dompdf->render(); + $dompdf->stream(); + + } + + + +} \ No newline at end of file diff --git a/app/Controllers/Sendmail.php b/app/Controllers/Sendmail.php new file mode 100644 index 0000000..f53ccef --- /dev/null +++ b/app/Controllers/Sendmail.php @@ -0,0 +1,62 @@ +setTo($to); + $email->setFrom('gowtham.manavalan.la@gmail.com', 'Confirm Registration'); + + $email->setSubject($subject); + $email->setMessage($message); + + if ($email->send()) + { + echo 'Email successfully sent'; + } + else + { + $data = $email->printDebugger(['headers']); + print_r($data); + } + + } + + function sendMail() { + $to = $this->request->getVar('mailTo'); + $subject = $this->request->getVar('subject'); + $message = $this->request->getVar('message'); + + $email = \Config\Services::email(); + + $email->setTo($to); + $email->setFrom('johndoe@gmail.com', 'Confirm Registration'); + + $email->setSubject($subject); + $email->setMessage($message); + + if ($email->send()) + { + echo 'Email successfully sent'; + } + else + { + $data = $email->printDebugger(['headers']); + print_r($data); + } + } + +} \ No newline at end of file diff --git a/app/Models/Dashboard_model.php b/app/Models/Dashboard_model.php index a07c213..4ea8d25 100644 --- a/app/Models/Dashboard_model.php +++ b/app/Models/Dashboard_model.php @@ -4,6 +4,8 @@ use CodeIgniter\Model; class Dashboard_model extends Model { + + public function getLoggedInUserData($id) { $builder = $this->db->table('user_management'); @@ -17,6 +19,7 @@ class Dashboard_model extends Model } } + function fetch_country() { diff --git a/app/Models/Donation_cause.php b/app/Models/Donation_cause.php index 4a28b29..46d276c 100644 --- a/app/Models/Donation_cause.php +++ b/app/Models/Donation_cause.php @@ -19,6 +19,19 @@ class Donation_cause extends Model $output = $result->getResultArray(); return $output; } + function fetch_cause_name() + { + + $builder = $this->db->table('donation_cause'); + $query = $builder->get(); + //print_r($query);die(); + $output = ''; + foreach($query->getResult() as $row) + { + $output .= ''; + } + return $output; + } // protected $returnType = 'array'; diff --git a/app/Models/Receipt_model.php b/app/Models/Receipt_model.php index d1c9927..9734629 100644 --- a/app/Models/Receipt_model.php +++ b/app/Models/Receipt_model.php @@ -18,7 +18,16 @@ class Receipt_model extends Model $result = $builder->get(); $output = $result->getResultArray(); return $output; - } + } + + function last_receipt() + { + + $builder=$this->db->query("SELECT receipt_id,receipt_no,date,donor_id,amount,mode_of_receipt,receipt_details,cause_name,remarks FROM receipts where receipt_id =(select max(receipt_id) from receipts) "); + $output = $builder->getResultArray(); + + return $output; + } // protected $returnType = 'array'; diff --git a/app/Views/add_donation_cause.php b/app/Views/add_donation_cause.php index 6f29eb5..1d5bb20 100644 --- a/app/Views/add_donation_cause.php +++ b/app/Views/add_donation_cause.php @@ -3,7 +3,7 @@
|
+ DONATION RECEIPT + |
+
+
+ Receipt No #: = $receipt['receipt_id'] ?> + Date := $receipt['date'] ?> + + |
+
|
+
+ = ucfirst($admindata['org_name']); ?> + = $admindata['address'] ?>,= $admindata['city'] ?>, + = $admindata['state'] ?>-= $admindata['pin_code'] ?>. + |
+
+
+ Email := $admindata['email'] ?> + Phone := $admindata['phone'] ?>. + + |
+
| + Donor + | + ++ = $donordata['name'] ?> + | +
| + Address + | + ++ = $donordata['address'] ?>,= $donordata['city'] ?>,= $donordata['state'] ?>,= $donordata['country'] ?>-= $donordata['pin_code'] ?> + | +
| + Donation Cause + | + ++ = $causedata['cause_name']; ?> + | +
| + Donation Cause Validity + | + ++ = $causedata['from_date']; ?>-to-= $causedata['to_date']; ?> + | +
| + Amount + | + ++ = $receipt['amount'] ?> + | +
| + Amount in Words + | + ++ + + + | +
| + Payment Mode + | + ++ = $receipt['mode_of_receipt'] ?> + | +
| + Payment Mode Referal + | + ++ + = $receipt['receipt_details'] ?> + | +
+
|
+ |||
|
+
+ = ucfirst($admindata['org_name']); ?> + = $admindata['address'] ?>,= $admindata['city'] ?>, + = $admindata['state'] ?>-= $admindata['pin_code'] ?>. + |
+
+
+ Email := $admindata['email'] ?> + Phone := $admindata['phone'] ?>. + + |
+ ||
| + Donation Cause + | + ++ = $causedata['cause_name']; ?> + | +||
| + Donation Cause Validity + | + ++ = $causedata['from_date']; ?>-to-= $causedata['to_date']; ?> + | +||
| + Payment Method + | + ++ Check # + | +||
| + Check + | + ++ + = $donordata['name'] ?> + + | +||
| + Item + | + ++ Price + | +||
| + Website design + | + ++ $300.00 + | +||
| + Hosting (3 months) + | + ++ $75.00 + | +||
| + Domain name (1 year) + | + ++ $10.00 + | +||
| + + | + Total: $385.00 + | +||
| Details | Cause | Action | +Get Receipt | Edit | +View Receipt |
|---|---|---|---|
+
|
+ |||
|
+
+ = ucfirst($admindata['org_name']); ?> + = $admindata['address'] ?>,= $admindata['city'] ?>, + = $admindata['state'] ?>-= $admindata['pin_code'] ?>. + |
+
+
+ Email := $admindata['email'] ?> + Phone := $admindata['phone'] ?>. + + |
+ ||
| + Donor + | + ++ = $donordata['name'] ?> + | +||
| + Address + | + ++ = $donordata['address'] ?>,= $donordata['city'] ?>,= $donordata['state'] ?>,= $donordata['country'] ?>-= $donordata['pin_code'] ?> + | +||
| + Donation Cause + | + ++ = $causedata['cause_name']; ?> + | +||
| + Donation Cause Validity + | + ++ = $causedata['from_date']; ?>-to-= $causedata['to_date']; ?> + | +||
| + Amount + | + ++ = $receipt['amount'] ?> + | +||
| + Amount in Words + | + ++ + + + | +||
| + Payment Mode + | + ++ = $receipt['mode_of_receipt'] ?> + | +||
| + Payment Mode Referal + | + ++ + = $receipt['receipt_details'] ?> + | +||