FEAT_ALL_MODULES_ADDED

This commit is contained in:
VENKATESHWARAN 2023-12-12 19:03:57 +05:30
parent 9c6ec3fc55
commit 213b850567
7063 changed files with 1567840 additions and 0 deletions

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014-2019 British Columbia Institute of Technology
Copyright (c) 2019-2023 CodeIgniter Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

6
app/.htaccess Normal file
View File

@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

15
app/Common.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* The goal of this file is to allow developers a location
* where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during
* the bootstrap process and is called during the framework's
* execution.
*
* This can be looked at as a `master helper` file that is
* loaded early on, and may also contain additional functions
* that you'd like to use throughout your entire application
*
* @see: https://codeigniter.com/user_guide/extending/common.html
*/

466
app/Config/App.php Normal file
View File

@ -0,0 +1,466 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\FileHandler;
class App extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Base Site URL
* --------------------------------------------------------------------------
*
* URL to your CodeIgniter root. Typically, this will be your base URL,
* WITH a trailing slash:
*
* http://example.com/
*/
// public string $baseURL = 'http://localhost:8080/';
public string $baseURL = 'http://localhost/doner_management/';
// public string $baseURL = 'http://localhost/vb_book/public/';
/**
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
* If you want to accept multiple Hostnames, set this.
*
* E.g. When your site URL ($baseURL) is 'http://example.com/', and your site
* also accepts 'http://media.example.com/' and
* 'http://accounts.example.com/':
* ['media.example.com', 'accounts.example.com']
*
* @var string[]
* @phpstan-var list<string>
*/
public array $allowedHostnames = [];
/**
* --------------------------------------------------------------------------
* Index File
* --------------------------------------------------------------------------
*
* Typically this will be your index.php file, unless you've renamed it to
* something else. If you are using mod_rewrite to remove the page set this
* variable so that it is blank.
*/
// public string $indexPage = 'index.php';
public string $indexPage = '';
/**
* --------------------------------------------------------------------------
* URI PROTOCOL
* --------------------------------------------------------------------------
*
* This item determines which server global should be used to retrieve the
* URI string. The default setting of 'REQUEST_URI' works for most servers.
* If your links do not seem to work, try one of the other delicious flavors:
*
* 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
* 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
* 'PATH_INFO' Uses $_SERVER['PATH_INFO']
*
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
// public string $uriProtocol = 'REQUEST_URI';
public $uriProtocol = 'PATH_INFO';
/**
* --------------------------------------------------------------------------
* Default Locale
* --------------------------------------------------------------------------
*
* The Locale roughly represents the language and location that your visitor
* is viewing the site from. It affects the language strings and other
* strings (like currency markers, numbers, etc), that your program
* should run under for this request.
*/
public string $defaultLocale = 'en';
/**
* --------------------------------------------------------------------------
* Negotiate Locale
* --------------------------------------------------------------------------
*
* If true, the current Request object will automatically determine the
* language to use based on the value of the Accept-Language header.
*
* If false, no automatic detection will be performed.
*/
public bool $negotiateLocale = false;
/**
* --------------------------------------------------------------------------
* Supported Locales
* --------------------------------------------------------------------------
*
* If $negotiateLocale is true, this array lists the locales supported
* by the application in descending order of priority. If no match is
* found, the first locale will be used.
*
* IncomingRequest::setLocale() also uses this list.
*
* @var string[]
*/
public array $supportedLocales = ['en'];
/**
* --------------------------------------------------------------------------
* Application Timezone
* --------------------------------------------------------------------------
*
* The default timezone that will be used in your application to display
* dates with the date helper, and can be retrieved through app_timezone()
*
* @see https://www.php.net/manual/en/timezones.php for list of timezones supported by PHP.
*/
// public string $appTimezone = 'UTC';
public $appTimezone = 'UTC'; // Set default timezone
public function __construct()
{
parent::__construct();
// Read APP_TIMEZONE from environment and update appTimezone if available
$envTimezone = $_ENV['APP_TIMEZONE'] ?? null;
if ($envTimezone) {
$this->appTimezone = $envTimezone;
}
}
/**
* --------------------------------------------------------------------------
* Default Character Set
* --------------------------------------------------------------------------
*
* This determines which character set is used by default in various methods
* that require a character set to be provided.
*
* @see http://php.net/htmlspecialchars for a list of supported charsets.
*/
public string $charset = 'UTF-8';
/**
* --------------------------------------------------------------------------
* Force Global Secure Requests
* --------------------------------------------------------------------------
*
* If true, this will force every request made to this application to be
* made via a secure connection (HTTPS). If the incoming request is not
* secure, the user will be redirected to a secure version of the page
* and the HTTP Strict Transport Security header will be set.
*/
public bool $forceGlobalSecureRequests = false;
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @deprecated use Config\Session::$driver instead.
*/
public string $sessionDriver = FileHandler::class;
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*
* @deprecated use Config\Session::$cookieName instead.
*/
public string $sessionCookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*
* @deprecated use Config\Session::$expiration instead.
*/
public int $sessionExpiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*
* @deprecated use Config\Session::$savePath instead.
*/
public string $sessionSavePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*
* @deprecated use Config\Session::$matchIP instead.
*/
public bool $sessionMatchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*
* @deprecated use Config\Session::$timeToUpdate instead.
*/
public int $sessionTimeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*
* @deprecated use Config\Session::$regenerateDestroy instead.
*/
public bool $sessionRegenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Session Database Group
* --------------------------------------------------------------------------
*
* DB Group for the database session.
*
* @deprecated use Config\Session::$DBGroup instead.
*/
public ?string $sessionDBGroup = null;
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*
* @deprecated use Config\Cookie::$prefix property instead.
*/
public string $cookiePrefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*
* @deprecated use Config\Cookie::$domain property instead.
*/
public string $cookieDomain = '';
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*
* @deprecated use Config\Cookie::$path property instead.
*/
public string $cookiePath = '/';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*
* @deprecated use Config\Cookie::$secure property instead.
*/
public bool $cookieSecure = false;
/**
* --------------------------------------------------------------------------
* Cookie HttpOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*
* @deprecated use Config\Cookie::$httponly property instead.
*/
public bool $cookieHTTPOnly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$cookieSecure` must also be set.
*
* @deprecated use Config\Cookie::$samesite property instead.
*/
public ?string $cookieSameSite = 'Lax';
/**
* --------------------------------------------------------------------------
* Reverse Proxy IPs
* --------------------------------------------------------------------------
*
* If your server is behind a reverse proxy, you must whitelist the proxy
* IP addresses from which CodeIgniter should trust headers such as
* X-Forwarded-For or Client-IP in order to properly identify
* the visitor's IP address.
*
* You need to set a proxy IP address or IP address with subnets and
* the HTTP header for the client IP address.
*
* Here are some examples:
* [
* '10.0.1.200' => 'X-Forwarded-For',
* '192.168.5.0/24' => 'X-Real-IP',
* ]
*
* @var array<string, string>
*/
public array $proxyIPs = [];
/**
* --------------------------------------------------------------------------
* CSRF Token Name
* --------------------------------------------------------------------------
*
* The token name.
*
* @deprecated Use `Config\Security` $tokenName property instead of using this property.
*/
public string $CSRFTokenName = 'csrf_test_name';
/**
* --------------------------------------------------------------------------
* CSRF Header Name
* --------------------------------------------------------------------------
*
* The header name.
*
* @deprecated Use `Config\Security` $headerName property instead of using this property.
*/
public string $CSRFHeaderName = 'X-CSRF-TOKEN';
/**
* --------------------------------------------------------------------------
* CSRF Cookie Name
* --------------------------------------------------------------------------
*
* The cookie name.
*
* @deprecated Use `Config\Security` $cookieName property instead of using this property.
*/
public string $CSRFCookieName = 'csrf_cookie_name';
/**
* --------------------------------------------------------------------------
* CSRF Expire
* --------------------------------------------------------------------------
*
* The number in seconds the token should expire.
*
* @deprecated Use `Config\Security` $expire property instead of using this property.
*/
public int $CSRFExpire = 7200;
/**
* --------------------------------------------------------------------------
* CSRF Regenerate
* --------------------------------------------------------------------------
*
* Regenerate token on every submission?
*
* @deprecated Use `Config\Security` $regenerate property instead of using this property.
*/
public bool $CSRFRegenerate = true;
/**
* --------------------------------------------------------------------------
* CSRF Redirect
* --------------------------------------------------------------------------
*
* Redirect to previous page with error on failure?
*
* @deprecated Use `Config\Security` $redirect property instead of using this property.
*/
public bool $CSRFRedirect = false;
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public string $CSRFSameSite = 'Lax';
/**
* --------------------------------------------------------------------------
* Content Security Policy
* --------------------------------------------------------------------------
*
* Enables the Response's Content Secure Policy to restrict the sources that
* can be used for images, scripts, CSS files, audio, video, etc. If enabled,
* the Response object will populate default values for the policy from the
* `ContentSecurityPolicy.php` file. Controllers can always add to those
* restrictions at run time.
*
* For a better understanding of CSP, see these documents:
*
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
* @see http://www.w3.org/TR/CSP/
*/
public bool $CSPEnabled = false;
}

101
app/Config/Autoload.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace Config;
use CodeIgniter\Config\AutoloadConfig;
/**
* -------------------------------------------------------------------
* AUTOLOADER CONFIGURATION
* -------------------------------------------------------------------
*
* This file defines the namespaces and class maps so the Autoloader
* can find the files as needed.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*/
class Autoload extends AutoloadConfig
{
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application to
* their location on the file system. These are used by the autoloader
* to locate files the first time they have been instantiated.
*
* The '/app' and '/system' directories are already mapped for you.
* you may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* Prototype:
* $psr4 = [
* 'CodeIgniter' => SYSTEMPATH,
* 'App' => APPPATH
* ];
*
* @var array<string, array<int, string>|string>
* @phpstan-var array<string, string|list<string>>
*/
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
'App\Libraries' => APPPATH . 'Libraries',
];
/**
* -------------------------------------------------------------------
* Class Map
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
* $classmap = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*
* @var array<string, string>
*/
public $classmap = [];
/**
* -------------------------------------------------------------------
* Files
* -------------------------------------------------------------------
* The files array provides a list of paths to __non-class__ files
* that will be autoloaded. This can be useful for bootstrap operations
* or for loading functions.
*
* Prototype:
* $files = [
* '/path/to/my/file.php',
* ];
*
* @var string[]
* @phpstan-var list<string>
*/
public $files = [];
/**
* -------------------------------------------------------------------
* Helpers
* -------------------------------------------------------------------
* Prototype:
* $helpers = [
* 'form',
* ];
*
* @var string[]
* @phpstan-var list<string>
*/
public $helpers = [];
}

View File

@ -0,0 +1,32 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. This will control whether Kint is loaded, and a few other
| items. It can always be used within your own application too.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);

View File

@ -0,0 +1,21 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', false);

View File

@ -0,0 +1,32 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);

View File

@ -0,0 +1,20 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class CURLRequest extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CURLRequest Share Options
* --------------------------------------------------------------------------
*
* Whether share options between requests or not.
*
* If true, all the options won't be reset between requests.
* It may cause an error request with unnecessary headers.
*/
public bool $shareOptions = true;
}

172
app/Config/Cache.php Normal file
View File

@ -0,0 +1,172 @@
<?php
namespace Config;
use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Cache\Handlers\DummyHandler;
use CodeIgniter\Cache\Handlers\FileHandler;
use CodeIgniter\Cache\Handlers\MemcachedHandler;
use CodeIgniter\Cache\Handlers\PredisHandler;
use CodeIgniter\Cache\Handlers\RedisHandler;
use CodeIgniter\Cache\Handlers\WincacheHandler;
use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Primary Handler
* --------------------------------------------------------------------------
*
* The name of the preferred handler that should be used. If for some reason
* it is not available, the $backupHandler will be used in its place.
*/
public string $handler = 'file';
/**
* --------------------------------------------------------------------------
* Backup Handler
* --------------------------------------------------------------------------
*
* The name of the handler that will be used in case the first one is
* unreachable. Often, 'file' is used here since the filesystem is
* always available, though that's not always practical for the app.
*/
public string $backupHandler = 'dummy';
/**
* --------------------------------------------------------------------------
* Cache Directory Path
* --------------------------------------------------------------------------
*
* The path to where cache files should be stored, if using a file-based
* system.
*
* @deprecated Use the driver-specific variant under $file
*/
public string $storePath = WRITEPATH . 'cache/';
/**
* --------------------------------------------------------------------------
* Cache Include Query String
* --------------------------------------------------------------------------
*
* Whether to take the URL query string into consideration when generating
* output cache files. Valid options are:
*
* false = Disabled
* true = Enabled, take all query parameters into account.
* Please be aware that this may result in numerous cache
* files generated for the same page over and over again.
* ['q'] = Enabled, but only take into account the specified list
* of query parameters.
*
* @var bool|string[]
*/
public $cacheQueryString = false;
/**
* --------------------------------------------------------------------------
* Key Prefix
* --------------------------------------------------------------------------
*
* This string is added to all cache item names to help avoid collisions
* if you run multiple applications with the same cache engine.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Default TTL
* --------------------------------------------------------------------------
*
* The default number of seconds to save items when none is specified.
*
* WARNING: This is not used by framework handlers where 60 seconds is
* hard-coded, but may be useful to projects and modules. This will replace
* the hard-coded value in a future release.
*/
public int $ttl = 60;
/**
* --------------------------------------------------------------------------
* Reserved Characters
* --------------------------------------------------------------------------
*
* A string of reserved characters that will not be allowed in keys or tags.
* Strings that violate this restriction will cause handlers to throw.
* Default: {}()/\@:
*
* NOTE: The default set is required for PSR-6 compliance.
*/
public string $reservedCharacters = '{}()/\@:';
/**
* --------------------------------------------------------------------------
* File settings
* --------------------------------------------------------------------------
* Your file storage preferences can be specified below, if you are using
* the File driver.
*
* @var array<string, int|string|null>
*/
public array $file = [
'storePath' => WRITEPATH . 'cache/',
'mode' => 0640,
];
/**
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
*
* @var array<string, bool|int|string>
*/
public array $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1,
'raw' => false,
];
/**
* -------------------------------------------------------------------------
* Redis settings
* -------------------------------------------------------------------------
* Your Redis server can be specified below, if you are using
* the Redis or Predis drivers.
*
* @var array<string, int|string|null>
*/
public array $redis = [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'timeout' => 0,
'database' => 0,
];
/**
* --------------------------------------------------------------------------
* Available Cache Handlers
* --------------------------------------------------------------------------
*
* This is an array of cache engine alias' and class names. Only engines
* that are listed here are allowed to be used.
*
* @var array<string, string>
* @phpstan-var array<string, class-string<CacheInterface>>
*/
public array $validHandlers = [
'dummy' => DummyHandler::class,
'file' => FileHandler::class,
'memcached' => MemcachedHandler::class,
'predis' => PredisHandler::class,
'redis' => RedisHandler::class,
'wincache' => WincacheHandler::class,
];
}

135
app/Config/Constants.php Normal file
View File

@ -0,0 +1,135 @@
<?php
/*
| --------------------------------------------------------------------
| App Namespace
| --------------------------------------------------------------------
|
| This defines the default Namespace that is used throughout
| CodeIgniter to refer to the Application directory. Change
| this constant to change the namespace that all application
| classes should use.
|
| NOTE: changing this will require manually modifying the
| existing namespaces of App\* namespaced-classes.
*/
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
/*
| --------------------------------------------------------------------------
| Composer Path
| --------------------------------------------------------------------------
|
| The path that Composer's autoload file is expected to live. By default,
| the vendor folder is in the Root directory, but you can customize that here.
*/
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
/*
|--------------------------------------------------------------------------
| Timing Constants
|--------------------------------------------------------------------------
|
| Provide simple ways to work with the myriad of PHP functions that
| require information to be in seconds.
*/
defined('SECOND') || define('SECOND', 1);
defined('MINUTE') || define('MINUTE', 60);
defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315_360_000);
/*
| --------------------------------------------------------------------------
| Exit Status Codes
| --------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
*/
define('EVENT_PRIORITY_LOW', 200);
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
*/
define('EVENT_PRIORITY_NORMAL', 100);
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
/**
* Constants For Api Integration.
*/
// define('VB_APIURL', 'https://vbp.venbait.in/wp-json/wc/v3/');
define('product','books');
define('product_column', ["book_id","wp_api_product_id"]);
define('product_child','book_images');
define('product_child_column', ["book_id","wp_api_img_id","book_img_id"]);
define('customer','customers');
define('customer_column', ["customer_id","wp_api_customer_id"]);
define('customer_child','customer_addresses');
define('customer_child_column', ["customer_id","","customer_address_id"]);
define('order','invoice');
define('order_column', ["invoice_id","wp_api_order_id","invoice_child_id"]);
define('order_child','invoiceitems');
define('order_child_column', ["invoice_id","wp_api_line_items_id","customer_id"]);
// define('WAAI_TOKEN', '652548474f4e4');
// define('WAAI_INSTANCE', '65254894E4A88');
// UAT - for testing Purpose..
// define('WAAI_TOKEN', '65685e954bcf6');
// define('WAAI_INSTANCE', '656863C54F90C');
// LIVE - Vel given.30th Nov.
// define('WAAI_TOKEN', '6568739969f28');
// define('WAAI_INSTANCE', '656876690A9FD');
define('SEND_WAAI_URL', 'https://waai.in/api/send');
define('SEND_WAAI_GROUP_URL', 'https://waai.in/api/send_group');
define('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_EMAIL');
define('EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP');

View File

@ -0,0 +1,176 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
*
* Suggested reference for explanations:
*
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/
class ContentSecurityPolicy extends BaseConfig
{
// -------------------------------------------------------------------------
// Broadbrush CSP management
// -------------------------------------------------------------------------
/**
* Default CSP report context
*/
public bool $reportOnly = false;
/**
* Specifies a URL where a browser will send reports
* when a content security policy is violated.
*/
public ?string $reportURI = null;
/**
* Instructs user agents to rewrite URL schemes, changing
* HTTP to HTTPS. This directive is for websites with
* large numbers of old URLs that need to be rewritten.
*/
public bool $upgradeInsecureRequests = false;
// -------------------------------------------------------------------------
// Sources allowed
// NOTE: once you set a policy to 'none', it cannot be further restricted
// -------------------------------------------------------------------------
/**
* Will default to self if not overridden
*
* @var string|string[]|null
*/
public $defaultSrc;
/**
* Lists allowed scripts' URLs.
*
* @var string|string[]
*/
public $scriptSrc = 'self';
/**
* Lists allowed stylesheets' URLs.
*
* @var string|string[]
*/
public $styleSrc = 'self';
/**
* Defines the origins from which images can be loaded.
*
* @var string|string[]
*/
public $imageSrc = 'self';
/**
* Restricts the URLs that can appear in a page's `<base>` element.
*
* Will default to self if not overridden
*
* @var string|string[]|null
*/
public $baseURI;
/**
* Lists the URLs for workers and embedded frame contents
*
* @var string|string[]
*/
public $childSrc = 'self';
/**
* Limits the origins that you can connect to (via XHR,
* WebSockets, and EventSource).
*
* @var string|string[]
*/
public $connectSrc = 'self';
/**
* Specifies the origins that can serve web fonts.
*
* @var string|string[]
*/
public $fontSrc;
/**
* Lists valid endpoints for submission from `<form>` tags.
*
* @var string|string[]
*/
public $formAction = 'self';
/**
* Specifies the sources that can embed the current page.
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
* and `<applet>` tags. This directive can't be used in
* `<meta>` tags and applies only to non-HTML resources.
*
* @var string|string[]|null
*/
public $frameAncestors;
/**
* The frame-src directive restricts the URLs which may
* be loaded into nested browsing contexts.
*
* @var array|string|null
*/
public $frameSrc;
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var string|string[]|null
*/
public $mediaSrc;
/**
* Allows control over Flash and other plugins.
*
* @var string|string[]
*/
public $objectSrc = 'self';
/**
* @var string|string[]|null
*/
public $manifestSrc;
/**
* Limits the kinds of plugins a page may invoke.
*
* @var string|string[]|null
*/
public $pluginTypes;
/**
* List of actions allowed.
*
* @var string|string[]|null
*/
public $sandbox;
/**
* Nonce tag for style
*/
public string $styleNonceTag = '{csp-style-nonce}';
/**
* Nonce tag for script
*/
public string $scriptNonceTag = '{csp-script-nonce}';
/**
* Replace nonce tag automatically
*/
public bool $autoNonce = true;
}

105
app/Config/Cookie.php Normal file
View File

@ -0,0 +1,105 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use DateTimeInterface;
class Cookie extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Expires Timestamp
* --------------------------------------------------------------------------
*
* Default expires timestamp for cookies. Setting this to `0` will mean the
* cookie will not have the `Expires` attribute and will behave as a session
* cookie.
*
* @var DateTimeInterface|int|string
*/
public $expires = 0;
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*/
public string $path = '/';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*/
public string $domain = '';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*/
public bool $secure = false;
/**
* --------------------------------------------------------------------------
* Cookie HTTPOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*/
public bool $httponly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$secure` must also be set.
*/
public string $samesite = 'Lax';
/**
* --------------------------------------------------------------------------
* Cookie Raw
* --------------------------------------------------------------------------
*
* This flag allows setting a "raw" cookie, i.e., its name and value are
* not URL encoded using `rawurlencode()`.
*
* If this is set to `true`, cookie names should be compliant of RFC 2616's
* list of allowed characters.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
* @see https://tools.ietf.org/html/rfc2616#section-2.2
*/
public bool $raw = false;
}

84
app/Config/Database.php Normal file
View File

@ -0,0 +1,84 @@
<?php
namespace Config;
use CodeIgniter\Database\Config;
/**
* Database Configuration
*/
class Database extends Config
{
/**
* The directory that holds the Migrations
* and Seeds directories.
*/
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
/**
* Lets you choose which connection group to
* use if no other is specified.
*/
public string $defaultGroup = 'default';
/**
* The default database connection.
*/
public array $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
/**
* This database connection is used when
* running PHPUnit database tests.
*/
public array $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
'busyTimeout' => 1000,
];
public function __construct()
{
parent::__construct();
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
if (ENVIRONMENT === 'testing') {
$this->defaultGroup = 'tests';
}
}
}

43
app/Config/DocTypes.php Normal file
View File

@ -0,0 +1,43 @@
<?php
namespace Config;
class DocTypes
{
/**
* List of valid document types.
*
* @var array<string, string>
*/
public array $list = [
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
];
/**
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
* for HTML5 compatibility.
*
* Set to:
* `true` - to be HTML5 compatible
* `false` - to be XHTML compatible
*/
public bool $html5 = true;
}

117
app/Config/Email.php Normal file
View File

@ -0,0 +1,117 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Email extends BaseConfig
{
public string $fromEmail = '';
public string $fromName = '';
public string $recipients = '';
/**
* The "user agent"
*/
public string $userAgent = 'CodeIgniter';
/**
* The mail sending protocol: mail, sendmail, smtp
*/
public string $protocol = 'smtp';
/**
* The server path to Sendmail.
*/
public string $mailPath = '/usr/sbin/sendmail';
/**
* SMTP Server Address
*/
public string $SMTPHost = 'smtp.sendgrid.net';
/**
* SMTP Username
*/
public string $SMTPUser = 'apikey';
/**
* SMTP Password
*/
public string $SMTPPass = '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';
/**
* SMTP Port
*/
public int $SMTPPort = 587;
/**
* SMTP Timeout (in seconds)
*/
public int $SMTPTimeout = 20;
/**
* Enable persistent SMTP connections
*/
public bool $SMTPKeepAlive = false;
/**
* SMTP Encryption. Either tls or ssl
*/
public string $SMTPCrypto = 'tls';
/**
* Enable word-wrap
*/
public bool $wordWrap = true;
/**
* Character count to wrap at
*/
public int $wrapChars = 76;
/**
* Type of mail, either 'text' or 'html'
*/
public string $mailType = 'html';
/**
* Character set (utf-8, iso-8859-1, etc.)
*/
public string $charset = 'UTF-8';
/**
* Whether to validate the email address
*/
public bool $validate = false;
/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*/
public int $priority = 3;
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $CRLF = "\r\n";
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $newline = "\r\n";
/**
* Enable BCC Batch Mode.
*/
public bool $BCCBatchMode = false;
/**
* Number of emails in each BCC batch
*/
public int $BCCBatchSize = 200;
/**
* Enable notify message from server
*/
public bool $DSN = false;
}

92
app/Config/Encryption.php Normal file
View File

@ -0,0 +1,92 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Encryption configuration.
*
* These are the settings used for encryption, if you don't pass a parameter
* array to the encrypter for creation/initialization.
*/
class Encryption extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Encryption Key Starter
* --------------------------------------------------------------------------
*
* If you use the Encryption class you must set an encryption key (seed).
* You need to ensure it is long enough for the cipher and mode you plan to use.
* See the user guide for more info.
*/
public string $key = '';
/**
* --------------------------------------------------------------------------
* Encryption Driver to Use
* --------------------------------------------------------------------------
*
* One of the supported encryption drivers.
*
* Available drivers:
* - OpenSSL
* - Sodium
*/
public string $driver = 'OpenSSL';
/**
* --------------------------------------------------------------------------
* SodiumHandler's Padding Length in Bytes
* --------------------------------------------------------------------------
*
* This is the number of bytes that will be padded to the plaintext message
* before it is encrypted. This value should be greater than zero.
*
* See the user guide for more information on padding.
*/
public int $blockSize = 16;
/**
* --------------------------------------------------------------------------
* Encryption digest
* --------------------------------------------------------------------------
*
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
*/
public string $digest = 'SHA512';
/**
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
* This setting is only used by OpenSSLHandler.
*
* Set to false for CI3 Encryption compatibility.
*/
public bool $rawData = true;
/**
* Encryption key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'encryption' for CI3 Encryption compatibility.
*/
public string $encryptKeyInfo = '';
/**
* Authentication key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'authentication' for CI3 Encryption compatibility.
*/
public string $authKeyInfo = '';
/**
* Cipher to use.
* This setting is only used by OpenSSLHandler.
*
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
* by CI3 Encryption default configuration.
*/
public string $cipher = 'AES-256-CTR';
}

48
app/Config/Events.php Normal file
View File

@ -0,0 +1,48 @@
<?php
namespace Config;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
/*
* --------------------------------------------------------------------
* Application Events
* --------------------------------------------------------------------
* Events allow you to tap into the execution of the program without
* modifying or extending core files. This file provides a central
* location to define your events, though they can always be added
* at run-time, also, if needed.
*
* You create code that can execute by subscribing to events with
* the 'on()' method. This accepts any form of callable, including
* Closures, that will be executed when the event is triggered.
*
* Example:
* Events::on('create', [$myInstance, 'myMethod']);
*/
Events::on('pre_system', static function () {
if (ENVIRONMENT !== 'testing') {
if (ini_get('zlib.output_compression')) {
throw FrameworkException::forEnabledZlibOutputCompression();
}
while (ob_get_level() > 0) {
ob_end_flush();
}
ob_start(static fn ($buffer) => $buffer);
}
/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
}
});

77
app/Config/Exceptions.php Normal file
View File

@ -0,0 +1,77 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Psr\Log\LogLevel;
/**
* Setup how the exception handler works.
*/
class Exceptions extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* LOG EXCEPTIONS?
* --------------------------------------------------------------------------
* If true, then exceptions will be logged
* through Services::Log.
*
* Default: true
*/
public bool $log = true;
/**
* --------------------------------------------------------------------------
* DO NOT LOG STATUS CODES
* --------------------------------------------------------------------------
* Any status codes here will NOT be logged if logging is turned on.
* By default, only 404 (Page Not Found) exceptions are ignored.
*/
public array $ignoreCodes = [404];
/**
* --------------------------------------------------------------------------
* Error Views Path
* --------------------------------------------------------------------------
* This is the path to the directory that contains the 'cli' and 'html'
* directories that hold the views used to generate errors.
*
* Default: APPPATH.'Views/errors'
*/
public string $errorViewPath = APPPATH . 'Views/errors';
/**
* --------------------------------------------------------------------------
* HIDE FROM DEBUG TRACE
* --------------------------------------------------------------------------
* Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token']
*/
public array $sensitiveDataInTrace = [];
/**
* --------------------------------------------------------------------------
* LOG DEPRECATIONS INSTEAD OF THROWING?
* --------------------------------------------------------------------------
* By default, CodeIgniter converts deprecations into exceptions. Also,
* starting in PHP 8.1 will cause a lot of deprecated usage warnings.
* Use this option to temporarily cease the warnings and instead log those.
* This option also works for user deprecations.
*/
public bool $logDeprecations = true;
/**
* --------------------------------------------------------------------------
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
* --------------------------------------------------------------------------
* If `$logDeprecations` is set to `true`, this sets the log level
* to which the deprecation will be logged. This should be one of the log
* levels recognized by PSR-3.
*
* The related `Config\Logger::$threshold` should be adjusted, if needed,
* to capture logging the deprecations.
*/
public string $deprecationLogLevel = LogLevel::WARNING;
}

30
app/Config/Feature.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Enable/disable backward compatibility breaking features.
*/
class Feature extends BaseConfig
{
/**
* Enable multiple filters for a route or not.
*
* If you enable this:
* - CodeIgniter\CodeIgniter::handleRequest() uses:
* - CodeIgniter\Filters\Filters::enableFilters(), instead of enableFilter()
* - CodeIgniter\CodeIgniter::tryToRouteIt() uses:
* - CodeIgniter\Router\Router::getFilters(), instead of getFilter()
* - CodeIgniter\Router\Router::handle() uses:
* - property $filtersInfo, instead of $filterInfo
* - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute()
*/
public bool $multipleFilters = false;
/**
* Use improved new auto routing instead of the default legacy version.
*/
public bool $autoRoutesImproved = false;
}

64
app/Config/Filters.php Normal file
View File

@ -0,0 +1,64 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars;
use CodeIgniter\Filters\SecureHeaders;
class Filters extends BaseConfig
{
/**
* Configures aliases for Filter classes to
* make reading things nicer and simpler.
*/
public array $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
];
/**
* List of filter aliases that are always
* applied before and after every request.
*/
public array $globals = [
'before' => [
// 'honeypot',
// 'csrf',
// 'invalidchars',
],
'after' => [
'toolbar',
// 'honeypot',
// 'secureheaders',
],
];
/**
* List of filter aliases that works on a
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'post' => ['foo', 'bar']
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don't expect could bypass the filter.
*/
public array $methods = [];
/**
* List of filter aliases that should run on any
* before or after URI patterns.
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*/
public array $filters = [];
}

View File

@ -0,0 +1,9 @@
<?php
namespace Config;
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
class ForeignCharacters extends BaseForeignCharacters
{
}

77
app/Config/Format.php Normal file
View File

@ -0,0 +1,77 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;
class Format extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Available Response Formats
* --------------------------------------------------------------------------
*
* When you perform content negotiation with the request, these are the
* available formats that your application supports. This is currently
* only used with the API\ResponseTrait. A valid Formatter must exist
* for the specified format.
*
* These formats are only checked when the data passed to the respond()
* method is an array.
*
* @var string[]
*/
public array $supportedResponseFormats = [
'application/json',
'application/xml', // machine-readable XML
'text/xml', // human-readable XML
];
/**
* --------------------------------------------------------------------------
* Formatters
* --------------------------------------------------------------------------
*
* Lists the class to use to format responses with of a particular type.
* For each mime type, list the class that should be used. Formatters
* can be retrieved through the getFormatter() method.
*
* @var array<string, string>
*/
public array $formatters = [
'application/json' => JSONFormatter::class,
'application/xml' => XMLFormatter::class,
'text/xml' => XMLFormatter::class,
];
/**
* --------------------------------------------------------------------------
* Formatters Options
* --------------------------------------------------------------------------
*
* Additional Options to adjust default formatters behaviour.
* For each mime type, list the additional options that should be used.
*
* @var array<string, int>
*/
public array $formatterOptions = [
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
'application/xml' => 0,
'text/xml' => 0,
];
/**
* A Factory method to return the appropriate formatter for the given mime type.
*
* @return FormatterInterface
*
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
*/
public function getFormatter(string $mime)
{
return Services::format()->getFormatter($mime);
}
}

42
app/Config/Generators.php Normal file
View File

@ -0,0 +1,42 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Generators extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Generator Commands' Views
* --------------------------------------------------------------------------
*
* This array defines the mapping of generator commands to the view files
* they are using. If you need to customize them for your own, copy these
* view files in your own folder and indicate the location here.
*
* You will notice that the views have special placeholders enclosed in
* curly braces `{...}`. These placeholders are used internally by the
* generator commands in processing replacements, thus you are warned
* not to delete them or modify the names. If you will do so, you may
* end up disrupting the scaffolding process and throw errors.
*
* YOU HAVE BEEN WARNED!
*
* @var array<string, string>
*/
public array $views = [
'make:cell' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
'make:cell_view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
];
}

42
app/Config/Honeypot.php Normal file
View File

@ -0,0 +1,42 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Honeypot extends BaseConfig
{
/**
* Makes Honeypot visible or not to human
*/
public bool $hidden = true;
/**
* Honeypot Label Content
*/
public string $label = 'Fill This Field';
/**
* Honeypot Field Name
*/
public string $name = 'honeypot';
/**
* Honeypot HTML Template
*/
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
/**
* Honeypot container
*
* If you enabled CSP, you can remove `style="display:none"`.
*/
public string $container = '<div style="display:none">{template}</div>';
/**
* The id attribute for Honeypot container tag
*
* Used when CSP is enabled.
*/
public string $containerId = 'hpc';
}

31
app/Config/Images.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Images\Handlers\GDHandler;
use CodeIgniter\Images\Handlers\ImageMagickHandler;
class Images extends BaseConfig
{
/**
* Default handler used if no other handler is specified.
*/
public string $defaultHandler = 'gd';
/**
* The path to the image library.
* Required for ImageMagick, GraphicsMagick, or NetPBM.
*/
public string $libraryPath = '/usr/local/bin/convert';
/**
* The available handler classes.
*
* @var array<string, string>
*/
public array $handlers = [
'gd' => GDHandler::class,
'imagick' => ImageMagickHandler::class,
];
}

69
app/Config/Kint.php Normal file
View File

@ -0,0 +1,69 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Kint\Parser\ConstructablePluginInterface;
use Kint\Renderer\AbstractRenderer;
use Kint\Renderer\Rich\TabPluginInterface;
use Kint\Renderer\Rich\ValuePluginInterface;
/**
* --------------------------------------------------------------------------
* Kint
* --------------------------------------------------------------------------
*
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
* that you can set to customize how Kint works for you.
*
* @see https://kint-php.github.io/kint/ for details on these settings.
*/
class Kint extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
/**
* @var array<int, ConstructablePluginInterface|string>
* @phpstan-var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>
*/
public $plugins;
public int $maxDepth = 6;
public bool $displayCalledFrom = true;
public bool $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public string $richTheme = 'aante-light.css';
public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;
/**
* @var array<string, string>
* @phpstan-var array<string, class-string<ValuePluginInterface>>
*/
public $richObjectPlugins;
/**
* @var array<string, string>
* @phpstan-var array<string, class-string<TabPluginInterface>>
*/
public $richTabPlugins;
/*
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
public bool $cliColors = true;
public bool $cliForceUTF8 = false;
public bool $cliDetectWidth = true;
public int $cliMinWidth = 40;
}

148
app/Config/Logger.php Normal file
View File

@ -0,0 +1,148 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Log\Handlers\FileHandler;
class Logger extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Error Logging Threshold
* --------------------------------------------------------------------------
*
* You can enable error logging by setting a threshold over zero. The
* threshold determines what gets logged. Any values below or equal to the
* threshold will be logged.
*
* Threshold options are:
*
* - 0 = Disables logging, Error logging TURNED OFF
* - 1 = Emergency Messages - System is unusable
* - 2 = Alert Messages - Action Must Be Taken Immediately
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
* - 5 = Warnings - Exceptional occurrences that are not errors.
* - 6 = Notices - Normal but significant events.
* - 7 = Info - Interesting events, like user logging in, etc.
* - 8 = Debug - Detailed debug information.
* - 9 = All Messages
*
* You can also pass an array with threshold levels to show individual error types
*
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
*
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
* your log files will fill up very fast.
*
* @var array|int
*/
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
/**
* --------------------------------------------------------------------------
* Date Format for Logs
* --------------------------------------------------------------------------
*
* Each item that is logged has an associated date. You can use PHP date
* codes to set your own date formatting
*/
public string $dateFormat = 'Y-m-d H:i:s';
/**
* --------------------------------------------------------------------------
* Log Handlers
* --------------------------------------------------------------------------
*
* The logging system supports multiple actions to be taken when something
* is logged. This is done by allowing for multiple Handlers, special classes
* designed to write the log to their chosen destinations, whether that is
* a file on the getServer, a cloud-based service, or even taking actions such
* as emailing the dev team.
*
* Each handler is defined by the class name used for that handler, and it
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
*
* The value of each key is an array of configuration items that are sent
* to the constructor of each handler. The only required configuration item
* is the 'handles' element, which must be an array of integer log levels.
* This is most easily handled by using the constants defined in the
* `Psr\Log\LogLevel` class.
*
* Handlers are executed in the order defined in this array, starting with
* the handler on top and continuing down.
*/
public array $handlers = [
/*
* --------------------------------------------------------------------
* File Handler
* --------------------------------------------------------------------
*/
FileHandler::class => [
// The log levels that this handler will handle.
'handles' => [
'critical',
'alert',
'emergency',
'debug',
'error',
'info',
'notice',
'warning',
],
/*
* The default filename extension for log files.
* An extension of 'php' allows for protecting the log files via basic
* scripting, when they are to be stored under a publicly accessible directory.
*
* NOTE: Leaving it blank will default to 'log'.
*/
'fileExtension' => '',
/*
* The file system permissions to be applied on newly created log files.
*
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,
/*
* Logging Directory Path
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => WRITEPATH . 'logs/',
],
/*
* The ChromeLoggerHandler requires the use of the Chrome web browser
* and the ChromeLogger extension. Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
// /*
// * The log levels that this handler will handle.
// */
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
// 'error', 'info', 'notice', 'warning'],
// ],
/*
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
* Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
// /* The log levels this handler can handle. */
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
//
// /*
// * The message type where the error should go. Can be 0 or 4, or use the
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
// */
// 'messageType' => 0,
// ],
];
}

52
app/Config/Migrations.php Normal file
View File

@ -0,0 +1,52 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Migrations extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Enable/Disable Migrations
* --------------------------------------------------------------------------
*
* Migrations are enabled by default.
*
* You should enable migrations whenever you intend to do a schema migration
* and disable it back when you're done.
*/
public bool $enabled = true;
/**
* --------------------------------------------------------------------------
* Migrations Table
* --------------------------------------------------------------------------
*
* This is the name of the table that will store the current migrations state.
* When migrations runs it will store in a database table which migration
* level the system is at. It then compares the migration level in this
* table to the $config['migration_version'] if they are not the same it
* will migrate up. This must be set.
*/
public string $table = 'migrations';
/**
* --------------------------------------------------------------------------
* Timestamp Format
* --------------------------------------------------------------------------
*
* This is the format that will be used when creating new migrations
* using the CLI command:
* > php spark make:migration
*
* NOTE: if you set an unsupported format, migration runner will not find
* your migration files.
*
* Supported formats:
* - YmdHis_
* - Y-m-d-His_
* - Y_m_d_His_
*/
public string $timestampFormat = 'Y-m-d-His_';
}

532
app/Config/Mimes.php Normal file
View File

@ -0,0 +1,532 @@
<?php
namespace Config;
/**
* Mimes
*
* This file contains an array of mime types. It is used by the
* Upload class to help identify allowed file types.
*
* When more than one variation for an extension exist (like jpg, jpeg, etc)
* the most common one should be first in the array to aid the guess*
* methods. The same applies when more than one mime-type exists for a
* single extension.
*
* When working with mime types, please make sure you have the ´fileinfo´
* extension enabled to reliably detect the media types.
*/
class Mimes
{
/**
* Map of extensions to mime types.
*/
public static array $mimes = [
'hqx' => [
'application/mac-binhex40',
'application/mac-binhex',
'application/x-binhex40',
'application/x-mac-binhex40',
],
'cpt' => 'application/mac-compactpro',
'csv' => [
'text/csv',
'text/x-comma-separated-values',
'text/comma-separated-values',
'application/vnd.ms-excel',
'application/x-csv',
'text/x-csv',
'application/csv',
'application/excel',
'application/vnd.msexcel',
'text/plain',
],
'bin' => [
'application/macbinary',
'application/mac-binary',
'application/octet-stream',
'application/x-binary',
'application/x-macbinary',
],
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => [
'application/octet-stream',
'application/vnd.microsoft.portable-executable',
'application/x-dosexec',
'application/x-msdownload',
],
'class' => 'application/octet-stream',
'psd' => [
'application/x-photoshop',
'image/vnd.adobe.photoshop',
],
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => [
'application/pdf',
'application/force-download',
'application/x-download',
],
'ai' => [
'application/pdf',
'application/postscript',
],
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => [
'application/vnd.ms-excel',
'application/msexcel',
'application/x-msexcel',
'application/x-ms-excel',
'application/x-excel',
'application/x-dos_ms_excel',
'application/xls',
'application/x-xls',
'application/excel',
'application/download',
'application/vnd.ms-office',
'application/msword',
],
'ppt' => [
'application/vnd.ms-powerpoint',
'application/powerpoint',
'application/vnd.ms-office',
'application/msword',
],
'pptx' => [
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
],
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'php' => [
'application/x-php',
'application/x-httpd-php',
'application/php',
'text/php',
'text/x-php',
'application/x-httpd-php-source',
],
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => [
'application/x-javascript',
'text/plain',
],
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => [
'application/x-tar',
'application/x-gzip-compressed',
],
'z' => 'application/x-compress',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => [
'application/x-zip',
'application/zip',
'application/x-zip-compressed',
'application/s-compressed',
'multipart/x-zip',
],
'rar' => [
'application/vnd.rar',
'application/x-rar',
'application/rar',
'application/x-rar-compressed',
],
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => [
'audio/mpeg',
'audio/mpg',
'audio/mpeg3',
'audio/mp3',
],
'aif' => [
'audio/x-aiff',
'audio/aiff',
],
'aiff' => [
'audio/x-aiff',
'audio/aiff',
],
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => [
'audio/x-wav',
'audio/wave',
'audio/wav',
],
'bmp' => [
'image/bmp',
'image/x-bmp',
'image/x-bitmap',
'image/x-xbitmap',
'image/x-win-bitmap',
'image/x-windows-bmp',
'image/ms-bmp',
'image/x-ms-bmp',
'application/bmp',
'application/x-bmp',
'application/x-win-bitmap',
],
'gif' => 'image/gif',
'jpg' => [
'image/jpeg',
'image/pjpeg',
],
'jpeg' => [
'image/jpeg',
'image/pjpeg',
],
'jpe' => [
'image/jpeg',
'image/pjpeg',
],
'jp2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'j2k' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpf' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpg2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpx' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpm' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'mj2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'mjp2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'png' => [
'image/png',
'image/x-png',
],
'webp' => 'image/webp',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'css' => [
'text/css',
'text/plain',
],
'html' => [
'text/html',
'text/plain',
],
'htm' => [
'text/html',
'text/plain',
],
'shtml' => [
'text/html',
'text/plain',
],
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => [
'text/plain',
'text/x-log',
],
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => [
'application/xml',
'text/xml',
'text/plain',
],
'xsl' => [
'application/xml',
'text/xsl',
'text/xml',
],
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => [
'video/x-msvideo',
'video/msvideo',
'video/avi',
'application/x-troff-msvideo',
],
'movie' => 'video/x-sgi-movie',
'doc' => [
'application/msword',
'application/vnd.ms-office',
],
'docx' => [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword',
'application/x-zip',
],
'dot' => [
'application/msword',
'application/vnd.ms-office',
],
'dotx' => [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword',
],
'xlsx' => [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/zip',
'application/vnd.ms-excel',
'application/msword',
'application/x-zip',
],
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
'word' => [
'application/msword',
'application/octet-stream',
],
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => [
'application/json',
'text/json',
],
'pem' => [
'application/x-x509-user-cert',
'application/x-pem-file',
'application/octet-stream',
],
'p10' => [
'application/x-pkcs10',
'application/pkcs10',
],
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' => [
'application/pkcs7-mime',
'application/x-pkcs7-mime',
],
'p7m' => [
'application/pkcs7-mime',
'application/x-pkcs7-mime',
],
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
'crt' => [
'application/x-x509-ca-cert',
'application/x-x509-user-cert',
'application/pkix-cert',
],
'crl' => [
'application/pkix-crl',
'application/pkcs-crl',
],
'der' => 'application/x-x509-ca-cert',
'kdb' => 'application/octet-stream',
'pgp' => 'application/pgp',
'gpg' => 'application/gpg-keys',
'sst' => 'application/octet-stream',
'csr' => 'application/octet-stream',
'rsa' => 'application/x-pkcs7',
'cer' => [
'application/pkix-cert',
'application/x-x509-ca-cert',
],
'3g2' => 'video/3gpp2',
'3gp' => [
'video/3gp',
'video/3gpp',
],
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => [
'video/mp4',
'video/x-f4v',
],
'flv' => 'video/x-flv',
'webm' => 'video/webm',
'aac' => 'audio/x-acc',
'm4u' => 'application/vnd.mpegurl',
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
'wmv' => [
'video/x-ms-wmv',
'video/x-ms-asf',
],
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
'ogg' => [
'audio/ogg',
'video/ogg',
'application/ogg',
],
'kmz' => [
'application/vnd.google-earth.kmz',
'application/zip',
'application/x-zip',
],
'kml' => [
'application/vnd.google-earth.kml+xml',
'application/xml',
'text/xml',
],
'ics' => 'text/calendar',
'ical' => 'text/calendar',
'zsh' => 'text/x-scriptzsh',
'7zip' => [
'application/x-compressed',
'application/x-zip-compressed',
'application/zip',
'multipart/x-zip',
],
'cdr' => [
'application/cdr',
'application/coreldraw',
'application/x-cdr',
'application/x-coreldraw',
'image/cdr',
'image/x-cdr',
'zz-application/zz-winassoc-cdr',
],
'wma' => [
'audio/x-ms-wma',
'video/x-ms-asf',
],
'jar' => [
'application/java-archive',
'application/x-java-application',
'application/x-jar',
'application/x-compressed',
],
'svg' => [
'image/svg+xml',
'image/svg',
'application/xml',
'text/xml',
],
'vcf' => 'text/x-vcard',
'srt' => [
'text/srt',
'text/plain',
],
'vtt' => [
'text/vtt',
'text/plain',
],
'ico' => [
'image/x-icon',
'image/x-ico',
'image/vnd.microsoft.icon',
],
'stl' => [
'application/sla',
'application/vnd.ms-pki.stl',
'application/x-navistyle',
],
];
/**
* Attempts to determine the best mime type for the given file extension.
*
* @return string|null The mime type found, or none if unable to determine.
*/
public static function guessTypeFromExtension(string $extension)
{
$extension = trim(strtolower($extension), '. ');
if (! array_key_exists($extension, static::$mimes)) {
return null;
}
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
}
/**
* Attempts to determine the best file extension for a given mime type.
*
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
*
* @return string|null The extension determined, or null if unable to match.
*/
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null)
{
$type = trim(strtolower($type), '. ');
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
if (
$proposedExtension !== ''
&& array_key_exists($proposedExtension, static::$mimes)
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
) {
// The detected mime type matches with the proposed extension.
return $proposedExtension;
}
// Reverse check the mime type list if no extension was proposed.
// This search is order sensitive!
foreach (static::$mimes as $ext => $types) {
if (in_array($type, (array) $types, true)) {
return $ext;
}
}
return null;
}
}

82
app/Config/Modules.php Normal file
View File

@ -0,0 +1,82 @@
<?php
namespace Config;
use CodeIgniter\Modules\Modules as BaseModules;
/**
* Modules Configuration.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*/
class Modules extends BaseModules
{
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all elements listed in
* $aliases below. If false, no auto-discovery will happen at all,
* giving a slight performance boost.
*
* @var bool
*/
public $enabled = true;
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery Within Composer Packages?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all namespaces loaded
* by Composer, as well as the namespaces configured locally.
*
* @var bool
*/
public $discoverInComposer = true;
/**
* The Composer package list for Auto-Discovery
* This setting is optional.
*
* E.g.:
* [
* 'only' => [
* // List up all packages to auto-discover
* 'codeigniter4/shield',
* ],
* ]
* or
* [
* 'exclude' => [
* // List up packages to exclude.
* 'pestphp/pest',
* ],
* ]
*
* @var array
*/
public $composerPackages = [];
/**
* --------------------------------------------------------------------------
* Auto-Discovery Rules
* --------------------------------------------------------------------------
*
* Aliases list of all discovery classes that will be active and used during
* the current application request.
*
* If it is not listed, only the base application elements will be used.
*
* @var string[]
*/
public $aliases = [
'events',
'filters',
'registrars',
'routes',
'services',
];
}

37
app/Config/Pager.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Pager extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Templates
* --------------------------------------------------------------------------
*
* Pagination links are rendered out using views to configure their
* appearance. This array contains aliases and the view names to
* use when rendering the links.
*
* Within each view, the Pager object will be available as $pager,
* and the desired group as $pagerGroup;
*
* @var array<string, string>
*/
public array $templates = [
'default_full' => 'CodeIgniter\Pager\Views\default_full',
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
'default_head' => 'CodeIgniter\Pager\Views\default_head',
];
/**
* --------------------------------------------------------------------------
* Items Per Page
* --------------------------------------------------------------------------
*
* The default number of results shown in a single page.
*/
public int $perPage = 20;
}

80
app/Config/Paths.php Normal file
View File

@ -0,0 +1,80 @@
<?php
namespace Config;
/**
* Paths
*
* Holds the paths that are used by the system to
* locate the main directories, app, system, etc.
*
* Modifying these allows you to restructure your application,
* share a system folder between multiple applications, and more.
*
* All paths are relative to the project's root folder.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*
* @immutable
*/
class Paths
{
/**
* ---------------------------------------------------------------
* SYSTEM FOLDER NAME
* ---------------------------------------------------------------
*
* This must contain the name of your "system" folder. Include
* the path if the folder is not in the same directory as this file.
*/
public string $systemDirectory = __DIR__ . '/../../system';
/**
* ---------------------------------------------------------------
* APPLICATION FOLDER NAME
* ---------------------------------------------------------------
*
* If you want this front controller to use a different "app"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path.
*
* @see http://codeigniter.com/user_guide/general/managing_apps.html
*/
public string $appDirectory = __DIR__ . '/..';
/**
* ---------------------------------------------------------------
* WRITABLE DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "writable" directory.
* The writable directory allows you to group all directories that
* need write permission to a single place that can be tucked away
* for maximum security, keeping it out of the app and/or
* system directories.
*/
public string $writableDirectory = __DIR__ . '/../../writable';
/**
* ---------------------------------------------------------------
* TESTS DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "tests" directory.
*/
public string $testsDirectory = __DIR__ . '/../../tests';
/**
* ---------------------------------------------------------------
* VIEW DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of the directory that
* contains the view files used by your application. By
* default this is in `app/Views`. This value
* is used when no value is provided to `Services::renderer()`.
*/
public string $viewDirectory = __DIR__ . '/../Views';
}

28
app/Config/Publisher.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace Config;
use CodeIgniter\Config\Publisher as BasePublisher;
/**
* Publisher Configuration
*
* Defines basic security restrictions for the Publisher class
* to prevent abuse by injecting malicious files into a project.
*/
class Publisher extends BasePublisher
{
/**
* A list of allowed destinations with a (pseudo-)regex
* of allowed files for each destination.
* Attempts to publish to directories not in this list will
* result in a PublisherException. Files that do no fit the
* pattern will cause copy/merge to fail.
*
* @var array<string,string>
*/
public $restrictions = [
ROOTPATH => '*',
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
];
}

178
app/Config/Routes.php Normal file
View File

@ -0,0 +1,178 @@
<?php
namespace Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
/*
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Authentication');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
// $routes->setAutoRoute(false);
/*
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
# Authentication Routes
$routes->get('/', 'Authentication::index');
$routes->get('login/', 'Authentication::index');
$routes->post('authenticate/', 'Authentication::authenticate');//Routes For Authentication.
$routes->get('logout/', 'Authentication::logout');
$routes->get('auth_confirm_mail/', 'Authentication::auth_confirm_mail');//Routes For Confirmation Mail alert page.
$routes->get('auth_reset_password/', 'Authentication::auth_reset_password');//Routes For Load Reset password Page.
$routes->post('auth_reset_password_save/', 'Authentication::auth_reset_password_save');//Routes For update the Resetted password.
$routes->get('lockscreen/', 'Authentication::lockscreen');
$routes->get('lock/', 'Authentication::lock');
$routes->post('unlock/', 'Authentication::unlock');
# Dashboard Routes
$routes->get('dashboard/', 'Home::index');
# Users Routes
$routes->get("user_list/", "Users::index");
$routes->get("user_page/(:any)", "Users::user_page/$1");
$routes->post("insert_users", "Users::insert_users");
$routes->get("delete_user/(:any)", "Users::delete_user/$1");
# Causes Routes
$routes->get("causes_list/", "Books::index");
$routes->get("add_causes/(:any)", "Books::add_causes/$1");
$routes->post("insert_books", "Books::insert_books");
$routes->get("delete_books/(:any)", "Books::delete_books/$1");
# Site-Setting Routes
$routes->get("sitesetting_list/", "Settings::index");
$routes->get("sitesetting_page/(:any)", "Settings::sitesetting_page/$1");
$routes->post("sitesetting_synchronization", "Settings::sitesetting_synchronization");
$routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1");
# Business Routes
$routes->get("business_list/", "Business::index");
$routes->get("new_bussiness/(:any)", "Business::new_bussiness/$1");
$routes->post("insert_business/", "Business::insert_business");
$routes->get("delete_business/(:any)", "Business::delete_business/$1");
# Doner Routes
$routes->get("doner_list/", "Customer::index");
$routes->get("new_doner/(:any)", "Customer::new_doner/$1");
$routes->post("insert_customer", "Customer::insert_customer");
$routes->get("delete_customer/(:any)", "Customer::delete_customer/$1");
# Routes for Customer group
$routes->get('customer_group/', 'Customer::customer_group');
$routes->get('view_customer_group/(:any)', 'Customer::view_customer_group/$1');
$routes->get('preview_customer_group/(:any)', 'Customer::preview_customer_group/$1');
$routes->get('delete_customer_group/(:any)', 'Customer::delete_customer_group/$1');
$routes->post("insert_customer_group", "Customer::insert_customer_group");
# Scheme Routes
$routes->get("scheme_list/", "Scheme::index");
$routes->get("new_scheme/(:any)", "Scheme::new_scheme/$1");
$routes->post("insert_scheme/", "Scheme::insert_scheme");
$routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1");
#subscription Routes
$routes->get("subscribers_list/", "Subscription::index");
$routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
$routes->post("add_subscription/", "Subscription::add_subscription/");
$routes->post('subscription/download_details', 'Subscription::download_details');
#adres priknt
$routes->get('addressprint/', 'Address::index');
$routes->post('address/generatePdf', 'Address::generatePdf');
#evnts
$routes->get("campaign_list/", "Event::index");
$routes->get("new_campaign/(:any)", "Event::new_campaign/$1");
$routes->post("insert_event/", "Event::insert_event");
$routes->get('invoice_number_format/(:any)', 'Event::invoice_number_format/$1');
$routes->post("insert_invoice_number_format", "Event::insert_invoice_number_format");
#Receipt Routes
$routes->get("receipt_list/", "Invoice::index");
$routes->get("new_receipt/(:any)", "Invoice::new_receipt/$1");
// $routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
$routes->post("load_details1/", "Invoice::load_details1/");
$routes->post("load_details2/", "Invoice::load_details2/");
$routes->post("save_invoice/", "Invoice::save_invoice/");
$routes->get("delete_invoice/(:any)", "Invoice::delete_invoice/$1");
$routes->add('approve_invoice/(:num)', 'Invoice::approve_invoice/$1');
$routes->get('generate_invoice_pdf/(:num)', 'Invoice::generate_invoice_pdf/$1');
$routes->get('print_address/(:num)', 'Invoice::print_address/$1');
$routes->get('print_address/(:num)', 'Invoice::print_address/$1');
$routes->match(['get','post'],'/general_inv_rp','Invoice::general_inv_rp');
$routes->match(['get','post'],'/mem_inv_rp','Invoice::general_membership_inv_rp');
$routes->match(['get','post'],'/itemwise_report','Invoice::itemwise_report');
# Notifications Routes
// $routes->get('controller/SubExpdetail/(:num)', 'YourController::SubExpdetail/$1');
$routes->cli("getExpCustomerDetail/(:num)",'Notifications::getExpCustomerDetail/$1');
$routes->get('send_whatsapp_message/', 'Notifications::send_whatsapp_message');
$routes->post('whatsapp_custom_notifications/', 'Notifications::whatsapp_custom_notifications');
$routes->match(['post', 'get'], 'mail_custom_notifications', 'Notifications::mail_custom_notifications');
// $routes->match(['post', 'get'], 'due_date_notifications', 'Notifications::due_date_notifications');
// $routes->get('due_date_notifications/(:any)', 'Notifications::due_date_notifications/$1');
$routes->get('due_date_notifications', 'Notifications::due_date_notifications');
$routes->get('template_creation/', 'Notifications::template_creation');
$routes->get('template_creation_form/(:any)', 'Notifications::template_creation_form/$1');
$routes->get('template_creation_delete/(:any)', 'Notifications::template_creation_delete/$1');
$routes->post("template_creation_insert", "Notifications::template_creation_insert");
$routes->get('campaign_creation/', 'Notifications::campaign_creation');
$routes->get('campaign_creation_form/(:any)', 'Notifications::campaign_creation_form/$1');
$routes->get('campaign_creation_delete/(:any)', 'Notifications::campaign_creation_delete/$1');
$routes->post("campaign_creation_insert", "Notifications::campaign_creation_insert");
# Api integration Routes
$routes->post('api/(:any)', 'ApiIntegration::api_integration/$1');
// $routes->group("api", function ($routes) {
// // $routes->post("create_products/", "ApiIntegration::save_book_details");
// // $routes->match(['put', 'post', 'get', 'delete'], 'products', 'ApiIntegration::book_api_integration');
// // $routes->match(['put', 'post', 'get', 'delete'], 'customers', 'ApiIntegration::customer_api_integration');
// // $routes->match(['put', 'post', 'get', 'delete'], 'orders', 'ApiIntegration::sales_api_integration');
// });
/*
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need it to be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}

101
app/Config/Security.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Security extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CSRF Protection Method
* --------------------------------------------------------------------------
*
* Protection Method for Cross Site Request Forgery protection.
*
* @var string 'cookie' or 'session'
*/
public string $csrfProtection = 'cookie';
/**
* --------------------------------------------------------------------------
* CSRF Token Randomization
* --------------------------------------------------------------------------
*
* Randomize the CSRF Token for added security.
*/
public bool $tokenRandomize = false;
/**
* --------------------------------------------------------------------------
* CSRF Token Name
* --------------------------------------------------------------------------
*
* Token name for Cross Site Request Forgery protection.
*/
public string $tokenName = 'csrf_test_name';
/**
* --------------------------------------------------------------------------
* CSRF Header Name
* --------------------------------------------------------------------------
*
* Header name for Cross Site Request Forgery protection.
*/
public string $headerName = 'X-CSRF-TOKEN';
/**
* --------------------------------------------------------------------------
* CSRF Cookie Name
* --------------------------------------------------------------------------
*
* Cookie name for Cross Site Request Forgery protection.
*/
public string $cookieName = 'csrf_cookie_name';
/**
* --------------------------------------------------------------------------
* CSRF Expires
* --------------------------------------------------------------------------
*
* Expiration time for Cross Site Request Forgery protection cookie.
*
* Defaults to two hours (in seconds).
*/
public int $expires = 7200;
/**
* --------------------------------------------------------------------------
* CSRF Regenerate
* --------------------------------------------------------------------------
*
* Regenerate CSRF Token on every submission.
*/
public bool $regenerate = true;
/**
* --------------------------------------------------------------------------
* CSRF Redirect
* --------------------------------------------------------------------------
*
* Redirect to previous page with error on failure.
*/
public bool $redirect = false;
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token.
*
* Allowed values are: None - Lax - Strict - ''.
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public string $samesite = 'Lax';
}

32
app/Config/Services.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseService;
/**
* Services Configuration file.
*
* Services are simply other classes/libraries that the system uses
* to do its job. This is used by CodeIgniter to allow the core of the
* framework to be swapped out easily without affecting the usage within
* the rest of your application.
*
* This file holds any application-specific services, or service overrides
* that you might need. An example has been included with the general
* method format you should use for your service methods. For more examples,
* see the core Services file at system/Config/Services.php.
*/
class Services extends BaseService
{
/*
* public static function example($getShared = true)
* {
* if ($getShared) {
* return static::getSharedInstance('example');
* }
*
* return new \CodeIgniter\Example();
* }
*/
}

102
app/Config/Session.php Normal file
View File

@ -0,0 +1,102 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
class Session extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @phpstan-var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*/
public string $cookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*/
public int $expiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*/
public string $savePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*/
public bool $matchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*/
public int $timeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*/
public bool $regenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Session Database Group
* --------------------------------------------------------------------------
*
* DB Group for the database session.
*/
public ?string $DBGroup = null;
}

91
app/Config/Toolbar.php Normal file
View File

@ -0,0 +1,91 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\Toolbar\Collectors\Database;
use CodeIgniter\Debug\Toolbar\Collectors\Events;
use CodeIgniter\Debug\Toolbar\Collectors\Files;
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
use CodeIgniter\Debug\Toolbar\Collectors\Views;
/**
* --------------------------------------------------------------------------
* Debug Toolbar
* --------------------------------------------------------------------------
*
* The Debug Toolbar provides a way to see information about the performance
* and state of your application during that page display. By default it will
* NOT be displayed under production environments, and will only display if
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
*/
class Toolbar extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Toolbar Collectors
* --------------------------------------------------------------------------
*
* List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from.
*
* @var string[]
*/
public array $collectors = [
Timers::class,
Database::class,
Logs::class,
Views::class,
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
Files::class,
Routes::class,
Events::class,
];
/**
* --------------------------------------------------------------------------
* Collect Var Data
* --------------------------------------------------------------------------
*
* If set to false var data from the views will not be colleted. Useful to
* avoid high memory usage when there are lots of data passed to the view.
*/
public bool $collectVarData = true;
/**
* --------------------------------------------------------------------------
* Max History
* --------------------------------------------------------------------------
*
* `$maxHistory` sets a limit on the number of past requests that are stored,
* helping to conserve file space used to store them. You can set it to
* 0 (zero) to not have any history stored, or -1 for unlimited history.
*/
public int $maxHistory = 20;
/**
* --------------------------------------------------------------------------
* Toolbar Views Path
* --------------------------------------------------------------------------
*
* The full path to the the views that are used by the toolbar.
* This MUST have a trailing slash.
*/
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/**
* --------------------------------------------------------------------------
* Max Queries
* --------------------------------------------------------------------------
*
* If the Database Collector is enabled, it will log every query that the
* the system generates so they can be displayed on the toolbar's timeline
* and in the query log. This can lead to memory issues in some instances
* with hundreds of queries.
*
* `$maxQueries` defines the maximum amount of queries that will be stored.
*/
public int $maxQueries = 100;
}

252
app/Config/UserAgents.php Normal file
View File

@ -0,0 +1,252 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* -------------------------------------------------------------------
* User Agents
* -------------------------------------------------------------------
*
* This file contains four arrays of user agent data. It is used by the
* User Agent Class to help identify browser, platform, robot, and
* mobile device data. The array keys are used to identify the device
* and the array values are used to set the actual name of the item.
*/
class UserAgents extends BaseConfig
{
/**
* -------------------------------------------------------------------
* OS Platforms
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $platforms = [
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS',
];
/**
* -------------------------------------------------------------------
* Browsers
* -------------------------------------------------------------------
*
* The order of this array should NOT be changed. Many browsers return
* multiple browser types so we want to identify the subtype first.
*
* @var array<string, string>
*/
public array $browsers = [
'OPR' => 'Opera',
'Flock' => 'Flock',
'Edge' => 'Spartan',
'Edg' => 'Edge',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser',
'Vivaldi' => 'Vivaldi',
];
/**
* -------------------------------------------------------------------
* Mobiles
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $mobiles = [
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'ipod' => 'Apple iPod Touch',
'sony' => 'Sony Ericsson',
'ericsson' => 'Sony Ericsson',
'blackberry' => 'BlackBerry',
'cocoon' => 'O2 Cocoon',
'blazer' => 'Treo',
'lg' => 'LG',
'amoi' => 'Amoi',
'xda' => 'XDA',
'mda' => 'MDA',
'vario' => 'Vario',
'htc' => 'HTC',
'samsung' => 'Samsung',
'sharp' => 'Sharp',
'sie-' => 'Siemens',
'alcatel' => 'Alcatel',
'benq' => 'BenQ',
'ipaq' => 'HP iPaq',
'mot-' => 'Motorola',
'playstation portable' => 'PlayStation Portable',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
// Operating Systems
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
// Browsers
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
// Other
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
// Fallback
'mobile' => 'Generic Mobile',
'wireless' => 'Generic Mobile',
'j2me' => 'Generic Mobile',
'midp' => 'Generic Mobile',
'cldc' => 'Generic Mobile',
'up.link' => 'Generic Mobile',
'up.browser' => 'Generic Mobile',
'smartphone' => 'Generic Mobile',
'cellphone' => 'Generic Mobile',
];
/**
* -------------------------------------------------------------------
* Robots
* -------------------------------------------------------------------
*
* There are hundred of bots but these are the most common.
*
* @var array<string, string>
*/
public array $robots = [
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'ia_archiver' => 'Alexa Crawler',
'MJ12bot' => 'Majestic-12',
'Uptimebot' => 'Uptimebot',
];
}

44
app/Config/Validation.php Normal file
View File

@ -0,0 +1,44 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\StrictRules\CreditCardRules;
use CodeIgniter\Validation\StrictRules\FileRules;
use CodeIgniter\Validation\StrictRules\FormatRules;
use CodeIgniter\Validation\StrictRules\Rules;
class Validation extends BaseConfig
{
// --------------------------------------------------------------------
// Setup
// --------------------------------------------------------------------
/**
* Stores the classes that contain the
* rules that are available.
*
* @var string[]
*/
public array $ruleSets = [
Rules::class,
FormatRules::class,
FileRules::class,
CreditCardRules::class,
];
/**
* Specifies the views that are used to display the
* errors.
*
* @var array<string, string>
*/
public array $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
];
// --------------------------------------------------------------------
// Rules
// --------------------------------------------------------------------
}

56
app/Config/View.php Normal file
View File

@ -0,0 +1,56 @@
<?php
namespace Config;
use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;
class View extends BaseView
{
/**
* When false, the view method will clear the data between each
* call. This keeps your data safe and ensures there is no accidental
* leaking between calls, so you would need to explicitly pass the data
* to each view. You might prefer to have the data stick around between
* calls so that it is available to all views. If that is the case,
* set $saveData to true.
*
* @var bool
*/
public $saveData = true;
/**
* Parser Filters map a filter name with any PHP callable. When the
* Parser prepares a variable for display, it will chain it
* through the filters in the order defined, inserting any parameters.
* To prevent potential abuse, all filters MUST be defined here
* in order for them to be available for use within the Parser.
*
* Examples:
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array
*/
public $filters = [];
/**
* Parser Plugins provide a way to extend the functionality provided
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*
* @var array
*/
public $plugins = [];
/**
* View Decorators are class methods that will be run in sequence to
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var class-string<ViewDecoratorInterface>[]
*/
public array $decorators = [];
}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Controllers;
use App\Models\CustomerModel;
class Address extends BaseController
{
public function index()
{
helper('session');
$customerModel = new CustomerModel();
$data['page_name'] = 'Customer Listing';
$data['customers'] = $customerModel->findAll();
return view('address_list', $data);
}
}
// public function generatePdf()
// {
// $customerModel = new CustomerModel();
// $customer_id = $this->request->getPost('customer_id');
// $customerData = $customerModel->find($customer_id);
// if ($customerData) {
// $options->set('isHtml5ParserEnabled', true);
// $options->set('isPhpEnabled', true);
// $dompdf = new Dompdf($options);
// $html = view('address_list', ['customerData' => $customerData]);
// $dompdf->loadHtml($html);
// $dompdf->setPaper('A4', 'portrait');
// $dompdf->render();
// $dompdf->stream('customer_information.pdf', ['Attachment' => 0]);
// } else {
// return redirect()->to('index');
// }
// }
// }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,333 @@
<?php
namespace App\Controllers;
use App\Models\AuthenticationModel;
## Authentication Controllers only for Login,Logout,forgotpassword,confirmationpassword,resetpassword,session,cookie,lock-screen Modules
class Authentication extends BaseController
{
## Load Login Page
public function index()
{
// Retrieve flashed session data
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data
// Here, we'll use the default View class for demonstration purposes
$alerts = [
'successMessage' => $successMessage,
'validationErrors' => $validationErrors,
];
return view('auth_login', $alerts);
}
## Authenticate the users and Redirect to Dashboard
public function authenticate()
{
$auth_model = new AuthenticationModel();
$rules = [
'username' => 'required',
'password' => 'required',
];
if ($this->validate($rules)) {
$username = $this->request->getPost('username');
$password = $this->request->getPost('password');
$user = $auth_model->where(['email'=>$username,'isactive'=>1])->first();
// $this->logger->info("Authenticate: Function Called.");
if (is_null($user)) {
$this->logger->error('User does not exist');
return redirect()->back()->withInput()->with('error', 'User does not exist');
}
$pwd_verify = password_verify((string)$password, $user['password']);
if (!$pwd_verify) {
$this->logger->error('Invalid Password');
return redirect()->back()->withInput()->with('error', 'Invalid Password.');
}
// You can implement your authentication logic here
// For example, check against a database, validate credentials, etc.
if ($username === $user['email'] && $pwd_verify) {
// Redirect to a dashboard or other protected area
helper('session');
set_logged_user_id($user['user_id']);
set_logged_name($user['first_name'] . " " . $user['last_name']);
set_user_role($user['role']);
set_business_id($user['business_id']);
return redirect()->to('dashboard');
// $cookie = \Config\Services::cookie();
// $cookie->setCookie('remember_username', 'Sri Harsha', 3600); // Cookie expires in 1 hour
} else {
// Invalid credentials, display error message
// return redirect()->back()->with('error', 'Invalid username or password.');
$this->logger->error('Invalid username or password.');
return redirect()->back()->withInput()->with('error', 'Invalid username or password.');
}
} else {
// Validation failed, display errors
// return redirect()->back()->withInput()->with('validation', $validation);
$this->logger->error('Username or password Required.');
return redirect()->back()->withInput()->with('error', 'Username or password Required.');
}
}
## Load Forgot password Confirmation Alert
public function auth_confirm_mail()
{
// Get the email address from the request
$mail_id = $this->request->getGet('email');
$url_domain = base_url();
// Validate the email address
$validation_rules = [
'email' => 'required|valid_email',
];
if (!$this->validate($validation_rules)) {
$this->logger->error('enter correct mail to reset your Password');
return redirect()->back()->withInput()->with('error', 'Enter correct E-mail to reset your password');
}
// Check if the email exists in the database
$auth_model = new AuthenticationModel();
// $user = $auth_model->where('email', $mail_id)->first();
$where = ['email' => $mail_id, 'isactive' => 1];
$user = $auth_model->where($where)->first();
if (!$user) {
$this->logger->error('There is no user enteries against given mail');
return redirect()->back()->withInput()->with('error', 'There is no user enteries against given mail');
} else {
$data['mail_id'] = $mail_id;
// Generate a unique token for password reset
$token = bin2hex(random_bytes(32));
$content = "Click the link below to reset your password : " . $url_domain . "auth_reset_password?email=" . $mail_id . "&token=" . $token;
$email = \Config\Services::email();
// $recipient = 'venbalap08@gmail.com';
$recipient = $mail_id;
// Compose the email
$email->setTo($recipient);
$email->setFrom('no-reply@tripapprovaltool.com', 'BB-VBP');
$email->setSubject('Email Notification');
// $email->setMessage('This is a notification email from CodeIgniter.');
$email->setMessage($content);
$update_token['reset_link'] = $token;
$auth_model->update($user['user_id'], $update_token);
$data['link'] = $url_domain . "auth_reset_password?email=" . $mail_id . "&token=" . $token;
// Retrieve flashed session data
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data
// Here, we'll use the default View class for demonstration purposes
$data['successMessage'] = $successMessage;
$data['validationErrors'] = $validationErrors;
// return view('auth_confirm_mail', $data);
if ($email->send()) {
// Email sent successfully
return view('auth_confirm_mail', $data);
} else {
$this->logger->error('Email Not Sended,Try Again');
return redirect()->back()->withInput()->with('error', 'Email Not Sended,Try Again');
}
}
}
## Load Reset password Page
public function auth_reset_password()
{
$email = $this->request->getGet('email');
$token = $this->request->getGet('token');
$auth_model = new AuthenticationModel();
$where = ['email' => $email, 'reset_link' => $token, 'isactive' => 1];
$user = $auth_model->where($where)->first();
if (!$user) {
$this->logger->error('Invaild link for this Email');
return redirect()->back()->withInput()->with('error', 'Invaild link for this Email');
//return back page is auth_login
} else {
$update_token['reset_link'] = NULL;
$auth_model->update($user['user_id'], $update_token);
$data['email'] = $email;
// Retrieve flashed session data
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data
// Here, we'll use the default View class for demonstration purposes
$data['successMessage'] = $successMessage;
$data['validationErrors'] = $validationErrors;
return view('auth_reset_password', $data);
}
}
## Save Resetted password. and Redirect to login
public function auth_reset_password_save()
{
$auth_model = new AuthenticationModel();
$rules = [
'password1' => 'required',
'password2' => 'required',
];
if ($this->validate($rules)) {
// echo "try";die;
$email = $this->request->getVar('email');
$password = $this->request->getVar('password1');
$confirmation = $this->request->getVar('password2');
$hash_password = password_hash($password, PASSWORD_DEFAULT);
// try {
// code for password confirmation
if ($password === $confirmation) {
$auth_model = new AuthenticationModel();
$user_details = $auth_model->where(['email' => $email, 'isactive' => 1])->first();
if ($user_details) {
$update_user_details = ['email' => $email, 'password' => $hash_password];
$auth_model->update($user_details['user_id'], $update_user_details);
}
// Retrieve flashed session data
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data
// Here, we'll use the default View class for demonstration purposes
$data['successMessage'] = $successMessage;
$data['validationErrors'] = $validationErrors;
return view('auth_login', $data);
} else {
// Password confirmation failed
$this->logger->error('Password confirmation failed');
return redirect()->back()->withInput()->with('error', 'Password confirmation failed');
}
// } catch (\Exception $e) {
// $error = "Exception Errno returned" . $e->getCode() . " <br/>";
// $error_msg = $e->getMessage();
// $this->logger->error($error . '(' . $error_msg . ')');
// return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')');
// }
} else {
// Validation failed, display errors
$this->logger->error('Password And Confirmation Password are Required.');
return redirect()->back()->withInput()->with('error', 'Password And Confirmation Password are Required.');
}
}
## Logout With destory Session Details
public function logout()
{
// Clear session and cookies
$session = session();
// Regenerate the session ID
$session->regenerate();
// Clear session data and perform logout logic
$session->destroy();
// $cookie = \Config\Services::cookie();
// $cookie->delete('ci_session');
// $remembered_username = $cookie->getCookie('remember_username');
// $cookie->delete('remember_username');
// Redirect to a logout confirmation page or login page
// return redirect()->to('/login'); // Replace with your login route
$this->response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
$this->response->setHeader('Pragma', 'no-cache');
$this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
$data = [];
return view('auth_logout', $data);
}
## Lock Screen - holded
public function lockscreen()
{
// Load the session library
helper('session');
$session_uid = get_logged_user_id();
$session_uname = get_logged_name();
$auth_model = new AuthenticationModel();
$details = $auth_model->getheringDetailsForHeader($session_uid);
$data['loggedin_person'] = $session_uname;
$data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
$data['company_logo_small'] = !empty($details[0]['company_logo_small']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = !empty($details[0]['company_logo_large']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data
// Here, we'll use the default View class for demonstration purposes
// Check if the session is locked
if (get_session_locked()) {
$data['successMessage'] = $successMessage;
$data['validationErrors'] = $validationErrors;
// Load the lock screen view
return view('auth_lock_screen', $data);
} else {
// Redirect the user to their previous page or dashboard
return redirect()->to('dashboard'); // Replace with appropriate URL
}
}
## Lock Screen
public function lock()
{
// Load the session library
helper('session');
// Set the session_locked flag
set_session_locked(true);
// Redirect the user to the lock screen
return redirect()->to('lockscreen'); // Replace with your lock screen URL
}
## Unlock Screen - holded
public function unlock()
{
// Load the session library
helper('session');
// Check password logic
$password = $this->request->getVar('password');
if ($this->checkPassword($password)) {
// Unlock the session
remove_session_locked();
return redirect()->to('dashboard'); // Redirect to dashboard
} else {
// Incorrect password, show error
return redirect()->back()->withInput()->with('error', 'Incorrect password.');
}
}
## Unlock Screen
private function checkPassword($password)
{
// Implement your password validation logic here
// For example, compare against a stored hash
// return $password === 'correct_password';
helper('session');
$session_uid = get_logged_user_id();
$auth_model = new AuthenticationModel();
$user = $auth_model->where('user_id', $session_uid)->first();
$pwd_verify = password_verify((string)$password, $user['password']);
return $pwd_verify ;
}
}

View File

@ -0,0 +1,130 @@
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Models\AuthenticationModel;
/**
* Class BaseController
*
* BaseController provides a convenient place for loading components
* and performing functions that are needed by all your controllers.
* Extend this class in any new controllers:
* class Home extends BaseController
*
* For security be sure to declare any new methods as protected or private.
*/
abstract class BaseController extends Controller
{
/**
* Instance of the main Request object.
*
* @var CLIRequest|IncomingRequest
*/
protected $request;
/**
* An array of helpers to be loaded automatically upon
* class instantiation. These helpers will be available
* to all other controllers that extend BaseController.
*
* @var array
*/
protected $helpers = [];
/**
* Be sure to declare properties for any property fetch you initialized.
* The creation of dynamic property is deprecated in PHP 8.2.
*/
// protected $session;
public $authData = [];
/**
*
*
* @return void
*/
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);
$uri = $request->getUri();
// Get the path or route from the URI
$requestedRoute = $uri->getPath();
$requestType = get_class($request);
if (php_sapi_name() === 'cli') {
echo "This is a command-line request.";
// echo $requestedRoute;
} else {
if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate') {
$this->authData = $this->session_log();
}
}
}
public function render_page($viewpage, $data){
helper('session');
$session_uid = get_logged_user_id();
$session_uname = get_logged_name();
$mergedData = array_merge($data, $this->authData);
$mergedData['browser_title']= $mergedData['company_name'] . ' | ' . $mergedData['company_short_name'] . ' ' . $mergedData['page_name'];
$mergedData['heading']= $mergedData['page_name'] === "Dashboard" ? 'Welcome to ' . $mergedData['company_name'] : "";
echo view('template/header.php', $mergedData );
echo view('template/topbar.php', $mergedData);
echo view($viewpage, $mergedData);
echo view('template/footer.php', $mergedData);
}
public function session_log()
{
helper('session');
$session_uid = get_logged_user_id();
$session_uname = get_logged_name();
if(!is_session_active()) {
header("Location: " . base_url("login"));
exit();
}
$auth_model = new AuthenticationModel();
$details = $auth_model->getheringDetailsForHeader($session_uid);
$data['company_name'] = $details[0]['site_name'];
$data['company_short_name'] = $details[0]['site_title'];
$data['company_address'] = $details[0]['company_address'];
$data['company_mobile_no'] = $details[0]['company_mobile_no'];
$data['company_email'] = $details[0]['company_email'];
$data['loggedin_person'] = $session_uname;
$data['loggedin_person_id'] = $session_uid;
$data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/uploads/avatar.png");
$data['company_logo_small'] = !empty($details[0]['company_logo_small']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = !empty($details[0]['company_logo_large']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$data['loggedin_person'] = $session_uname;
$session_bid = get_business_id();
$data['bid'] = $session_bid;
$data['footer_about'] = $details[0]['footer_about'];
return $data;
}
}

142
app/Controllers/Books.php Normal file
View File

@ -0,0 +1,142 @@
<?php
namespace App\Controllers;
use App\Models\BooksModel;
class Books extends BaseController
{
## For Book Listing
public function index()
{
helper('session');
if (is_session_active()) {
$session_role = get_user_role();
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['causes.business_id' => $session_bid, 'causes.isactive' => 1];
} else {
$where = ['causes.isactive !=' => NULL];
}
$model = new BooksModel();
$model->setTable('causes');
$data['page_name'] = 'Causes List';
$data['details'] = $model->where('causes.business_id', $session_bid)->where('causes.isactive', 1)->findAll();
// echo '<pre>';
// print_r($data); die;
$this->render_page('book_list', $data);
} else {
// Session is not active or user is not logged in
return redirect()->to('login');
}
}
## To Load Book Form (Add/Update)
public function add_causes($id)
{
helper('session');
$data['session_bid'] = get_business_id();
// Fetch categories from the model
$model = new BooksModel();
if ($id === '0') {
$data['page_name'] = 'Add Causes';
$data['details'] = [];
} elseif ($id !== '0') {
$data['page_name'] = 'Edit Causes';
$data['details'] = $model->where('causes.causes_id', $id)->findAll();
}
$this->render_page('book_form', $data);
}
## For inserting/updating details of book
public function insert_books()
{
try{
helper('session');
$session_uid = get_logged_user_id();
$session_bid = get_business_id();
$BooksModel = new BooksModel();
$data = [
'name' => $this->request->getPost('name'),
'description' => $this->request->getPost('description'),
'business_id'=>$session_bid
];
$causes_id = $this->request->getPost('causes_id'); // Get the book ID for update purpose
if (empty($causes_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$causes_id = $BooksModel->insert($data);
if ($BooksModel->insert($data)) {
session()->setFlashdata('success', 'causes successfully created.');
$this->logger->info("Books: has been added successfully. Inserted ID = " . $BooksModel->insertID());
} else {
session()->setFlashdata('error', 'causes could not be created. Please try again..');
$this->logger->error("Books: Err could not be added. Please try again.");
}
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
$BooksModel->update($causes_id, $data);
if ($BooksModel->update($causes_id, $data)) {
session()->setFlashdata('success', 'causes successfully updated.');
$this->logger->info("Books: has been updated successfully. Updated Book ID = " . $causes_id);
} else {
session()->setFlashdata('error', 'causes updation failed. Please try again.');
$this->logger->error("Books: Err Failed to update ID =" . $causes_id);
}
}
} catch (\Exception $e) {
$this->logger->error("Book: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('causes_list');
}
## For delete the book details (Which means inactive the details)
public function delete_books($id)
{
try {
helper('session');
$session_uid = get_logged_user_id();
// print_r($session_uid);
$BooksModel = new BooksModel();
$data = ['isactive' => 0 , 'updated_by' => $session_uid];
// print_r($data); die;
if ($BooksModel->update($id, $data)) {
session()->setFlashdata('success', 'causes successfully deleted.');
$this->logger->info("BOOK: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("BOOK: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
} catch (\Exception $e) {
$this->logger->error("Book: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('causes_list');
}
}

View File

@ -0,0 +1,138 @@
<?php
namespace App\Controllers;
use App\Models\BusinessModel;
class Business extends BaseController
{
## For Business Listing
public function index()
{
helper('session');
if (is_session_active()) {
$session_role = get_user_role();
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Buiness: Listing In admin role .");
$where = ['business_id' => (int)get_business_id(), 'isactive' => 1];
} else {
$this->logger->info("Buiness: Listing In Super-admin role .");
$where = ['isactive !=' => NULL];
}
$BusinessModel = new BusinessModel();
$data['page_name'] = 'Organization Details';
$data['businesses'] = $BusinessModel->where($where)->findAll();
// $data['lastQuery'] = $BusinessModel->getLastQuery();
// print_r($data);die;
$this->render_page('business_list', $data);
} else {
return redirect()->to('login');
}
}
## To Load Business Form (Add/Update)
public function new_bussiness($id)
{
if ($id === '0') {
$data['page_name'] = 'Add Organization';
$data['businesses'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Organization';
$model = new BusinessModel();
$model->setTable('business');
$edit_user_details = $model->where(['business_id ' => $id])->first();
$data['businesses'] = $edit_user_details;
}
// echo '<pre>';
// print_r($data); die();
$this->render_page('business_form', $data);
}
## For inserting/updating details of business
public function insert_business()
{
helper('session');
$session_uid = get_logged_user_id();
$session_role = get_user_role();
$img = $this->request->getFile('bfile');
$business_id = $this->request->getPost('business_id');
$filePath = 'public/uploads/' . $this->request->getPost('bfile');
$fileName = $img->getName();
if($fileName !== ""){
if ($img->isValid() && !$img->hasMoved()) {
$img->move(ROOTPATH . 'public/uploads', $fileName);
}
}
$BusinessModel = new BusinessModel();
$data = [
'title' => $this->request->getPost('bname'),
'email' => $this->request->getPost('bmail'),
'mobile_no' => $this->request->getPost('bmobile'),
'address' => $this->request->getPost('baddress'),
'city' => $this->request->getPost('bcity'),
'state' => $this->request->getPost('bstate'),
'postal_code' => $this->request->getPost('bzip'),
'pan_no'=>$this->request->getPost('pan_no'),
'org_reg_no'=>$this->request->getPost('org_reg_no'),
'terms'=>$this->request->getPost('bterms'),
'80G'=>$this->request->getPost('80G')
];
if($fileName !== "")
{
$data['business_logo'] = $fileName;
}
$business_id = $this->request->getPost('business_id'); // Get the business ID for update
if (empty($business_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$BusinessModel->insert($data);
} else {
// It's an update operation
if($session_role === 'sadmin'){
$isactive = $this->request->getPost('bcheckbox');
$data['isactive'] = ($isactive == 'on') ? 1 : 0; }
$data['updated_by'] = $session_uid;
$BusinessModel->update($business_id, $data);
}
return redirect()->route('dashboard');
}
## For delete the business details (Which means inactive the details)
public function delete_business($id)
{
helper('session');
$session_uid = get_logged_user_id();
$BusinessModel = new BusinessModel();
// Check if the business ID exists
$existingBusiness = $BusinessModel->find($id);
if (!$existingBusiness) {
return redirect()->route('business_list');
}
// Delete the business record
$data['isactive'] = 0;
$data['updated_by'] = $session_uid;
$BusinessModel->update($id, $data);
//$BusinessModel->delete($id);
return redirect()->route('business_list');
}
}

View File

@ -0,0 +1,538 @@
<?php
namespace App\Controllers;
use App\Models\CustomerModel;
use App\Models\SubscriptionModel;
class Customer extends BaseController
{
## For Customer Listing
public function index()
{
helper('session');
if (is_session_active()) {
$session_role = get_user_role();
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Doner: Listing In admin role . BID = ".$session_bid);
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
} else {
$this->logger->info("Doner: Listing In Super-admin role .");
$where = ['isactive != ' => NULL];
}
$CustomerModel = new CustomerModel();
$data['page_name'] = 'Doner Details';
$data['customer'] = $CustomerModel->where($where)->orderBy('doner_id', 'DESC')->findAll();
// print_r($data); die();
$this->render_page('customer_list', $data);
} else {
return redirect()->to('login');
}
}
## To Load Doner Form (Add/Update)
public function new_doner($id)
{
helper('session');
$session_bid = get_business_id();
if ($id === '0') {
// Add Doner
$data['page_name'] = 'Add Doner Details';
$data['customer'] = [];
} else if ($id !== '0') {
// Edit Doner
$data['page_name'] = 'Edit Doner Details';
// Load your Customer Model
$customerModel = new CustomerModel();
// Retrieve customer details by customer ID
$edit_user_details = $customerModel->where(['doner_id' => $id])->first();
$data['customer'] = $edit_user_details;
}
$data['session_bid'] = $session_bid;
$data['country_details'] = $this->get_country_details();
$data['state_details'] = $this->get_state_details();
// echo '<pre>';
// print_r($data); die;
$this->render_page('customer_form', $data);
}
## For inserting/updating details of customer
public function insert_customer()
{
$requestData = $this->request->getPost();
// print_r($requestData);die;
$this->logger->info("Doner: Inserting/Updating Details");
try {
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$session_role = get_user_role();
$model = new CustomerModel();
$dob = $this->request->getPost('dob');
$dob = (isset($dob) && $dob != "") ? $dob : NULL ;
$data = [
'first_name' => $this->request->getPost('cfname'),
'last_name' => $this->request->getPost('csname'),
'mobile_no' => $this->request->getPost('cmobile'),
'email' => $this->request->getPost('cmail'),
'date_of_birth' => $dob,
'pan_no' => $this->request->getPost('pan_no'),
'doner_type' => $this->request->getPost('donerType'),
'org_name' => $this->request->getPost('org_name') !== '' || $this->request->getPost('org_name') !== null ? $this->request->getPost('org_name') : NULL,
'address' => $this->request->getPost('address'),
'city' => $this->request->getPost('city'),
'state' => $this->request->getPost('state') ? $this->request->getPost('state') : $this->request->getPost('state_text'),
'postal_code' => $this->request->getPost('zip'),
'country' => $this->request->getPost('country'),
'business_id' => $this->request->getPost('business_id'),
];
// print_r($data); die();
$doner_id = $this->request->getPost('doner_id'); // Get the business ID for update
if (empty($doner_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
if ($model->insert($data)) {
session()->setFlashdata('success', 'Doner successfully created.');
$this->logger->info("Doner : has been added successfully. Inserted ID = " . $model->insertID());
$doner_id_for_addresses = $model->insertID();// for Doner ADDRESS Table
} else {
session()->setFlashdata('error', 'Doner could not be added. Please try again..');
$this->logger->error("Doner: Err could not be added. Please try again.");
$doner_id_for_addresses = "";
}
} else {
// It's an update operation
if ($session_role !== 'manager') {
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
}
$data['updated_by'] = $session_uid;
$doner_id_for_addresses = $doner_id; // for Customer ADDRESS Table
if ($model->update($doner_id, $data)) {
session()->setFlashdata('success', 'Doner successfully updated');
$this->logger->info("Doner: has been updated successfully. Updated Doner ID = " . $doner_id_for_addresses);
} else {
session()->setFlashdata('error', 'Doner updation failed. Please try again.');
$this->logger->error("Doner: Err Failed to update ID =" . $doner_id_for_addresses);
}
}
// if($doner_id_for_addresses != ""){
// $this->logger->info("Doner: i got Doner id for addresses = " . $doner_id_for_addresses);
// $requestData = $this->request->getPost();
// $bill_addr = $this->save_customer_addresses($doner_id_for_addresses, $requestData, 'b');
// $this->logger->info("Customer: bill addr final message = " .implode(" ",$bill_addr));
// $ship_addr = $this->save_customer_addresses($doner_id_for_addresses, $requestData, 's');
// $this->logger->info("Doner: Ship addr final message = " . implode(" ",$ship_addr));
// }
} catch (\Exception $e) {
$this->logger->error("Doner : Err Occur =" . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('doner_list');
}
## For Save the customer addresses details (Using Letting Flag and Customer ID)
// public function save_customer_addresses($id, $requestData, $letteringflag)
// {
// try {
// $addressType = ($letteringflag == 'b') ? 1 : 2;
// $this->logger->info("Doner: Addresses Lettering Flag = " . $letteringflag . " Doner address type = " . $addressType);
// $getAddressdetails = $this->get_customer_address($id, $addressType);
// $CAid = $requestData[$letteringflag . 'customer_address_id']; // Available Address IDS in Form Fields.
// $session_uid = get_logged_user_id();
// $model = new CustomerModel();
// ## IF Any Missing value Means that values are Inactive here....
// if(!empty($CAid)){
// $this->logger->info("Doner: Primary Addresses ID = ".implode(",",$CAid));
// $filteringAddressIds = [];
// for ($y = 0; $y < count($getAddressdetails); $y++) {
// $filteringAddressIds[$y] = $getAddressdetails[$y]['customer_address_id'];
// }
// if (!empty($filteringAddressIds)) {
// $A = $filteringAddressIds;
// $B = $CAid;
// $missingValues = array_diff($A, $B);
// if (!empty($missingValues)) {
// $where = ['isactive' => 1, 'doner_id' => (int)$id, 'address_type' => $addressType];
// $model->inactiveMissingAddressDetails($where, $missingValues);
// $this->logger->info("Doner: Inactived Missing Addresses Count = " . count($missingValues)." That Primary Addresses ID = ".implode(",",$CAid));
// }
// }
// }
// $baddress1 = $requestData[$letteringflag . 'address1'];
// $baddress2 = $requestData[$letteringflag . 'address2'];
// $bcountry = $requestData[$letteringflag . 'country'];
// $bcity = $requestData[$letteringflag . 'city'];
// $binputstate = $requestData[$letteringflag . 'istate'];
// $bdropdownstate = $requestData[$letteringflag . 'dstate'];
// $bzip = $requestData[$letteringflag . 'zip'];
// $count = count($CAid);
// $address_array = [];
// if ($count > 0) {
// for ($x = 0; $x < $count; $x++) {
// $address_array[$x]['first_name'] = $requestData['cfname'];
// $address_array[$x]['last_name'] = $requestData['csname'];
// // $address_array[$x]['company'] = "";
// $address_array[$x]['email'] = $requestData['cmail'];
// $address_array[$x]['mobile_no'] = $requestData['cmobile'];
// $address_array[$x]['address_1'] = $baddress1[$x];
// $address_array[$x]['address_2'] = $baddress2[$x];
// $address_array[$x]['city'] = $bcity[$x];
// $address_array[$x]['state'] = $bcountry[$x] === 'IN' ? $bdropdownstate[$x] : $binputstate[$x] ;
// $address_array[$x]['country'] = $bcountry[$x];
// $address_array[$x]['postal_code'] = $bzip[$x];
// $address_array[$x]['doner_id'] = $id;
// $address_array[$x]['address_type'] = $addressType;
// $address_array[$x]['created_by'] = $session_uid;
// $address_array[$x]['updated_by'] = $CAid[$x] ? $session_uid : null;
// $address_array[$x]['customer_address_id'] = $CAid[$x];
// }
// $statement = !empty($address_array) ? $model->saveAddressDetails($address_array) : ["No data found For addresses"];
// $this->logger->info("Doner: Address Final message = " . implode(",",$statement));
// }
// } catch (\Exception $e) {
// $this->logger->error("Doner: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
// $statement = ['Message: ' . $e->getMessage()];
// }
// return $statement;
// }
## For delete the customer details (Which means inactive the details)
public function delete_customer($id)
{
try {
helper('session');
$session_uid = get_logged_user_id();
$CustomerModel = new CustomerModel();
$where = ['doner_id' => (int)$id, 'isactive =' => 1];
// Check if the business ID exists
$existingCustomer = $CustomerModel->where($where)->find($id);
if ($existingCustomer) {
$this->logger->Info("Doner: Going to Inactive ID = ".$id);
$data = ['isactive' => 0 , 'updated_by' => $session_uid];
// Delete the business record
if ($CustomerModel->update($id, $data)) {
$billAddressdetails = $this->get_customer_address($id, 1);
if(!empty($billAddressdetails)){
for ($y = 0; $y < count($billAddressdetails); $y++) {
$billAddressIds[$y] = $billAddressdetails[$y]['customer_address_id'];
}
$CustomerModel->inactiveMissingAddressDetails($where, $billAddressIds);
}
$shipAddressdetails = $this->get_customer_address($id, 2);
if(!empty($shipAddressdetails)){
for ($z = 0; $z < count($shipAddressdetails); $z++) {
$shipAddressIds[$z] = $shipAddressdetails[$z]['customer_address_id'];
}
$CustomerModel->inactiveMissingAddressDetails($where, $shipAddressIds);
}
session()->setFlashdata('success', 'Doner successfully deleted.');
$this->logger->info("Doner: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("Doner: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
}
} catch (\Exception $e) {
$this->logger->error("Customer: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('doner_list');
}
public function get_customer_address($id,$type){
$model = new CustomerModel();
$model->setTable('customer_addresses');
$where = ['isactive' => 1, 'doner_id' => (int)$id,'address_type'=>(int)$type];
$address_details = $model->where($where)->findAll();
return $address_details;
}
public function get_country_details()
{
$model = new CustomerModel();
$model->setTable('countries');
$country_details = $model->orderBy('country_id', 'ASC')->findAll();
return $country_details;
}
public function get_state_details()
{
$model = new CustomerModel();
$model->setTable('states');
$state_details = $model->orderBy('state_id', 'ASC')->findAll();
return $state_details;
}
public function customer_group(){
$data['page_name'] = 'Doner Group Details';
$model = new CustomerModel();
$data['customer_group'] = $model->getGroupDetails();
$this->render_page('customer_group', $data);
}
public function view_customer_group($id){
helper('session');
$session_bid = get_business_id();
$data['field'] = [
['value'=>'','fieldflag'=>1,'text'=> 'Choose the Field','disable' => false],
['value'=>'C.type','fieldflag'=>1,'text'=> 'Type','disable' => false],
['value'=>'CA.city','fieldflag'=>1,'text'=> 'City','disable' => false],
// ['value'=>'CA.state','fieldflag'=>1,'text'=> 'State','disable' => false],
['value'=>'CA.postal_code','fieldflag'=>1,'text'=> 'Postal Code','disable' => false],
['value'=>'C.mode','fieldflag'=>3,'text'=> 'Mode','disable' => false],
['value'=>'CM.name','fieldflag'=>1,'text'=> 'Category','disable' => false],
['value'=>'I.invoice_date','fieldflag'=>2,'text'=> 'Invoice Date','disable' => false],
['value'=>'S.to_subscription','fieldflag'=>2,'text'=> 'Expiry Date','disable' => false]];
$data['operator'] = [
'' => 'Choose the operator',
'equal' => 'Equal to (=)',
'not equal' => 'Not Equal (!=)',
'like' => 'Like (%)',
'greater than' => 'Greater than (>)',
'greater than or equal to' => 'Greater than or Equal to (>=)',
'less than' => 'Less than (<)',
'less than or equal to' => 'Less than or Equal to (<=)',
'contain' => 'Contain (in)',
'not contain' => 'Not Contain (not in)',
'between' => 'Between',
'is null' => 'Is NULL',
'is not null' => 'Is Not NULL',
];
$data['customer_group'] = [];
if ($id === '0') {
// Add Customer
$data['page_name'] = 'Add Doner Group';
} else if ($id !== '0') {
// Edit Customer
$data['page_name'] = 'Edit Doner Group';
// Load your Customer Model
$model = new CustomerModel();
$model->setTable('customer_groups');
$where = ['group_id'=>$id];
$result = $model->where($where)->findAll();
if (!empty($result)) {
$data['customer_group']['groupname'] = $result[0]['group_name'];
$data['customer_group']['column'] = $result[0]['column'] ? unserialize($result[0]['column']) : [];
$data['customer_group']['operator'] = $result[0]['operator'] ? unserialize($result[0]['operator']) : [];
$data['customer_group']['values'] = $result[0]['value'] ? unserialize($result[0]['value']) : [];
$data['customer_group']['group_id'] = $result[0]['group_id'];
$data['customer_group']['isactive'] = $result[0]['isactive'];
}
}
$this->render_page('customer_group_form', $data);
}
public function preview_customer_group($id){
try {
helper('session');
$model = new CustomerModel();
$model->setTable('customer_groups');
$where = ['isactive' => 1,'group_id'=>$id];
$result = $model->where($where)->findAll();
$db = \Config\Database::connect();
$sql = (string)$result[0]['group_query'];
//print_r($sql);die;
if($sql){
$query = $db->query($sql);
$results = $query->getResultArray();
if(empty($results)){
throw new \Exception("Data Not Available");
}else{
return $this->response->setJSON($results);
}
}else{
return $this->response->setJSON([]);
}
} catch (\Exception $e) {
$this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
}
public function delete_customer_group($id){
try {
helper('session');
$session_uid = get_logged_user_id();
$model = new CustomerModel();
$model->setTable('customer_groups');
$where = ['isactive' => 1,'group_id'=>(int)$id];
$result = $model->where($where)->findAll();
if ($result) {
$this->logger->Info("Doner Group: Going to Inactive ID = ".$id);
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'group_id'=>(int)$id];
$statement = $model->saveGroupDetails($data);// just updating Inactive status only.
if ($statement['success']) {
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Doner Group: Err Occur on data the Doner Group Inactive");
}
}
} catch (\Exception $e) {
$this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('customer_group');
}
public function insert_customer_group(){
try {
$this->logger->info("Doner Group: Inserting/Updating Details");
helper('session');
$session_uid = get_logged_user_id();
$request_data = $this->request->getPost();
$string_flag = $request_data['string_flag'];
// $this->logger->info("Customer Group: Request data = ".json_encode($request_data));
$model = new CustomerModel();
// Array ( [groupname] => nil [column] => Array ( [0] => city [1] => state ) [operator] => Array ( [0] => not contain [1] => not equal ) [values] => Array ( [0] => 2 [1] => 3 ) )
$data = [
'group_name' => $request_data['groupname'],
'column' => serialize($request_data['column']),
'operator' => serialize($request_data['operator']),
'value' => serialize($request_data['values'])
];
// Initialize an empty array to store the conditions
$conditions = array();
// Loop through the elements and build the conditions
for ($i = 0; $i < count($request_data['column']); $i++) {
$column = $request_data['column'][$i];
$operator = $request_data['operator'][$i];
$value = $request_data['values'][$i];
// Handle different operators and build corresponding conditions
switch ($operator) {
case 'equal':
$conditionStrings[] = "LOWER($column) = LOWER('$value') ";
break;
case 'not equal':
$conditionStrings[] = "LOWER($column) <> LOWER('$value') ";
break;
case 'like':
$conditionStrings[] = "LOWER($column) LIKE '%$value%'";
break;
case 'contain':
case 'in':
$values = explode(',', $value);
$conditionStrings[] = "LOWER($column) IN ('" . implode("', '", $values) . "')";
break;
case 'not contain':
case 'not in':
$values = explode(',', $value);
$conditionStrings[] = "LOWER($column) NOT IN ('" . implode("', '", $values) . "')";
break;
case 'between':
$dates = explode(',', $value);
$conditionStrings[] = "$column BETWEEN '$dates[0]' AND '$dates[1]'";
break;
case 'greater than':
$conditionStrings[] = "$column > $value";
break;
case 'greater than or equal to':
$conditionStrings[] = "$column >= $value";
break;
case 'less than':
$conditionStrings[] = "$column < $value";
break;
case 'less than or equal to':
$conditionStrings[] = "$column <= $value";
break;
case 'is null':
$conditionStrings[] = "$column IS NULL";
break;
case 'is not null':
$conditionStrings[] = "$column IS NOT NULL";
break;
}
}
// Join the conditions with 'AND'
$whereCondition = implode(' AND ', $conditionStrings);
// echo "*************** whereCondition =>>> ";
// echo $whereCondition;
// If a groupname is specified, include it in the condition
// if ($conditionsArray['groupname'] !== 'nil') {
// $whereCondition = "($whereCondition) AND groupname = '{$conditionsArray['groupname']}'";
// }
// Now you can use $whereCondition in your SQL query
$db = \Config\Database::connect();
// $sql = "SELECT doner_id,CONCAT(first_name,'',last_name) as customer_name,email,mobile_no FROM customers WHERE ".$whereCondition;
$sql = "SELECT CA.city,CA.state,I.invoice_date,C.doner_id,CONCAT(C.first_name,'',C.last_name) as customer_name,C.email,C.mobile_no ,S.to_subscription as due_date, C.isactive ,count(I.invoice_id) as invoice_count_raised_by_customer, S.scheme_id , CM.name
FROM customers as C
LEFT JOIN invoice I on I.doner_id = C.doner_id and I.isactive = 1
LEFT JOIN customer_addresses CA on CA.doner_id = C.doner_id and CA.address_type = 1 and CA.isactive = 1
LEFT JOIN subscription S on S.doner_id = C.doner_id
LEFT JOIN book_categories BC on BC.book_id = S.scheme_id
LEFT JOIN category CM on CM.id = BC.category_id
WHERE C.isactive = 1 AND ".$whereCondition." GROUP BY C.doner_id";
$this->logger->info("Customer Group: SQL = ".$sql);
// Execute the query
$query = $db->query($sql);
// Get the result
$results = $query->getResult();
$this->logger->info("Customer Group: ".json_encode($results));
$group_id = $request_data['group_id']; // Get the ID for update
$isactive = $group_id != "" ? $request_data['isactive'] : 'on';
if($string_flag == "save"){
$data['group_query'] = $sql;
$data['group_id'] = $group_id;
$data['isactive'] = (($isactive == 'on') ? 1 : 0);
$data['created_by'] = $session_uid;
$data['updated_by'] = $session_uid;
$statement = $model->saveGroupDetails($data);
if ($statement['success']) {
session()->setFlashdata('success', $statement['success']);
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Doner Group: Err Occur on data the Save");
}
}else if($string_flag == "preview"){
return $this->response->setJSON($results);
}else{
throw new \Exception("Data Not Found");
}
} catch (\Exception $e) {
$this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('customer_group');
}
}

189
app/Controllers/Event.php Normal file
View File

@ -0,0 +1,189 @@
<?php
namespace App\Controllers;
use App\Models\EventModel;
class Event extends BaseController
{
public function index()
{
helper('session');
if (is_session_active()) {
$session_role = get_user_role();
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['campaign.business_id' => (int)$session_bid];
} else {
$where = ['campaign.business_id != ' => NULL];
}
$EventModel = new EventModel();
$data['page_name'] = 'Campaign Details';
$campaigns = $EventModel->where($where)->orderBy('campaign_id', 'DESC')->findAll(); // Retrieve the campaigns
// Sort the campaigns by ID in descending order (newest first)
// usort($campaigns, function ($a, $b) {
// return $b['id'] - $a['id'];
// });
$data['campaign'] = $campaigns; // Assign the sorted array to $data['campaign']
$data['session_bid'] = $session_bid;
// echo '<pre>';
// print_r($data); die;
$this->render_page('event_list', $data);
} else {
return redirect()->to('login');
}
}
public function new_campaign($id)
{
helper('session');
$session_bid = get_business_id();
if ($id === '0') {
$data['page_name'] = 'Add Campaign';
$data['campaign'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Campaign';
$model = new EventModel();
$model->setTable('campaign');
$edit_campaign_details = $model->where(['campaign_id' => $id])->first();
$data['campaign'] = $edit_campaign_details;
}
$data['session_bid'] = $session_bid;
$this->render_page('event_form', $data);
}
public function insert_event()
{
$this->logger->info("Event: Inserting/Updating Details");
try {
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$EventModel = new EventModel();
$inputdate1 = date("Y-m-d", strtotime($this->request->getVar('start_date')));
$inputdate2 = date("Y-m-d", strtotime($this->request->getVar('end_date')));
$data = [
'name' => $this->request->getPost('name'),
'description' => $this->request->getPost('description'),
'start_date' =>$inputdate1,
'end_date' =>$inputdate2 ,
'business_id' => $this->request->getPost('business_id')
];
$campaign_id = $this->request->getPost('campaign_id'); // Get the business ID for update
if (empty($campaign_id)) {
// It's an insert operation
$data['created_by'] = $session_uid;
// echo '<pre>';
// print_r($data);
// $value = $EventModel->insert($data);
// $builder = $EventModel;
// // Get the last run query
// $lastQuery = $builder->getLastQuery();
// // Output or log the last query
// echo $lastQuery; die;
if ($EventModel->insert($data)) {
session()->setFlashdata('success', 'Event has been added successfully.');
$this->logger->info("Event : has been added successfully. Inserted ID = " . $EventModel->insertID());
} else {
session()->setFlashdata('error', 'Event could not be added. Please try again..');
$this->logger->error("Event: Err data could not be added. Please try again.");
}
} else {
// It's an update operation
$data['updated_by'] = $session_uid;
if ($EventModel->update($campaign_id, $data)) {
session()->setFlashdata('success', 'Event has been updated successfully.');
$this->logger->info("Event: has been updated successfully. Updated Event ID = " . $campaign_id);
} else {
session()->setFlashdata('error', 'Event update failed. Please try again.');
$this->logger->error("Event: Err Failed to update ID =" . $campaign_id);
}
}
} catch (\Exception $e) {
$this->logger->error("Event: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('campaign');
}
public function invoice_number_format($id)
{
helper('session');
$session_bid = get_business_id();
$data['page_name'] = 'Edit invoice number formatting';
$model = new EventModel();
$edit_campaign_details = $model->setTable('invoice_number_formatting')->where(['id' => (int)$id,'business_id'=>$session_bid])->first();
$data['campaign'] = $edit_campaign_details;
$data['session_bid'] = $session_bid;
$this->render_page('invoice_number_formatting', $data);
}
public function insert_invoice_number_format()
{
$this->logger->info("insert_invoice_number_format: Inserting/Updating Details");
try {
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$EventModel = new EventModel();
$data = [
'next_id' => $this->request->getPost('nextid'),
'left_pad' => $this->request->getPost('leftpad'),
'id_formating' => $this->request->getPost('formating'),
'business_id' => $this->request->getPost('business_id')
];
$pk_id = $this->request->getPost('id'); // Get the business ID for update
if (empty($pk_id)) {
// It's an insert operation
$data['created_by'] = $session_uid;
// $EventModel->insert($data);
$insert_result = $EventModel->insertData('invoice_number_formatting', $data);
if ($insert_result['info']) {
session()->setFlashdata('success', "updated Successfully");
$this->logger->info($insert_result['info']);
} else {
session()->setFlashdata('error', $insert_result['err']);
$this->logger->error($insert_result['err']);
}
} else {
// It's an update operation
$data['updated_by'] = $session_uid;
$where = ['id' => $pk_id, 'business_id' => get_business_id()];
$update_result = $EventModel->updateData('invoice_number_formatting', $data,$where);
if ($update_result['info']) {
session()->setFlashdata('success',"updated Successfully");
$this->logger->info($update_result['info']);
} else {
session()->setFlashdata('error', $update_result['err']);
$this->logger->error($update_result['err']);
}
}
} catch (\Exception $e) {
$this->logger->error("Event: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->to(base_url("invoice_number_format/1"));
}
}

40
app/Controllers/Home.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace App\Controllers;
use App\Models\HomeModel;
## Home Controllers only for Dashboards,Report Modules
class Home extends BaseController
{
public function index()
{
// echo "hwllo"
helper('session');
$session_role = get_user_role();
$session_bid = get_business_id();
$data['page_name'] = 'Dashboard';
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
} else if (!empty($session_role) && $session_role !== "admin") {
$where = ['isactive != ' => NULL];
} else {
$where = [];
}
$model = new HomeModel();
$data['customer'] = $model->customers($where);
$data['customer']['label'] = "Doners";
// echo '<pre>';
// print_r($data); die;
// $data['invoice'] = $model->invoice();
// $data['active_category'] = array_filter($model->schemes(), function ($element) {
// return $element['count'] !== '0' ;
// });
// $data['book_published'] = $model->book_published_list();
$this->render_page('dashboard', $data);
}
}

624
app/Controllers/Invoice.php Normal file
View File

@ -0,0 +1,624 @@
<?php
namespace App\Controllers;
use App\Models\EventModel;
use App\Models\CustomerModel;
use App\Models\InvoiceModel;
use App\Helpers\NotificationHelper;
use Mpdf\Mpdf;
class Invoice extends BaseController
{
## For Invoice Listing..
public function index()
{
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['doners'] = $model->getData('customers', $where);
$data['page_name'] = 'Receipt Details';
$data['receipt'] = $model->where(["business_id"=>$session_bid])->findAll();
// echo '<pre>';
// print_r($data); die;
$this->logger->info("Invoice: Listing Count ." . count($data['receipt']));
$this->render_page('invoice_list', $data);
} else {
return redirect()->to('login');
}
}
## To Load Invoice ADD/EDIT page...
public function new_receipt($id = '0')
{
helper('session');
$model = new InvoiceModel();
$where = ['business_id' => (int)get_business_id()];
// Get customer names for the dropdown, events details, and books details
$data['customers'] = $model->getData('customers', $where);
$data['causes'] = $model->getData('causes', $where);
if ($id === '0') {
$this->logger->info("Receipt: In Add Details");
$data['page_name'] = 'Add Receipt Details';
$data['receipt_details'] = [];
} 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();
}
// echo '<pre>';
// print_r($data);die;
$this->render_page('invoice_form', $data);
}
## For Ajax Call To Fetch/Retrive All Address Details Based On Customer...
public function load_details1()
{
$id = $this->request->getPost('selectedValue');
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$id];
$where['address_type'] = 1;
$data['customer_billing'] = $this->get_customer_address($where, []);
$select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"];
$where['address_type'] = 2;
$data['customer_shipping'] = $this->get_customer_address($where, $select);
$data['customer_membership'] = $this->get_customer_membership("membership",(int)$id);
return $this->response->setJSON(['data' => $data]);
}
## For Ajax Call To Fetch/Retrive Shipping Address Details Only Based On Customer...
public function load_details2()
{
$customer_id = $this->request->getPost('customerValue');
$address_id = $this->request->getPost('selectedValue');
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
$data['customer_shipping'] = $this->get_customer_address($where, []);
return $this->response->setJSON(['data' => $data]);
}
// public function generate_serial_no(){}
## For Gethering Address Details...
public function get_customer_address($where, $select)
{
$model = new CustomerModel();
$model->setTable('customer_addresses');
if (empty($select)) {
$select = ["customer_addresses.customer_id","customer_addresses.customer_address_id","customer_addresses.first_name","customer_addresses.last_name ","customer_addresses.company","customer_addresses.email","customer_addresses.mobile_no","customer_addresses.address_type","customer_addresses.address_1","customer_addresses.address_2","customer_addresses.city","customer_addresses.state","customer_addresses.postal_code","customer_addresses.country","states.state_name","countries.country_name"];
}
$address_details = $model->select($select)->join('states', 'states.state_short_name = customer_addresses.state AND customer_addresses.country = "IN"', 'left')->join('countries', 'countries.country_short_name = customer_addresses.country', 'left')->where($where)->findAll();
return $address_details;
}
public function get_customer_membership($category,$id){
$model = new InvoiceModel();
$result = $model->getMembershipListForCustomer($category,$id);
return $result;
}
## To insert or update the details of the invoice
public function save_invoice()
{
$this->logger->info("Invoice: Insert/Update Details");
try {
## Declarions
helper('session');
$model = new InvoiceModel();
$receipt_date = $this->request->getVar('receipt_date');
$receipt_id = (!empty($this->request->getPost('receipt_id'))) ? $this->request->getPost('receipt_id') : "";
$customer_id = (int)$this->request->getPost('doner_id');
$data = [
'receipt_number' => $this->request->getPost('receipt_number'),
'doner_id' => $customer_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'),
'payment_mode' => $this->request->getPost('payment_mode'),
'payment_ref_no' => $this->request->getPost('payment_ref_no'),
'causes_id' => (int)$this->request->getPost('causes_id'),
'business_id' => (int)get_business_id(),
'isactive' => 1
];
## Based on the invoice ID, we designated Insert or Update on Details...
if (empty($receipt_id)) {
$data['created_by'] = (int)get_logged_user_id();
if ($model->insert($data, 'invoices')) {
$receipt_id = $model->insertID();
session()->setFlashdata('success', 'Receipt has been added successfully.');
$this->logger->info("Receipt: has been added successfully. Inserted ID = " . $receipt_id);
} else {
session()->setFlashdata('error', 'Receipt could not be added. Please try again.');
$this->logger->error("Receipt: Err Occur could not be added. Please try again.");
}
} else {
$data['updated_by'] = (int)get_logged_user_id();
if ($model->update($receipt_id, $data)) {
session()->setFlashdata('success', 'Receipt has been updated successfully.');
$this->logger->info("Receipt: has been updated successfully. Updated ID = " . $receipt_id);
} else {
session()->setFlashdata('error', 'Receipt update failed. Please try again.');
$this->logger->error("Receipt: Err Failed to update ID =" . $receipt_id);
}
}
} catch (\Exception $e) {
$this->logger->error("Receipt: Err Occur =" . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('receipt_list');
}
## For Updating Events Details ..
public function update_number_formatting($update_events)
{
// `id``event_name``business_id``updated_by``updated_on``next_id`
$model = new InvoiceModel();
$model->setTable('invoice_number_formatting');
$where = ['isactive' => 1, 'id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id'], 'next_id' => $update_events['next_id']];
$details = $model->where($where)->findAll();
if (empty($details)) {
$update_where = ['id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id']];
$update_data = ['next_id' => $update_events['next_id'], 'updated_by' => $update_events['updated_by']];
$model->updateData('invoice_number_formatting', $update_data, $update_where);
}
}
## To insert or update invoice item details based on invoice ID
public function save_invoice_item($id, $requestData)
{
## Get Invoice item details (to checking purpose exist or not based on invoice ID)
$getInvoiceItemDetails = $this->get_invoice_item($id);
## Declaration
$statement = "";
$model = new InvoiceModel();
$itemid = $requestData['invoice_child_id'];
## IF Any Missing value Means that values are Inactive here....
if (!empty($itemid)) {
$filteringInvoiceItemIds = [];
for ($y = 0; $y < count($getInvoiceItemDetails); $y++) {
$filteringInvoiceItemIds[$y] = $getInvoiceItemDetails[$y]['invoice_child_id'];
}
if (!empty($filteringInvoiceItemIds)) {
$A = $filteringInvoiceItemIds;
$B = $itemid;
$missingValues = array_diff($A, $B);
if (!empty($missingValues)) {
$where = ['isactive' => 1, 'receipt_id' => (int)$id];
$model->inactiveMissingInvoiceItemDetails($where, $missingValues);
}
}
}
// echo "<br/>....................";
$count = count($itemid);
$invoiceitem_arr = [];
if ($count > 0) {
for ($x = 0; $x < $count; $x++) {
if(!empty($requestData['item_details'][$x])){
$invoiceitem_arr[$x]['receipt_id'] = $id;
$invoiceitem_arr[$x]['product'] = (int)$requestData['item_details'][$x];
$invoiceitem_arr[$x]['quantity'] = (int)$requestData['quantity'][$x];
$invoiceitem_arr[$x]['tax'] = (int)$requestData['tax'][$x];
$invoiceitem_arr[$x]['unit_price'] = (int)$requestData['rate'][$x];
$invoiceitem_arr[$x]['subtotal'] = (int)$requestData['amount'][$x];
$invoiceitem_arr[$x]['discount_amount'] = (int)$requestData['discount_amount'][$x];
$invoiceitem_arr[$x]['discount_type'] =$requestData['discount_type'][$x];
if (!empty($requestData['from_subscription'])) {
$invoiceitem_arr[0]['from_subscription'] = $requestData['from_subscription'];
}
if (!empty($requestData['to_subscription'])) {
$invoiceitem_arr[0]['to_subscription'] = $requestData['to_subscription'];
}
$invoiceitem_arr[$x]['created_by'] = (int)get_logged_user_id();
$invoiceitem_arr[$x]['updated_by'] = (int)get_logged_user_id();
$invoiceitem_arr[$x]['isactive'] = 1;
$invoiceitem_arr[$x]['invoice_child_id'] = $itemid[$x];
}
}
$statement = $model->saveInvoiceItemDetails($invoiceitem_arr);
}
return $statement;
}
## To Retrive Invoice item details based on invoice ID
public function get_invoice_item($id)
{
$model = new InvoiceModel();
$model->setTable('invoiceitems');
$where = ['isactive' => 1, 'receipt_id' => (int)$id];
$details = $model->where($where)->findAll();
return $details;
}
## To Inactive Invoice details based on invoice ID Including Invoice Item Details also
public function delete_invoice($id)
{
helper('session');
$session_uid = get_logged_user_id();
try {
$model = new InvoiceModel();
$where = ['isactive' => 1, 'business_id' => (int)get_business_id(), 'receipt_id' => (int)$id];
$existed = $model->where($where)->findAll();
$this->logger->Info("Invoice : Going to Inactive ID = " . $id);
if ($existed) {
$data['isactive'] = 0;
$data['updated_by'] = get_logged_user_id();
if ($model->update($id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Invoice: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("Invoice: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
$getInvoiceItemDetails = $this->get_invoice_item($id);
if ($getInvoiceItemDetails) {
$update_where = ['receipt_id' => (int)$id];
$model->updateData('invoiceitems', $data, $update_where);
}
} else {
$this->logger->error("Invoice: Does Not Exist To Inactive, ID = " . $id);
throw new \Exception("Invoice Already Deleted");
}
} catch (\Exception $e) {
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('receipt_list');
}
## To Approve Invoice details based on invoice ID
public function approve_invoice($id)
{
try {
if (!$id) {
throw new \Exception("Invoice can't able to Approved. Because ID can't Found");
}
$model = new InvoiceModel();
helper('session');
$where = ['isactive' => 1, 'status' => 'Approved', 'receipt_id' => (int)$id];
$details = $model->where($where)->findAll();
if (empty($details)) { // Array Empty Means allow to Approve.
$data = ['status' => 'Approved', 'updated_by' => get_logged_user_id()];
if ($model->update($id, $data)) {
$this->approve_notifications((int)$id);
session()->setFlashdata('success', 'Invoice has been Approved Successfully.');
$this->logger->info("Invoice: has been Approved successfully. ID = " . $id);
} else {
$this->logger->error("Invoice: Does Not Exist To Approved");
throw new \Exception("Invoice can't Approved");
}
} else {
$this->logger->error("Invoice: already Approved ID = " . $id);
throw new \Exception("Invoice already Approved");
}
} catch (\Exception $e) {
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
// Redirect back to the invoice list
return redirect()->route('receipt_list');
}
public function approve_notifications($receipt_id)
{
$model = new InvoiceModel();
$where = ['I.business_id' => (int)get_business_id(), 'I.receipt_id' => $receipt_id, 'I.isactive' => 1];
$details = $model->getDetailForApproveNotifications($where);
$records = [];
$reference_number = "";
$invoice_serial_number = "";
$recipient_name = "";
$approval_date = "";
$approved_by = "";
$recipient_email = "";
$recipient_mobile = "";
$subtotal = "";
$tax = "";
$total_amount = "";
$payment_method = "";
$business_name= "";
$business_address= "";
$business_city= "";
$business_state= "";
$business_postal_code= "";
$business_email= "";
$business_mobile_no= "";
if (isset($details)) {
$this->logger->info("Invoice: approve notification Request data type = ".gettype($details));
}
helper('notification');
$notification = new NotificationHelper();
foreach ($details['invoice'] as $rec) {
$reference_number = $rec['order_number'];
$invoice_serial_number = $rec['invoice_number'];
$recipient_name = $rec['customer_name'];
$approval_date = $rec['updated_on'];
$approved_by = $rec['updated_by_name'];
$recipient_email = $rec['customer_email'];
$recipient_mobile = $rec['customer_mobile'];
$subtotal = $rec['subtotal'];
$tax = $rec['tax'];
$total_amount = $rec['total_amount'];
$payment_method = $rec['payment_method'];
$business_name= $rec['business_name'];
$business_address= $rec['business_address'];
$business_city= $rec['business_city'];
$business_state= $rec['business_state'];
$business_postal_code= $rec['business_postal_code'];
$business_email= $rec['business_email'];
$business_mobile_no= $rec['business_mobile_no'];
}
$records['invoice_order_number'] = $reference_number;
$records['invoice_serial_number'] = $invoice_serial_number;
$records['recipient_name'] = $recipient_name;
$records['recipient_email'] = $recipient_email ? $recipient_email : "sanjeev.p@venbainfotech.com";
$records['subtotal'] = $subtotal;
$records['tax'] = $tax;
$records['total_amount'] = $total_amount;
$records['payment_method'] = $payment_method;
$records['favicon'] = base_url("public/uploads/default.ico");
$records['browser_title'] = "bbb-bp | Approve Template";
$records['page_name'] = 'Approve Template';
// view('approve_template',$records);
// $this->logger->info("Approve : Request data = ".json_encode($records));
// view('approve_template',$records);
$records['template_name'] = 'approve_template';
$records['item'] = $details['item'];
$records['subject'] = $invoice_serial_number . " - Approval Notification";
$records['description'] = "<html><head><title>VBP Approve Information</title></head><body>
<p>Dear $recipient_name,</p>
<p> &ensp;&ensp; We are pleased to inform you that your Invoice has been approved.</p>
<p><strong>Details:</strong></p>
<ul><li>Approval Date:" . $approval_date . "</li>
<li>Approved By:" . $approved_by . "</li>
<li>Reference ID:" . $reference_number . "</li>
</ul><br>
<p>Best regards,</p>
<ul style='list-style: none;'>
<li>".$business_name.",</li>
<li>".$business_address." ".$business_city." ".$business_state." - ".$business_postal_code."</li>
<li>Call Us: +91 ".$business_mobile_no."</li>
<li>Email Us: ".$business_email."</li></body></html>";
$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;
$params = (object) Null;
$params->number = (int)'91' . $recipient_mobile;
$params->type = "text";
$params->message = $template;
$params->instance_id = WAAI_INSTANCE;
$params->access_token = WAAI_TOKEN;
$this->logger->info("receipt: approve notification Email Request data = ".json_encode($records));
$email_result = $notification->sendEmail($records);
$this->logger->info("receipt: approve notification Email Response = " . json_encode($email_result));
$this->logger->info("receipt: approve notification Whatsapp Request data = ".json_encode($params));
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
$this->logger->info("receipt: approve notification Whatsapp Response = " . json_encode($whatsapp_result));
}
## To Generate receipt PDF based on receipt ID
public function generate_invoice_pdf($id)
{
// Fetch the receipt data based on $receipt_id
$model = new InvoiceModel();
$data = $model->getInvoiceData($id);
// Create an mPDF object
$mpdf = new Mpdf();
$mpdf->autoLangToFont = true;
$mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Receipt');
$mpdf->SetAuthor('ORG');
$mpdf->SetCreator('');
// Set the page size to letter
// Add a page with letter size (8.5 x 11 inches)
$mpdf->AddPage('L', 'LETTER');
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', ['data' => $data]);
// echo $html; die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
// Output the PDF to the browser for download
$mpdf->Output('Receipt' . date('Y-m-d H-i-s') . '.pdf', 'D');
}
public function print_address($id)
{
// Fetch the invoice data based on $id
$model = new InvoiceModel();
$invoiceData = $model->getInvoiceData($id);
// print_r($invoiceData);die();
// Initialize an empty PDF with custom paper size (4x6 inches)
$config = [
'mode' => 'utf-8',
'format' => [101.6, 152.4],
'default_font_size' => 12,
'default_font' => 'Arial',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P', // Portrait
];
$mpdf = new Mpdf($config);
$mpdf->SetTitle('Doner Address');
$mpdf->SetAuthor('Venba');
$mpdf->SetCreator('');
// Generate the PDF content (HTML) with customer and address data
$html = view('address_pdf_template', ['invoiceData' => $invoiceData]);
// Load the mPDF library
// Set PDF properties
// Load HTML content into mPDF
$mpdf->WriteHTML($html);
// Output the PDF for download
$pdfFileName = 'customer_address_' . date('Y-m-d H-i-s') . '.pdf';
$mpdf->Output($pdfFileName, 'D');
}
public function general_inv_rp()
{
if($this->request->getmethod() == 'get')
{
$model = new InvoiceModel();
$data['report_data'] = $model->get_general_invoice_data();
$this->logger->info("Invoice Report ");
$data['page_name'] = 'General Invoice Report';
$this->render_page('report_general_invoice', $data);
}
else
{
$dateParts = explode(' - ', $this->request->getVar('date') );
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
$dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
$model = new InvoiceModel();
$data['report_data'] = $model->get_general_invoice_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
$this->logger->info("Invoice Report ");
$data['page_name'] = 'General Invoice Report';
$data['selected_data'] = $this->request->getVar('date');
$this->render_page('report_general_invoice', $data);
}
}
public function general_membership_inv_rp()
{
if($this->request->getmethod() == 'get')
{
$model = new InvoiceModel();
$data['report_data'] = $model->get_mem_invoice_data();
$this->logger->info("Membership Invoice Report ");
$data['page_name'] = 'Membership Invoice Report';
$this->render_page('report_mem_invoice', $data);
}
else
{
$dateParts = explode(' - ', $this->request->getVar('date') );
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
$dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
$model = new InvoiceModel();
$data['report_data'] = $model->get_mem_invoice_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
$this->logger->info("Membership Invoice Report ");
$data['page_name'] = 'Membership Invoice Report';
$data['selected_data'] = $this->request->getVar('date');
$this->render_page('report_mem_invoice', $data);
}
}
public function itemwise_report()
{
if($this->request->getmethod() == 'get')
{
$model = new InvoiceModel();
$data['report_data'] = $model->itemwise_report_data();
$this->logger->info("Itemwise Report ");
$data['page_name'] = 'Itemwise Report';
$this->render_page('report_itemwise', $data);
}
else
{
$dateParts = explode(' - ', $this->request->getVar('date') );
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
$dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
$model = new InvoiceModel();
$data['report_data'] = $model->itemwise_report_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
$this->logger->info("Itemwise Report ");
$data['page_name'] = 'Itemwise Report';
$data['selected_data'] = $this->request->getVar('date');
$this->render_page('report_itemwise', $data);
}
}
}
// public function generate_invoice_pdf($id)
// {
// // Load the mPDF library
// $mpdf = new \Mpdf\Mpdf();
// // Fetch invoice data
// $invoice = $this->find($id);
// if ($invoice) {
// // Fetch related invoice items
// $invoiceItems = $this->getInvoiceItems($id);
// // Create the HTML content for the PDF
// $html = view('pdf/invoice_template', ['invoice' => $invoice, 'invoiceItems' => $invoiceItems]);
// // Load HTML content into mPDF
// $mpdf->WriteHTML($html);
// // Set PDF filename
// $pdfFileName = 'invoice_' . $invoice->invoice_number . '.pdf';
// // Output the PDF for download
// $mpdf->Output($pdfFileName, 'D');
// }
// }
// public function getInvoiceItems($invoiceId)
// {
// // Fetch invoice items related to the given invoice ID
// return $this->db->table('invoice_items')->where('receipt_id', $invoiceId)->get()->getResult();
// }

View File

@ -0,0 +1,439 @@
<?php
namespace App\Controllers;
use App\Helpers\NotificationHelper;
use App\Models\NotificationModel;
class Notifications extends BaseController
{
## Email Section :
public function mail_custom_notifications()
{
$request = \Config\Services::request();
if ($request->is('post')) {
$records = $request->getVar();
$records['template_name'] = "";
helper('notification');
$notification = new NotificationHelper();
$data = $notification->sendEmail($records);
if (isset($data['error'])) {
session()->setFlashdata('error', 'Message: ' . $data['error']);
}
if (isset($data['success'])) {
session()->setFlashdata('success', 'Message: ' . $data['success']);
}
}
$data['page_name'] = 'Custom Notifications';
$this->render_page('notifications_form', $data);
}
public function whatsapp_custom_notifications()
{
$request = \Config\Services::request();
if ($request->is('post')) {
$records = $request->getVar();
$params = (object) Null;
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] ." - ". $_ENV['WAAI_TOKEN']);
try {
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
if($records['group_id'] != ""){ $params->group_id = $records['group_id']; }
else{ throw new \Exception("Group Id Missing Please Try again.."); }
}else if ($records['categories'] == 'SEND_WAAI_URL') {
if($records['mobile'] != ""){ $params->number = (int)'91' . $records['mobile']; }
else{ throw new \Exception("Mobile Number Missing Please Try again.."); }
}else{
throw new \Exception("Please Choose your Category");
}
if ($records['type'] == 'media') {
if($records['media_url'] != ""){ $params->media_url = $records['media_url']; }
else{ throw new \Exception("Media Url Missing Please Try again.."); }
}
$url = constant($records['categories']);
$params->type = $records['type'] == "" ? "text" : $records['type'];
$params->instance_id = $_ENV['WAAI_INSTANCE'];
$params->access_token = $_ENV['WAAI_TOKEN'];
$params->message = $records['description'];
$this->logger->info("Whatsapp : sending message request = " . json_encode($params));
$this->logger->info("Whatsapp : sending message request type b4 = " . gettype($params));
helper('notification');
$notification = new NotificationHelper();
$success = $notification->sendWhatsAppMessage($url, "POST", $params);
session()->setFlashdata('success', 'Message : ' . $success);
$this->logger->info("Whatsapp : Reponse = " . $success);
} catch (\Exception $e) {
$this->logger->error("Whatsapp : Exception Message = " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
}
$data['page_name'] = 'Custom Notifications';
$this->render_page('notifications_form', $data);
}
public function due_date_notifications()
{
$date = $this->request->getGet('date');
$model = new NotificationModel();
$details = $model->getSubscriptionDueDetail($date);
// echo "<pre>";
// print_r($details);
// echo "</pre>";
// die;
$records = [];
$recipient_name = "";
$recipient_email = "";
$recipient_mobile = "";
$subscription_name = "";
$business_name= "";
$to_subscription= "";
if (isset($details)) {
$this->logger->info("Notification : Duedate notification Request data type = ".gettype($details));
}
helper('notification');
$notification = new NotificationHelper();
foreach ($details as $rec) {
$recipient_name = $rec['customer_name'];
$recipient_email = $rec['customer_email'];
$recipient_mobile = $rec['customer_mobile'];
// $recipient_email = "sanjeev.p@venbainfotech.com";
// $recipient_mobile = 6369084112;
$business_name= $rec['business_name'];
$subscription_name = $rec['title'];
$to_subscription= $rec['to_subscription'];
}
$records['template_name'] = '';
$records['recipient_name'] = $recipient_name;
$records['recipient_email'] = $recipient_email ? $recipient_email : "sanjeev.p@venbainfotech.com";
$records['subject'] = $business_name ." - Due Date Reminder";
$records['description'] = "<!DOCTYPE html>
<html>
<head><title>Due Date Reminder</title></head>
<body>
<p>Hello ".$recipient_name.",</p>
<p>This is a reminder that the following subscription is due soon:</p>
<p><strong>Subscription Name:</strong>".$subscription_name." </p>
<p><strong>Due Date:</strong> ".$to_subscription."</p>
<p>Please make sure to complete this subscription on time.</p>
<p>Thank you.</p>
</body>
</html>";
$template = "Hello " . $recipient_name . ",\r\r\n\nThis is a reminder that the following subscription is due soon:\r\n- Subscription Name: " . $subscription_name . "\r\n Due Date: " . $to_subscription . "\r\n\nPlease make sure to complete this subscription on time.\n Thank you.";
$params = (object) Null;
$params->number = (int)'91' . $recipient_mobile;
$params->type = "text";
$params->message = $template;
$params->instance_id = $_ENV['WAAI_INSTANCE'];
$params->access_token = $_ENV['WAAI_TOKEN'];
$this->logger->info("Notification : Duedate notification Email Request data = ".json_encode($records));
$email_result = $notification->sendEmail($records);
$this->logger->info("Notification : Duedate notification Email Response = " . json_encode($email_result));
$this->logger->info("Notification : Duedate notification Whatsapp Request data = ".json_encode($params));
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
$this->logger->info("Notification : Duedate notification Whatsapp Response = " . json_encode($whatsapp_result));
}
public function template_creation(){
$data['page_name'] = 'Template Details';
$model = new NotificationModel();
$data['template'] = $model->getTemplateDetails();
$this->render_page('template_creation', $data);
// echo "templates";die;
}
public function template_creation_form($id){
$data['group_details'] = $this->get_group_details();
$model = new NotificationModel();
if ($id === '0') {
$this->logger->info("Template Creation: In Add Page");
$data['page_name'] = 'Add Template';
$data['template_details'] = [];
} elseif ($id !== '0') {
$this->logger->info("Template Creation: In Edit Page ID =" . $id);
$data['page_name'] = 'Edit Template';
$model->setTable('templates');
$where = ['template_id'=>(int)$id];
$result = $model->where($where)->findAll();
$data['template_details'] = !empty($result[0]) ? $result[0] : [];
}
// print_r($data['template_details']);die();
$this->render_page('template_creation_form', $data);
}
public function template_creation_delete($id){
try {
helper('session');
$session_uid = get_logged_user_id();
$model = new NotificationModel();
$model->setTable('templates');
$where = ['template_id'=>(int)$id];
$result = $model->where($where)->findAll();
if ($result) {
$this->logger->Info("Template: Going to Inactive ID = ".$id);
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'template_id'=>(int)$id];
$statement = $model->saveDetails($data,'template_id','templates');// just updating Inactive status only.
if ($statement['success']) {
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Template: Err Occur on data the Template Inactive");
}
}
} catch (\Exception $e) {
$this->logger->error("Template: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('template_creation');
}
public function get_group_details()
{
$model = new NotificationModel();
$model->setTable('customer_groups');
// $details = $model->where('isactive',1)->orderBy('group_id', 'ASC')->findAll();
$where = ['isactive' => 1, 'group_name != ' => 'EXPIRYDATE'];
$details = $model->where($where)->orderBy('group_id', 'ASC')->findAll();
return $details;
}
public function get_template_details(){
$model = new NotificationModel();
$model->setTable('templates');
$details = $model->where('isactive',1)->orderBy('template_id', 'ASC')->findAll();
return $details;
}
public function template_creation_insert(){
$this->logger->info("Template: Inserting/Updating Details");
try {
## Declarions
helper('session');
$model = new NotificationModel();
$session_uid = get_logged_user_id();
$id = $this->request->getPost('template_id');
$subject = $this->request->getPost('subject') ? $this->request->getPost('subject') : NULL;
$isactive = $id != "" ? $this->request->getPost('isactive') : 'on';
$data = [
'template_id' => $id,
'template_name' => $this->request->getPost('templatename'),
'subject' => $subject,
'message' => $this->request->getPost('templatemessage'),
'mode' => $this->request->getPost('mode'),
'isactive' => (($isactive == 'on') ? 1 : 0),
'created_by' => $session_uid,
'updated_by' => $session_uid
];
$statement = $model->saveDetails($data,'template_id','templates');
if ($statement['success']) {
session()->setFlashdata('success', $statement['success']);
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Template: Err Occur");
}
}catch(\Exception $e) {
$this->logger->error("Template: Err Occur =".$e->getMessage());
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
}
return redirect()->route('template_creation');
}
public function campaign_creation(){
$data['page_name'] = 'Campaign Details';
$model = new NotificationModel();
$data['campaign'] = $model->getCampaignDetails();
$this->render_page('campaign_creation', $data);
// echo "templates";die;
}
public function campaign_creation_form($id){
$data['group_details'] = $this->get_group_details();
$data['template_details'] = $this->get_template_details();
$model = new NotificationModel();
if ($id === '0') {
$this->logger->info("Campaign Creation: In Add Page");
$data['page_name'] = 'Add Campaign';
$data['campaign_details'] = [];
} elseif ($id !== '0') {
$this->logger->info("Campaign Creation: In Edit Page ID =" . $id);
$data['page_name'] = 'Edit Campaign';
$model->setTable('notification_campaign');
$where = ['campaign_id'=>(int)$id];
$result = $model->where($where)->findAll();
if (!empty($result)) {
foreach ($result as $i => $item) {
$result[$i]['group_id'] = unserialize($item['group_id']);
}
}
$data['campaign_details'] = !empty($result[0]) ? $result[0] : [];
}
$this->render_page('campaign_creation_form', $data);
}
public function campaign_creation_delete($id){
try {
helper('session');
$session_uid = get_logged_user_id();
$model = new NotificationModel();
$model->setTable('templates');
$where = ['campaign_id'=>(int)$id];
$result = $model->where($where)->findAll();
if ($result) {
$this->logger->Info("Campaign: Going to Inactive ID = ".$id);
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'campaign_id'=>(int)$id];
$statement = $model->saveDetails($data,'campaign_id','notification_campaign');// just updating Inactive status only.
if ($statement['success']) {
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Campaign: Err Occur on data the Template Inactive");
}
}
} catch (\Exception $e) {
$this->logger->error("Campaign: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('campaign_creation');
}
public function campaign_creation_insert(){
$this->logger->info("Campaign: Inserting/Updating Details");
try {
## Declarions
helper('session');
$model = new NotificationModel();
$session_uid = get_logged_user_id();
$id = $this->request->getPost('campaign_id');
$isactive = $this->request->getPost('isactive');
// print_r($this->request->getPost());die;
$data = [
'campaign_id' => $id,
'campaign_name' => $this->request->getPost('campaign_name'),
'template_id' => $this->request->getPost('template_id'),
'scheduled_date' => $this->request->getPost('scheduled_date'),
'scheduled_time' => $this->request->getPost('scheduled_time'),
'mode' => $this->request->getPost('mode'),
'group_id' => serialize($this->request->getPost('group_id')),
'isactive' => $id ? (($isactive == 'on') ? 1 : 0) : 1,
'created_by' => $session_uid,
'updated_by' => $session_uid
];
$statement = $model->saveDetails($data,'campaign_id','notification_campaign');
if ($statement['success']) {
session()->setFlashdata('success', $statement['success']);
$this->logger->info($statement['log']);
} else if ($statement['error']) {
session()->setFlashdata('error', $statement['error']);
$this->logger->error($statement['log']);
}else{
throw new \Exception("Campaign: Err Occur");
}
}catch(\Exception $e) {
$this->logger->error("Campaign: Err Occur =".$e->getMessage());
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
}
return redirect()->route('campaign_creation');
}
public function getExpCustomerDetail($window_time = null)
{
// Step 1: add the days to retrive th e data//
$providedDate = date('Y-m-d');
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
// Step 2 :Get the custoemr detail//
$NotificationModel = new NotificationModel();
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
if (empty($ExpCustomerDetail)) {
$this->logger->info('There is no query');
return;
}
//Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
// print_r($modifiedQuery);die;
if (empty($modifiedQuery)) {
$this->logger->info('There is no sub query');
return;
}
$db = \Config\Database::connect();
$queryResult = $db->query($modifiedQuery)->getResultArray();
$notification = new NotificationHelper();
if (empty($queryResult)) {
$this->logger->info("There is no data against customer on given date:{$newDate}");
return;
}
foreach ($queryResult as $row) {
$templateName = $NotificationModel->getTempName();
if (empty($templateName)) {
$this->logger->info('There is no template found');
return;
}
$userFirstName = $row['first_name'];
$userLastName = $row['last_name'];
$fullName = $userFirstName . ' ' . $userLastName;
$schemename = $row['title'];
$expirydate = $row['to_subscription'];
if (empty($fullName)) {
$this->logger->info('There is no subcription Name');
return;
}
//Step 4: Prepare email content based on the template
$emailContent = $templateName[0]['message'];
$emailContent = str_replace("{User}", $fullName, $emailContent);
$emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent);
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
$emailData = [
'template_name'=>'',
'recipient_email' => $row['email'],
'subject' => 'Your Subscription Expiry Notification',
'description' =>$emailContent,
];
// Step 5:Send email using NotificationHelper
$emailResult = $notification->sendEmail($emailData);
if (isset($emailResult['success'])) {
echo 'Email sent successfully';
} else {
echo 'Failed to send email';
}
$templateName = $NotificationModel->getTempName();
}
}
}

195
app/Controllers/Scheme.php Normal file
View File

@ -0,0 +1,195 @@
<?php
namespace App\Controllers;
use App\Models\SchemeModel;
class Scheme extends BaseController
{
## For Scheme Listing
public function index()
{
helper('session');
if (is_session_active()) {
$session_bid = get_business_id();
$session_role = get_user_role();
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
} else {
$where = ['isactive != ' => NULL];
}
$SchemeModel = new SchemeModel();
$data['page_name'] = 'Scheme Details';
$data['scheme'] = $SchemeModel->getSchemeNamesAndDurationsByBusiness($session_bid);
$this->render_page('scheme_list', $data);
} else {
return redirect()->to('login');
}
}
## To Load Scheme Form (Add/Update)
public function new_scheme($id)
{
helper('session');
$session_bid = get_business_id();
if ($id === '0') {
$data['page_name'] = 'Add Scheme';
$data['scheme'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Scheme';
$model = new SchemeModel();
$imageData = $model->getBooksAndImagesByBookId($id);
$data['scheme'] = $imageData[0];
// print_r($data);die();
}
$data['session_bid'] = $session_bid;
$this->render_page('scheme_form', $data);
}
## For inserting/updating details of scheme
public function insert_scheme()
{
try{
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$SchemeModel = new SchemeModel();
$data = [
'title' => $this->request->getPost('sname'),
'description' => $this->request->getPost('sdescription'),
'price' => $this->request->getPost('sprice'),
'duration' => $this->request->getPost('sduration'),
'sku' => $this->request->getPost('sku'),
'business_id' => $this->request->getPost('business_id')
];
$scheme_id = $this->request->getPost('book_id'); // Get the business ID for update
if (empty($scheme_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
if ($SchemeModel->insert($data)) {
$last_inserted_id = $SchemeModel->insertID();
// Retrieve the category name 'membership'
$category_name = 'membership';
// Find the category ID for 'membership' from the category table
$db = db_connect();
$category = $db->table('category')
->select('id')
->where('name', $category_name)
->get()
->getRow();
// Check if the category exists
if ($category) {
// Insert data into book_categories table
$db->table('book_categories')->insert([
'book_id' => $last_inserted_id,
'category_id' => $category->id,
'created_by' => $session_uid
]);
}
session()->setFlashdata('success', 'Scheme has been added successfully.');
$this->logger->info("Scheme: has been added successfully. Inserted ID = " . $last_inserted_id);
} else {
session()->setFlashdata('error', 'Scheme could not be added. Please try again..');
$this->logger->error("Scheme: Err could not be added. Please try again.");
}
if (!empty($_FILES['img_name']['name'])) {
// A new image has been uploaded
// First, delete the previous image file if it exists
if (!empty($imageData) && file_exists(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name)) {
unlink(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name);
}
$imageData = [
'book_id' => $last_inserted_id, // Assuming $last_inserted_id contains the ID of the inserted scheme
'img_name' => $_FILES['img_name']['name'],
'is_cover' => 1, // Set this based on your requirements
'type' => $_FILES['img_name']['type']
];
// Move the uploaded image to a desired location
$imagePath = 'public/uploads/' . $_FILES['img_name']['name'];
move_uploaded_file($_FILES['img_name']['tmp_name'], $imagePath);
// Update image data in the 'book_images' table
$SchemeModel->insertImage($imageData);
}
}
else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive) ? 1 : 0;
$data['updated_by'] = $session_uid;
$SchemeModel->update($scheme_id, $data);
if ($SchemeModel->update($scheme_id, $data)) {
session()->setFlashdata('success', 'Scheme has been updated successfully.');
$this->logger->info("Scheme: has been updated successfully. Updated Scheme ID = " . $scheme_id);
} else {
session()->setFlashdata('error', 'Scheme update failed. Please try again.');
$this->logger->error("Scheme: Err Failed to update ID =" . $scheme_id);
}
}
} catch (\Exception $e) {
$this->logger->error("Scheme: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('scheme_list');
}
## For delete the Scheme details (Which means inactive the details)
public function delete_scheme($id)
{
try {
helper('session');
$session_uid = get_logged_user_id();
$SchemeModel = new SchemeModel();
$where = ['book_id' => (int)$id, 'isactive =' => 1];
// $existingScheme = $SchemeModel->find($id);
$existingScheme = $SchemeModel->where($where)->find($id);
if ($existingScheme) {
$this->logger->Info("Scheme: Going to Inactive ID = ".$id);
$data = ['isactive' => 0 , 'updated_by' => $session_uid];
if ($SchemeModel->update($id, $data)) {
$activeSchemeCategory = $SchemeModel->getData('book_categories', $where);
if(!empty($activeSchemeCategory)){
for ($z = 0; $z < count($activeSchemeCategory); $z++) {
$SchemeCategoryIds[$z] = $activeSchemeCategory[$z]->id;
}
if(!empty($SchemeCategoryIds)){
$this->logger->Info("Scheme: Categories Going to Inactived = ".implode(" ",$SchemeCategoryIds));
$inactive_category_whereIn[0] = 'id';
$inactive_category_whereIn[1] = $SchemeCategoryIds;
$SchemeModel->inactiveMissingDetails('book_categories',$data,$where, $inactive_category_whereIn);
}
}
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Scheme: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("Scheme: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
}
} catch (\Exception $e) {
$this->logger->error("Scheme: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('scheme_list');
}
}

View File

@ -0,0 +1,201 @@
<?php
namespace App\Controllers;
use App\Models\BusinessModel;
use App\Models\SettingsModel;
class Settings extends BaseController
{
public function index()
{
helper('session');
$session_role = get_user_role();
$session_bid = get_business_id();
$where = ['settings.isactive' => 1];
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['settings.business_id' => $session_bid, 'settings.isactive' => 1];
}
$model = new SettingsModel();
$model->setTable('settings');
$sitesetting_details = $model->where($where)->orderBy('setting_id', 'DESC')->findAll();
$data['page_name'] = 'Site Settings Details';
$data['details'] = $sitesetting_details;
$data['session_role'] = $session_role;
$this->render_page('setting_list', $data);
}
## To Load Settings Add/Update page
public function sitesetting_page($id)
{
if ($id === '0') {
$data['page_name'] = 'Add Site Settings';
$data['details'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Site Settings';
$model = new SettingsModel();
$model->setTable('settings');
$details = $model->where(['setting_id' => $id, 'isactive' => 1])->first();
$data['details'] = $details;
}
$data['business_details']=$this->business_details();
$this->render_page('setting_form', $data);
}
public function business_details()
{
$model = new BusinessModel();
$model->setTable('business');
$business_details = $model->orderBy('business_id', 'DESC')->findAll();
return $business_details;
}
## To Save/Update Setting Data on DB.
public function sitesetting_synchronization()
{
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$validationRule = [
'usersetiing' => [
'label' => 'Image File',
'rules' => [
'uploaded[slogo]',
'is_image[slogo]',
'mime_in[slogo,image/jpg,image/jpeg,image/gif,image/png,image/webp]',
],
],
'favicon' => [
'label' => 'Favicon',
'rules' => [
'uploaded[favicon]',
'is_image[favicon]',
'mime_in[favicon,image/ico,image/x-icon]',
],
],
];
if (!$this->validate($validationRule)) {
// Validation failed, return to the form with errors
$data['validation_errors'] = $this->validator->getErrors();
$this->render_page('setting_form', $data);
return;
}
$img = $this->request->getFile('slogo');
$setting_id = $this->request->getPost('setting_id');
$business_id = $this->request->getPost('business_id');
$filePath ='public/uploads/' . $this->request->getPost('slogo');
## File Already Existing or not
if ($img->isValid() && !$img->hasMoved()) {
$fileName = $img->getName();
$img->move('public/uploads/', $fileName);
// Delete the previous image file if it exists
if ($setting_id) {
$previousFileName = $this->request->getPost('previous_sfile');
if ($previousFileName && is_file('public/uploads/' . $previousFileName)) {
unlink('public/uploads/' . $previousFileName);
}
}
} else {
$fileName = $this->request->getPost('previous_sfile', ''); // Use the previous filename if no new image is provided
}
$favicon = $this->request->getFile('favicon');
if ($favicon->isValid() && !$favicon->hasMoved()) {
$faviconName = $favicon->getName();
$favicon->move('public/uploads/', $faviconName);
// Delete the previous favicon file if it exists
if ($setting_id) {
$previousFaviconName = $this->request->getPost('previous_favicon');
if ($previousFaviconName && is_file('public/uploads/' . $previousFaviconName)) {
unlink('public/uploads/' . $previousFaviconName);
}
}
} else {
$faviconName = $this->request->getPost('previous_favicon', ''); // Use the previous favicon filename if no new favicon is provided
}
$SettingsModel = new SettingsModel();
$data = [
'site_name' => $this->request->getPost('site_name'),
'site_title' => $this->request->getPost('site_title'),
'favicon' => $this->request->getPost('favicon'),
'logo' => $this->request->getPost('logo'),
'terms_service' => $this->request->getPost('terms_service'),
'footer_about' => $this->request->getPost('footer_about'),
'admin_email' => $this->request->getPost('admin_email'),
'mobile'=> $this->request->getPost('mobile'),
'copyright'=> $this->request->getPost('copyright'),
'pagination_limit'=> $this->request->getPost('pagination_limit'),
'site_info'=> $this->request->getPost('site_info'),
'about_info'=> $this->request->getPost('about_info'),
'mail_protocol'=> $this->request->getPost('mail_protocol'),
'mail_title'=> $this->request->getPost('mail_title'),
'mail_host'=> $this->request->getPost('mail_host'),
'mail_port'=> $this->request->getPost('mail_port'),
'mail_encryption'=> $this->request->getPost('mail_encryption'),
'mail_username'=> $this->request->getPost('mail_username'),
'mail_password'=> $this->request->getPost('mail_password'),
'currency'=> $this->request->getPost('currency'),
'country'=> $this->request->getPost('country'),
'business_id'=> $this->request->getPost('business_id'),
'logo'=>$fileName,
'favicon'=>$faviconName
];
$setting_id = $this->request->getPost('setting_id'); // Get the business ID for update
if (empty($setting_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$SettingsModel->insert($data);
// print_r($data);die;
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
$SettingsModel->update($setting_id, $data);
}
return redirect()->route('sitesetting_list');
}
}
// $model = new SettingsModel();
// $model->setTable('settings');
// if ($this->request->is('post')) {
// $requestData = $this->request->getVar();
// }
// $requestData['business_id'] = $session_bid;
// if ($requestData['setting_id']) {
// #edit
// $requestData['updated_by'] = $session_uid;
// $requestData['isactive'] = isset($requestData['isactive']) && $requestData['isactive'] == 'on' ? 1 : 0;
// $model->saveData($requestData, $requestData['setting_id']);
// $alert_message = "Site Settings details successfully updated.";
// } else {
// #add
// $requestData['created_by'] = $session_uid;
// $requestData['isactive'] = 1;
// $model->saveData($requestData, null);
// $alert_message = "Site Settings details successfully created.";
// }
// return redirect()->route('sitesetting_list');
// }
// }

View File

@ -0,0 +1,217 @@
<?php
namespace App\Controllers;
// use App\Models\SubscriptionModel;
use App\Models\CustomerModel;
use App\Models\SubscriptionModel;
use App\Models\SchemeModel;
use App\Models\InvoiceModel;
use Mpdf\Mpdf;
class Subscription extends BaseController
{ public function index()
{
// echo base_url('public/uploads/vijayabharathampdf.png');die();
helper('session');
if (is_session_active()) {
$session_role = get_user_role();
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Invoice: Listing In Admin BID = " . $session_bid);
$where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1];
} else {
$this->logger->info("Invoice: Listing In the Super-Admin ");
$where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL];
}
$model = new InvoiceModel();
$data['page_name'] = 'Subscription Invoice Details';
$data['invoice'] = $model->getSubscriptionInvoiceDetail($where);
$this->logger->info("Invoice: Listing Count ." . count($data['invoice']));
// $data['subscriber'] = $SubscriptionModel->where($where)->findAll();;
$SubscriptionModel = new SubscriptionModel();
$swhere = ['subscription.business_id' => (int)$session_bid];
$data['subscriber'] = $SubscriptionModel->getAllSubscribersWithNames($swhere);
$this->render_page('subscribers_list', $data);
}else {
return redirect()->to('login');
}
}
public function new_subscription() {
helper('session');
helper('session');
$session_bid = get_business_id();
$data['page_name'] = 'Subscription Details';
$customerModel = new CustomerModel();
$schemeModel = new SchemeModel();
$business_id = get_business_id();
// Get scheme names and durations from the SchemeModel
$data['customers'] = $customerModel->getCustomerNamesByBusiness($business_id);
$data['scheme_names'] = $schemeModel->getSchemeNamesAndDurationsByBusiness($business_id);
//print_r($data);die();
$this->render_page('subscription_form', $data);
}
// Subscription Controller (Subscription.php)
public function add_subscription() {
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$SubscriptionModel = new SubscriptionModel();
$data = [
'scheme_id' =>$this->request->getPost('scheme'),
'customer_id' =>$this->request->getPost('customer'),
'from_subscription' => $this->request->getPost('from_date'),
'to_subscription' => $this->request->getPost('to_date'),
// 'type' => "subscribed customer",
'type' => "customer",
'mode' => $this->request->getPost('mode'),
'business_id'=>$session_bid
];
$SubscriptionModel->insert($data);
// $data['subscriber'] = $subscriberModel->getAllSubscribersWithNames();
// print_r($data);die();
return redirect()->to('subscribers_list')->with('data', $data);
}
// Subscription.php (Controller)
// public function download_details()
// {
// $selectedScheme = $this->request->getPost('selected_scheme');
// // Call the model method to get customer details for the selected scheme
// $subscriptionModel = new SubscriptionModel();
// $business = $subscriptionModel->getCustomerAddressesBySchemeName($selectedScheme);
// $shippingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($selectedScheme, 2);
// $customerName = $subscriptionModel->getCustomerNameBySchemeName($selectedScheme);
// // Create an HTML content string using the view file (similar to print_addresses.php)
// if ($customerName !== 'Customer not found') {
// $html = view('print_addresses_form', ['customerName' => $customerName, 'shippingInfo' => $shippingInfo, 'business' => $business]);
// // Generate a PDF from the HTML content
// $pdf = new Mpdf();
// $pdf->WriteHTML($html);
// // Set the PDF filename
// $filename = 'CustomerDetails_' . date('YmdHis') . '.pdf';
// // Output the PDF for download
// $pdf->Output($filename, 'D');
// } else {
// // Handle the case where the customer is not found
// echo 'Customer not found';
// }
// }
public function download_details()
{
$selectedSchemes = $this->request->getPost('selected_schemes');
$action = $this->request->getPost('action');
// Initialize an empty PDF with custom paper size (4x6 inches)
$config = [
'mode' => 'utf-8',
'format' => [101.6, 152.4],
'default_font_size' => 12,
'default_font' => 'Arial',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P', // Portrait
];
$configA4 = [
'mode' => 'utf-8',
'format' => [101.6 * 2, 152.4 * 4], // 2x4 inches for each label
'default_font_size' => 12,
'default_font' => 'Arial',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P', // Portrait
];
if($action == 1) $pdf = new Mpdf($config);
else $pdf = new Mpdf();
$customerDetails = [];
// Iterate through selected schemes
if (!empty($selectedSchemes)) {
foreach ($selectedSchemes as $selectedScheme) {
// Call the model method to get customer details for each selected scheme
$subscriptionModel = new SubscriptionModel();
$details = $subscriptionModel->getAllCustomerDetailsBySchemeName($selectedScheme);
$customerDetails = array_merge($customerDetails, $details);
}
if (!empty($customerDetails)) {
$html = view('print_addresses_form', ['customerDetails' => $customerDetails , 'action' => $action , 'pdf' => $pdf]);
// Add the current scheme's details to the PDF
// echo $html;die;
// $pdf->AddPage();
$pdf->WriteHTML($html);
// Set the PDF filename
$filename = 'CustomerDetails_' . date('YmdHis') . '.pdf';
// Output the PDF for download
$pdf->Output($filename, 'D');
$this->logger->info("Print Addresses (Scheme) : Downloaded = ".$filename);
} else {
echo "<script>alert('Customer Details Not Available.');</script>";
$this->logger->info("Print Addresses (Scheme) : Details Not Available ");
}
} else {
echo "<script>alert('Schemes Not Choosen.');</script>";
$this->logger->info("Print Addresses (Scheme) : Schemes Not Choosen ");
}
}
}
// public function generate_pdf()
// {
// $schemeName = $this->request->getGet('scheme_name');
// // Call the model method to get the customer's name and address (billing or shipping)
// $subscriptionModel = new SubscriptionModel();
// // For billing address
// $billingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($schemeName, 1);
// // For shipping address
// $shippingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($schemeName, 2);
// print_r($billingInfo);
// print_r($shippingInfo);
// // Handle the PDF generation using $billingInfo['customer_name'], $billingInfo['address'] (for billing address)
// // and $shippingInfo['customer_name'], $shippingInfo['address'] (for shipping address)
// }

276
app/Controllers/Users.php Normal file
View File

@ -0,0 +1,276 @@
<?php
namespace App\Controllers;
use App\Models\UsersModel;
use App\Models\BusinessModel;
use CodeIgniter\Files\File;
class Users extends BaseController
{
## For User Listing
public function index()
{
helper('session');
$session_role = get_user_role();
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Users: Listing In admin role . BID = ".$session_bid);
$where = ['users.business_id' => (int)$session_bid, 'users.isactive' => 1];
} else {
$this->logger->info("Users: Listing In Super-admin role .");
$where = ['users.isactive !=' => NULL];
}
$model = new UsersModel();
$model->setTable('users');
$user_details = $model->where($where)->orderBy('user_id', 'DESC')->findAll();
$this->logger->info("Users: Listing Count .".count($user_details));
$data['page_name'] = 'User Details';
$data['details'] = $user_details;
$this->render_page('user_list', $data);
}
## To Load User Add/Update page
public function user_page($id)
{
helper('session');
$session_role = get_user_role();
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
if ($id === '0') {
$this->logger->info("Users: In Add page");
$data['page_name'] = 'Add User';
$business_details = $this->business_details();
$render_page_name = 'user_form';
$data['details'] = [];
} else if ($id !== '0') {
$this->logger->info("Users: In Edit page");
$model = new UsersModel();
$model->setTable('users');
if (!empty($session_role)){
switch ($session_role) {
case "sadmin":
$where = ['users.user_id' => $id, 'users.isactive !=' => NULL];
$edit_user_details = $model->where($where)->first();
$business_details = $this->business_details();
$render_page_name = 'user_form';
$data['page_name'] = 'Edit User';
break;
case "admin":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$edit_user_details = $model->where($where)->first();
$business_details = [];
$render_page_name = 'user_form';
$data['page_name'] = 'Edit User';
break;
case "manager":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$edit_user_details = $model->where($where)->first();
$business_details = [];
if($session_uid === $id && $session_role === "manager"){
$data['page_name'] = 'Edit User';
$render_page_name = 'user_form';
}else{
$data['page_name'] = 'Page Not Found';
$render_page_name = 'pages_404';
}
break;
default:
$data['page_name'] = 'Page Not Found';
$render_page_name = 'pages_404';
}
}
$data['details'] = $edit_user_details;
}
$data['business_details'] = $business_details;
$data['session_bid'] = $session_bid;
$this->render_page($render_page_name, $data);
}
## For SuperAdmin Role business Dropdown displayed on Userpage.otherwise Hidden fields
public function business_details()
{
$model = new BusinessModel();
$model->setTable('business');
$business_details = $model->orderBy('business_id', 'DESC')->findAll();
return $business_details;
}
## For inserting/updating details of user
public function insert_users()
{
$this->logger->info("Users: Inserting/Updating Details");
try {
## CI validation rule for profile_picture
$validationRule = [
'profile_picture' => [
'label' => 'Image File',
'rules' => 'uploaded[profile_picture]|is_image[profile_picture]|mime_in[profile_picture,image/jpg,image/jpeg,image/gif,image/png,image/webp]'
]
];
## Declarions
helper('session');
$UsersModel = new UsersModel();
$session_uid = get_logged_user_id();
$session_bid = get_business_id();
$user_id = $this->request->getPost('user_id');
$business_id = $this->request->getPost('business_id')?$this->request->getPost('business_id'):$session_bid;
$img_details = $this->request->getFile('profile_picture'); // Here I Have Image details ;
$final_img_name = NULL;//Just flag
$existing_img_name = $this->request->getPost('existing_profile_picture_name'); // HiddenField for if have any pic name means;
$img_path = 'public/uploads/';
##Step 1 : image details available
if($img_details){
$this->logger->info("Users: image details avaiable");
##Step 2 : i have image details .<br/>
if ($img_details->isValid()) {
##Step 3 : image Name.$new_img_name."<br/>";
$new_img_name = $img_details->getName(); // before movement name
$this->logger->info("Users: Image Name B4 Upload".$new_img_name);
##Step 4 : Validation Rule Apply here.if not throw the error"<br/>";
if (!$this->validate($validationRule)) {
if($new_img_name !== ''){
$error = $this->validator->getErrors();
// echo "Error : ".(string)$error."<br/>";
$this->logger->error("Users: Err on image upload".$error['profile_picture']);
throw new \Exception((string)$error['profile_picture']);
}
}
##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder
if($new_img_name !== $existing_img_name){
$this->logger->info("Users: Image Name are Differ".$new_img_name." & ".$existing_img_name);
## Step 6 : Different Image Name means removed on target folder using Unlink;
if ($existing_img_name && is_file($img_path.$existing_img_name)) {
$this->logger->info("Users: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted.");
// echo "Deleted_file : ".(string)$img_path.$existing_img_name."<br/>";
unlink($img_path.$existing_img_name);
}
## Step 7 : Moved to target;
$img_details->move($img_path, $new_img_name);
$final_img_name = $img_details->getName(); // after movement name
$this->logger->info("Users: Image Name After Upload".$final_img_name);
}else{
$final_img_name = $existing_img_name;
$this->logger->info("Users: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload");
}
}
else{
## Step 8 : Not a Vaild Image File so replace Existing file name;
$final_img_name = $existing_img_name;
$this->logger->info("Users: Not a Vaild Image File Nothing To Update/Upload");
// throw new \Exception("Not a Vaild Image File");
}
}
else{
## Step 9 : Testing Purpose File Details Not Available. so i can't move it.;
$this->logger->info("Users: Testing Purpose Image Details Not Available. so i can't move it.");
$final_img_name = $existing_img_name;
//throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice");
}
$data = [
'profile_picture' => $final_img_name,
'city' => $this->request->getPost('city'),
'state' => $this->request->getPost('state'),
'email' => $this->request->getPost('email'),
'postal_code' => $this->request->getPost('postal_code'),
'country' => $this->request->getPost('country'),
'role' => $this->request->getPost('role'),
'first_name' => $this->request->getPost('first_name'),
'last_name' => $this->request->getPost('last_name'),
'mobile_no' => $this->request->getPost('mobile_no'),
'date_of_birth' => NULL,
'address' => $this->request->getPost('address'),
'gender' => $this->request->getPost('gender'),
'business_id' => $business_id
];
if (empty($user_id)) {
// It's an insert operation
$password = $this->request->getVar('password');
$hash_password = password_hash($password, PASSWORD_DEFAULT);
$data['isactive'] = 1;
$data['password'] = $hash_password;
$data['created_by'] = $session_uid;
//print_r($data);die;
// ($UsersModel->insert($data)) ? session()->setFlashdata('success', 'User has been added successfully.')
// : session()->setFlashdata('error', 'User could not be added. Please try again.');
if ($UsersModel->insert($data)) {
session()->setFlashdata('success', 'User has been added successfully.');
$this->logger->info("Users: has been added successfully. Inserted ID = ".$UsersModel->insertID());
} else {
session()->setFlashdata('error', 'User could not be added. Please try again.');
$this->logger->error("Users: Err could not be added. Please try again.");
}
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['updated_by'] = $session_uid;
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
if($session_uid == $user_id && $data['isactive'] == 0){
throw new \Exception("Cant able to Update Because logged-In persons can't remove. Please Contact your Admin!....");
}
if ($UsersModel->update($user_id, $data)) {
session()->setFlashdata('success', 'User has been updated successfully.');
$this->logger->info("Users: has been updated successfully. Updated ID = ".$user_id);
} else {
session()->setFlashdata('error', 'User update failed. Please try again.');
$this->logger->error("Users: Err Failed to update ID =".$user_id);
}
}
}catch(\Exception $e) {
$this->logger->error("Users: Err Occur =".$e->getMessage());
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
}
return redirect()->route('user_list');
}
## For delete the user details (Which means inactive the details)
public function delete_user($id)
{
helper('session');
$session_uid = get_logged_user_id();
try {
if($id == $session_uid){
throw new \Exception("Your Logged-In, Can't able delete");
}
$model = new UsersModel();
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$existingUser = $model->where($where)->find($id);
$this->logger->Info("Users: Going to Inactive ID = ".$id);
if ($existingUser) {
$data['isactive'] = 0;
$data['updated_by'] = $session_uid;
if(!empty($existingUser['profile_picture']) && file_exists(FCPATH."public/uploads/".$existingUser['profile_picture'])){
unlink('public/uploads/'.$existingUser['profile_picture']);
$data['profile_picture'] = NULL;
}
if ($model->update($id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Users: has been Inactived successfully. Inactived ID = ".$id);
} else {
$this->logger->error("Users: Not able to Inactive ID =".$id);
throw new \Exception("Data Not able to Deleted");
}
}
else{
$this->logger->error("Users: Does Not Exist To Inactive, ID = ".$id);
throw new \Exception("User Already Deleted");
}
}catch(\Exception $e) {
$this->logger->error("Users: Err Occur = ".$e->getMessage());
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
}
return redirect()->route('user_list');
}
}

View File

View File

0
app/Filters/.gitkeep Normal file
View File

0
app/Helpers/.gitkeep Normal file
View File

View File

@ -0,0 +1,128 @@
<?php
// app/Helpers/NotificationHelper.php
namespace App\Helpers;
class NotificationHelper
{
protected $email;
protected $logger;
public function __construct()
{
$this->email = service('email');
$this->logger = service('logger');
}
public function sendEmail($records)
{
$this->logger->info('Helper : Email Request Data type = '.gettype($records));
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
try {
if($records['recipient_email'] == "" && $records['subject'] == ""){
throw new \Exception("Email and Subject are Must Please Try again..");
}
$this->email->setTo($records['recipient_email']);
$this->logger->info('Helper : Email recipient = '.$records['recipient_email']);
$this->email->setFrom('no-reply@tripapprovaltool.com', isset($records['company'])?$records['company']:"VBP");
$this->email->setSubject($records['subject']);
$this->logger->info('Helper : Email subject = '.$records['subject']);
if($records['template_name'] != ""){
$this->logger->info('Helper : Email Template = '.$records['template_name']);
$this->logger->info("Helper : Email Request data = ".json_encode($records));
$emailContent = view($records['template_name'],$records);
$this->email->setMessage($emailContent);
}else{
$this->logger->info('Helper : Email Dynamic Template');
$this->email->setMessage($records['description']);
}
if (!empty($cc)) {
$ccRecipients = explode(',', $cc);
$this->logger->info('Helper : Email carboncopy CC recipient = '.$ccRecipients);
foreach ($ccRecipients as $ccRecipient) {
$this->email->setCC(trim($ccRecipient));
}
}
if (!empty($bcc)) {
$bccRecipients = explode(',', $bcc);
$this->logger->info('Helper : Email blindcarboncopy BCC recipient = '.$bccRecipients);
foreach ($bccRecipients as $bccRecipient) {
$this->email->setBCC(trim($bccRecipient));
}
}
if ($this->email->send()) {
$message['success'] = 'Email sent successfully';
$this->logger->info('Helper : Email = sent successfully');
} else {
throw new \Exception('Email sending failed.');
}
} catch (\Exception $e) {
$this->logger->error('Helper : Email Error: ' . $e->getMessage());
$message['error'] = 'Email Exception Occur : ' . $e->getMessage();
}
return $message;
}
public function sendWhatsAppMessage($url,$method,$data)
{
try{
$this->logger->info('Helper : Whatsapp');
$curl = curl_init();
$headers = array('Content-Type:application/json');
$jsonencoded = json_encode($data);
curl_setopt( $curl,CURLOPT_URL, $url);
$this->logger->info('Helper : Whatsapp url = '.$url);
switch ($method) {
case "POST":
curl_setopt( $curl,CURLOPT_POST, true );
if ($data) {
$this->logger->info('Helper : Whatsapp jsonencoded = '.$jsonencoded);
curl_setopt( $curl,CURLOPT_POSTFIELDS, $jsonencoded);
}
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data) {
// print_r($data);die();
$url = sprintf("%s?%s", $url, http_build_query((array)$data));
}
}
curl_setopt( $curl,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $curl,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl,CURLOPT_SSL_VERIFYPEER, true );
$curl_exec = curl_exec($curl);
$this->logger->info('Helper : Whatsapp Reponse = '.$curl_exec);
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($http_status === 200) {
$result = json_decode($curl_exec);
if ($result->status === "error") {
$this->logger->error('Helper : Whatsapp Err occur = '.$result->message);
throw new \Exception($result->message);
}else{
$final_result = " Sended Success ";
}
}else{
$curl_errno= curl_errno($curl);
$this->logger->error('Helper : Whatsapp curl error occur = '.$curl_errno);
throw new \Exception(" Errno returned ".$curl_errno);
}
curl_close($curl);
}catch (\Exception $e) {
$this->logger->error('Helper : Whatsapp Exception Occur = ' . $e->getMessage());
$final_result = "Exception Errno returned ".$e->getMessage()." <br/>";
}
return $final_result;
}
}
?>

View File

@ -0,0 +1,68 @@
<?php
function perform_whatsapp_request($url,$method,$data){
// log_message('INFO',"PerformWhatsappRequest : request url = ".$url);
// log_message('INFO',"PerformWhatsappRequest : request data type = ".$data);
// log_message('INFO',"PerformWhatsappRequest : method = ".$method);
}
function perform_http_request_old($method, $url, $data = false) {
$username = "ck_935889d13267b63c2341168e42ffafe3c1ee831a";
$password = "cs_6ce1321c3f08049dfb3c8098ea21137796446bc4";
$encodekey = base64_encode($username.':'.$password);
$headers = array(
'Content-Type:application/json',
'Authorization: Basic '. $encodekey
);
try{
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
switch ($method) {
case "POST":
curl_setopt($curl, CURLOPT_POST, true);
if ($data) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data) {
// print_r($data);die();
$url = sprintf("%s?%s", $url, http_build_query((array)$data));
}
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //If SSL Certificate Not Available, for example, I am calling from http://localhost URL
curl_setopt( $curl,CURLOPT_SSL_VERIFYPEER, true );
curl_setopt($curl, CURLOPT_FAILONERROR, true);
$result = curl_exec($curl);
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$curl_errno= curl_errno($curl);
if($curl_errno){
if ($http_status==503){
$error = "HTTP Status == 503 <br/> Curl Errno returned $curl_errno <br/>";
}
else{ $error = "Curl Errno returned $curl_errno <br/>"; }
$error_msg = curl_error($curl);
}else{
$error = "";
$error_msg = "";
}
curl_close($curl);
$response = (array) json_decode($result);
}catch (Exception $e) {
$error = "Exception Errno returned".$e->getCode()." <br/>";
$error_msg = $e->getMessage();
$response = array();
}
$final = array( "response"=>$response,"error"=>$error,"error_msg"=>$error_msg);
return $final;
}
?>

View File

@ -0,0 +1,118 @@
<?php
if (!function_exists('is_session_active')) {
function is_session_active()
{
$session = \Config\Services::session();
// echo "i am in helper ...".$session->get('user_id');die();
return $session->get('user_id');
}
}
if (!function_exists('get_logged_user_id')) {
function get_logged_user_id()
{
$session = \Config\Services::session();
return $session->get('user_id');
}
}
if (!function_exists('set_logged_user_id')) {
function set_logged_user_id($userId)
{
$session = \Config\Services::session();
$session->set('user_id', $userId);
}
}
if (!function_exists('unset_logged_user')) {
function unset_logged_user()
{
$session = \Config\Services::session();
$session->remove('user_id');
}
}
if (!function_exists('get_logged_name')) {
function get_logged_name()
{
$session = \Config\Services::session();
return $session->get('user_name');
}
}
if (!function_exists('set_logged_name')) {
function set_logged_name($userName)
{
$session = \Config\Services::session();
$session->set('user_name', $userName);
}
}
if (!function_exists('set_user_role')) {
function set_user_role($userRole)
{
$session = \Config\Services::session();
$session->set('user_role', $userRole);
}
}
if (!function_exists('get_user_role')) {
function get_user_role()
{
$session = \Config\Services::session();
return $session->get('user_role');
}
}
if (!function_exists('set_business_id')) {
function set_business_id($businessId)
{
$session = \Config\Services::session();
$session->set('business_id', $businessId);
}
}
if (!function_exists('get_business_id')) {
function get_business_id()
{
$session = \Config\Services::session();
return $session->get('business_id');
}
}
if (!function_exists('is_session_destroy')) {
function is_session_destroy()
{
$session = \Config\Services::session();
$session->destroy();
}
}
if (!function_exists('set_session_locked')) {
function set_session_locked()
{
$session = \Config\Services::session();
$session->set('session_locked', true);
}
}
if (!function_exists('get_session_locked')) {
function get_session_locked()
{
$session = \Config\Services::session();
return $session->get('session_locked');
}
}
if (!function_exists('remove_session_locked')) {
function remove_session_locked()
{
$session = \Config\Services::session();
$session->remove('session_locked');
}
}
?>

0
app/Language/.gitkeep Normal file
View File

View File

@ -0,0 +1,4 @@
<?php
// override core en language system validation or define your own en language validation message
return [];

0
app/Libraries/.gitkeep Normal file
View File

0
app/Models/.gitkeep Normal file
View File

View File

@ -0,0 +1,113 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ApiIntegrationModel extends Model
{
protected $table;
public function setTable($tableName)
{
$this->table = $tableName;
return $this;
}
public function insertData($table, $data)
{
try {
$this->db->table($table)->insert($data);
$last_insert_id = $this->db->insertID();
return ["info"=>$last_insert_id,"err"=>""];
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
} catch (\Exception $e) {
return ["info"=>"","err"=>'An error occurred: ' . $e->getMessage()];
}
}
public function updateData($table, $data, $where)
{
try {
$this->db->table($table)->update($data, $where);
$affected_rows = $this->db->affectedRows();
return ["info"=>$affected_rows." Affected","err"=>""];
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
} catch (\Exception $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
}
}
public function countAll($table, $where = null)
{
$query = $this->db->table($table);
if ($where) {
$query->where($where);
}
return $query->countAllResults();
}
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 insertAndUpdateChildDetails($data,$table_name,$column_name){
$i = 1;
$text = ' Child-table Name = '.str_replace("_", " ",ucwords($table_name)) .', Column = '.str_replace("_", " ",ucwords($column_name)) .'. ';
foreach ($data as $row) {
$id = isset($row[$column_name]) ? $row[$column_name] : "";
if($id != ''){
unset($row[$column_name]); // Remove the primary Id from the data to avoid updating it.
$where = [$column_name=>$id,'isactive'=>1];
$child_affected_rows = $this->updateData($table_name, $row, $where);
$text .= $child_affected_rows["info"] ? $i.') Id = '.$id.', '.$child_affected_rows["info"].'. '
: $i.') Id = '.$id.', Err = '.$child_affected_rows["err"].'. ';
}else{
$child_insert_id = $this->insertData($table_name, $row);
$text .= $child_insert_id["info"] ? $i.') Inserted ID = '.$child_insert_id["info"].'. '
: $i.') Err = '.$child_insert_id["err"].'. ' ;
}
$i++;
}
return $text;
}
// public function inactiveMissingDetails($table_name,$where,$whereIn){
// $dataToUpdate = ['isactive' => 0];
// $this->db->table($table_name)->where($where)->whereIn($whereIn[0],$whereIn[1])->update($dataToUpdate);
// }
public function inactiveMissingDetails($table_name,$dataToUpdate,$where = null,$whereIn = null)
{
$this->db->table($table_name);
$query = $this->db->table($table_name);
if ($where) {
$query->where($where);
}
if ($whereIn) {
$query->whereIn($whereIn[0], $whereIn[1]);
}
$query->update($dataToUpdate);
}
public function getBookCategories($product_id){
return $this->db->table('book_categories as BC')
->join('category as C', 'C.id = BC.category_id', 'left')
->join('books as B', 'B.book_id = BC.book_id', 'left')
->select('BC.id,BC.book_id,BC.category_id,C.wp_api_category_id,C.name as category_name,B.title as book_name,B.sku,B.duration')
->where(['BC.isactive'=>1,'B.wp_api_product_id'=>$product_id])
->get()
->getResultArray();
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class AuthenticationModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
protected $allowedFields = ['user_id','email','first_name','last_name','password','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','reset_link'];
public function getheringDetailsForHeader($user_id)
{
$builder = $this->db->table('users');
$builder->select('users.user_id,users.business_id,users.profile_picture,users.role,settings.site_name,settings.site_title,settings.favicon,settings.logo as company_logo_large,business.business_logo as company_logo_small,business.email as company_email,business.address as company_address,business.mobile_no as company_mobile_no,business.title,settings.footer_about');
$builder->join('settings', 'settings.business_id = users.business_id', 'left');
$builder->join('business', 'business.business_id = users.business_id', 'left');
$builder->where('user_id', $user_id);
//$template_mapping_details['fk_entity_id'];
$query = $builder->get();
return $query->getResultArray();
}
}

49
app/Models/BooksModel.php Normal file
View File

@ -0,0 +1,49 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
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','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)
{
if ($id === null) {
// Insert new record
return $this->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 inactiveMissingDetails($table_name,$dataToUpdate,$where = null,$whereIn = null)
{
$this->db->table($table_name);
$query = $this->db->table($table_name);
if ($where) {
$query->where($where);
}
if ($whereIn) {
$query->whereIn($whereIn[0], $whereIn[1]);
}
return $query->update($dataToUpdate);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BusinessModel extends Model
{
protected $table = 'business';
protected $primaryKey = 'business_id';
protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code' ,'business_logo','isactive', 'pan_no', 'org_reg_no', '80G'];
public function insertBusiness($data)
{
return $this->insert($data);
}
}
?>

View File

@ -0,0 +1,163 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class CustomerModel extends Model
{
protected $table = 'customers';
protected $primaryKey = 'doner_id ';
// protected $allowedFields = ['doner_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','isactive','business_id'];
protected $allowedFields = ['doner_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','org_name','date_of_birth','pan_no','doner_type','isactive','business_id','created_by','updated_by'];
public function insertCustomer($data)
{
return $this->insert($data);
}
public function getCustomerNamesByBusiness($business_id)
{
$this->builder()->select('doner_id,CONCAT(first_name, " ", last_name) as full_name', false);
$this->builder()->where('business_id ', $business_id); // Filter by business_id
$query = $this->builder()->get(); // Use findAll() instead of get()
return ($query->getResult());
}
// $customerNames = [];
// foreach ($query->getResult() as $row) {
// $customerNames[] = [ $row->full_name ];
// }
// print_r($customerNames);
// die();
// public function getCustomerIdByName($customerName, $businessId)
// {
// $customer = $this->builder()
// ->select('doner_id')
// ->where('CONCAT(first_name, " ", last_name)', $customerName)
// ->where('business_id', $businessId)
// ->get()
// ->getRow();
// if ($customer) {
// return $customer->doner_id;
// }
// return null; // Customer not found
// }
public function insertAddress($addressData) {
$this->db->table('customer_addresses')->insert($addressData);
return $this->db->insertID(); // Return the last inserted ID
}
public function insertAddressBatch($addressesDataArray) {
$this->db->table('customer_addresses')->insertBatch($addressesDataArray);
return $this->db->insertID(); // Note: insertID() might not be applicable for batch inserts
}
public function saveAddressDetails($data){
$i = 0;
$statement = [];
foreach ($data as $row) {
$id = $row['customer_address_id'];
if($id != ''){
unset($row['customer_address_id']); // Remove the id from the data to avoid updating it
unset($row['created_by']); // bcoz here data Updating here.
$this->db->table('customer_addresses')->where('customer_address_id', $id)->update($row);// Update the row with the specified id
$affectedRows = $this->db->affectedRows();
$statement[$i] = "address - ".$id." ". ($affectedRows ? " Updated":" Nothing to Updated");
}else{
$this->db->table('customer_addresses')->insert($row);
$insertID = $this->db->insertID();
$statement[$i] = "address - ".$insertID." Inserted";
}
$i++;
}
return $statement;
}
public function inactiveMissingAddressDetails($where,$missingValues){
$dataToUpdate = ['isactive' => 0];
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
}
public function getInvoicesByCustomerId($doner_id)
{
return $this->db->table('invoice')
->select('invoice_number, subtotal, invoice_date')
->where('doner_id', $doner_id)
->get()
->getResult();
}
public function getSubscriberDataByCustomerId($customerId)
{
// Assuming 'subscription' is the table name where subscriber data is stored.
$builder = $this->db->table('subscription');
$builder->join('books', 'books.book_id = subscription.scheme_id');
// Define the columns you want to select from the subscription table.
$builder->select('subscription.*,books.title');
// Add a where condition to filter results based on customer ID.
$builder->where('doner_id', $customerId);
// Execute the query and return the result as an array of objects.
return $builder->get()->getResult();
}
public function saveGroupDetails($data){
$id = $data['group_id'];
if($id != ''){
unset($data['group_id']); // Remove the id from the data to avoid updating it
unset($data['created_by']); // bcoz here data Updating here.
if ($this->db->table('customer_groups')->where('group_id', $id)->update($data)) {
$affectedRows = $this->db->affectedRows();
$statement['success'] = 'Customer Group has been updated successfully.';
$statement['error'] = "";
$statement['log'] = "Customer Group: has been updated successfully. Updated Customer Group ID = " .$id." Affected Rows = ".$affectedRows;
} else {
$statement['success'] = "";
$statement['error'] = 'Customer group update failed. Please try again.';
$statement['log'] = "Customer Group: Err Failed to update ID = " .$id ;
}
}else{
unset($data['updated_by']);
if ($this->db->table('customer_groups')->insert($data)) {
$insertID = $this->db->insertID();
$statement['success'] = 'Customer Group has been Inserted successfully.';
$statement['error'] = "";
$statement['log'] = "Customer Group : has been added successfully. Inserted ID = " .$insertID ;
} else {
$statement['success'] = "";
$statement['error'] = "Customer could not be added. Please try again..";
$statement['log'] = "Customer: Err could not be added. Please try again.";
}
}
return $statement;
}
public function getGroupDetails()
{
return $this->db->table('customer_groups as CG' )
->join('users as U1', 'U1.user_id = CG.created_by', 'left')
->join('users as U2', 'U2.user_id = CG.updated_by', 'left')
->select('CG.group_id,CG.group_name,CG.created_on,CG.created_by,CG.updated_on,CG.updated_by,DATE_FORMAT(CG.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,CG.isactive')
->where(['CG.group_name != ' => 'EXPIRYDATE'])
// ->where(['CG.isactive' => 1])
->get()
->getResultArray();
}
}
?>

57
app/Models/EventModel.php Normal file
View File

@ -0,0 +1,57 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class EventModel extends Model
{
protected $table = 'campaign';
protected $primaryKey = 'campaign_id';
protected $allowedFields = ['campaign_id','name', 'description','start_date', 'end_date','created_by','created_on','updated_on' ,'updated_by','business_id'];
public function getEventnamesByBusiness($business_id)
{
$this->builder()->where('business_id ', $business_id); // Filter by business_id
$query = $this->builder()->get(); // Use findAll() instead of get()
return ($query->getResult());
}
public function setTable($tableName)
{
$this->table = $tableName;
return $this;
}
public function insertData($table, $data)
{
try {
$this->db->table($table)->insert($data);
$last_insert_id = $this->db->insertID();
return ["info"=>$last_insert_id,"err"=>""];
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
} catch (\Exception $e) {
return ["info"=>"","err"=>'An error occurred: ' . $e->getMessage()];
}
}
public function updateData($table, $data, $where)
{
try {
$this->db->table($table)->update($data, $where);
$affected_rows = $this->db->affectedRows();
return ["info"=>$affected_rows." Affected","err"=>""];
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
} catch (\Exception $e) {
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
}
}
}
?>

96
app/Models/HomeModel.php Normal file
View File

@ -0,0 +1,96 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class HomeModel extends Model
{
public function customers($where) {
$query = $this->db->table('customers');
$totalCustomers = $query->where($where)->countAll();
$activeCustomers = $query->where($where)->countAllResults();
$where['DATE(created_on)'] = date('Y-m-d');
$todayCustomers = $query->where($where)->countAllResults();
if ($totalCustomers > 0) {
$customer['percentage'] = ($activeCustomers / $totalCustomers) * 100;
} else {
$customer['percentage'] = 0;
}
$customer['total'] = $totalCustomers;
$customer['active'] = $activeCustomers;
$customer['today'] = $todayCustomers;
return $customer;
}
// public function invoice() {
// if (date('m') <= 3) {
// $invoice['financial_year'] = (date('Y')-1) . '-' . date('Y');
// $start_date = (date('Y')-1).'-04-01';
// $end_date = date('Y').'-03-31';
// } else {
// $invoice['financial_year'] = date('Y') . '-' . (date('Y') + 1);
// $start_date = date('Y').'-04-01';
// $end_date = (date('Y')+1).'-03-31';
// }
// $date_where = ['DATE(created_on)' => date('Y-m-d'),'isactive'=>1];
// $date_query = $this->db->table('invoice')->where($date_where)->countAllResults();
// $month_where = ['MONTH(created_on)' => date('m'),'isactive'=>1];
// $month_query = $this->db->table('invoice')->where($month_where)->countAllResults();
// $fin_year_where = ['DATE(created_on) >= ' => $start_date , 'DATE(created_on) <= ' => $end_date,'isactive'=>1];
// $fin_year_query = $this->db->table('invoice')->where($fin_year_where)->countAllResults();
// $invoice['today'] = $date_query;
// $invoice['month'] = $month_query;
// $invoice['year'] = $fin_year_query;
// return $invoice;
// }
// public function schemes(){
// $query = $this->db->table('category AS C')
// ->select('C.id,C.name,LEFT(C.name, 1) AS first_letter, COUNT(S.customer_id) AS count')
// ->join('subscription AS S', 'C.id = S.scheme_id', 'left')
// ->where(['C.isactive'=>1,'C.business_id'=>1])
// ->groupBy('C.id, S.scheme_id');
// $results = $query->get()->getResultArray();
// return $results;
// }
// public function expiring_membership_list(){
// $now = date('Y-m-d');
// $last30days = date('Y-m-d', strtotime('+30 days'));
// return $this->db->table('subscription as S')
// ->join('customers as C', 'C.customer_id = S.customer_id', 'left')
// ->join('books as BK', 'BK.book_id = S.scheme_id', 'left')
// ->join('book_categories as BC', 'BC.book_id = S.scheme_id', 'left')
// ->join('category as CM', 'CM.id = BC.category_id', 'left')
// ->select('CM.name, CONCAT(C.first_name, " ", C.last_name) as customer_name, C.email as customer_email, C.mobile_no as customer_mobile, S.sub_id, S.scheme_id, S.customer_id, S.business_id, S.to_subscription, S.from_subscription, BK.title, BK.book_id,DATEDIFF(S.to_subscription, CURDATE()) as countdays,DATE_FORMAT(S.to_subscription, "%d-%m-%Y") as to_subscription_date_format')
// ->where('S.to_subscription >=', $now)
// ->where('S.to_subscription <=', $last30days)
// // ->where('BC.category_id', 5)
// ->where('LOWER(CM.name)', strtolower("Membership"))
// ->orderBy('S.to_subscription', 'ASC')
// ->groupBy('S.sub_id')
// ->get()
// ->getResultArray();
// }
// public function book_published_list(){
// $now = date('Y-m-d');
// $oneMonthAgo = date('Y-m-d', strtotime($now . ' -1 month'));
// return $this->db->table('books as B')
// ->select("B.book_id, B.title, B.created_on, B.publisher, B.author, B.publication_date, DATE_FORMAT(B.publication_date, '%d-%m-%Y') as publication_date_format, GROUP_CONCAT(CM.name, ',') as categories")
// ->join('book_categories as BC', 'BC.book_id = B.book_id and BC.isactive = 1', 'left')
// ->join('category as CM', 'BC.category_id = CM.id', 'left')
// ->where('B.created_on >=', $oneMonthAgo)
// ->where('B.created_on <=', $now)
// ->where('B.isactive', 1)
// ->orderBy('B.publication_date', 'DESC')
// ->groupBy('B.book_id')
// ->get()
// ->getResultArray();
// }
}

303
app/Models/InvoiceModel.php Normal file
View File

@ -0,0 +1,303 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class InvoiceModel extends Model
{
protected $table = 'receipt';
protected $primaryKey = 'receipt_id';
// protected $allowedFields = ['invoice_id','invoice_number','doner_id','invoice_date','event_id','business_id','created_on','business_id'];
protected $allowedFields = ['receipt_id', 'receipt_number', 'doner_id','notes','amount', 'payment_mode', 'business_id', 'created_on', 'created_by', 'updated_on', 'updated_by','isactive', 'payment_ref_no', 'receipt_date','causes_id'];
public function saveInvoiceItemDetails($data){
$i = 0;
$statement = [];
foreach ($data as $row) {
$id = isset($row['invoice_child_id']) ? $row['invoice_child_id'] : '';
if($id != ''){
unset($row['invoice_child_id']); // Remove the id from the data to avoid updating it
unset($row['created_by']); // bcoz here data are Updating here.
$this->db->table('invoiceitems')->where('invoice_child_id', $id)->update($row);// Update the row with the specified id
$affectedRows = $this->db->affectedRows();
$statement[$i] = "Invoice Item - ".$id." ".$affectedRows ? " Updated":" Not Updated";
}else{
unset($row['updated_by']); // bcoz here data are inserting here.
$this->db->table('invoiceitems')->insert($row);
$insertID = $this->db->insertID();
$statement[$i] = "Invoice Item - ".$insertID." Inserted";
}
}
return $statement;
}
public function inactiveMissingInvoiceItemDetails($where,$missingValues){
$dataToUpdate = ['isactive' => 0];
$this->db->table('invoiceitems')->where($where)->whereIn('invoice_child_id',$missingValues)->update($dataToUpdate);
}
public function updateData($table, $data, $where)
{
$this->db->table($table)->update($data, $where);
$affected_rows = $this->db->affectedRows();
return $affected_rows;
}
public function getSubscriptionInvoiceDetail($where)
{
$result = $this->getJoinedData($where);
// print_r($result);die;
if(!empty($result)){
foreach ($result as $i => $item) {
$invoiceId = $item['invoice_id'];
$scheme_name = [];
$from_subscription = [];
$to_subscription = [];
$invoiceItems = $this->getInvoiceItems($invoiceId,'');
foreach ($invoiceItems as $j => $child) {
if ($child->category_name == 'Membership') {
$scheme_name[] = $child->title;
$from_subscription[] = ($j == 0 && !empty($child->from_subscription) && $child->from_subscription !== null) ? date('d/m/Y', strtotime($child->from_subscription)) : "";
$to_subscription[] = ($j == 0 && !empty($child->to_subscription) && $child->from_subscription !== null ) ? date('d/m/Y', strtotime($child->to_subscription)) : "";
}
}
$result[$i]['scheme_name'] = !empty($scheme_name) ? implode(", ", $scheme_name) : '';
$result[$i]['from_subscription'] = !empty($from_subscription) ? implode(" ", $from_subscription) : '';
$result[$i]['to_subscription'] = !empty($to_subscription) ? implode(" ", $to_subscription) : '';
$result[$i]['invoice_items_details'] = $invoiceItems;
}
}
return $result;
}
public function getJoinedData($where)
{
return $this->db->table($this->table.' as I' )
->join('customers as C', 'C.doner_id = I.doner_id', 'left')
->join('Campaign as E', 'E.Campaign_id = I.event_id', 'left')
->join('business as B', 'B.business_id = I.business_id', 'left')
->join('users as U1', 'U1.user_id = I.created_by', 'left')
->join('users as U2', 'U2.user_id = I.updated_by', 'left')
->select('I.invoice_id, (C.first_name," ",C.last_name) as customer_name , I.business_id, I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name, I.updated_on, I.updated_by,concat(U2.first_name," ",U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile')
->where($where)
->orderBy('invoice_id', 'DESC')
->get()
->getResultArray();
// I.shipping_address_id, I.billing_address_id,
}
public function getDetailForApproveNotifications($where)
{
$result = $this->getJoinedData($where);
if(!empty($result)){
foreach ($result as $object) {
$invoiceId = $object['invoice_id'];
$items = $this->getInvoiceItems($invoiceId,'');
}
}else{
$items = [];
}
$data['invoice'] = $result;
$data['item'] = $items;
return $data;
}
public function getData($table, $where = null)
{
$query = $this->db->table($table);
if ($where) {
$query->where($where);
}
return $query->get()->getResult();
}
public function getInvoiceData($id)
{
// Fetch invoice data
return $this->db->table('receipt')
->where('receipt_id', $id)
->join('customers as C','C.doner_id= receipt.doner_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('B.title ,B.business_logo,B.terms,B.address,B.city,B.state,B.postal_code,B.email,B.mobile_no, B.pan_no, B.org_reg_no')
->get()
->getResult();
}
// // this function Also Used For Approve Notification.
// public function getInvoiceItems($id,$stringflag)
// {
// if ($stringflag == 'groupby') {
// $select = 'invoiceitems.*, B.*, GROUP_CONCAT(C.name SEPARATOR \',\') as name';
// $group_by = 'invoiceitems.invoice_child_id';
// } else {
// $select = 'invoiceitems.*, B.*, C.name as category_name';
// $group_by = "";
// }
// $data = $this->db->table('invoiceitems')
// ->where(['invoice_id' => $id, 'invoiceitems.isactive' => 1])
// ->join('causes as B', 'B.causes_id = invoiceitems.product', 'left')
// ->select($select)
// ->groupBy($group_by) // Fixed the variable name here
// ->get()
// ->getResult();
// //->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order
// //->limit(1,0)
// // print_r($this->db->getLastQuery());die;
// // print_r($data);die("ends -- here");
// return $data;
// }
// public function getMembershipListForCustomer($category, $id)
// {
// $data = $this->db->table('subscription as S')
// ->join('customers as C', 'C.doner_id = S.doner_id', 'left')
// ->join('category as CM', 'CM.id = S.scheme_id', 'left')
// ->join('book_categories as BC', 'BC.category_id = S.scheme_id', 'left')
// ->join('causes as BK', 'BC.causes_id = BK.causes_id', 'left')
// ->select('S.doner_id, CONCAT(C.first_name, " ", C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription, S.created_on, CM.name, BK.title, BK.causes_id')
// ->where('CM.name', strtolower($category))
// ->where('S.doner_id', $id)
// ->groupBy('S.sub_id')
// ->orderBy('S.created_on', 'ASC')
// ->get()
// ->getResultArray();
// return $data;
// }
public function getProductImgs($productId)
{
$data = $this->db->table('book_images')
->where(['causes_id' => $productId])
// ->join('causes as B', 'B.causes_id = invoiceitems.product', 'left')
// ->join('book_images as BI', 'BI.causes_id = invoiceitems.product', 'left')
->select('book_images.*')
//->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order
//->limit(1,0)
->get()
->getResult();
// print_r($this->db->getLastQuery());
return $data;
}
public function getCategoryBooks()
{
return $this->db->table('causes')
->join('book_categories', 'book_categories.causes_id= causes.causes_id', 'left')
->join('category','category.id=book_categories.category_id')
->where('category.name', 'membership')
->get()
->getResult();
}
public function getNonMembershipCategoryBooks()
{
$data = $this->db->table('causes')
->select('causes.*')
->join('book_categories', 'book_categories.causes_id= causes.causes_id', 'left')
->join('category','category.id=book_categories.category_id')
->where('category.name !=', 'membership')
->groupBy('causes.causes_id')
->get()
->getResult();
return $data;
}
public function insertSubscriptionData($data)
{
return $this->db->table('subscription')->insert($data);
}
// ***********************REPORT**********************
public function get_general_invoice_data($f_date = null, $t_date = null)
{
// Fetch invoice data
$query = $this->db->table('invoice')
->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count')
->where('invoice.isactive', 1)
->where('invoice.invoice_type', 1)
->where('invoiceitems.isactive', 1);
// Add date range filter if provided
if ($f_date !== null && $t_date !== null) {
$query->where('invoice.invoice_date >=', $f_date)
->where('invoice.invoice_date <=', $t_date);
}
$result = $query->join('customers', 'customers.doner_id = invoice.doner_id', 'left')
->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
->join('causes', 'causes.causes_id = invoiceitems.product', 'left')
->groupBy('invoice.invoice_id') // Assuming invoice_id is the primary key of the invoice table
->get()
->getResult();
return $result;
}
public function get_mem_invoice_data($f_date = null, $t_date = null)
{
// Fetch invoice data
$query = $this->db->table('invoice')
->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count')
->where('invoice.isactive', 1)
->where('invoice.invoice_type', 2)
->where('invoiceitems.isactive', 1);
// Add date range filter if provided
if ($f_date !== null && $t_date !== null) {
$query->where('invoice.invoice_date >=', $f_date)
->where('invoice.invoice_date <=', $t_date);
}
$result = $query->join('customers', 'customers.doner_id = invoice.doner_id', 'left')
->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
->join('causes', 'causes.causes_id = invoiceitems.product', 'left')
->groupBy('invoice.invoice_id') // Assuming invoice_id is the primary key of the invoice table
->get()
->getResult();
return $result;
}
public function itemwise_report_data($f_date = null, $t_date = null)
{
// Fetch invoice data
$query = $this->db->table('invoice')
->select('invoice.*, causes.* , COUNT(invoiceitems.product) as item_count , sum(invoiceitems.product * invoiceitems.unit_price) as item_cost')
->where('invoice.isactive', 1)
->where('causes.isactive', 1);
// Add date range filter if provided
if ($f_date !== null && $t_date !== null) {
$query->where('invoice.invoice_date >=', $f_date)
->where('invoice.invoice_date <=', $t_date);
}
$result = $query->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
->join('causes', 'causes.causes_id = invoiceitems.product', 'left')
->groupBy('causes.causes_id')
->get()
->getResult();
return $result;
}
}

View File

@ -0,0 +1,186 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class NotificationModel extends Model
{
protected $table;
public function setCustomTable($tableName)
{
$this->table = $tableName;
}
// public function getTasksDueLastWeek()
// {
// $now = date('Y-m-d');
// $oneWeekAgo = date('Y-m-d', strtotime('-7 days', strtotime($now)));
// return $this->where('due_date >=', $oneWeekAgo)
// ->where('due_date <=', $now)
// ->findAll();
// }
public function getSubscriptionDueDetail($date){
// $now = date('Y-m-d');
// $lastWeek = date('Y-m-d', strtotime('+7 days'));
// $date_format = date('Y-m-d', $date);
return $this->db->table('subscription as S' )
->join('customers as C', 'C.customer_id = S.customer_id', 'left')
->join('category as CM', 'CM.id = S.scheme_id', 'left')
->join('business as B', 'B.business_id = S.business_id', 'left')
->join('book_categories as BC', 'BC.category_id = S.scheme_id', 'left')
->join('books as BK', 'BC.book_id = BK.book_id', 'left')
->select('concat("Your subscription going to expried in ",DATEDIFF(S.to_subscription, CURDATE())," days") as statement,DATEDIFF(S.to_subscription, CURDATE()) as countdays,CM.name,concat(C.first_name, " ", C.last_name) as customer_name,C.email as customer_email,C.mobile_no as customer_mobile,S.sub_id,S.scheme_id,S.customer_id,S.from_subscription,S.to_subscription,S.business_id,B.title as business_name,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.to_subscription,S.from_subscription,BK.title,BK.book_id')
// ->where('S.to_subscription >=', $now)->where('S.to_subscription <=',$lastWeek)
->where('S.to_subscription =',date('Y-m-d', strtotime($date)))
->groupBy('S.sub_id')
->get()->getResultArray();
}
public function getTemplateDetails(){
return $this->db->table('templates as T' )
->join('users as U1', 'U1.user_id = T.created_by', 'left')
->join('users as U2', 'U2.user_id = T.updated_by', 'left')
->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,T.isactive')
->get()->getResultArray();
}
public function saveDetails($data,$pk_name,$t_name){
$id = $data[$pk_name];
if($id != ''){
unset($data[$pk_name]); // Remove the id from the data to avoid updating it
unset($data['created_by']); // bcoz here data Updating here.
if ($this->db->table($t_name)->where($pk_name, $id)->update($data)) {
$affectedRows = $this->db->affectedRows();
$statement['success'] = ucfirst($t_name).' has been updated successfully.';
$statement['error'] = "";
$statement['log'] = ucfirst($t_name).": has been updated successfully. Updated ".$pk_name." = " .$id." Affected Rows = ".$affectedRows;
} else {
$statement['success'] = "";
$statement['error'] = ucfirst($t_name).' update failed. Please try again.';
$statement['log'] = ucfirst($t_name).": Err Failed to update ID = " .$id ;
}
}else{
unset($data['updated_by']);
if ($this->db->table($t_name)->insert($data)) {
$insertID = $this->db->insertID();
$statement['success'] = ucfirst($t_name).' has been Inserted successfully.';
$statement['error'] = "";
$statement['log'] = ucfirst($t_name).": has been added successfully. Inserted ID = " .$insertID ;
} else {
$statement['success'] = "";
$statement['error'] = ucfirst($t_name)." could not be added. Please try again..";
$statement['log'] = ucfirst($t_name).": Err could not be added. Please try again.";
}
}
return $statement;
}
public function getCampaignDetails(){
$result = $this->db->table('notification_campaign as NC' )
->join('users as U1', 'U1.user_id = NC.created_by', 'left')
->join('users as U2', 'U2.user_id = NC.updated_by', 'left')
->join('templates as T', 'T.template_id = NC.template_id', 'left')
->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,NC.scheduled_time')
->get()->getResultArray();
if (!empty($result)) {
foreach ($result as $i => $item) {
$group_id = unserialize($item['group_id']);
$group_names = [];
$group_query = [];
foreach ($group_id as $j) {
$cg_data = $this->db->table('customer_groups as CG')
->select('CG.group_id, CG.group_name,CG.group_query, CG.isactive')
->where(['CG.isactive' => 1, 'CG.group_id' => $j])
->get()
->getRowArray();
if ($cg_data) {
$group_names[] = $cg_data['group_name'];
$group_query[] = $cg_data['group_query'];
// array_push($group_sql, $cg_data['group_query']);
}
}
$result[$i]['group_name'] = !empty($group_names) ? implode(", ", $group_names) : '';
$result[$i]['customer_group'] = !empty($group_query) ? $this->customerGroupQueryExecution($group_query) : '';
$result[$i]['customer_group_count'] = !empty($result[$i]['customer_group']) ? count($this->customerGroupQueryExecution($group_query)) : 0;
}
}
return $result;
}
public function customerGroupQueryExecution($queries){
$results = [];
// Execute the queries
foreach ($queries as $query) {
if(!empty($query)){
$queryResult = $this->db->query($query)->getResult();
$results[] = $queryResult;}
}
// echo "<pre>";
// print_r($results);
// echo "</pre>";
// Create a new array to store the unique results based on customer_id
$uniqueCustomers = array();
foreach ($results as $innerArray) {
foreach ($innerArray as $customer) {
$customerId = $customer->customer_id;
// Check if the customer_id already exists in $uniqueCustomers
if (!isset($uniqueCustomers[$customerId])) {
$uniqueCustomers[$customerId] = $customer;
}
}
}
// Convert the $uniqueCustomers array back to a numerically indexed array
$uniqueCustomers = array_values($uniqueCustomers);
return $uniqueCustomers;
// echo "<pre>";
// print_r($uniqueCustomers);
// echo "</pre>";
// die;
}
public function getExpDate()
{
$db = \Config\Database::connect();
$query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDAT'";
$result = $db->query($query)->getResultArray();
if (isset($result[0]["group_query"])) {
return $result[0]["group_query"];
} else {
error_log('group_query is not available in getExpDate()');
return ;
}
}
public function getTempName()
{
$db = \Config\Database::connect();
$query = "SELECT * FROM templates WHERE template_name = '".EXPIRAY_NOTIFY_TEMPLATE_EMAIL."'";
// print_r($query);die;
$result = $db->query($query)->getResultArray();
if (isset($result)) {
return $result;
} else {
error_log('group_query is not available in getExpDate()');
return $query;
}
}
}

170
app/Models/SchemeModel.php Normal file
View File

@ -0,0 +1,170 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class SchemeModel extends Model
{
protected $table = 'books';
protected $primaryKey = 'book_id';
protected $allowedFields = ['book_id ','title','sku','description','price','features','duration','business_id','updated_by','category','isactive','created_by'];
public function insertScheme($data)
{
return $this->insert($data);
}
public function getSchemeNamesAndDurationsByBusiness($business_id)
{
$builder = $this->builder();
$builder->select('books.book_id, books.title, books.price, books.duration, category.name as category_name');
$builder->join('book_categories', 'book_categories.book_id = books.book_id', 'left');
$builder->join('category', 'category.id = book_categories.category_id', 'left');
$builder->where('books.business_id', $business_id);
$builder->where('category.name', 'membership');
$builder->where('books.isactive', 1);
$query = $builder->get();
$schemes = [];
foreach ($query->getResult() as $row) {
$schemes[$row->book_id] = [
'title' => $row->title,
'price' => $row->price,
'duration' => $row->duration,
'category_name' => $row->category_name,
'book_id'=>$row->book_id
];
}
return $schemes;
}
public function getBooksAndImagesByBookId($id)
{
$builder = $this->db->table('books');
$builder->select('books.*, book_images.img_name, book_images.is_cover, book_images.type');
$builder->join('book_images', 'book_images.book_id = books.book_id', 'left');
$builder->where('books.book_id', $id);
$query = $builder->get();
return $query->getResultArray();
}
public function insertImage($imageData)
{
return $this->db->table('book_images')->insert($imageData);
}
// public function getSchemeDuration($schemeId)
// {
// $query = $this->select('duration')
// ->where('scheme_id', $schemeId)
// ->get();
// if ($query->getNumRows() === 1) {
// $row = $query->getRow();
// return $row->duration;
// } else {
// return null;
// }
// }
public function getSchemeNamesByBusiness($business_id)
{
$builder = $this->builder();
$builder->select('scheme_id, scheme_name');
$builder->where('business_id', $business_id);
$query = $builder->get();
$schemes = [];
foreach ($query->getResult() as $row) {
$schemes[$row->scheme_id] = $row->scheme_name;
}
return $schemes;
}
public function getSchemeNames()
{
$builder = $this->builder();
$builder->select('scheme_id, scheme_name');
$query = $builder->get();
$schemes =[];
foreach ($query->getResult() as $row) {
$schemes[$row->scheme_id] = $row->scheme_name;
}
return $schemes;
print_r($schemes);die();
}
public function getSchemeNameById($schemeId)
{
// Query the database to retrieve the scheme name by ID
$builder = $this->db->table('schemes');
$builder->select('scheme_name');
$builder->where('scheme_id', $schemeId);
$query = $builder->get();
// Check if a record was found
if ($query->getNumRows() > 0) {
$row = $query->getRow();
return $row->scheme_name;
} else {
return null; // Return null if no scheme with the given ID is found
}
}
public function getAllSchemes()
{
return $this->findAll();
}
public function updateImage($schemeId, $imageData)
{
$builder = $this->db->table('book_images');
$builder->set($imageData);
$builder->where('book_id', $schemeId);
$builder->update();
}
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 inactiveMissingDetails($table_name,$dataToUpdate,$where = null,$whereIn = null)
{
$this->db->table($table_name);
$query = $this->db->table($table_name);
if ($where) {
$query->where($where);
}
if ($whereIn) {
$query->whereIn($whereIn[0], $whereIn[1]);
}
return $query->update($dataToUpdate);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class SettingsModel extends Model
{
protected $table = 'settings';
protected $primaryKey = 'setting_id';
protected $allowedFields = ['setting_id','site_name','site_title','favicon','logo','terms_service','footer_about','admin_email','mobile','copyright','pagination_limit','site_info','about_info','mail_protocol','mail_title','mail_host','mail_port','mail_encryption','mail_username','mail_password','currency','country','isactive','business_id'];
public function saveData($data, $id = null)
{
if ($id === null) {
// Insert new record
return $this->insert($data);
} else {
// Update existing record
return $this->update($id, $data);
}
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class SubscriptionModel extends Model
{
protected $table = 'subscription';
protected $primaryKey = 'sub_id';
protected $allowedFields = ['sub_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','created_by','business_id'];
public function getAllSubscribersWithNames($where)
{
$builder = $this->db->table('subscription');
$builder->select('subscription.*, books.title, CONCAT(customers.first_name, " ", customers.last_name) as customer_name');
$builder->join('books', 'books.book_id = subscription.scheme_id');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->where($where);
return $builder->get()->getResultArray();
}
public function getCustomerNameBySchemeName($schemeName)
{
$builder = $this->db->table('subscription');
$builder->select('customers.first_name, customers.last_name');
$builder->select('customer_addresses.address_1, customer_addresses.address_2');
$builder->join('customer_addresses', 'customer_addresses.customer_id = subscription.customer_id');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
$builder->where('schemes.scheme_name', $schemeName);
$query = $builder->get();
if ($query->getNumRows() > 0) {
$row = $query->getRow();
return $row->first_name . ' ' . $row->last_name;
} else {
return 'Customer not found'; // You can return a default value or handle the case where the customer is not found.
}
}
public function getCustomerAddressesBySchemeName($schemeName)
{
$builder = $this->db->table('subscription');
$builder->select('CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state,customer_addresses.postal_code, customer_addresses.address_type,business.address,business.city,business.state,business.postal_code,business.country');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->join('customer_addresses', 'customer_addresses.customer_id = subscription.customer_id');
$builder->join('business', 'business.business_id = subscription.business_id');
$builder->join('books', 'books.book_id = subscription.scheme_id');
$builder->where('books.title', $schemeName);
$query = $builder->get();
$addresses = [];
if ($query->getNumRows() > 0) {
foreach ($query->getResult() as $row) {
$addressType = $row->address_type;
$addresses[$addressType] = [
'customer_name' => $row->customer_name,
'address_1' => $row->address_1,
'address_2' =>$row->address_2,
'city' => $row->city,
'state' => $row->state,
'postal_code'=>$row->postal_code,
];
}
} else {
$addresses = [
'billing' => [
'customer_name' => 'Customer not found',
'address_line' => 'Billing Address not found',
'city' => '',
'state' => '',
],
'shipping' => [
'customer_name' => 'Customer not found',
'address_line' => 'Shipping Address not found',
'city' => '',
'state' => '',
],
];
}
return $addresses;
}
public function getAllCustomerDetailsBySchemeName($schemeName)
{
$builder = $this->db->table('subscription');
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title,business.address,business.city,business.state,business.postal_code,books.title,from_subscription,to_subscription');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
$builder->join('business', 'business.business_id = subscription.business_id');
$builder->join('books', 'books.book_id = subscription.scheme_id');
$builder->where('books.title', $schemeName);
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
// Fetch the query result
$query = $builder->get();
$customerDetails = [];
if ($query->getNumRows() > 0) {
$currentCustomerID = null;
$shippingAddress = [];
foreach ($query->getResultArray() as $row) {
$customerID = $row['customer_id'];
if ($currentCustomerID !== $customerID) {
// New customer, add the previous customer's details (if any)
if (!empty($shippingAddress)) {
$customerDetails[] = $shippingAddress;
}
// Start a new customer's details
$shippingAddress = [
'customer_name' => $row['customer_name'],
'address_1' => $row['address_1'],
'address_2' => $row['address_2'],
'mobile_no'=>$row['mobile_no'],
'city' => $row['city'],
'state' => $row['state'],
'postal_code' => $row['postal_code'],
'address' => $row['address'],
'city' => $row['city'],
'state' => $row['state'],
'postal_code' => $row['postal_code'],
'title' => $row['title'],
'to_subscription'=>$row['to_subscription'],
'title'=>$row['title'],
];
$currentCustomerID = $customerID;
}
}
// Add the last customer's details (if any)
if (!empty($shippingAddress)) {
$customerDetails[] = $shippingAddress;
}
}
return $customerDetails;
}
}

22
app/Models/UsersModel.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class UsersModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
protected $allowedFields = ['user_id','user_name','email','first_name','last_name','password','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','created_by','updated_by'];
public function saveData($data, $id = null)
{
if ($id === null) {
// Insert new record
return $this->insert($data);
} else {
// Update existing record
return $this->update($id, $data);
}
}
}

0
app/ThirdParty/.gitkeep vendored Normal file
View File

View File

@ -0,0 +1,66 @@
<!-- plugin css -->
<link href="<?= base_url()."public/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css" ?>" rel="stylesheet" type="text/css" />
<!-- third party css -->
<link href="<?= base_url()."public/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-select-bs4/css//select.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<!-- third party css end -->
<!-- App css -->
<link href="<?= base_url()."public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url()."public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url()."public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url()."public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url()."public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<!-- Begin page -->
<div id="wrapper"> <!-- close div on footer.php -->
<!-- ========== Left Sidebar Start ========== -->
<div class="left-side-menu">
<!-- LOGO -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
</div>
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Name</th>
<th>Author</th>
<th>Category</th>
<th>Language</th>
<th>Year Of Release</th>
<th>Price of the Book</th>
<th>Description</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shipping Label Template</title>
<style>
body{
font-family:Helvetica!important;
line-height:24px;
color:#000!important;
}
.invoice {
width: 4in;
/* height: 6in; */
margin: 20px auto;
border: 1px solid #000;
padding:15px;
box-sizing: border-box;
}
.header {
text-align: center;
background:#fff!important;
}
.business-logo {
max-width:175px;
height: auto;
width:100%;
}
.bill-details {
margin-bottom: 20px;
}
.customer-details {
margin-top: 20px;
}
.row {
clear: both;
}
</style>
</head>
<body>
<?php
foreach ($invoiceData as $value) :
?>
<div class="invoice">
<div class="bill-details">
<?= $value->customer_name ?>
<?= $value->customer_bill_address ?>
<?= $value->customer_bill_city ?>&nbsp;<?= $value->customer_bill_state ?>
<?= $value->customer_bill_postal_code ?>
<?= $value->customer_bill_country ?>
</div>
<div class="header">
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"><br> -->
<div style="float:left; width:80px;margin-right:10px;"><img src="<?= base_url('public/uploads/vijayabharathampdf.png') ?>" alt="Business Logo" class="business-logo"/></div>
<div style="text-align:left;font-size:12px;">From<br/>
<?= $value->address ?>,<br><?= $value->city ?>, <?= $value->state ?>,
<?= $value->postal_code ?>
</div>
</div>
<?php endforeach; ?>
</body>
</html>

View File

@ -0,0 +1,202 @@
<!DOCTYPE html>
<html style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', Helvetica Neue, Roboto;font-size: 15px;width: 600px;margin: 0 auto;text-align: center;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-rendering: optimizeLegibility;">
<body style="background-color: rgb(189 194 199);">
<!-- HEADER: MENULOGO + MENUCONTENT SECTION -->
<header style="padding: .4rem 0rem 0rem;">
<div style="padding: 0rem 2rem;">
<div style="padding : 15px 35px;
background-color : rgb(255,255,255);
border-radius : 5px 5px 0px 0px;
border-width : 2px 0px;
border-style : solid hidden;
border-top-color : rgb(104,104,104); border-right-color : initial;
border-bottom-color : rgb(104,104,104); border-left-color : initial;" align="center">
<img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png"><br>
</div>
</div>
<div style="padding: 0rem 2rem;text-align: center;">
<div style="padding : 15px 35px; background-color : rgb(249,249,249); ">
<div align="center">
<h2><span>Thanks for your Order</span></h2>
<div>
<p style="padding : 35px 0px 0px; ">
<span style="font-size : 24px; ">Order #<?= $invoice_serial_number ? $invoice_order_number.'('.$invoice_serial_number.')' : $invoice_order_number ; ?>.</span><br>
</p>
<p style="padding : 10px 0px 0px; ">
<span style="font-size : 20px; ">Hi <?= $recipient_name; ?>, Thank you for your purchase.</span><br>
</p>
<p style="padding : 10px 0px 0px; ">
<span style="font-size : 20px; ">We are processing your order.</span><br>
</p>
<div style="width : 204px;">
<a href="https://vijayabharathambooks.com" style="display : block; text-decoration : none; background-color : rgb(244,105,46);
line-height : 44px; min-height : 44px; color : rgb(238,238,238); " target="_blank">
<span style="color : rgb(238, 238, 238); ">VIEW YOUR ORDER</span><br>
</a>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- CONTENT -->
<section style="padding: 0rem 2rem;">
<div style="padding : 20px 35px; background-color : rgb(255,255,255); ">
<?php if (!empty($item)) {
foreach ($item as $ii) { ?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="30%">
<a style="color: rgba(221, 72, 20, 1);" href="https://vijayabharathambooks.com/books/pasumpon-thevar-potriya-rss/" target="_blank"><img src="https://vijayabharathambooks.com/wp-content/uploads/2023/01/front-1-300x450.jpg" alt="Image" style="max-width: 100%; height: auto; display: block;"></a><br>
</td>
<td valign="middle" width="70%" style="padding:16px;">
<div><a style="color: rgba(221, 72, 20, 1);" href="https://vijayabharathambooks.com/books/pasumpon-thevar-potriya-rss/" target="_blank">
<span style="font-size : 15px; margin : 0px; padding : 0px; font-weight : 400; line-height : 18.2px; "><?= $ii->title; ?></span>
</a><br>
</div>
<div>
<p style="text-align:left;">
<span style="color : rgb(60, 67, 74); "><span style=" font-weight : 400; line-height : 18.2px; ">x <?= $ii->quantity; ?></span></span>
<span style="color : rgb(60, 67, 74); float:right; "><span style="text-align : right; white-space : nowrap; font-weight : 400; line-height : 18.2px; ">&nbsp;<?= $ii->subtotal; ?></span></span>
</p>
</div>
</td>
</tr>
</table>
<?php }}else{?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="30%">
<a style="color: rgba(221, 72, 20, 1);" href="https://vijayabharathambooks.com/books/pasumpon-thevar-potriya-rss/" target="_blank"><img src="https://vijayabharathambooks.com/wp-content/uploads/2023/01/front-1-300x450.jpg" alt="Image" style="max-width: 100%; height: auto; display: block;"></a><br>
</td>
<td valign="middle" width="70%" style="padding:16px;">
<div><a style="color: rgba(221, 72, 20, 1);" href="https://vijayabharathambooks.com/books/pasumpon-thevar-potriya-rss/" target="_blank">
<span style="font-size : 15px; margin : 0px; padding : 0px; font-weight : 400; line-height : 18.2px; ">பசும்பொன் தேவர் போற்றிய ஆர்.எஸ்.எஸ்<small> (#VB-65)</small>
</span>
</a><br>
</div>
<div>
<p style="text-align:left;">
<span style="color : rgb(60, 67, 74); "><span style=" font-weight : 400; line-height : 18.2px; ">x 1</span></span>
<span style="color : rgb(60, 67, 74); float:right; "><span style="text-align : right; white-space : nowrap; font-weight : 400; line-height : 18.2px; ">&nbsp;125</span></span>
</p>
</div>
</td>
</tr>
</table>
<?php } ?>
</div>
<div style="padding : 15px 35px; background-color : rgb(249,249,249); " align="center">
<div style="display: flex;justify-content: space-between;text-align: left;width: 100%;">
<div style="text-align: left; width: 48%;">
<div style=" width : 265px; line-height : 30px; ">
<p><span style="font-size : 20px; ">Payment Method</span><br>
</p>
</div>
<div style=" width : 265px; line-height : 22px; ">
<p>Paytm Payment Gateway<br> </p>
</div>
<div style=" width : 265px; line-height : 22px; ">
<p><span style="font-size : 20px; ">Shipment Method</span><br>
</p>
</div>
<div style=" width : 265px; line-height : 22px; ">
<p>Flexible Shipping<br> </p>
</div>
</div>
<div style="text-align: left; width: 26%;">
<div style=" color : rgb(68,68,68); line-height : 24px; ">
<div style="padding : 0px; border : 0px hidden; text-align : left; ">
<p>Subtotal<br></p>
</div>
<div style="padding : 0px; border : 0px hidden; text-align : left; ">
<p>Shipping<br></p>
</div>
</div>
<div style="font-size : 20px; font-weight : 400; color : rgb(68,68,68); line-height : 30px;">
<div style="padding : 0px; border : 0px hidden; text-align : left; ">
<p style="font-weight : 400;">Total<br></p>
</div>
</div>
</div>
<div style="text-align: left; width: 26%;">
<div style=" color : rgb(68,68,68); line-height : 24px; ">
<div style="padding : 0px; border : 0px hidden; text-align : right; ">
<p><span style="font-weight : 300;"><span></span>&nbsp;<?= $subtotal; ?></span><br></p>
</div>
<div style="padding : 0px; border : 0px hidden; text-align : right; ">
<p><span style=" font-weight : 300;"><span></span>&nbsp;<?= $tax; ?></span><br></p>
</div>
</div>
<div style="font-size : 20px; font-weight : 400; color : rgb(68,68,68); line-height : 30px;">
<div style="padding : 0px; border : 0px hidden; text-align : right;">
<p><span style="font-weight : 400;"><span></span>&nbsp;<?= $total_amount; ?></span><br></p>
<!-- float:right; -->
</div>
</div>
</div>
</div>
<div style="line-height:24px;text-align: left;font-size: 24px;color: #333;padding-top: 15px;">Note</div>
<div style="display: flex;justify-content: space-between;text-align: left;width: 100%;">
<p> A publisher manages the design, editing, and production process with the help of proofreaders, printers, and editors. Publishers make schedules for every stage of the process and work backward from the planned date for publication. They distribute promotional catalogs to libraries and booksellers. </p><br>
</div>
</div>
<div style="background-color: rgb(255, 255, 255);width: 100%;display:flex;text-align: left;">
<div style="width: 50%;padding-left: 2.5em;" >
<h1 style="font-size: 24px; color: #333;">Billing Address</h1>
<div style="font-weight : 300; color : rgb(68,68,68); line-height : 22px; ">
<p>
<span><?= $recipient_name; ?><br></span>
<span><?= $recipient_name; ?><br> </span>
<span><?= $recipient_name; ?><br> </span>
<span><?= $recipient_name; ?><br></span>
<span><?= $recipient_name; ?><br></span>
<span><a style="color : rgb(68,68,68); font-weight : 300; " target="_blank">+91<?= $recipient_name; ?></a><br></span>
<span><a style="color : rgb(68,68,68); font-weight : 300; " target="_blank"><?= $recipient_name; ?></a><br></span>
</p>
</div>
</div>
<div style="width: 50%;" >
<!-- Content for the right side -->
<h1 style="font-size: 24px; color: #333;">Shipping Address</h1>
<div style="text-align: left; font-weight : 300; color : rgb(68,68,68); line-height : 22px;">
<p>
<span><?= $recipient_name; ?><br></span>
<span>22/2, SriKrishna Apartments<br> </span>
<span>1st Street, Subramania Nagar, Kodambakkam<br> </span>
<span>CHENNAI 600024<br></span>
<span>Tamil Nadu<br></span>
<span><a style="color : rgb(68,68,68); font-weight : 300; " target="_blank"><?= $recipient_mobile;?></a><br></span>
<span><a style="color : rgb(68,68,68); font-weight : 300; " target="_blank"><?= $recipient_mobile;?></a><br></span>
</p>
</div>
</div>
</div>
</section>
<!-- FOOTER: DEBUG INFO + COPYRIGHTS -->
<footer style="padding: 0rem 2rem;text-align: center;">
<div style="background-color: rgba(62, 62, 62, 1);color: rgba(200, 200, 200, 1);padding: 25px 35px;">
<p style="display: block;margin-block-start: 1em;margin-block-end: 1em;margin-inline-start: 0px;margin-inline-end: 0px; text-align : center; line-height : 22px; padding: 20px 0px;color : rgb(245, 245, 245);">
<span style="font-size : 20px; line-height : 22px; ">Get in Touch<br></span>
</p>
<p style="display: block;margin-block-start: 1em;margin-block-end: 1em;margin-inline-start: 0px;margin-inline-end: 0px; text-align : center; line-height : 22px; padding: 20px 0px;">
<span style="color : rgb(245, 245, 245); ">
<span style="font-size : 12px; ">For any questions, please send an email to&nbsp;</span>
</span>
<span style="color : rgb(255, 255, 255); ">
<a style="font-size : 12px; color : rgb(255,255,255); " href="mailto:contact@vijayabharathambooks.com" target="_blank">contact@vijayabharathambooks.com</a>
</span><br>
</p>
<div style=" line-height : 22px; background-image : none; background-color : transparent; border-radius : 0px; border-width : 0px; border-style : hidden; ">
<p class="space" style="text-align : center; "><span style="font-size : 12px; "><a style="color : rgb(245,245,245); " href="https://vijayabharathambooks.com/privacy-policy/" target="_blank">Privacy Policy</a><span style="color : rgb(245, 245, 245); ">&nbsp; |&nbsp;&nbsp;</span><a style="color : rgb(245,245,245); " href="https://vijayabharathambooks.com/terms-conditions/" target="_blank">Terms &amp; Conditions</a></span><br>
</p>
</div>
</div>
</footer>
<br>
</body>
</html>

View File

@ -0,0 +1,135 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Confirm Email Alert</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url() . "public/uploads/default.ico" ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="card">
<div class="card-body p-4">
<div class="text-center w-75 m-auto">
<div class="auth-logo">
<a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span>
</a>
<a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span>
</a>
</div>
</div>
<div class="mt-3 text-center">
<svg version="1.1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 98 98" style="height: 120px;" xml:space="preserve">
<style type="text/css">
.st0 {
fill: #FFFFFF;
}
.st1 {
fill: #1abc9c;
}
.st2 {
fill: #FFFFFF;
stroke: #1abc9c;
stroke-width: 2;
stroke-miterlimit: 10;
}
.st3 {
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10;
}
</style>
<g i:extraneous="self">
<circle id="XMLID_50_" class="st0" cx="49" cy="49" r="49" />
<g id="XMLID_4_">
<path id="XMLID_49_" class="st1" d="M77.3,42.7V77c0,0.6-0.4,1-1,1H21.7c-0.5,0-1-0.5-1-1V42.7c0-0.3,0.1-0.6,0.4-0.8l27.3-21.7
c0.3-0.3,0.8-0.3,1.2,0l27.3,21.7C77.1,42.1,77.3,42.4,77.3,42.7z" />
<path id="XMLID_48_" class="st2" d="M66.5,69.5h-35c-1.1,0-2-0.9-2-2V26.8c0-1.1,0.9-2,2-2h35c1.1,0,2,0.9,2,2v40.7
C68.5,68.6,67.6,69.5,66.5,69.5z" />
<path id="XMLID_47_" class="st1" d="M62.9,33.4H47.2c-0.5,0-0.9-0.4-0.9-0.9v-0.2c0-0.5,0.4-0.9,0.9-0.9h15.7
c0.5,0,0.9,0.4,0.9,0.9v0.2C63.8,33,63.4,33.4,62.9,33.4z" />
<path id="XMLID_46_" class="st1" d="M62.9,40.3H47.2c-0.5,0-0.9-0.4-0.9-0.9v-0.2c0-0.5,0.4-0.9,0.9-0.9h15.7
c0.5,0,0.9,0.4,0.9,0.9v0.2C63.8,39.9,63.4,40.3,62.9,40.3z" />
<path id="XMLID_45_" class="st1" d="M62.9,47.2H47.2c-0.5,0-0.9-0.4-0.9-0.9v-0.2c0-0.5,0.4-0.9,0.9-0.9h15.7
c0.5,0,0.9,0.4,0.9,0.9v0.2C63.8,46.8,63.4,47.2,62.9,47.2z" />
<path id="XMLID_44_" class="st1" d="M62.9,54.1H47.2c-0.5,0-0.9-0.4-0.9-0.9v-0.2c0-0.5,0.4-0.9,0.9-0.9h15.7
c0.5,0,0.9,0.4,0.9,0.9v0.2C63.8,53.7,63.4,54.1,62.9,54.1z" />
<path id="XMLID_43_" class="st2" d="M41.6,40.1h-5.8c-0.6,0-1-0.4-1-1v-6.7c0-0.6,0.4-1,1-1h5.8c0.6,0,1,0.4,1,1v6.7
C42.6,39.7,42.2,40.1,41.6,40.1z" />
<path id="XMLID_42_" class="st2" d="M41.6,54.2h-5.8c-0.6,0-1-0.4-1-1v-6.7c0-0.6,0.4-1,1-1h5.8c0.6,0,1,0.4,1,1v6.7
C42.6,53.8,42.2,54.2,41.6,54.2z" />
<path id="XMLID_41_" class="st1" d="M23.4,46.2l25,17.8c0.3,0.2,0.7,0.2,1.1,0l26.8-19.8l-3.3,30.9H27.7L23.4,46.2z" />
<path id="XMLID_40_" class="st3" d="M74.9,45.2L49.5,63.5c-0.3,0.2-0.7,0.2-1.1,0L23.2,45.2" />
</g>
</g>
</svg>
<h3>Success !</h3>
<p class="text-muted mt-2"> A email has been send to <span class="font-weight-medium"><?= $mail_id; ?></span>.
Please check for an email from company and click on the included link to
reset your password. </p>
<a href="<?= base_url(); ?>" class="btn btn-block btn-primary waves-effect waves-light mt-3">Back to Home</a>
<!-- <a href="<?= $link; ?>" class="btn btn-block btn-primary waves-effect waves-light mt-3" target="_blank">Alternative So Click here</a> -->
</div>
</div> <!-- end card-body -->
</div>
<!-- end card -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>"></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
</body>
</html>

View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lock Screen </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= $favicon; ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="card">
<div class="card-body p-4">
<div class="text-center mb-4">
<div class="auth-logo">
<a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span>
</a>
<a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span>
</a>
</div>
</div>
<div class="text-center w-75 m-auto">
<img src="<?= $profile_picture; ?>" alt="user-image" class="rounded-circle avatar-lg img-thumbnail">
<h4 class="text-dark-50 text-center mt-3"><?= 'Hi ! '.$loggedin_person; ?></h4>
<p class="text-muted mb-4">Enter your password to access the <?= $loggedin_person_role; ?></p>
</div>
<form action="<?= base_url() . "unlock" ?>" method="post">
<div class="form-group mb-3">
<label for="password">Password</label>
<input class="form-control" type="password" required="" id="password" name="password" placeholder="Enter your password">
</div>
<?php if (isset($validationErrors)) : ?>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<p style="color: #f1556c!important;" class="mt-0" style><?= $validationErrors; ?></p>
</div>
</span>
<?php endif; ?>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary btn-block" type="submit"> Log In </button>
</div>
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<p class="text-muted">Not you? return <a href="<?= base_url(); ?>" class="text-primary font-weight-medium ml-1">Sign In</a></p>
</div> <!-- end col -->
</div>
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>" ></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>" ></script>
</body>
</html>

134
app/Views/auth_login.php Normal file
View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BigBambooBookPublish | BBBP </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url() . "public/uploads/default.ico" ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="card">
<div class="card-body p-4">
<div class="text-center w-75 m-auto">
<div class="auth-logo">
<a href="javascript: void(0);" class="logo logo-dark text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="80">
</span>
</a>
<a href="javascript: void(0);" class="logo logo-light text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="80">
</span>
</a>
</div>
<p class="text-muted mb-4 mt-3">Enter your email address and password to access admin panel.</p>
</div>
<!-- <form action=""> -->
<form action="<?= base_url() . "authenticate" ?>" method="post">
<div class="form-group mb-3">
<label for="emailaddress">Email address</label>
<input class="form-control" type="email" name="username" id="emailaddress" required placeholder="Enter your email" autocomplete="off">
</div>
<div class="form-group mb-3">
<!-- <a href="auth-recoverpw-2.html" class="text-muted float-right"><small>Forgot your password?</small></a> -->
<!-- <a href="<?= base_url()."auth_confirm_mail"; ?>" class="text-muted float-right"><small>Forgot your password?</small></a> -->
<a href="#" id="resetLink" class="text-muted float-right"><small>Forgot your password?</small></a>
<label for="password">Password</label>
<div class="input-group input-group-merge">
<input class="form-control" type="password" name="password" id="password" required placeholder="Enter your password" autocomplete="off">
<div class="input-group-append" data-password="false">
<div class="input-group-text">
<span class="password-eye"></span>
</div>
</div>
</div>
</div>
<!-- <div class="form-group mb-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-signin" checked>
<label class="custom-control-label" for="checkbox-signin">Remember me</label>
</div>
</div> -->
<?php if (isset($validationErrors)) : ?>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<p style="color: #f1556c!important;" class="mt-0" style><?= $validationErrors; ?></p>
</div>
</span>
<?php endif; ?>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary btn-block" type="submit"> Log In </button>
</div>
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<!-- <p> <a href="auth-recoverpw.html" class="text-muted ml-1">Forgot your password?</a></p> -->
<!-- <p class="text-muted">Don't have an account? <a href="auth-register.html" class="text-primary font-weight-medium ml-1">Sign Up</a></p> -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>"></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
<script>
$(document).ready(function() {
// Fetch email value and set it as href for the reset link
$('#emailaddress').on('input', function() {
var emailValue = $(this).val();
$('#resetLink').attr('href', 'auth_confirm_mail?email='+emailValue);
});
});
</script>
</body>
</html>

105
app/Views/auth_logout.php Normal file
View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Logout </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url() . "public/uploads/default.ico" ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap.min.css"?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app.min.css"?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css"?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-dark.min.css"?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css"?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="card">
<div class="card-body p-4">
<div class="text-center w-75 m-auto">
<div class="auth-logo">
<a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span><br/>
</a>
<a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/uploads/default.png" ?>" alt="" height="55">
</span><br/>
</a>
</div>
</div>
<div class="text-center">
<div class="mt-4">
<div class="logout-checkmark">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 161.2 161.2" enable-background="new 0 0 161.2 161.2" xml:space="preserve">
<path class="logout-path" fill="none" stroke="#d1dee4" stroke-miterlimit="10" d="M425.9,52.1L425.9,52.1c-2.2-2.6-6-2.6-8.3-0.1l-42.7,46.2l-14.3-16.4
c-2.3-2.7-6.2-2.7-8.6-0.1c-1.9,2.1-2,5.6-0.1,7.7l17.6,20.3c0.2,0.3,0.4,0.6,0.6,0.9c1.8,2,4.4,2.5,6.6,1.4c0.7-0.3,1.4-0.8,2-1.5
c0.3-0.3,0.5-0.6,0.7-0.9l46.3-50.1C427.7,57.5,427.7,54.2,425.9,52.1z"></path>
<circle class="logout-path" fill="none" stroke="#1abc9c" stroke-width="4" stroke-miterlimit="10" cx="80.6" cy="80.6" r="62.1"></circle>
<polyline class="logout-path" fill="none" stroke="#1abc9c" stroke-width="6" stroke-linecap="round" stroke-miterlimit="10" points="113,52.8
74.1,108.4 48.2,86.4 "></polyline>
<circle class="logout-spin" fill="none" stroke="#d1dee4" stroke-width="4" stroke-miterlimit="10" stroke-dasharray="12.2175,12.2175" cx="80.6" cy="80.6" r="73.9"></circle>
</svg>
</div>
</div>
<h3>See you again !</h3>
<p class="text-muted"> You are now successfully sign out. </p>
</div>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<p class="text-muted">Back to <a href="<?= base_url(); ?>" class="text-primary font-weight-medium ml-1">Sign In</a></p>
</div> <!-- end col -->
</div>
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>"></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
</body>
</html>

View File

@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Reset password</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url() . "public/uploads/default.ico" ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap-creative.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-creative.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-creative-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-creative-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<!-- <div class="col-md-8 col-lg-6 col-xl-5"> -->
<div class="col-md-8 col-lg-7 col-xl-5">
<div class="card">
<div class="card-body p-3">
<div class="text-center w-75 m-auto">
<p class="text-muted mb-4 mt-3">Enter your email address and we'll send you an email with instructions to reset your password.</p>
</div>
<form action="<?= base_url()."auth_reset_password_save"?>" method="post" role="form" class="parsley-examples">
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="emailaddress">Email : </label>
<div class="col-sm-10">
<input type="text" readonly class="form-control-plaintext" id="emailaddress" name="email" value="<?= $email ?>">
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="hori-pass1">Password<span class="text-danger">*</span></label>
<div class="input-group input-group-merge">
<input id="hori-pass1" name="password1" type="password" placeholder="Password" required class="form-control">
<!-- <div class="input-group-append" data-password="false">
<div class="input-group-text">
<span class="password-eye"></span>
</div>
</div> -->
</div>
</div>
<div class="form-group col-md-6">
<label for="hori-pass2">Confirm Password<span class="text-danger">*</span></label>
<div class="input-group input-group-merge">
<input data-parsley-equalto="#hori-pass1" type="password" required placeholder="Confirm Password" class="form-control" id="hori-pass2" name="password2">
<!-- <div class="input-group-append" data-password="false">
<div class="input-group-text">
<span class="password-eye"></span>
</div>
</div> -->
</div>
</div>
</div>
<?php if (isset($validationErrors)) : ?>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<p style="color: #f1556c!important;" class="mt-0" style><?= $validationErrors; ?></p>
</div>
</span>
<?php endif; ?>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary btn-block" type="submit"> Reset Password </button>
</div>
</div>
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<p class="text-muted">Back to <a href="<?= base_url(); ?>" class="text-primary font-weight-medium ml-1">Log in</a></p>
</div> <!-- end col -->
</div>
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>"></script>
<!-- Plugin js-->
<script src="<?= base_url() . "public/assets/libs/parsleyjs/parsley.min.js" ?>"></script>
<!-- Validation init js-->
<script src="<?= base_url() . "public/assets/js/pages/form-validation.init.js" ?>"></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
</body>
</html>

121
app/Views/book_form.php Normal file
View File

@ -0,0 +1,121 @@
<html>
<head>
</head>
<style>
/* CSS for the preview image */
.preview-image {
display: block;
/* Ensure the image is displayed as a block element */
width: 120px;
/* Set the desired width for passport size */
height: 160px;
/* Set the desired height for passport size */
object-fit: cover;
/* Maintain the aspect ratio and fill the container */
margin-top: 10px;
/* Add a top margin for spacing */
}
</style>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<?php endif; ?>
<form class="needs-validation" novalidate method="post" enctype="multipart/form-data"
action="<?= base_url() . "insert_books"; ?>">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="title" class="col-form-label">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="title" name="name" value="<?= isset($details[0]['name']) ? $details[0]['name'] : '' ?>" placeholder="Name of the Causes" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Description<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="publisher" name="description" placeholder="Description" value="<?= isset($details[0]['description']) ? $details[0]['description'] : '' ?>" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
</div>
<input type="hidden" id="causes_id" name="causes_id" placeholder="hidden for book id" value="<?= isset($details[0]['causes_id']) ? $details[0]['causes_id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
<?php if (!empty($details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="isactive" name="isactive" class="form-control"
<?= isset($details) && $details[0]['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit">Submit</button>
<button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button>
<a href="<?= base_url() . "book_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div><!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function() {
const coverPictureInput = documenxt.getElementById("cover_picture");
const imagePreviewContainer = document.querySelector(".image-previews");
coverPictureInput.addEventListener("change", function(event) {
// imagePreviewContainer.innerHTML = ""; // Clear previous previews
const selectedImages = Array.from(event.target.files);
selectedImages.forEach(function(image, index) {
const imageWrapper = document.createElement("div");
imageWrapper.classList.add("mr-3");
const imagePreview = document.createElement("img");
imagePreview.src = URL.createObjectURL(image);
imagePreview.classList.add("preview-image");
imagePreview.style.width = "120px"; // Set width as needed
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.classList.add("image-checkbox");
checkbox.checked = false; // Set default as unchecked
imageWrapper.appendChild(checkbox);
imageWrapper.appendChild(imagePreview);
imagePreviewContainer.appendChild(imageWrapper);
});
});
});
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script>
</body>
</html>

78
app/Views/book_list.php Normal file
View File

@ -0,0 +1,78 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="<?= base_url() . "add_causes/0"; ?>" class="btn btn-primary waves-effect"> <span> <i class="mdi mdi-book-plus"></i></span> Add Causes </a>
</div>
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="scroll-horizontal-datatable_new" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th hidden></th>
<th>Name</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($details as $row) :
if ($row['isactive']) {
$class = 'badge badge-soft-success';
$message = 'Active';
} else {
$class = 'badge badge-soft-danger';
$message = 'In-Active';
}
$edit_page_route = base_url() . "add_causes/" . $row['causes_id'];
?>
<tr>
<td hidden><?php echo $row['causes_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['description']; ?></td>
<td>
<a href="<?php echo $edit_page_route; ?>" class="edit-button"> <i class="ri-pencil-line"></i></a>
<a href="<?= base_url() . "delete_books/" . $row['causes_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->
<script>
$(document).ready(function() {
$('#scroll-horizontal-datatable_new').DataTable({
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options
});
});
</script>

139
app/Views/business_form.php Normal file
View File

@ -0,0 +1,139 @@
<html>
<head>
</head>
<style>
/* CSS for the preview image */
.preview-image {
display: block;
/* Ensure the image is displayed as a block element */
width: 120px;
/* Set the desired width for passport size */
height: 160px;
/* Set the desired height for passport size */
object-fit: cover;
/* Maintain the aspect ratio and fill the container */
margin-top: 10px;
/* Add a top margin for spacing */
}
</style>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p>
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_business"; ?>" id="myForm">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="bname" class="col-form-label">Organization Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="bname" name="bname" value="<?= isset($businesses['title']) ? $businesses['title'] : '' ?>" placeholder="Business Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="bmail" class="col-form-label">Organization Email<span class="text-danger">*</span></label>
<input type="email" class="form-control" name="bmail" value="<?= isset($businesses['email']) ? $businesses['email'] : '' ?>" placeholder="Email" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="bmobile" class="col-form-label">Organization PAN Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="pan_no" value="<?= isset($businesses['pan_no']) ? $businesses['pan_no'] : '' ?>" placeholder="PAN Number" required data-parsley-type="number" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="baddress" class="col-form-label">Organization Reg Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="org_reg_no" value="<?= isset($businesses['org_reg_no']) ? $businesses['org_reg_no'] : '' ?>" placeholder="Organization Register Number" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="bmobile" class="col-form-label">Organization Mobile Number<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="bmobile" value="<?= isset($businesses['mobile_no']) ? $businesses['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required data-parsley-type="number" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="baddress" class="col-form-label">Organization Address<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="baddress" value="<?= isset($businesses['address']) ? $businesses['address'] : '' ?>" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="baddress" class="col-form-label">80G <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="80G" value="<?= isset($businesses['80G']) ? $businesses['80G'] : '' ?>" placeholder="80G Tax Free" />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="bcity" class="col-form-label">City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bcity" value="<?= isset($businesses['city']) ? $businesses['city'] : '' ?>" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="bstate" class="col-form-label">State<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bstate" value="<?= isset($businesses['state']) ? $businesses['state'] : '' ?>" placeholder="State" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bzip" value="<?= isset($businesses['postal_code']) ? $businesses['postal_code'] : '' ?>" placeholder="Postal Code (Eg: Pincode)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-12">
<label for="bterms" class="col-form-label">Receipt Note</label>
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50"><?= isset($businesses['terms']) ? $businesses['terms'] : '' ?></textarea>
</div>
</div>
<?php if (!empty($businesses['business_logo'])) { ?>
<div class="form-group col-md-12">
<label for="bfile" class="col-form-label">Current Business Logo</label>
<img src="<?= base_url('public/uploads/' . $businesses['business_logo']) ?>" alt="Business Logo" class="preview-image" />
</div>
<?php } ?>
<div class="form-row">
<div class="form-group col-md-12">
<label for="bfile" class="col-form-label">File</label>
<input type="file" class="form-control" style="border: 0px !important;" id="bfile" name="bfile" value="<?= isset($businesses['business_logo']) ? $businesses['business_logo'] : null ?>" multiple />
</div>
</div>
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= isset($businesses['business_id']) ? $businesses['business_id'] : '' ?>" />
<?php if (!empty($businesses) && ($loggedin_person_role === 'sadmin')) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="bcheckbox" name="bcheckbox" class="form-control" <?= isset($businesses) && $businesses['isactive'] == 1 ? 'checked' : '' ?>>
<label for="bcheckbox"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">Submit</button>
<button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button><a href="<?= base_url() . "business_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div><!-- end row -->
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script>

View File

@ -0,0 +1,57 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<?php if($loggedin_person_role === 'sadmin'): ?>
<a href="<?= base_url()."new_bussiness/0"; ?>" class="btn btn-primary"><i class="ri-briefcase-4-fill"></i> Add Organization </a>
<?php endif; ?>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Business Name</th>
<th>Email</th>
<th>Mobile Number</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>File</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($businesses as $business) : ?>
<tr>
<td><?= $business['title']; ?></td>
<td><?= $business['email']; ?></td>
<td><?= $business['mobile_no']; ?></td>
<td><?= $business['address']; ?></td>
<td><?= $business['city']; ?></td>
<td><?= $business['state']; ?></td>
<td><?= $business['postal_code']; ?></td>
<td><?= $business['business_logo']; ?></td>
<td>
<a href="<?= base_url() . "new_bussiness/" . $business['business_id']; ?>" class="edit-button" title="Click to Edit Business"><i class="ri-pencil-line"></i></a>
<?php if($loggedin_person_role === 'sadmin'): ?>
<a href="<?= base_url() . "delete_business/" . $business['business_id']; ?>" class="delete-button" title="Click to Delete Business"><i class="ri-delete-bin-line"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->

View File

@ -0,0 +1,88 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="<?= base_url()."campaign_creation_form/0"; ?>" class="btn btn-primary"><i class="ri-file-edit-line"></i> Add campaign </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<table id="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th hidden></th>
<th>Campaign Name</th>
<th>Template Name</th>
<th>Group Name</th>
<th>Total Customer</th>
<th>Scheduled at</th>
<th>Created at</th>
<th>Created by</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<?php foreach ($campaign as $c) :
if ($c['isactive']) {
$class = 'badge badge-soft-success';
$message = 'Active';
} else {
$class = 'badge badge-soft-danger';
$message = 'In-Active';
}
$scheduled_date = date('d/m/Y', strtotime($c['scheduled_date']));
$scheduled_time = date('h:i A', strtotime($c['scheduled_time']));
?>
<tr>
<td hidden><?= $c['campaign_id']; ?></td>
<td><?= $c['campaign_name']; ?></td>
<td><?= $c['template_name']; ?></td>
<td><?= $c['group_name']; ?></td>
<td><?= $c['customer_group_count']; ?></td>
<td><?= $scheduled_date." ".$scheduled_time; ?></td>
<td><?= $c['formatted_created_on']; ?></td>
<td><?= $c['created_by_name']; ?></td>
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
<td>
<a href="<?= base_url()."campaign_creation_form/".$c['campaign_id']; ?>" class="edit-button" title="Click to Edit Campaign" ><i class="ri-pencil-line"></i></a>
<?php if ($c['isactive']) { ?> <a href="<?= base_url() . "campaign_creation_delete/".$c['campaign_id']; ?>" class="delete-button" title="Click to Delete Campaign" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div><!-- end row-->
<script>
$(document).ready(function() {
$('#scroll-horizontal-datatable_customer').DataTable({
"order": [
[0, "desc"]
] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options
});
});
</script>

View File

@ -0,0 +1,164 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<form class="parsley-examples" action="<?= base_url() . "campaign_creation_insert"; ?>" method="post" enctype="multipart/form-data" id="myForm">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="campaign_name" class="col-form-label">Campaign Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="campaign_name" name="campaign_name" value="<?= isset($campaign_details['campaign_name']) ? $campaign_details['campaign_name'] : '' ?>" placeholder="Campaign Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="group_id" class="col-form-label">Group<span class="text-danger"> *</span></label>
<!-- <select id="group_id" name="group_id[]" class="form-control select2-multiple" data-toggle="select2" multiple="multiple" data-placeholder="Choose ..." required> -->
<select id="group_id" name="group_id[]" class="form-control" multiple="multiple" required>
<option value="">Choose the Group</option>
<?php foreach ($group_details as $value) { ?>
<option value="<?php echo $value['group_id']; ?>"
<?php if (isset($campaign_details['group_id']) && in_array($value['group_id'], $campaign_details['group_id'])) echo "selected"; ?>>
<?php echo $value['group_name']; ?>
</option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="mode" class="col-form-label col-md-3">Mode<span class="text-danger"></span></label>
<div class="col-md-9 mt-1">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="emailRadio" name="mode" class="custom-control-input" value="Email" checked>
<label class="custom-control-label" for="emailRadio">Email</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="whatsappRadio" name="mode" class="custom-control-input" value="Whatsapp">
<label class="custom-control-label" for="whatsappRadio">Whatsapp</label>
</div>
</div>
</div>
<div class="form-group col-md-8">
<label for="scheduled" class="col-form-label">Scheduled Date/Time<span class="text-danger"></span></label>
<div class="row">
<div class="col-6">
<input class="form-control" type="date" name="scheduled_date" id="example-date" value="<?= isset($campaign_details['scheduled_date']) ? $campaign_details['scheduled_date'] : '' ?>">
</div>
<div class="col-6">
<input class="form-control" type="time" name="scheduled_time" id="example-time" value="<?= isset($campaign_details['scheduled_time']) ? $campaign_details['scheduled_time'] : '' ?>">
</div>
</div>
</div>
<div class="form-group col-md-12">
<label for="load_templateid" class="col-form-label">Template<span class="text-danger"> *</span></label>
<select id="load_templateid" name="template_id" class="form-control" required>
<option value="">Choose the Template</option>
<!-- <?php foreach ($template_details as $value) { ?>
<option value="<?php echo $value['template_id']; ?>" <?php if (isset($campaign_details['template_id']) && ($campaign_details['template_id'] === $value['template_id'])) echo "selected"; ?>>
<?php echo $value['template_name']; ?></option>
<?php } ?> -->
</select>
</div>
<!-- <div class="form-group col-md-12">
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
<textarea id="summernote-basic" name="templatemessage" class="form-control" rows="7">
<?php if(isset($campaign_details['message'])){ echo $campaign_details['message']; }else{ ?>
<h5>Hello {User}, </h5>
<p>Please, write text here!</p>
<?php } ?>
</textarea>
</div> -->
</div>
<input type="hidden" id="campaign_id" name="campaign_id" placeholder="hidden for template id" value="<?= isset($campaign_details['campaign_id']) ? $campaign_details['campaign_id'] : '' ?>" />
<?php if (!empty($campaign_details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($campaign_details) && $campaign_details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">
Submit
</button>
<button type="reset" class="btn btn-primary waves-effect mr-1">
Reset
</button>
<a href="<?= base_url() . "campaign_creation"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div><!-- end row -->
<script>
$(document).ready(function() {
// Listen for changes in the radio buttons
var mode = "<?= isset($campaign_details['mode']) ? $campaign_details['mode'] : ""; ?>";
var template = "<?= isset($campaign_details['template_id']) ? $campaign_details['template_id'] : ""; ?>";
load_details(mode,template);
$('input[name="mode"]').on('change', function() {
var selectedValue = $(this).val();
console.log('selectedValue',selectedValue);
load_details(selectedValue,template);
});
if(mode != ""){
var emailRadio = document.getElementById("emailRadio");
var whatsappRadio = document.getElementById("whatsappRadio");
if(mode == 'Email'){
emailRadio.checked = true;
whatsappRadio.checked = false;
}
if(mode == 'Whatsapp'){
emailRadio.checked = false;
whatsappRadio.checked = true;
}
load_details(mode,template);
}
});
function load_details(mode,template) {
var mode = (mode != "") ? mode : 'Email';
var temp_arr = <?php echo json_encode($template_details); ?>;
var filtered_data = $.grep(temp_arr, function(item) {
return item['mode'] === mode;
});
$('#load_templateid').empty();
$('#load_templateid').append($('<option>', { value: "", text: "Choose the Template" }));
$.each(filtered_data, function(k, v) {
$('#load_templateid').append($('<option>', {
value: v.template_id,
text: v.template_name,
selected: (v.template_id == template) ? true : false
}));
});
}
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script>
<script>
// Get the current date and time
const now = new Date();
const currentDate = now.toISOString().split('T')[0]; // Get current date in YYYY-MM-DD format
const dateInput = document.getElementById('example-date');
dateInput.setAttribute('min', currentDate);
</script>

450
app/Views/customer_form.php Normal file
View File

@ -0,0 +1,450 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<?php if ($page_name === 'Edit Customer Details') : ?>
<ul class="nav nav-tabs" id="customerTabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
</li>
<li class="nav-item">
<a class="nav-link" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
</li>
<li class="nav-item">
<a class="nav-link" id="invoiceDetails-tab" data-toggle="tab" href="#invoiceDetails" role="tab" aria-controls="invoiceDetails" aria-selected="false">Invoice Details</a>
</li>
</ul>
<?php endif; ?>
<div class="tab-content">
<!-- Customer Details Tab -->
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
<!-- Customer details form fields -->
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm">
<!-- <img src="<?= base_url() . "public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
<div class="form-row">
<div class="form-group col-md-4">
<label for="donerType" class="col-form-label">Doner Type<span class="text-danger"> *</span></label>
<select class="form-control" id="donerType" name="donerType" required>
<option value="<?= isset($customer['doner_type']) ? $customer['doner_type'] : '' ?>"><?= isset($customer['doner_type']) ? ($customer['doner_type'] === 'option1' ? 'Individual' : ($customer['doner_type'] === 'option2' ? 'Organization' : 'Select Donor Type')) : 'Select Donor Type'; ?></option>
<option value="option1">Individual</option>
<option value="option2">Organization</option>
</select>
<div class="invalid-feedback">Please provide.</div>
</div>
<div class="form-group col-md-4" id="org_name">
<label for="csname" class="col-form-label">Organization Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="org_name_field" name="org_name" value="<?= isset($customer['org_name']) ? $customer['org_name'] : '' ?>" placeholder="Organization Name"/>
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="cfname" class="col-form-label"><span class="contactPerson">Contact Person </span>First Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cfname" name="cfname" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="csname" class="col-form-label"><span class="contactPerson">Contact Person </span>Last Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="cmail" class="col-form-label"><span class="contactPerson">Contact Person </span>Email</label>
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)" />
<span id="emailValidationMessage"></span>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="cmobile" class="col-form-label"><span class="contactPerson">Contact Person </span>Mobile<span class="text-danger"> *</span></label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">+91</div>
</div>
<input type="text" class="form-control" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required maxlength="10" onkeypress="return restriction(event)" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-group col-md-4">
<label for="dob" class="col-form-label">Date Of Birth</label>
<input type="date" class="form-control" name="dob" value="<?= isset($customer['date_of_birth']) ? $customer['date_of_birth'] : '' ?>" placeholder="Date Of Birth" />
</div>
<div class="form-group col-md-4">
<label for="csname" class="col-form-label">PAN<span class="text-danger"> *</span></label>
<input type="text" class="form-control" name="pan_no" value="<?= isset($customer['pan_no']) ? $customer['pan_no'] : '' ?>" placeholder="PAN Number" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<input type="hidden" id="doner_id" name="doner_id" placeholder="hidden for customer id" value="<?= isset($customer['doner_id']) ? $customer['doner_id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<br />
<div class="after-add-more">
<hr />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="baddress1" class="col-form-label">Address<span class="text-danger"> *</span></label>
<textarea type="text" class="form-control" id="baddress1" name="address" placeholder="Address (eg : 1234 Main St)" required style="width:202%"><?= isset($customer['address']) ? $customer['address'] : '' ?></textarea>
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="bcountry" name="country" required>
<option value=""><?= isset($customer['country']) ? $customer['country'] : ''?><?= isset($customer['country']) ? '' : 'Choose your Country';?></option>
<?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_name']; ?>">
<?php
if($customer['country'] === $value['country_name']){
echo $value['country_name'];
}
else{
echo $value['country_name'];
}
?>
</option>
<?php } ?>
</select>
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<div id="billinput" style="display: block">
<label for="bistate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bistate" name="state_text" placeholder="State" value="<?= isset($customer['state']) ? $customer['state'] : ''?>"/>
<!-- <div class="invalid-feedback"> Please provide. </div> -->
</div>
</div>
<div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="city" value="<?= isset($customer['city']) ? $customer['city'] : '' ?>" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bzip" name="zip" value="<?= isset($customer['postal_code']) ? $customer['postal_code'] : '' ?>" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<input type="hidden" id="bcustomer_address_id" name="bcustomer_address_id[]" placeholder="hidden for billing customer address id" />
</div>
</div>
<br />
<?php if (!empty($customer)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer) && $customer['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit">Submit</button>
<!-- <button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button> -->
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</form>
</div><!-- end customer Details Tab -->
</div><!-- end tab-content-->
</div><!-- end card-body-->
</div>
</div>
</div>
<!-- <script>
$("#addressCopiedAsShipping").on("change", function() {
var count = $(".after-shipping-addr-add-more").length;
var counter = $("#counter").val() === "" ? count : parseInt($("#counter").val(), 10);
if ($(this).is(":checked")) {
var customerAddress1 = $("#baddress1").val();
var customerAddress2 = $("#baddress2").val();
var customerCountry = $("#bcountry").val();
var customerDropdownState = $("#bdstate").val();
var customerInputState = $("#bistate").val();
var customerCity = $("#bcity").val();
var customerPostalCode = $("#bzip").val();
$("#saddress1").val(customerAddress1).prop("readonly", false);
$("#saddress2").val(customerAddress2).prop("readonly", false);
$("#scountry"+counter).val(customerCountry).prop("readonly", false);
if (customerCountry == 'IN') {
$("#sistate"+counter).val(customerInputState).css("display", "none").prop("readonly", false);
$("#sdstate"+counter).val(customerDropdownState).css("display", "block").prop("readonly", false);
} else {
$("#sistate"+counter).val(customerInputState).css("display", "block").prop("readonly", false);
$("#sdstate"+counter).val(customerDropdownState).css("display", "none").prop("readonly", false);
}
$("#scity").val(customerCity).prop("readonly", false);
$("#szip").val(customerPostalCode).prop("readonly", false);
$("#counter").val(counter++).prop("readonly", true);
} else {
// Clear the billing address fields when the checkbox is unchecked
$("#saddress1").val("").prop("readonly", false);
$("#saddress2").val("").prop("readonly", false);
$("#scity").val("").prop("readonly", false);
$("#scountry"+counter).val("").prop("readonly", false);
$("#sistate"+counter).val("").css("display", "block").prop("readonly", false);
$("#sdstate"+counter).val("").css("display", "none").prop("readonly", false);
$("#szip").val("").prop("readonly", false);
$("#scustomer_address_id").val("") // Hidden Field ressetted bcoz Adress history
}
});
$("#bcountry").on("change", function() {
var country = $("#bcountry").val();
var dropdownField = $("#billdropdown");
var textField = $("#billinput");
if (country === 'IN') {
dropdownField.show();
textField.hide();
} else {
dropdownField.hide();
textField.show();
}
});
$(document).ready(function() {
if (barray.length > 0) {
for (var i = 0; i < barray.length; i++) {
$("#baddress1").val(barray[i]['address_1']);
$("#baddress2").val(barray[i]['address_2']);
$("#bcountry").val(barray[i]['country']);
$("#bcity").val(barray[i]['city']);
if (barray[i]['country'] == 'IN') {
$("#bdstate").val(barray[i]['state']);
$("#billdropdown").show();
$("#billinput").hide();
} else {
$("#bistate").val(barray[i]['state']);
$("#billdropdown").hide();
$("#billinput").show();
}
$("#bzip").val(barray[i]['postal_code']);
$('#bcustomer_address_id').val(barray[i]['customer_address_id']);
}
}
/*****************************************************************************************/
if (sarray.length > 0) {
j = 0;
for (var i = 0; i < sarray.length; i++) {
if (i == 0) {
var html = $(".after-shipping-addr-add-more").first();
} else {
var html = $(".after-shipping-addr-add-more").first().clone();
}
if ((barray[0]['address_1'] == sarray[i]['address_1']) &&
(barray[0]['city'] == sarray[i]['city']) &&
(barray[0]['state'] == sarray[i]['state']) &&
(barray[0]['country'] == sarray[i]['country']) &&
(barray[0]['postal_code'] == sarray[i]['postal_code'])) {
$("#addressCopiedAsShipping").prop("checked", true);
}
html.find('input#scustomer_address_id').val(sarray[i]['customer_address_id']);
html.find('input#saddress1').val(sarray[i]['address_1']);
html.find('input#saddress2').val(sarray[i]['address_2']);
html.find('input#scity').val(sarray[i]['city']);
html.find('select#scountry0').val(sarray[i]['country']);
html.find('select#scountry0').attr('id', 'scountry' + j);
html.find('input#counter').val(j).prop("readonly", true);
if (sarray[i]['country'] === 'IN') {
// html.find('select#sdstate0').attr('id','sdstate'+$j).val(sarray[i]['state']);
html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "block").val(sarray[i]['state']);
html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "none").val('');
} else {
html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "block").val(sarray[i]['state']);
html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "none").val('');
}
html.find('input#szip').val(sarray[i]['postal_code']);
if (i !== 0) {
html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
html.insertAfter(".after-shipping-addr-add-more:last");
}
j++;
toggleButtons();
}
} else {
toggleButtons();
}
$("body").on("click", ".shipping-addr-add-more", function() {
var html = $(".after-shipping-addr-add-more").first().clone();
var count = $(".after-shipping-addr-add-more").length;
html.find('select#scountry0').attr('id', 'scountry' + count).val('')
html.find('select#sdstate0').attr('id', 'sdstate' + count).css("display", "none").val('');
html.find('input#sistate0').attr('id', 'sistate' + count).css("display", "block").val('');
html.find('input').val(''); // Clear input values in the cloned element
html.find('input#counter').val(count).prop("readonly", true);
html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
html.insertAfter(".after-shipping-addr-add-more:last");
toggleButtons();
});
$("body").on("click", ".shipping-addr-remove", function() {
var rows = $(".after-shipping-addr-add-more");
if (rows.length > 1) {
$(this).parents(".after-shipping-addr-add-more").remove();
} else {
alert("At least one Shipping Address must be displayed.");
}
toggleButtons();
// if($('#addressCopiedAsShipping').is(':checked')){}
// else{ $('#addressCopiedAsShipping').prop("checked", false); }
});
function toggleButtons() {
var elementCount = $(".after-shipping-addr-add-more").length;
// console.log('elementCount == ' + elementCount);
if (elementCount > 1) {
$(".shipping-addr-remove").show(); // Show the "shipping-addr-remove" buttons
} else {
$(".shipping-addr-remove").hide(); // Hide the "shipping-addr-remove" buttons
}
$(".after-shipping-addr-add-more .shipping-addr-add-more").hide();
$(".after-shipping-addr-add-more:last .shipping-addr-add-more").show();
}
$('#submit-button').click(function() {
// Disable the button
$(this).prop('disabled', true);
// Change the button content to a spinner
$(this).html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...');
// Simulate a delay to demonstrate loading (you can replace this with your actual loading logic)
setTimeout(function() {
// Re-enable the button and restore the original text
$('#submit-button').prop('disabled', false);
$('#submit-button').html('Submit');
}, 3000); // Replace 3000 with the actual loading time in milliseconds
});
});
function changeFields(element) {
var selectedValue = $(element).val();
var elementId = $(element).attr('id');
var match = elementId.match(/\d+/);
if (match) {
var idnumber = parseInt(match[0], 10);
if (selectedValue == 'IN') {
$("#sdstate" + idnumber).show();
$("#sistate" + idnumber).hide();
} else {
$("#sdstate" + idnumber).hide();
$("#sistate" + idnumber).show();
}
} else {
// alert("No number found in the ID");
}
}
</script> -->
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script>
<script>
function validateEmail(email) {
// Regular expression for a basic email validation
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var emailInput = document.getElementById("cmail");
var validationMessage = document.getElementById("emailValidationMessage");
if (emailPattern.test(email)) {
validationMessage.textContent = "";
} else if (email == "") {
validationMessage.textContent = "";
} else {
validationMessage.textContent = "Invalid email address";
validationMessage.style.color = "red";
}
}
</script>
<script>
function restriction(event) {
var charCode = event.which || event.keyCode;
if ((charCode >= 48 && charCode <= 57)) {
return true;
} else {
event.preventDefault(); // Prevent the character from being entered
return false;
}
}
$(document).ready(function(){
$('#org_name').hide();
$('.contactPerson').hide();
let orgName = $('#org_name_field').val()
if(orgName !== '' && orgName !== null){
$('#org_name').show();
$('.contactPerson').show();
$('#org_name_field').prop('required', true);
}
else{
$('#org_name').hide();
$('.contactPerson').hide();
$('#org_name_field').prop('required', false);
}
$('#donerType').on('change', function(){
let donerType = $(this).val();
if(donerType === 'option2'){
$('#org_name').show();
$('.contactPerson').show();
$('#org_name_field').prop('required', true);
}
else{
$('#org_name').hide();
$('.contactPerson').hide();
}
})
});
</script>

View File

@ -0,0 +1,153 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="<?= base_url()."view_customer_group/0"; ?>" class="btn btn-primary"><i class="ri-team-line"></i> Add Doner Group </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<table id="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th hidden></th>
<th>Group Name</th>
<th>Created at</th>
<th>Created by</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<?php foreach ($customer_group as $group) :
if ($group['isactive']) {
$class = 'badge badge-soft-success';
$message = 'Active';
} else {
$class = 'badge badge-soft-danger';
$message = 'In-Active';
} ?>
<tr>
<td hidden><?= $group['group_id']; ?></td>
<td><?= $group['group_name']; ?></td>
<td><?= $group['formatted_created_on']; ?></td>
<td><?= $group['created_by_name']; ?></td>
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
<td>
<a href="<?= base_url() . "view_customer_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a>
<a class="preview-button" title="Customer list" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a>
<?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_customer_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<div class="modal" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="scrollableModalTitle">Customer list</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="ajax-content">
<table class="table table-bordered" id="data-table">
<thead>
<tr>
<th style="width:10%;">#</th>
<th style="width:30%;">Name</th>
<th style="width:30%;">Email</th>
<th style="width:30%;">Mobile</th>
</tr>
</thead>
<tbody>
<!-- Table rows will be populated here -->
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- end row-->
<script>
$(document).ready(function() {
$('#scroll-horizontal-datatable_customer').DataTable({
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options
});
});
</script>
<script>
$(document).ready(function() {
$('#scrollable-modal').on('show.bs.modal', function(event) {
// Get the data-primary-key attribute from the modal trigger
var primaryKey = $(event.relatedTarget).data('primary-key');
var groupName = $(event.relatedTarget).data('group-name');
$('#scrollableModalTitle').text(groupName + ' - Customer list');
// Get the table reference
var table = $("#data-table tbody");
var route = "<?= base_url().'preview_customer_group/'?>"+primaryKey;
$.ajax({
method: 'GET',
url: route,
success: function(response) {
if (response.length > 0) {
// Clear existing rows
table.empty();
$x=0;
// Loop through the response and create table rows
$.each(response, function (index, item) {
var row = $("<tr>");
row.append($("<td style='width:10%;'>").text(++$x));
row.append($("<td style='width:30%;'>").text(item.customer_name));
row.append($("<td style='width:30%;'>").text(item.email));
row.append($("<td style='width:30%;'>").text(item.mobile_no));
table.append(row);
});
} else {
// Handle the case where there is no data
table.empty();
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
}
},
error: function () {
// alert("An error occurred.");
console.log("CG Preview List - An error occurred.");
table.empty();
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
}
});
});
});
</script>

View File

@ -0,0 +1,598 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"></p>
<form id="myForm" class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer_group"; ?>" >
<div class="form-row">
<div class="form-group col-md-12">
<label for="groupname" class="col-form-label">Group Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="groupname" name="groupname" value="<?= isset($customer_group['groupname']) ? $customer_group['groupname'] : '' ?>" placeholder="Group Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<br />
<div class="form-row">
<div class="form-group col-md-12">
<h4 class="header-title">Select Criteria</h4>
<table class="table table-borderless" id="itemTable">
<thead>
<tr>
<th>Field</th>
<th>Condition</th>
<th>Value</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if(!empty($customer_group) && !empty($customer_group['column'])){ for ($i = 0; $i < count($customer_group['column']); $i++) { ?>
<tr>
<td style="width:30%;">
<select class="form-control" data-toggle="select2" id=<?= "column".$i; ?> name="column[]" >
<?php foreach ($field as $f) : ?>
<option value="<?= $f['value']; ?>"
fieldflag="<?= $f['fieldflag']; ?>"
<?php if ($f['disable']) echo 'disabled'; ?>
<?php if(isset($customer_group['column'][$i]) && $customer_group['column'][$i] == $f['value'] ){echo "selected";}?>>
<?= $f['text']; ?></option>
<?php endforeach; ?>
</select>
</td>
<td style="width:30%;">
<select class="form-control" data-toggle="select2" id=<?= "operator".$i; ?> name="operator[]" onchange="FieldChange(this,<?= $i; ?>)">
<?php foreach ($operator as $value => $label) { ?>
<option value="<?php echo $value; ?>" <?php if(isset($customer_group['operator'][$i]) && $customer_group['operator'][$i] == $value ){echo "selected";}?> >
<?php echo $label; ?>
</option>
<?php } ?>
</select>
</td>
<td style="width:30%;">
<?php if ($customer_group['operator'][$i] == 'greater than' || $customer_group['operator'][$i] == 'greater than or equal to' || $customer_group['operator'][$i] == 'less than' || $customer_group['operator'][$i] == 'less than or equal to') { ?>
<input type="date" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Date" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
<?php }else if($customer_group['operator'][$i] === 'between') {
$dates = (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? explode(',', $customer_group['values'][$i]) : [] ;
?>
<div style="display: inline-flex;">
<input type="date" class="form-control" id=<?= "values".$i.'1'; ?> placeholder="Enter the Start Date" onchange="concatBetween(<?= $i ?>)" value="<?= (isset($dates[0]) && $dates[0] != "" ) ? str_replace(' ', '', $dates[0]) : '' ?>" />
<input type="date" class="form-control ml-1" id=<?= "values".$i.'2'; ?> placeholder="Enter the End Date" onchange="concatBetween(<?= $i ?>)" value="<?= (isset($dates[1]) && $dates[1] != "" ) ? str_replace(' ', '', $dates[1]) : '' ?>" />
</div>
<input type="hidden" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="values" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
<?php } else if(($customer_group['operator'][$i] === 'contain' || $customer_group['operator'][$i] == 'not contain')) { ?>
<input type="text" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Multiple Values with comma Seprator" onkeypress="return restriction(event,'M')" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
<?php }else if($customer_group['operator'][$i] === 'is null' || $customer_group['operator'][$i] == 'is not null') { ?>
<input type="hidden" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Values" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
<?php }else if($customer_group['column'][$i] == 'C.mode' && ($customer_group['operator'][$i] === 'equal' || $customer_group['operator'][$i] == 'not equal' || $customer_group['operator'][$i] == 'like' )) { ?>
<select class="form-control" id=<?= "values".$i; ?> name="values[]">
<option value="">Choose the mode</option>
<option value="Online" <?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] == "Online") ? 'selected' : '' ?>>Online</option>
<option value="Offline" <?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] == "Offline") ? 'selected' : '' ?>>Offline</option>
</select>
<?php } else { ?>
<input type="text" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,2)"
value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
<?php } ?>
</td>
<td style="width:10%;">
<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item "><i class="fa fa-trash"></i></button>
</td>
</tr>
<?php } }else{ ?>
<tr>
<td style="width:30%;">
<select class="form-control" data-toggle="select2" id="column0" name="column[]" >
<?php foreach ($field as $f) : ?>
<option value="<?= $f['value']; ?>"
fieldflag="<?= $f['fieldflag']; ?>"
<?php if ($f['disable']) echo 'disabled'; ?> >
<?= $f['text']; ?></option>
<?php endforeach; ?>
</select>
</td>
<td style="width:30%;">
<select class="form-control" data-toggle="select2" id="operator0" name="operator[]" onchange="FieldChange(this,0)">
<?php foreach ($operator as $value => $label) { ?>
<option value="<?php echo $value; ?>">
<?php echo $label; ?>
</option>
<?php } ?>
</select>
</td>
<td style="width:30%;">
<input type="text" class="form-control" id="values0" name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,1)" />
</td>
<td style="width:10%;">
<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item "><i class="fa fa-trash"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="form-group text-right m-b-0">
<button type="button" id="addItem" class="btn btn-soft-dark btn-rounded waves-effect waves-light mr-3 add-item"> + Add New Criteria</button>
</div>
<?php if (!empty($customer_group)) { ?>
<div class="form-group text-right checkbox checkbox-purple mr-3">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer_group) && $customer_group['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label>
</div>
<?php } ?>
<input type="hidden" id="string_flag" name="string_flag" placeholder="hidden" value="preview" />
<input type="hidden" id="group_id" name="group_id" placeholder="hidden for primary id" value="<?= isset($customer_group['group_id']) ? $customer_group['group_id'] : '' ?>" />
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn btn-purple waves-effect mr-1" data-toggle="modal" data-target="#scrollable-modal">Save</button>
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
<a href="<?= base_url() . "customer_group"; ?>" class="btn btn-secondary waves-effect mr-3">Cancel</a>
</div>
<div class="modal" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="scrollableModalTitle">Customer list</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="ajax-content">
<table class="table table-bordered" id="data-table">
<thead>
<tr>
<th style="width:10%;">#</th>
<th style="width:30%;">Name</th>
<th style="width:30%;">Email</th>
<th style="width:30%;">Mobile</th>
</tr>
</thead>
<tbody>
<!-- Table rows will be populated here -->
</tbody>
</table>
</div>
<div class="modal-footer">
<button id="save" class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn"> Submit </button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</form>
</div>
</div>
</div>
</div>
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<script>
const myArray = [];
document.getElementById("addItem").addEventListener("click", function() {
var fieldArray = <?php echo json_encode($field); ?>;
var operatorArray = <?php echo json_encode($operator); ?>;
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var rows = table.getElementsByTagName("tr");
var hasValue = false;
var rowCounter = rows.length; // Get the current number of rows
// Check if any existing fields are empty
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
for (var j = 0; j < cells.length; j++) {
var input = cells[j].querySelector('input, select');
if (input && input.value.trim() === "") {
alert("Field in row " + (i + 1) + " is empty.");
return; // Exit the loop after the first empty field is found.
} else {
hasValue = true;
}
}
}
if (!hasValue) {
alert("At least one row should contain a value.");
return; // Exit the function to prevent adding a new row.
}
var newRow = table.insertRow(rowCounter);
var cell1 = newRow.insertCell(0);
var cell2 = newRow.insertCell(1);
var cell3 = newRow.insertCell(2);
var cell4 = newRow.insertCell(3);
const select1 = document.createElement('select');
select1.className = 'form-control';
select1.name = 'column[]';
select1.setAttribute("data-toggle", "select2");
select1.id = 'column' + rowCounter; // Set a dynamic ID for the select input
// select1.onchange = function() {
// disableSelectedOptions(this,rowCounter);
// };
const select2 = document.createElement('select');
select2.className = 'form-control';
select2.name = 'operator[]';
select2.setAttribute("data-toggle", "select2");
select2.id = 'operator' + rowCounter; // Set a dynamic ID for the select input
select2.onchange = function() {
FieldChange(this, rowCounter);
};
exstingColumnId = 'column'+(rowCounter-1);
// if($('#' + exstingColumnId).val() != ""){
// myArray.push($('#' + exstingColumnId).val());
// }
// console.log(myArray);
fieldArray.forEach((option) => {
const fieldoption = document.createElement('option');
fieldoption.value = option.value;
fieldoption.setAttribute("fieldflag", option.fieldflag);
fieldoption.text = option.text;
// fieldoption.disabled = option.disable ? true : (option.disable == myArray[0] ? true : false);
// if (myArray.includes(option.value)) {
// fieldoption.disabled = true;
// }
// else{
// fieldoption.disabled = false;
// }
select1.appendChild(fieldoption);
});
for (const value in operatorArray) {
const optionElement = document.createElement('option');
optionElement.value = value;
optionElement.text = operatorArray[value];
select2.appendChild(optionElement);
}
const inputElement = document.createElement('input');
inputElement.type = 'text';
inputElement.className = 'form-control';
inputElement.name = 'values[]';
inputElement.placeholder = 'Enter the Values';
inputElement.id = 'values' + rowCounter; // Set a dynamic ID for the input field
cell1.appendChild(select1);
cell2.appendChild(select2);
cell3.appendChild(inputElement);
cell4.innerHTML = '<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item"><i class="fa fa-trash"></i></button>';
$(select1).select2();
$(select2).select2();
});
// document.getElementById("addItemold").addEventListener("click", function() {
// var fieldArray = <?php echo json_encode($field); ?>;
// var operatorArray = <?php echo json_encode($operator); ?>;
// var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
// var rows = table.getElementsByTagName("tr");
// var hasValue = false;
// // Check if any existing fields are empty
// for (var i = 0; i < rows.length; i++) {
// var cells = rows[i].getElementsByTagName("td");
// for (var j = 0; j < cells.length; j++) {
// var input = cells[j].querySelector('input, select');
// if (input && input.value.trim() === "") {
// alert("Field in row " + (i + 1) + " is empty.");
// return; // Exit the loop after the first empty field is found.
// }else {
// hasValue = true;
// }
// }
// }
// if (!hasValue) {
// alert("At least one row should contain a value.");
// return; // Exit the function to prevent adding a new row.
// }
// var newRow = table.insertRow(table.rows.length);
// var cell1 = newRow.insertCell(0);
// var cell2 = newRow.insertCell(1);
// var cell3 = newRow.insertCell(2);
// var cell4 = newRow.insertCell(3);
// const select1 = document.createElement('select');
// select1.className = 'form-control';
// select1.name = 'column[]';
// select1.setAttribute("data-toggle", "select2");
// const select2 = document.createElement('select');
// select2.className = 'form-control';
// select2.name = 'operator[]';
// select2.setAttribute("data-toggle", "select2");
// for (const fieldvalue in fieldArray) {
// const fieldoption = document.createElement('option');
// fieldoption.value = fieldvalue;
// fieldoption.text = fieldArray[fieldvalue];
// select1.appendChild(fieldoption);
// }
// for (const value in operatorArray) {
// const optionElement = document.createElement('option');
// optionElement.value = value;
// optionElement.text = operatorArray[value];
// select2.appendChild(optionElement);
// }
// const inputElement = document.createElement('input');
// inputElement.type = 'text';
// inputElement.className = 'form-control';
// inputElement.name = 'values[]';
// inputElement.placeholder = 'Enter the Values';
// cell1.appendChild(select1);
// cell2.appendChild(select2);
// cell3.appendChild(inputElement);
// cell4.innerHTML = '<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item"><i class="fa fa-trash"></i></button>';
// $(select1).select2();
// $(select2).select2();
// });
</script>
<script>
// Function to remove a row from the table
function removeItem(row) {
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var rows = table.getElementsByTagName("tr");
if (rows.length > 1) {
var rowIndex = row.rowIndex; // Get the row index
console.log(rowIndex);
var exstingColumnId = 'column' + (rowIndex-1);
var valueToRemove = $('#' + exstingColumnId).val();
// var indexToRemove = myArray.indexOf(valueToRemove);
// if (indexToRemove !== -1) {
// myArray.splice(indexToRemove, 1); // Remove the element at the specified index
// }
// console.log('myArray',myArray);
table.removeChild(row);
} else {
alert('At least one row should contain a value.');
}
}
// Attach the removeItem function to the Remove buttons using event delegation
document.querySelector("#itemTable tbody").addEventListener("click", function(event) {
if (event.target.classList.contains("remove-item")) {
var row = event.target.closest("tr"); // Find the closest row to the clicked button
removeItem(row);
}
});
</script>
<!-- function removeItem(row) {
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var rows = table.getElementsByTagName("tr");
var hasValue = false; // Flag to track if the row to be removed has a value.
// Check if the row to be removed has values
var cells = row.getElementsByTagName("td");
for (var j = 0; j < cells.length; j++) {
var input = cells[j].querySelector('input, select');
if (input && input.value.trim() !== "") {
hasValue = true;
break; // Exit the loop after the first value is found in the row.
}
}
if (hasValue || rows.length > 1) {
table.removeChild(row);
} else {
alert('At least one row should contain a value.');
}
} -->
<!-- <script>
document.getElementById('previewButton').addEventListener('click', function() {
const name = "sanjeev";
const email = "document.getElementById('email').value";
// Update the modal with the preview data
// document.getElementById('previewName').textContent = name;
// document.getElementById('previewEmail').textContent = email;
// Show the modal
const modal = document.getElementById('previewModal');
modal.style.display = 'block';
// Close the modal when the close button is clicked
document.getElementById('closeModal').addEventListener('click', function() {
modal.style.display = 'none';
});
// Close the modal when clicking outside of it
window.onclick = function(event) {
if (event.target === modal) {
modal.style.display = 'none';
}
};
});
</script> -->
<script>
$(document).ready(function() {
$('#scrollable-modal').on('show.bs.modal', function() {
var formData = $("#myForm").serialize();
var groupName = $("#groupname").val();
// Use AJAX to load content into the modal
// Get the table reference
var table = $("#data-table tbody");
$.ajax({
type: "POST",
url: "<?= base_url() . 'insert_customer_group' ?>",
data: formData,
dataType: "json", // Expect JSON response
success: function(response) {
if (response.length > 0) {
$('#scrollableModalTitle').text(groupName + ' - Customer list');
// Clear existing rows
table.empty();
$x=0;
// Loop through the response and create table rows
$.each(response, function (index, item) {
var row = $("<tr>");
row.append($("<td style='width:10%;'>").text(++$x));
row.append($("<td style='width:30%;'>").text(item.customer_name));
row.append($("<td style='width:30%;'>").text(item.email));
row.append($("<td style='width:30%;'>").text(item.mobile_no));
table.append(row);
});
} else {
// Handle the case where there is no data
table.empty();
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
}
},
error: function () {
// alert("An error occurred.");
console.log("CG Preview Form - An error occurred.");
table.empty();
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
}
});
});
});
</script>
<script>
$("#save").on("click", function () {
$("#string_flag").val("save");
});
function FieldChange(selectElement, rowCounter) {
var id = selectElement.id;
var selectedOperator = selectElement.value;
var inputId = 'values' + rowCounter;
var column = $("#column"+rowCounter).find(':selected').attr('fieldflag');
if (column == 2 && (selectedOperator == 'greater than' || selectedOperator == 'greater than or equal to' || selectedOperator == 'less than' || selectedOperator == 'less than or equal to')) {
$('#' + inputId).parent().html('<input type="date" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Date" />');
}else if (column == 2 && selectedOperator === 'between') {
var newInput = '<div style="display: inline-flex;"><input type="date" class="form-control" id="' + inputId + '1" placeholder="Enter the Start Date" onchange="concatBetween(' + rowCounter + ')" />' +
'<input type="date" class="form-control ml-1" id="' + inputId + '2" placeholder="Enter the End Date" onchange="concatBetween(' + rowCounter + ')" /></div>' +
'<input type="hidden" class="form-control" id="' + inputId + '" name="values[]" placeholder="values" />';
$('#' + inputId).parent().html(newInput);
}
else if(column == 1 && (selectedOperator === 'contain' || selectedOperator == 'not contain')) {
// $('#' + inputId).replaceWith('<input type="text" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Multiple Values with comma Seprator" onkeypress="return restriction(event,2)" />');
$('#' + inputId).parent().html('<input type="text" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Multiple Values with comma Seprator" onkeypress="return restriction(event,2)" />');
}else if(selectedOperator === 'is null' || selectedOperator == 'is not null') {
$('#' + inputId).parent().html('<input type="hidden" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Values" value="0" />');
}else if(column == 3 && (selectedOperator === 'equal' || selectedOperator == 'not equal' || selectedOperator == 'like' )){
$('#' + inputId).parent().html('<select class="form-control" id="' + inputId + '" name="values[]" ><option value="">Choose the mode</option><option value="Online">Online</option><option value="Offline">Offline</option></select>');
}else{
$('#' + inputId).parent().html('<input type="text" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,1)" />');
}
}
function concatBetween(Counter) {
// This function will be called when the date input changes
var Id = 'values' + Counter;
var started = $('#' +Id+'1').val();
var ended = $('#' +Id+'2').val();
if(started != "" && ended != ""){
$("#"+Id).val(started + ',' + ended);
}
// console.log("id: " + Id);
// console.log("counter: " + Counter);
// console.log("sv: " + started);
// console.log("ev: " + ended);
}
</script>
<script>
function restriction(event,temporary_flag) {
var charCode = event.which || event.keyCode;
if (Number(temporary_flag) == 2 &&
((charCode >= 65 && charCode <= 90) || // A-Z
(charCode >= 97 && charCode <= 122) || // a-z
(charCode >= 48 && charCode <= 57) || // 0-9
charCode == 44 // comma
)){
return true;
}
else if (Number(temporary_flag) == 1 &&
((charCode >= 48 && charCode <= 57) || // 0-9
(charCode >= 65 && charCode <= 90) || // A-Z
(charCode >= 97 && charCode <= 122) // a-z
)) {
return true;
} else {
event.preventDefault(); // Prevent the character from being entered
return false;
}
}
</script>
<script>
// // Function to disable options in the "Choose the Field" dropdowns
// function disableOptions(selectId) {
// console.log('inside');
// // Get all select elements with the specified name attribute
// var selectElements = document.querySelectorAll('select[name="column[]"]');
// // Iterate through the select elements
// selectElements.forEach(function (select) {
// console.log(select.id,selectId);
// if (select.id !== selectId) {
// console.log('if');
// // Find the "Choose the Field" option and disable it
// var chooseOption = select.querySelector('option[value=""]');
// if (chooseOption) {
// console.log('if-if');
// chooseOption.disabled = true;
// }
// }
// });
// }
// // Event listener for changes in the "Choose the Field" dropdowns
// document.addEventListener('change', function (e) {
// var target = e.target;
// console.log(target,'target');
// if (target.name === 'column[]' && target.value === '') {
// console.log('if');
// // Disable the "Choose the Field" option in other dropdowns
// disableOptions(target.id);
// }else{
// console.log('else');
// }
// });
// function disableSelectedOptions(selectElement, rowCounter) {
// var id = selectElement.id;
// var selectedOperator = selectElement.value;
// }
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script>

View File

@ -0,0 +1,67 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="<?= base_url() . "new_doner/0"; ?>" class="btn btn-primary"><i class="ri-map-pin-user-fill"></i> Add Doner </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<table id="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th hidden></th>
<th>Name</th>
<th>Mobile Number</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<?php foreach ($customer as $value) :?>
<tr>
<td hidden><?$value['doner_id'];?></td>
<td><?= $value['first_name'].' '.$value['last_name'] ; ?></td>
<td><?= $value['mobile_no']; ?></td>
<td><?= $value['email']; ?></td>
<td>
<a href="<?= "new_doner/" . $value['doner_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<a href="<?= "delete_customer/" . $value['doner_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->
<script>
$(document).ready(function() {
$('#scroll-horizontal-datatable_customer').DataTable({
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options
});
});
</script>

Some files were not shown because too many files have changed in this diff Show More