diff --git a/app/Config/Email.php b/app/Config/Email.php index 5cb4e15..90eb872 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -28,22 +28,22 @@ class Email extends BaseConfig /** * SMTP Server Address */ - public string $SMTPHost = 'smtp.sendgrid.net'; + public string $SMTPHost = 'mail.venbait.in'; /** * SMTP Username */ - public string $SMTPUser = 'apikey'; + public string $SMTPUser = 'bbone@venbait.in'; /** * SMTP Password */ - public string $SMTPPass = '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'; + public string $SMTPPass = 'xk!L(N_-R#};'; /** * SMTP Port */ - public int $SMTPPort = 587; + public int $SMTPPort = 465; /** * SMTP Timeout (in seconds) @@ -58,7 +58,7 @@ class Email extends BaseConfig /** * SMTP Encryption. Either tls or ssl */ - public string $SMTPCrypto = 'tls'; + public string $SMTPCrypto = 'ssl'; /** * Enable word-wrap diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1960d08..fbe72b6 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -110,6 +110,11 @@ $routes->post("insert_invoice_number_format", "Event::insert_invoice_number_form #Routes for Receipt Routes $routes->get("receipt_list/", "Invoice::index"); $routes->get("new_receipt/(:any)", "Invoice::new_receipt/$1"); +$routes->post("donor_cash_success/", "Invoice::donor_cash_success"); +$routes->post("donor_cash_delete/", "Invoice::donor_cash_delete"); +$routes->get("donations_accepted/", "Invoice::donations_accepted"); +$routes->post("save_donations_accepted/", "Invoice::save_donations_accepted"); +$routes->get("audit_history", "Invoice::audit_history"); $routes->post("load_details1/", "Invoice::load_details1/"); $routes->post("load_details2/", "Invoice::load_details2/"); diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index e5c2fce..1ad5723 100644 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -23,6 +23,7 @@ class Books extends BaseController $model = new BooksModel(); $model->setTable('causes'); + $data['cause_list'] = $model->getData('donations_accepted',null,null); $data['page_name'] = 'Causes List'; $data['details'] = $model->where('causes.business_id', $session_bid)->where('causes.isactive', 1)->findAll(); // echo '
';
@@ -45,9 +46,13 @@ class Books extends BaseController
     
         if ($id === '0') {
             $data['page_name'] = 'Add Causes';
+            $where = ['is_active' => 1 ];
+            $data['cause_list'] = $model->getData('donations_accepted',$where,null);
             $data['details'] = [];
         } elseif ($id !== '0') {
             $data['page_name'] = 'Edit Causes';
+            $where = ['is_active' => 1 ];
+            $data['cause_list'] = $model->getData('donations_accepted',$where,null);
             $data['details'] = $model->where('causes.causes_id', $id)->findAll();
            
         }
@@ -68,6 +73,8 @@ class Books extends BaseController
 
             'name' => $this->request->getPost('name'),
             'description' => $this->request->getPost('description'),
+            'from_date' => ($this->request->getPost('from_date') != '') ? $this->request->getPost('from_date') : null,
+            'to_date' => ($this->request->getPost('to_date') != '') ? $this->request->getPost('to_date') : null,
             'business_id'=>$session_bid
             
         ];
diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php
index 836ce5b..79c28f9 100644
--- a/app/Controllers/Customer.php
+++ b/app/Controllers/Customer.php
@@ -143,7 +143,16 @@ class Customer extends BaseController
             $this->logger->error("Donor : Err Occur =" . $e->getMessage());
             session()->setFlashdata('error', 'Message: ' . $e->getMessage());
         }
-        return redirect()->route('Donor_list');
+
+        if(isset($requestData['new_receipt']))
+        {
+            // return redirect()->route('new_receipt');
+            return redirect()->back();
+        }
+        else
+        {
+            return redirect()->route('Donor_list');
+        }
     }
 
 
diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php
index 20f0cce..355df73 100644
--- a/app/Controllers/Invoice.php
+++ b/app/Controllers/Invoice.php
@@ -4,7 +4,11 @@ namespace App\Controllers;
 
 use App\Models\EventModel;
 use App\Models\CustomerModel;
+use App\Models\SettingsModel;
 use App\Models\InvoiceModel;
+use App\Models\BooksModel;
+use App\Models\AuditHistoryModel;
+use App\Models\UsersModel;
 use App\Helpers\NotificationHelper;
 
 use Mpdf\Mpdf;
@@ -14,6 +18,14 @@ use Dompdf\Options;
 
 class Invoice extends BaseController
 {
+
+    public function __construct()
+	{
+
+		$this->AuditHistoryModel = new AuditHistoryModel();
+
+	}
+
     ## For Invoice Listing..
     public function index()
     {
@@ -38,16 +50,82 @@ class Invoice extends BaseController
         }
     }
 
+    public function donations_accepted()
+    {
+        try 
+        {
+            helper('session');
+            if (is_session_active()) {
+                $session_role = get_user_role();
+                $session_bid = get_business_id();
+    
+                $model = new InvoiceModel();
+                // $where = ['business_id' => (int)get_business_id()];
+                $data['list'] = $model->getData('donations_accepted',null);
+                $data['page_name'] = 'Donations Accepted';
+                // print_r($data);die();
+                $this->render_page('donations_accepted', $data);
+            } else {
+                return redirect()->to('login');
+            }
+        } 
+        catch (\Throwable $e) 
+        {
+            $this->logger->error("donations_accepted: Err Occur =" . $e->getMessage());
+        }
+    }
+
+    public function save_donations_accepted()
+    {
+        try 
+        {
+            helper('session');
+            // print_r($this->request->getPost());die;
+            $model = new InvoiceModel();
+            $list = $model->getData('donations_accepted',null);
+            foreach ($list as $key => $value) {
+                if(in_array($value->id, $this->request->getPost('name')))
+                {
+                    $where = ['id' => $value->id ];
+                    $data['is_active'] = 1;
+                    $upt_data = $model->updateData('donations_accepted', $data, $where);
+                }
+                else
+                {
+                    $where = ['id' => $value->id];
+                    $data['is_active'] = 0;
+                    $upt_data = $model->updateData('donations_accepted', $data, $where);
+                }
+            }
+            session()->setFlashdata('success', 'Causes has been added successfully.');
+            return redirect()->route('donations_accepted');
+        } 
+        catch (\Throwable $e) 
+        {
+            $this->logger->error("donations_accepted: Err Occur =" . $e->getMessage());
+        }
+    }
+
     ## To Load Invoice ADD/EDIT page...
     public function new_receipt($id = '0')
     {
         helper('session');
         $model = new InvoiceModel();
+        $bmodel = new BooksModel();
+        $setting_model = new SettingsModel();
         $where = ['business_id' => (int)get_business_id()];
-    
+        $receipt = $model->getData('receipt', $where);
+        $count_receipt_no = (count($receipt) > 0) ? count($receipt) + 1 : 1;
         // Get customer names for the dropdown, events details, and books details
+        $data['currency'] =  $setting_model->select('currency')->where($where)->findAll();
         $data['customers'] = $model->getData('donor', $where);
-        $data['causes']    = $model->getData('causes', $where);
+        // $data['causes']    = $model->getData('causes', $where);
+        $data['causes']  = $bmodel->select('causes.* , donations_accepted.id as donations_accepted_id , donations_accepted.name as donations_accepted_name')
+											->join('donations_accepted', 'causes.name = donations_accepted.id', 'left')
+											->where('causes.business_id', (int)get_business_id() )
+											->get()->getResult();
+        $data['count_receipt_no'] = $count_receipt_no;
+        $data['campaign']    = $model->getData('campaign', $where);
         $data['invoice_number_formatting'] = $model->getData('settings', $where);
 
         if ($id === '0') {
@@ -57,13 +135,89 @@ class Invoice extends BaseController
         } elseif ($id !== '0') {
             $this->logger->info(" Book Invoice: In Edit Details ID = " . $id);
             $data['page_name']       = 'Edit Receipt Details';
-            $data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first();
+            if(get_user_role() == 'accounts') 
+            {
+                $data['receipt_details'] = $model->where(['receipt_id' => $id])->first();
+            }
+            else
+            {
+                $data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first();
+            }
         }
 
         // echo '
';    
         // print_r($data['invoice_number_formatting']);die;
         $this->render_page('invoice_form', $data);
     }
+
+    public function donor_cash_success()
+    {
+        helper('session');
+        $model = new InvoiceModel();
+        // echo $this->request->getPost('id');die;
+        $where = ['business_id' => (int)get_business_id(),'receipt_id' => $this->request->getPost('id') ];
+        $data['receipt_header'] = 'Receipt';
+        $data['isactive'] = 1;
+        $updata = $model->getData('receipt', $where);
+        $upt_data = $model->updateData('receipt', $data, $where);
+
+        //**********AUDIT HISTORY*************/ 
+        $myArray = array();
+        array_push($myArray, $data);
+        $olddata['receipt_header'] = $updata[0]->receipt_header;
+        $olddata['isactive'] = $updata[0]->isactive;
+        $myArray1 = array();
+        array_push($myArray1, $olddata);
+        /************************** */
+        $currentDateTime = date('Y-m-d H:i:s');
+        $audit_data = [
+            'module' => 'receipt',
+            'business_id' => (int)get_business_id(),
+            'is_edit' => 1,
+            'old_data' => json_encode($myArray1),
+            'current_data' => json_encode($myArray),
+            'updated_on' => $currentDateTime,
+            'updated_by' => (int)get_logged_user_id()
+        ];
+        $this->AuditHistoryModel->save($audit_data);
+        /************************************* */
+
+        if($upt_data) echo true;
+        else echo false;
+    }
+
+    public function donor_cash_delete()
+    {
+        helper('session');
+        $model = new InvoiceModel();
+        $where = ['business_id' => (int)get_business_id(),'receipt_id' => $this->request->getPost('id') ];
+        $data['isactive'] = 0;
+        $data['receipt_header'] = 'Receipt Deleted';
+        $data['reason'] = $this->request->getPost('reason');
+        $updata = $model->getData('receipt', $where);
+        $upt_data = $model->updateData('receipt', $data, $where);
+
+        //**********AUDIT HISTORY*************/ 
+        /**get old data for history */
+        $olddata['receipt_number'] = $updata[0]->receipt_number;
+        $myArray = array();
+        array_push($myArray, $olddata);
+        /************************** */
+        $currentDateTime = date('Y-m-d H:i:s');
+        $audit_data = [
+            'module' => 'receipt',
+            'business_id' => (int)get_business_id(),
+            'is_delete' => 1,
+            // 'old_data' => json_encode($myArray1),
+            'current_data' => json_encode($myArray),
+            'updated_on' => $currentDateTime,
+            'updated_by' => (int)get_logged_user_id()
+        ];
+        $this->AuditHistoryModel->save($audit_data);
+        /************************************* */
+
+        return redirect()->route('receipt_list');
+    }
     
 
     ## For Ajax Call To Fetch/Retrive All Address Details Based On Customer...
@@ -114,7 +268,6 @@ class Invoice extends BaseController
     {
         $this->logger->info("Invoice: Insert/Update Details");
         try {
-
             ## Declarions
             helper('session');
             $model = new InvoiceModel();
@@ -127,9 +280,10 @@ class Invoice extends BaseController
             $data = [
                 'receipt_number' => $this->request->getPost('receipt_number'),
                 'donor_id' => $customer_id,
+                'campaign_id' => (int)$this->request->getPost('campaign_id'),
                 'notes'=>$this->request->getPost('notes'),
                 'receipt_date' => (!empty($receipt_date)) ? date("Y-m-d", strtotime($receipt_date)) : NULL,
-                'amount' => (int)$this->request->getPost('amount'),
+                'amount' => $this->request->getPost('amount'),
                 'payment_mode' => $this->request->getPost('payment_mode'),
                 'payment_ref_no' => $this->request->getPost('payment_ref_no'),
                 'causes_id' => (int)$this->request->getPost('causes_id'),
@@ -141,6 +295,21 @@ class Invoice extends BaseController
                 $data['created_by'] = (int)get_logged_user_id();
                 if ($model->insert($data, 'invoices')) {
                     $receipt_id = $model->insertID();
+                    //**********AUDIT HISTORY*************/ 
+                    $myArray = array();
+                    array_push($myArray, $data);
+                    $currentDateTime = date('Y-m-d H:i:s');
+                    $audit_data = [
+                        'module' => 'receipt',
+                        'business_id' => (int)get_business_id(),
+                        'is_add' => 1,
+                        'current_data' => json_encode($myArray),
+                        'created_by' => (int)get_logged_user_id(),
+                        'updated_on' => $currentDateTime,
+                        'updated_by' => (int)get_logged_user_id()
+                    ];
+                    $this->AuditHistoryModel->save($audit_data);
+                    /************************************* */
                     session()->setFlashdata('success', 'Receipt has been added successfully.');
                     $this->logger->info("Receipt: has been added successfully. Inserted ID = " . $receipt_id);
                                  
@@ -150,8 +319,27 @@ class Invoice extends BaseController
                 }
             
             } else {
+                /**get old data for history */
+                $where = ['business_id' => (int)get_business_id(), 'receipt_id' => $receipt_id];
+                $olddata = $model->getData('receipt', $where);
+                /************************** */
                 $data['updated_by'] = (int)get_logged_user_id();
                 if ($model->update($receipt_id, $data)) {
+                    $newdata = $model->getData('receipt', $where);
+                    //**********AUDIT HISTORY***********/ 
+                    $currentDateTime = date('Y-m-d H:i:s');
+                    $audit_data = [
+                        'module' => 'receipt',
+                        'business_id' => (int)get_business_id(),
+                        'is_edit' => 1,
+                        'old_data' => json_encode($olddata),
+                        'current_data' => json_encode($newdata),
+                        'updated_on' => $currentDateTime,
+                        'updated_by' => (int)get_logged_user_id()
+                    ];
+                    $this->AuditHistoryModel->save($audit_data);
+                    /************************************* */
+
                     session()->setFlashdata('success', 'Receipt has been updated successfully.');
                     $this->logger->info("Receipt: has been updated successfully. Updated ID = " . $receipt_id);
                 } else {
@@ -171,6 +359,33 @@ class Invoice extends BaseController
                 print_r($update_events);
                 $this->update_number_formatting($update_events);}
             
+                // get donor whatsapp no and mail
+                $where = ['donor_id' => (int)$this->request->getPost('donor_id') ,'business_id' => (int)get_business_id()];
+                $donordata = $model->getData('donor', $where);
+                // generate recipt
+                $html = $this->generate_invoice_pdf($receipt_id, 'mail');
+                // echo $html;die;
+                // send mail
+                $notification = new NotificationHelper();
+                if($donordata[0]->email != null || $donordata[0]->email != '')
+                {
+                    $records['recipient_email'] = $donordata[0]->email;
+                    $records['subject'] = 'DONOR RECEIPT';
+                    $records['description'] = $html;
+                    $notification->sendEmail($records);
+                }
+                
+                // $template = "Dear " . '$recipient_name' . ",\r\r\n\nYour Invoice has been approved.\n\nDetails:\r\n- Approval Date: " . '$approval_date' . "\r\n- Approved By: " . '$approved_by' . "\r\n- Reference ID: " . '$reference_number' . "\r\n\nBest regards,\n".'$business_name'.",\n".'$business_address'." ".'$business_city'." ".'$business_state'." - ".'$business_postal_code'.".\nCall Us: +91 ".'$business_mobile_no'."\nEmail Us:".'$business_email';
+
+                // // WHATSAPP
+                // $params = (object) Null;
+                // // $params->number = (int)'91' . $donordata[0]->mobile_no;
+                // $params->number = (int)'919677462018';
+                // $params->type = "text";
+                // $params->message = $template;
+                // $params->instance_id = '65C9B978325A2';
+                // $params->access_token = '65c715e797d16';
+                // $whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
           
         } catch (\Exception $e) {
             $this->logger->error("Receipt: Err Occur =" . $e->getMessage());
@@ -178,9 +393,81 @@ class Invoice extends BaseController
         }
         return redirect()->route('receipt_list');
 
-      
-    
+    }
 
+    public function audit_history()
+    {
+        helper('session');
+        $model = new InvoiceModel();
+        $usermodel = new UsersModel();
+        $where = ['business_id' => (int)get_business_id()];
+        $data = $model->getData('audit_history', $where);
+        // echo $data[0]->current_data;die;
+        $diff = [];
+
+        foreach ($data as $audit_data) {
+            $arr1 = json_decode($audit_data->current_data, true);
+            $arr2 = json_decode($audit_data->old_data, true);
+
+            $temp_diff = [];
+
+            // Check each key-value pair in arr1
+            foreach ($arr1[0] as $key => $value) {
+                $con = $key != 'created_on' && $key != 'created_by' && $key != 'updated_on' && $key != 'updated_by';
+                if ($audit_data->is_edit == 1 && $arr2[0][$key] !== $value) {
+                    $user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll();
+                    if($con){
+                        $temp_diff[] = (object) [
+                            'key' => $key,
+                            'old_value' => $value,
+                            'new_value' => $arr2[0][$key],
+                            'module' => $audit_data->module,
+                            'mode' => 'Update',
+                            'updated_by' => $user[0]['first_name'].' '.$user[0]['last_name'],
+                            'updated_on' => $audit_data->updated_on
+                        ];
+                    }
+                }
+                else if($con && $audit_data->is_add == 1){
+                    // echo $key;die;
+                    $user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->created_by)->findAll();
+                    $temp_diff[] = (object) [
+                        'key' => '-',
+                        'old_value' => '-',
+                        'new_value' => 'New Receipt No "'.$arr1[0]['receipt_number'].'" Created',
+                        'module' => $audit_data->module,
+                        'mode' => 'Create',
+                        'updated_by' => $user[0]['first_name'].' '.$user[0]['last_name'],
+                        'updated_on' => $audit_data->created_on
+                    ];
+                    break;
+                }
+                else if($con && $audit_data->is_delete == 1){
+                    // echo $key;die;
+                    $user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll();
+                    $temp_diff[] = (object) [
+                        'key' => '-',
+                        'old_value' => '-',
+                        'new_value' => 'Receipt No "'.$arr1[0]['receipt_number'].'" Deleted',
+                        'module' => $audit_data->module,
+                        'mode' => 'Delete',
+                        'updated_by' => $user[0]['first_name'].' '.$user[0]['last_name'],
+                        'updated_on' => $audit_data->created_on
+                    ];
+                    break;
+                }
+            }
+
+            // Add temp_diff to $diff array if it's not empty
+            if (!empty($temp_diff)) {
+                $diff[] = $temp_diff;
+            }
+        }
+
+        // print_r($diff);
+        $response['page_name'] = 'History';
+        $response['data'] = $diff;
+        $this->render_page('audit_history', $response);
     }
 
     ## For Updating Events Details .. 
@@ -309,39 +596,64 @@ class Invoice extends BaseController
     }
 
 
-    public function generate_invoice_pdf($id)
+    public function generate_invoice_pdf($id, $dest = null)
     {
-        // Fetch the receipt data based on $receipt_id
-        $model = new InvoiceModel();
-        $data = $model->getInvoiceData($id);
-        // echo '
';
-        // print_r($data);die;
+        try {
+            // Fetch the receipt data based on $receipt_id
+            $model = new InvoiceModel();
+            $setting_model = new SettingsModel();
+            $where = ['business_id' => (int)get_business_id()];
+            $currency_data =  $setting_model->select('currency')->where($where)->findAll();
+            $data = $model->getInvoiceData($id);
+            // Check if data is empty
+            if (!$data || !$currency_data) {
+                throw new Exception('Data not found or empty');
+            }
+    
+            $options = new Options();
+            $options->set('isHtml5ParserEnabled', true);
+            $options->set('isPhpEnabled', true);
+            // $options->set('isRemoteEnabled', true);
+            $options->set('font_subsetting', true);
+    
+            $dompdf = new Dompdf($options);
+    
+            define("DOMPDF_UNICODE_ENABLED", true);
 
-        $options = new Options();
-        $options->set('isHtml5ParserEnabled', true);
-        $options->set('isPhpEnabled', true);
-        $options->set('isRemoteEnabled', true);
-        $options->set('font_subsetting', true);
+            $baseurl = base_url()."public/uploads/".$data[0]->business_logo;
+            $html = view('invoice_pdf_template', ['data' => $data[0],'currency' => $currency_data[0]['currency'] ,'baseurl' => $baseurl]);
+            // echo $html;die;
+            
+            $dompdf->loadHtml($html);
+            $dompdf->setPaper('letter', 'landscape');
+    
+            $dompdf->render();
+    
+            if($dest == 'mail') {
+                // Generate filename based on current date and time
+                // $filename = date('dmYHis') . '.pdf';
 
-        $dompdf = new Dompdf($options);
-
-        define("DOMPDF_UNICODE_ENABLED", true);
-        $html = view('invoice_pdf_template', ['data' => $data[0]]);
-
-        // echo $html; die;
-
-        $dompdf->loadHtml($html, 'UTF-8');
-        $dompdf->setPaper('letter', 'landscape');
-
-        $dompdf->render();
-
-        $output = $dompdf->output();
-
-        $dompdf->stream('document.pdf', ['Attachment' => 1]);
+                // // Save PDF file to a directory
+                // $outputFilePath = base_url() . 'pdf/' . $filename; // Assuming WRITEPATH is defined
+                // file_put_contents($outputFilePath, $dompdf->output());
 
+                // // Provide download link with the generated filename
+                // $downloadLink = base_url() . 'pdf/' . $filename;
+                // echo $downloadLink;die;
+                return $html;
+            }
+            $dompdf->stream('document.pdf', ['Attachment' => 1]);
+        } catch (Exception $e) {
+            // Handle the exception
+            // For example, log the error, display a user-friendly message, or return an error response
+            echo 'Error: ' . $e->getMessage();
+        }
     }
 
 
+    
+
+
     // public function approve_notifications($receipt_id)
     // {
     //     $model = new InvoiceModel();
diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php
index d5fdc53..72b2f24 100644
--- a/app/Controllers/Users.php
+++ b/app/Controllers/Users.php
@@ -97,6 +97,22 @@ class Users extends BaseController
                             $render_page_name = 'pages_404';
                         }
                         break;
+
+                    case "accounts":
+                        $where = ['users.user_id' => $id, 'users.isactive =' => 1];
+                        $edit_user_details = $model->where($where)->first();
+                        $render_page_name = 'user_form';
+                        $data['page_name'] = 'Edit User';
+                        $data['branches'] = $this->getOrganizationBranches($edit_user_details['business_id']);
+                        break;
+
+                    case "auditor":
+                        $where = ['users.user_id' => $id, 'users.isactive =' => 1];
+                        $edit_user_details = $model->where($where)->first();
+                        $render_page_name = 'user_form';
+                        $data['page_name'] = 'Edit User';
+                        $data['branches'] = $this->getOrganizationBranches($edit_user_details['business_id']);
+                        break;
     
                     default:
                         $data['page_name'] = 'Page Not Found';
@@ -299,7 +315,7 @@ class Users extends BaseController
             $where = ['users.user_id' => $id, 'users.isactive =' => 1];
             $existingUser = $model->where($where)->find($id);
             $this->logger->Info("Users: Going to Inactive ID = ".$id);
-
+            // print_r($existingUser);die;
             if ($existingUser) {
                 $data['isactive'] = 0;
                 $data['updated_by'] = $session_uid;
@@ -310,7 +326,7 @@ class Users extends BaseController
                     
                   
                 if ($model->update($id, $data)) {
-                    session()->setFlashdata('success', 'Deleted successfully.');
+                    session()->setFlashdata('success', 'User Deactivated successfully.');
                     $this->logger->info("Users: has been Inactived successfully. Inactived ID = ".$id);        
                 } else {
                     $this->logger->error("Users: Not able to Inactive ID =".$id);
@@ -339,7 +355,7 @@ class Users extends BaseController
             $where = ['users.user_id' => $user_id, 'users.isactive =' => 0];
             $existingUser = $model->where($where)->find($user_id);
             $this->logger->Info("Users: Going to ActiveUser ID = ".$user_id);
-
+            // print_r($existingUser);die;
             if ($existingUser) {
                 $data['isactive'] = 1;
                 $data['updated_by'] = $session_uid;
diff --git a/app/Helpers/NotificationHelper.php b/app/Helpers/NotificationHelper.php
index da34e98..5089c8e 100644
--- a/app/Helpers/NotificationHelper.php
+++ b/app/Helpers/NotificationHelper.php
@@ -17,7 +17,7 @@ class NotificationHelper
 
     public function sendEmail($records)
     {
-        $this->logger->info('Helper : Email Request Data type = '.gettype($records));    
+        $this->logger->info('Helper : Email Request Data type = '.gettype($records));      
 
         $cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
         $bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
@@ -29,7 +29,7 @@ class NotificationHelper
             }
             $this->email->setTo($records['recipient_email']);
             $this->logger->info('Helper : Email recipient = '.$records['recipient_email']);    
-            $this->email->setFrom('web@vijayabharathambooks.com', isset($records['company'])?$records['company']:"VB");
+            $this->email->setFrom('bbone@venbait.in', "DONOR");
             $this->email->setSubject($records['subject']);
             $this->logger->info('Helper : Email subject = '.$records['subject']);    
             $this->email->setMessage($records['description']);            
diff --git a/app/Models/AuditHistoryModel.php b/app/Models/AuditHistoryModel.php
new file mode 100644
index 0000000..3caf191
--- /dev/null
+++ b/app/Models/AuditHistoryModel.php
@@ -0,0 +1,44 @@
+db->table('audit_history')->insert($data);
+        } else {
+            // Update existing record
+            return $this->update($id, $data);
+        }
+    }
+
+
+    public function getData($table, $where = null,$whereIn = null)
+    {
+            $query = $this->db->table($table);
+            if ($where) {
+                $query->where($where);
+            }
+            if($whereIn){
+                // $query->whereIn($column_name,$missingValues)
+                $query->whereIn($whereIn[0],$whereIn[1]);
+            }
+            return $query->get()->getResult();
+    }
+
+    public function updateData($table, $data, $where)
+    {
+            $this->db->table($table)->update($data, $where);
+            $affected_rows = $this->db->affectedRows();
+            return $affected_rows;
+    }
+
+
+
+}
diff --git a/app/Models/BooksModel.php b/app/Models/BooksModel.php
index 8a485a9..5419fc0 100644
--- a/app/Models/BooksModel.php
+++ b/app/Models/BooksModel.php
@@ -5,7 +5,7 @@ class BooksModel extends Model
 {
     protected $table = 'causes';
     protected $primaryKey = 'causes_id';
-    protected $allowedFields = ['causes_id','name','description', 'business_id', 'created_on','created_by','updated_on','updated_by','isactive'];
+    protected $allowedFields = ['causes_id','name','description','from_date', 'to_date', 'business_id', 'created_on','created_by','updated_on','updated_by','isactive'];
     // protected $allowedFields = ['causes_id','title','cover_picture','publication_date','isbn_code','publisher','category','genre','language','description','page_count','tax','price','created_on','created_by','updated_on','updated_by','isactive','business_id'];
 
     public function saveData($data, $id = null)
diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php
index 71fbe0b..7b9db78 100644
--- a/app/Models/InvoiceModel.php
+++ b/app/Models/InvoiceModel.php
@@ -8,7 +8,7 @@ class InvoiceModel extends Model
 protected $table = 'receipt';
 protected $primaryKey = 'receipt_id';
 // protected $allowedFields = ['invoice_id','invoice_number','donor_id','invoice_date','event_id','business_id','created_on','business_id'];
-protected $allowedFields = ['receipt_id', 'receipt_number', 'donor_id','notes','amount', 'payment_mode', 'business_id',  'created_on', 'created_by', 'updated_on', 'updated_by','isactive', 'payment_ref_no', 'receipt_date','causes_id'];
+protected $allowedFields = ['receipt_id', 'receipt_number', 'donor_id','notes','amount', 'payment_mode', 'business_id',  'created_on', 'created_by', 'updated_on', 'updated_by','isactive', 'payment_ref_no', 'receipt_date','causes_id','campaign_id','receipt_header','reason'];
 
 public function saveInvoiceItemDetails($data){
     $i = 0;
@@ -123,8 +123,9 @@ public function updateData($table, $data, $where)
         return $this->db->table('receipt')
         ->where('receipt_id', $id)
         ->join('donor as C','C.donor_id= receipt.donor_id','left')
+        ->join('causes as D','D.causes_id= receipt.causes_id','left')
         ->join('business as B','B.business_id = receipt.business_id','left')
-        ->select('receipt.*,concat(C.first_name," ",C.last_name) as customer_name,C.address, C.postal_code,C.city, C.state,C.mobile_no as customer_mobile, C.pan_no as cust_pan_no')
+        ->select('receipt.*,concat(C.first_name," ",C.last_name) as customer_name,C.address, C.postal_code,C.city, C.state,C.mobile_no as customer_mobile, C.pan_no as cust_pan_no, D.name as cause_name')
         ->select('B.title ,B.business_logo,B.terms,B.address as org_address ,B.city as org_city,B.state as org_state,B.postal_code as org_zip,B.email as org_email,B.mobile_no as org_mobile, B.pan_no as org_pan, B.org_reg_no, B.signature')
         ->get()
         ->getResult();
diff --git a/app/Views/audit_history.php b/app/Views/audit_history.php
new file mode 100644
index 0000000..3f7dbd3
--- /dev/null
+++ b/app/Views/audit_history.php
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ActionModuleKeyOld ValueNew ValueUpdated ByUpdated On
mode ?>module ?>key ?>old_value ?>new_value ?>updated_by ?>updated_on ?>
+ +
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/Views/book_form.php b/app/Views/book_form.php index 014e416..6203e3e 100644 --- a/app/Views/book_form.php +++ b/app/Views/book_form.php @@ -29,13 +29,20 @@ getFlashdata('success')) : ?>
getFlashdata('success') ?>
-
">
- + + + +
Please provide.
@@ -46,7 +53,22 @@
Please provide.
- + +
+
+ + + +
+ + +
+ + + +
+
+ @@ -60,9 +82,9 @@
@@ -70,6 +92,26 @@ + + + + + + \ No newline at end of file diff --git a/app/Views/event_form.php b/app/Views/event_form.php index 7b171f6..82069f5 100644 --- a/app/Views/event_form.php +++ b/app/Views/event_form.php @@ -44,7 +44,7 @@ @@ -52,6 +52,27 @@ + + + + + + + + + + + diff --git a/app/Views/invoice_list.php b/app/Views/invoice_list.php index 94c686c..f9e5043 100644 --- a/app/Views/invoice_list.php +++ b/app/Views/invoice_list.php @@ -34,6 +34,7 @@ Receipt Date Donor Name Amount + Status/Reason Action @@ -50,9 +51,12 @@ + / " class="edit-button" title="Edit the Invoice">  - " class="download-pdf-button" title="Download the Invoice">  + + " class="download-pdf-button" title="Download the Invoice">  + diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php index 6bdaf7a..d3c0ac8 100644 --- a/app/Views/invoice_pdf_template.php +++ b/app/Views/invoice_pdf_template.php @@ -225,7 +225,7 @@ body{
- business_logo ?>" height="50" width="50" > +

title ?>

Email : org_email ?>

@@ -242,7 +242,7 @@ body{

customer_name?>

- Monile No : customer_mobile?>
+ Mobile No : customer_mobile?>
PAN No : cust_pan_no?>
Address :address?>
@@ -258,6 +258,10 @@ body{ Date : receipt_date));?>

+

+ Recipt Type : + receipt_header?> +

@@ -270,7 +274,7 @@ body{

Donated Amount

-

Rs. amount?> /-

+

. amount?> /-

@@ -286,10 +290,10 @@ body{ diff --git a/app/Views/notifications_form.php b/app/Views/notifications_form.php index c46ffe9..bfb9e91 100644 --- a/app/Views/notifications_form.php +++ b/app/Views/notifications_form.php @@ -193,6 +193,26 @@ + + +