diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..541f92c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+# Add any directories, files, or patterns you don't want to be tracked by version control
\ No newline at end of file
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..e69de29
diff --git a/api/.htaccess b/api/.htaccess
new file mode 100644
index 0000000..abf6332
--- /dev/null
+++ b/api/.htaccess
@@ -0,0 +1,12 @@
+ErrorDocument 404 index.php
+
+# SetEnv CI_ENV production
+
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} ^/system.*
+ RewriteRule ^(.*)$ index.php?/$1 [L]
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule ^(.+)$ index.php?/$1 [L]
+
diff --git a/api/README.MD b/api/README.MD
new file mode 100644
index 0000000..55abdfc
--- /dev/null
+++ b/api/README.MD
@@ -0,0 +1,206 @@
+Esta e uma tradução do Readme do projeto [CodeIgniter Rest Server](https://github.com/chriskacerguis/codeigniter-restserver/)
+de [Chris Kacerguis](https://github.com/chriskacerguis)
+
+A tradução foi feita por [Daniel Coder](https://github.com/netofire) nesse fork [aqui](https://github.com/netofire/codeigniter-restserver/blob/master/README_pt_BR.MD)
+
+# CodeIgniter Rest Server
+
+Implementação completa de um servidor RESTful para CodeIgniter usando uma biblioteca, um arquivo config e um controller.
+
+## Requisitos
+
+1. PHP 5.4+
+2. CodeIgniter 3.0+
+
+_Nota: para suporte à versão 1.7.x baixe a v2.2 da aba de Downloads_
+
+## Atualização importante na vs. 4.0.0
+
+Note que a versão 4.0.0 está em andamento, e é considerada uma versão "breaking change". Como o CI 3.1.0 agora tem suporte nativo ao Composer, esta biblioteca está sendo criada baseada no composer.
+
+Dê uma olhada no branch "development" e veja o que está acontecendo.
+
+## Instalação
+
+Arraste os arquivos **application/libraries/Format.php** e **application/libraries/REST_Controller.php** para dentro do diretório da sua aplicação. Para usar `require_once` no topo dos seus controllers pra carregá-los dentro do escopo. Adicionalmente, copie o arquivo **rest.php** de **application/config** para o diretório de configuração de sua aplicação.
+
+## Tratando Requisições
+
+Quando seu controller extende de `REST_Controller`, os nomes dos métodos vão ser sufixados com o método HTTP usado para acessar a requisição. Se você está fazendo uma chamada HTTP `GET` para `/books`, por exemplo, será chamado o método `Books#index_get()`.
+
+Isso permite a você implementar uma interface RESTful facilmente:
+
+```php
+class Books extends REST_Controller
+{
+ public function index_get()
+ {
+ // Display all books
+ }
+
+ public function index_post()
+ {
+ // Create a new book
+ }
+}
+```
+
+`REST_Controller` também suporta os métodos `PUT` e `DELETE`, permitindo a você implementar uma real interface RESTful.
+
+
+Acessar parâmetros também é fácil. Apenas use o nome do método HTTP como um método:
+
+```php
+$this->get('blah'); // parâmetro GET
+$this->post('blah'); // parâmetro POST
+$this->put('blah'); // parâmetro PUT
+```
+
+A especificação HTTP para requisições do tipo DELETE impede o uso de parâmetros. Para estas requisições, você pode adicionar itens à URL:
+
+```php
+public function index_delete($id)
+{
+ $this->response([
+ 'returned from delete:' => $id,
+ ]);
+}
+```
+
+Se parâmetros de consulta (query strings) são passados através da URL, independentemente de ser de uma requisição GET, podem ser obtidos através do método `query`:
+
+```php
+$this->query('blah'); // Query param
+```
+
+## Content Types
+
+`REST_Controller` suporta vários tipos de formato request/response, incluindo XML, JSON and PHP serializado. Por padrão, a classe vai checar a URL e procurar por um formato seja como uma extensão ou um segmento separado.
+
+Isso significa que suas URLs podem ser assim:
+```
+http://example.com/books.json
+http://example.com/books?format=json
+```
+
+Isso pode ser ruim de trabalhar junto com segmentos URI, então, a recomendado usar um cabeçalho HTTP `Accept`:
+
+```bash
+$ curl -H "Accept: application/json" http://example.com
+```
+
+Qualquer resposta (response) que você faça na classe (veja [responses](#responses) para mais detalhes) serão serializadas no formato solicitado.
+
+## Respostas (responses)
+
+A classe provê um método `response()` que permite retornar os dados no formato solicitado pelo usuário.
+
+Retornar um objeto / array / string / etc é simples:
+
+```php
+public function index_get()
+{
+ $this->response($this->db->get('books')->result());
+}
+```
+
+Isto automaticamente vai retornar uma resposta `HTTP 200 OK`. Você pode especificar o status HTTP no segundo parâmetro:
+
+```php
+public function index_post()
+ {
+ // ...cria um novo livro
+ $this->response($book, 201); // Envia HTTP 201 Created
+ }
+```
+
+Se você não especificar um código de resposta e o resultado retornado for avaliado como `== FALSE` (um array ou string vazia, por exemplo), o código de resposta será automaticamente setado para `404 Not Found`:
+
+```php
+$this->response([]); // HTTP 404 Not Found
+```
+
+## Suporte multi-idioma
+
+Se sua aplicação utiliza arquivos de idioma para dar suporte a múltiplas localidades, a classe `REST_Controller` vai automaticamente analisar o cabeçalho HTTP `Accept-Language` e prover os idiomas(s) nas actions. Esta informação pode ser encontrada no objeto `$this->response->lang`:
+
+```php
+public function __construct()
+{
+ parent::__construct();
+
+ if (is_array($this->response->lang))
+ {
+ $this->load->language('application', $this->response->lang[0]);
+ }
+ else
+ {
+ $this->load->language('application', $this->response->lang);
+ }
+}
+```
+
+## Autenticação
+
+Esta classe também implementa suporte para autenticação básica via HTTP e/ou a autenticação digest HTTP (mais segura).
+
+Você pode habilitar a autenticação básica setando `$config['rest_auth']` para `'basic'`. A diretiva `$config['rest_valid_logiVns']` serve para você setar os usernames e passwords habilitados a acessar seu sistema. A classe vai automaticamente enviar todos os cabeçalhos corretos pra abrir o diálogo de autenticação:
+
+```php
+$config['rest_valid_logins'] = ['username' => 'password', 'outra_pessoa' => 'seguro123'];
+```
+
+Habilitar a autenticação do tipo 'digest' é igualmente simples. Configure os logins permitidos no arquivo de config, como acima e sete `$config['rest_auth']` para `'digest'`. A classe vai automaticamente enviar os cabeçalhos para habilitar a autenticação 'digest'.
+
+Se você está amarrando esta biblioteca em um endpoint AJAX, onde os clientes autenticam com sessões PHP, você provavelmente não vai gostar nem da autenticação básica nem da 'digest'. Neste caso, você pode dizer para a biblioteca REST qual variável de sessão PHP deve ser checada. Se a variável existir, o usuário está autorizado. É responsabilidade da sua aplicação setar tal variável. Vocẽ pode definir a variável em ``$config['auth_source']``. Então, dizer à biblioteca para usar uma variável de sessão, setando ``$config['rest_auth']`` para ``session``.
+
+Todos os três métodos de autenticação podem ficar mais seguros usando uma lista de IPs permitidos. Se você habilitar `$config['rest_ip_whitelist_enabled']` no seu arquivo de configuração, você pode setar uma lista de IPs permitidos.
+
+Qualquer cliente conectando à sua API será verificado usando o array de IPs. Se eles estiverem na lista, terão o acesso permitido. Caso contrário, não. A lista de Ips é uma string separada por vírgulas:
+
+```php
+$config['rest_ip_whitelist'] = '123.456.789.0, 987.654.32.1';
+```
+
+Seus IPs locais (`127.0.0.1` e `0.0.0.0`) são permitidos por padrão.
+
+## Chaves de API
+
+Em adição aos métodos de autenticação acima, a classe `REST_Controller` também suporta o uso de chaves API. Habilitar é simples. Habilite no seu arquivo **config/rest.php**:
+
+```php
+$config['rest_enable_keys'] = TRUE;
+```
+
+Você vai precisar criar uma tabela de banco de dados para armazenar e acessar as chaves. `REST_Controller` vai automaticamente assumir que você possui uma tabela como esta:
+
+```sql
+CREATE TABLE `keys` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `key` VARCHAR(40) NOT NULL,
+ `level` INT(2) NOT NULL,
+ `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0',
+ `date_created` INT(11) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+```
+
+A classe vai procurar por um cabeçalho HTTP com a chave da API a cada requisição. Uma chave inválida ou ausente irá resultar em um erro `HTTP 403 Forbidden`.
+
+Por padrão, o HTTP será `X-API-KEY`. Isto pode ser configurado no arquivo **config/rest.php**.
+
+```bash
+$ curl -X POST -H "X-API-KEY: sua_chave_aqui" http://example.com/books
+```
+
+## Outra Documentação / Tutoriais
+
+* [NetTuts: Working with RESTful Services in CodeIgniter](http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/)
+
+## Contribuições
+
+Este projeto foi originalmente escrito por Phil Sturgeon, no entanto o seu envolvimento foi excluído visto que ele não estava mais usando-o. A partir de 20/11/2013 o desenvolvimento e suporte são feitos por Chris Kacerguis.
+
+Pull Requests são as melhores maneiras de consertar bugs e adicionar ferramentas. Eu sei que muitos de vocês usam, então por favor, contribua se você tem melhorias a serem feitas, e eu continuarei a realizar versões com o passar do tempo.
+
+[](https://raw.githubusercontent.com/chriskacerguis/codeigniter-restserver/master/LICENSE)
diff --git a/api/application/.htaccess b/api/application/.htaccess
new file mode 100644
index 0000000..6c63ed4
--- /dev/null
+++ b/api/application/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
\ No newline at end of file
diff --git a/api/application/cache/.htaccess b/api/application/cache/.htaccess
new file mode 100644
index 0000000..6c63ed4
--- /dev/null
+++ b/api/application/cache/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
\ No newline at end of file
diff --git a/api/application/cache/index.html b/api/application/cache/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/cache/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/config/autoload.php b/api/application/config/autoload.php
new file mode 100644
index 0000000..ca068cd
--- /dev/null
+++ b/api/application/config/autoload.php
@@ -0,0 +1,135 @@
+ 'ua');
+*/
+$autoload['libraries'] = array('database', 'JWT');
+
+/*
+| -------------------------------------------------------------------
+| Auto-load Drivers
+| -------------------------------------------------------------------
+| These classes are located in system/libraries/ or in your
+| application/libraries/ directory, but are also placed inside their
+| own subdirectory and they extend the CI_Driver_Library class. They
+| offer multiple interchangeable driver options.
+|
+| Prototype:
+|
+| $autoload['drivers'] = array('cache');
+|
+| You can also supply an alternative property name to be assigned in
+| the controller:
+|
+| $autoload['drivers'] = array('cache' => 'cch');
+|
+*/
+$autoload['drivers'] = array();
+
+/*
+| -------------------------------------------------------------------
+| Auto-load Helper Files
+| -------------------------------------------------------------------
+| Prototype:
+|
+| $autoload['helper'] = array('url', 'file');
+*/
+$autoload['helper'] = array('url');
+
+/*
+| -------------------------------------------------------------------
+| Auto-load Config files
+| -------------------------------------------------------------------
+| Prototype:
+|
+| $autoload['config'] = array('config1', 'config2');
+|
+| NOTE: This item is intended for use ONLY if you have created custom
+| config files. Otherwise, leave it blank.
+|
+*/
+$autoload['config'] = array();
+
+/*
+| -------------------------------------------------------------------
+| Auto-load Language files
+| -------------------------------------------------------------------
+| Prototype:
+|
+| $autoload['language'] = array('lang1', 'lang2');
+|
+| NOTE: Do not include the "_lang" part of your file. For example
+| "codeigniter_lang.php" would be referenced as array('codeigniter');
+|
+*/
+$autoload['language'] = array();
+
+/*
+| -------------------------------------------------------------------
+| Auto-load Models
+| -------------------------------------------------------------------
+| Prototype:
+|
+| $autoload['model'] = array('first_model', 'second_model');
+|
+| You can also supply an alternative model name to be assigned
+| in the controller:
+|
+| $autoload['model'] = array('first_model' => 'first');
+*/
+$autoload['model'] = array();
diff --git a/api/application/config/config.php b/api/application/config/config.php
new file mode 100644
index 0000000..f2dbc7a
--- /dev/null
+++ b/api/application/config/config.php
@@ -0,0 +1,514 @@
+]+$/i
+|
+| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
+|
+*/
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
+
+/*
+|--------------------------------------------------------------------------
+| Enable Query Strings
+|--------------------------------------------------------------------------
+|
+| By default CodeIgniter uses search-engine friendly segment based URLs:
+| example.com/who/what/where/
+|
+| By default CodeIgniter enables access to the $_GET array. If for some
+| reason you would like to disable it, set 'allow_get_array' to FALSE.
+|
+| You can optionally enable standard query string based URLs:
+| example.com?who=me&what=something&where=here
+|
+| Options are: TRUE or FALSE (boolean)
+|
+| The other items let you set the query string 'words' that will
+| invoke your controllers and its functions:
+| example.com/index.php?c=controller&m=function
+|
+| Please note that some of the helpers won't work as expected when
+| this feature is enabled, since CodeIgniter is designed primarily to
+| use segment based URLs.
+|
+*/
+$config['allow_get_array'] = TRUE;
+$config['enable_query_strings'] = FALSE;
+$config['controller_trigger'] = 'c';
+$config['function_trigger'] = 'm';
+$config['directory_trigger'] = 'd';
+
+/*
+|--------------------------------------------------------------------------
+| Error Logging Threshold
+|--------------------------------------------------------------------------
+|
+| You can enable error logging by setting a threshold over zero. The
+| threshold determines what gets logged. Threshold options are:
+|
+| 0 = Disables logging, Error logging TURNED OFF
+| 1 = Error Messages (including PHP errors)
+| 2 = Debug Messages
+| 3 = Informational Messages
+| 4 = All Messages
+|
+| You can also pass an array with threshold levels to show individual error types
+|
+| array(2) = Debug Messages, without Error Messages
+|
+| For a live site you'll usually only enable Errors (1) to be logged otherwise
+| your log files will fill up very fast.
+|
+*/
+$config['log_threshold'] = 0;
+
+/*
+|--------------------------------------------------------------------------
+| Error Logging Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| application/logs/ directory. Use a full server path with trailing slash.
+|
+*/
+$config['log_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Log File Extension
+|--------------------------------------------------------------------------
+|
+| The default filename extension for log files. The default '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 'php'.
+|
+*/
+$config['log_file_extension'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Log File Permissions
+|--------------------------------------------------------------------------
+|
+| 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.)
+*/
+$config['log_file_permissions'] = 0644;
+
+/*
+|--------------------------------------------------------------------------
+| 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
+|
+*/
+$config['log_date_format'] = 'Y-m-d H:i:s';
+
+/*
+|--------------------------------------------------------------------------
+| Error Views Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| application/views/errors/ directory. Use a full server path with trailing slash.
+|
+*/
+$config['error_views_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Cache Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| application/cache/ directory. Use a full server path with trailing slash.
+|
+*/
+$config['cache_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| 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.
+| array('q') = Enabled, but only take into account the specified list
+| of query parameters.
+|
+*/
+$config['cache_query_string'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Encryption Key
+|--------------------------------------------------------------------------
+|
+| If you use the Encryption class, you must set an encryption key.
+| See the user guide for more info.
+|
+| https://codeigniter.com/user_guide/libraries/encryption.html
+|
+*/
+$config['encryption_key'] = 'rodrigo';
+
+/*
+|--------------------------------------------------------------------------
+| Session Variables
+|--------------------------------------------------------------------------
+|
+| 'sess_driver'
+|
+| The storage driver to use: files, database, redis, memcached
+|
+| 'sess_cookie_name'
+|
+| The session cookie name, must contain only [0-9a-z_-] characters
+|
+| 'sess_expiration'
+|
+| The number of SECONDS you want the session to last.
+| Setting to 0 (zero) means expire when the browser is closed.
+|
+| 'sess_save_path'
+|
+| The location to save sessions to, 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!
+|
+| 'sess_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.
+|
+| 'sess_time_to_update'
+|
+| How many seconds between CI regenerating the session ID.
+|
+| 'sess_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.
+|
+| Other session cookie settings are shared with the rest of the application,
+| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
+|
+*/
+$config['sess_driver'] = 'database';
+$config['sess_cookie_name'] = 'ci_session';
+$config['sess_expiration'] = 7200;
+$config['sess_save_path'] = 'ci_sessions';
+$config['sess_match_ip'] = FALSE;
+$config['sess_time_to_update'] = 300;
+$config['sess_regenerate_destroy'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Cookie Related Variables
+|--------------------------------------------------------------------------
+|
+| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions
+| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
+| 'cookie_path' = Typically will be a forward slash
+| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists.
+| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
+|
+| Note: These settings (with the exception of 'cookie_prefix' and
+| 'cookie_httponly') will also affect sessions.
+|
+*/
+$config['cookie_prefix'] = '';
+$config['cookie_domain'] = '';
+$config['cookie_path'] = '/';
+$config['cookie_secure'] = FALSE;
+$config['cookie_httponly'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Standardize newlines
+|--------------------------------------------------------------------------
+|
+| Determines whether to standardize newline characters in input data,
+| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value.
+|
+| This is particularly useful for portability between UNIX-based OSes,
+| (usually \n) and Windows (\r\n).
+|
+*/
+$config['standardize_newlines'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Global XSS Filtering
+|--------------------------------------------------------------------------
+|
+| Determines whether the XSS filter is always active when GET, POST or
+| COOKIE data is encountered
+|
+| WARNING: This feature is DEPRECATED and currently available only
+| for backwards compatibility purposes!
+|
+*/
+$config['global_xss_filtering'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Cross Site Request Forgery
+|--------------------------------------------------------------------------
+| Enables a CSRF cookie token to be set. When set to TRUE, token will be
+| checked on a submitted form. If you are accepting user data, it is strongly
+| recommended CSRF protection be enabled.
+|
+| 'csrf_token_name' = The token name
+| 'csrf_cookie_name' = The cookie name
+| 'csrf_expire' = The number in seconds the token should expire.
+| 'csrf_regenerate' = Regenerate token on every submission
+| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
+*/
+$config['csrf_protection'] = FALSE;
+$config['csrf_token_name'] = 'csrf_test_name';
+$config['csrf_cookie_name'] = 'csrf_cookie_name';
+$config['csrf_expire'] = 7200;
+$config['csrf_regenerate'] = TRUE;
+$config['csrf_exclude_uris'] = array();
+
+/*
+|--------------------------------------------------------------------------
+| Output Compression
+|--------------------------------------------------------------------------
+|
+| Enables Gzip output compression for faster page loads. When enabled,
+| the output class will test whether your server supports Gzip.
+| Even if it does, however, not all browsers support compression
+| so enable only if you are reasonably sure your visitors can handle it.
+|
+| Only used if zlib.output_compression is turned off in your php.ini.
+| Please do not use it together with httpd-level output compression.
+|
+| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
+| means you are prematurely outputting something to your browser. It could
+| even be a line of whitespace at the end of one of your scripts. For
+| compression to work, nothing can be sent before the output buffer is called
+| by the output class. Do not 'echo' any values with compression enabled.
+|
+*/
+$config['compress_output'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Master Time Reference
+|--------------------------------------------------------------------------
+|
+| Options are 'local' or any PHP supported timezone. This preference tells
+| the system whether to use your server's local time as the master 'now'
+| reference, or convert it to the configured one timezone. See the 'date
+| helper' page of the user guide for information regarding date handling.
+|
+*/
+$config['time_reference'] = 'local';
+date_default_timezone_set('Asia/Kolkata');
+
+/*
+|--------------------------------------------------------------------------
+| Rewrite PHP Short Tags
+|--------------------------------------------------------------------------
+|
+| If your PHP installation does not have short tag support enabled CI
+| can rewrite the tags on-the-fly, enabling you to utilize that syntax
+| in your view files. Options are TRUE or FALSE (boolean)
+|
+| Note: You need to have eval() enabled for this to work.
+|
+*/
+$config['rewrite_short_tags'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| 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
+| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
+| the visitor's IP address.
+|
+| You can use both an array or a comma-separated list of proxy addresses,
+| as well as specifying whole subnets. Here are a few examples:
+|
+| Comma-separated: '10.0.1.200,192.168.5.0/24'
+| Array: array('10.0.1.200', '192.168.5.0/24')
+*/
+$config['proxy_ips'] = '';
diff --git a/api/application/config/constants.php b/api/application/config/constants.php
new file mode 100644
index 0000000..0ec317d
--- /dev/null
+++ b/api/application/config/constants.php
@@ -0,0 +1,170 @@
+ md5
+defined('ENCR_PASSWORD') OR define('ENCR_PASSWORD','e99a18c428cb38d5f260853678922e03');
+//end of encripted password
\ No newline at end of file
diff --git a/api/application/config/database.php b/api/application/config/database.php
new file mode 100644
index 0000000..f8df5be
--- /dev/null
+++ b/api/application/config/database.php
@@ -0,0 +1,96 @@
+db->last_query() and profiling of DB queries.
+| When you run a query, with this setting set to TRUE (default),
+| CodeIgniter will store the SQL statement for debugging purposes.
+| However, this may cause high memory usage, especially if you run
+| a lot of SQL queries ... disable this to avoid that problem.
+|
+| The $active_group variable lets you choose which connection group to
+| make active. By default there is only one group (the 'default' group).
+|
+| The $query_builder variables lets you determine whether or not to load
+| the query builder class.
+*/
+$active_group = 'default';
+$query_builder = TRUE;
+
+$db['default'] = array(
+ 'dsn' => '',
+ 'hostname' => 'apollodec.com',
+ 'username' => 'apollod4_DEV',
+ 'password' => 'apollo1234',
+ 'database' => 'apollod4_ApolloDECDev',
+ 'dbdriver' => 'mysqli',
+ 'dbprefix' => '',
+ 'pconnect' => FALSE,
+ 'db_debug' => (ENVIRONMENT !== 'production'),
+ 'cache_on' => FALSE,
+ 'cachedir' => '',
+ 'char_set' => 'utf8',
+ 'dbcollat' => 'utf8_general_ci',
+ 'swap_pre' => '',
+ 'encrypt' => FALSE,
+ 'compress' => FALSE,
+ 'stricton' => FALSE,
+ 'failover' => array(),
+ 'save_queries' => TRUE
+);
diff --git a/api/application/config/doctypes.php b/api/application/config/doctypes.php
new file mode 100644
index 0000000..59a7991
--- /dev/null
+++ b/api/application/config/doctypes.php
@@ -0,0 +1,24 @@
+ '',
+ 'xhtml1-strict' => '',
+ 'xhtml1-trans' => '',
+ 'xhtml1-frame' => '',
+ 'xhtml-basic11' => '',
+ 'html5' => '',
+ 'html4-strict' => '',
+ 'html4-trans' => '',
+ 'html4-frame' => '',
+ 'mathml1' => '',
+ 'mathml2' => '',
+ 'svg10' => '',
+ 'svg11' => '',
+ 'svg11-basic' => '',
+ 'svg11-tiny' => '',
+ 'xhtml-math-svg-xh' => '',
+ 'xhtml-math-svg-sh' => '',
+ 'xhtml-rdfa-1' => '',
+ 'xhtml-rdfa-2' => ''
+);
diff --git a/api/application/config/foreign_chars.php b/api/application/config/foreign_chars.php
new file mode 100644
index 0000000..ac406e3
--- /dev/null
+++ b/api/application/config/foreign_chars.php
@@ -0,0 +1,103 @@
+ 'ae',
+ '/ö|œ/' => 'oe',
+ '/ü/' => 'ue',
+ '/Ä/' => 'Ae',
+ '/Ü/' => 'Ue',
+ '/Ö/' => 'Oe',
+ '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
+ '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
+ '/Б/' => 'B',
+ '/б/' => 'b',
+ '/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
+ '/ç|ć|ĉ|ċ|č/' => 'c',
+ '/Д/' => 'D',
+ '/д/' => 'd',
+ '/Ð|Ď|Đ|Δ/' => 'Dj',
+ '/ð|ď|đ|δ/' => 'dj',
+ '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
+ '/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
+ '/Ф/' => 'F',
+ '/ф/' => 'f',
+ '/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
+ '/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
+ '/Ĥ|Ħ/' => 'H',
+ '/ĥ|ħ/' => 'h',
+ '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
+ '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
+ '/Ĵ/' => 'J',
+ '/ĵ/' => 'j',
+ '/Ķ|Κ|К/' => 'K',
+ '/ķ|κ|к/' => 'k',
+ '/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
+ '/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
+ '/М/' => 'M',
+ '/м/' => 'm',
+ '/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
+ '/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
+ '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
+ '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
+ '/П/' => 'P',
+ '/п/' => 'p',
+ '/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
+ '/ŕ|ŗ|ř|ρ|р/' => 'r',
+ '/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
+ '/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
+ '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
+ '/ț|ţ|ť|ŧ|т/' => 't',
+ '/Þ|þ/' => 'th',
+ '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
+ '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
+ '/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
+ '/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
+ '/В/' => 'V',
+ '/в/' => 'v',
+ '/Ŵ/' => 'W',
+ '/ŵ/' => 'w',
+ '/Ź|Ż|Ž|Ζ|З/' => 'Z',
+ '/ź|ż|ž|ζ|з/' => 'z',
+ '/Æ|Ǽ/' => 'AE',
+ '/ß/' => 'ss',
+ '/IJ/' => 'IJ',
+ '/ij/' => 'ij',
+ '/Œ/' => 'OE',
+ '/ƒ/' => 'f',
+ '/ξ/' => 'ks',
+ '/π/' => 'p',
+ '/β/' => 'v',
+ '/μ/' => 'm',
+ '/ψ/' => 'ps',
+ '/Ё/' => 'Yo',
+ '/ё/' => 'yo',
+ '/Є/' => 'Ye',
+ '/є/' => 'ye',
+ '/Ї/' => 'Yi',
+ '/Ж/' => 'Zh',
+ '/ж/' => 'zh',
+ '/Х/' => 'Kh',
+ '/х/' => 'kh',
+ '/Ц/' => 'Ts',
+ '/ц/' => 'ts',
+ '/Ч/' => 'Ch',
+ '/ч/' => 'ch',
+ '/Ш/' => 'Sh',
+ '/ш/' => 'sh',
+ '/Щ/' => 'Shch',
+ '/щ/' => 'shch',
+ '/Ъ|ъ|Ь|ь/' => '',
+ '/Ю/' => 'Yu',
+ '/ю/' => 'yu',
+ '/Я/' => 'Ya',
+ '/я/' => 'ya'
+);
diff --git a/api/application/config/hooks.php b/api/application/config/hooks.php
new file mode 100644
index 0000000..a8f38a5
--- /dev/null
+++ b/api/application/config/hooks.php
@@ -0,0 +1,13 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/config/memcached.php b/api/application/config/memcached.php
new file mode 100644
index 0000000..5c23b39
--- /dev/null
+++ b/api/application/config/memcached.php
@@ -0,0 +1,19 @@
+ array(
+ 'hostname' => '127.0.0.1',
+ 'port' => '11211',
+ 'weight' => '1',
+ ),
+);
diff --git a/api/application/config/migration.php b/api/application/config/migration.php
new file mode 100644
index 0000000..4b585a6
--- /dev/null
+++ b/api/application/config/migration.php
@@ -0,0 +1,84 @@
+migration->current() this is the version that schema will
+| be upgraded / downgraded to.
+|
+*/
+$config['migration_version'] = 0;
+
+/*
+|--------------------------------------------------------------------------
+| Migrations Path
+|--------------------------------------------------------------------------
+|
+| Path to your migrations folder.
+| Typically, it will be within your application path.
+| Also, writing permission is required within the migrations path.
+|
+*/
+$config['migration_path'] = APPPATH.'migrations/';
diff --git a/api/application/config/mimes.php b/api/application/config/mimes.php
new file mode 100644
index 0000000..0176533
--- /dev/null
+++ b/api/application/config/mimes.php
@@ -0,0 +1,183 @@
+ array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
+ 'cpt' => 'application/mac-compactpro',
+ 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
+ 'bin' => array('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' => array('application/octet-stream', 'application/x-msdownload'),
+ 'class' => 'application/octet-stream',
+ 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
+ 'ai' => array('application/pdf', 'application/postscript'),
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => array('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' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
+ 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
+ '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' => array('application/x-httpd-php', 'application/php', 'application/x-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' => array('application/x-javascript', 'text/plain'),
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
+ 'z' => 'application/x-compress',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
+ 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
+ 'aif' => array('audio/x-aiff', 'audio/aiff'),
+ 'aiff' => array('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' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
+ 'bmp' => array('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',
+ 'jpeg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpe' => array('image/jpeg', 'image/pjpeg'),
+ 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'png' => array('image/png', 'image/x-png'),
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => array('text/css', 'text/plain'),
+ 'html' => array('text/html', 'text/plain'),
+ 'htm' => array('text/html', 'text/plain'),
+ 'shtml' => array('text/html', 'text/plain'),
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => array('text/plain', 'text/x-log'),
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => array('application/xml', 'text/xml', 'text/plain'),
+ 'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => array('application/msword', 'application/vnd.ms-office'),
+ 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
+ 'dot' => array('application/msword', 'application/vnd.ms-office'),
+ 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
+ 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
+ 'word' => array('application/msword', 'application/octet-stream'),
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822',
+ 'json' => array('application/json', 'text/json'),
+ 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
+ 'p10' => array('application/x-pkcs10', 'application/pkcs10'),
+ 'p12' => 'application/x-pkcs12',
+ 'p7a' => 'application/x-pkcs7-signature',
+ 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7r' => 'application/x-pkcs7-certreqresp',
+ 'p7s' => 'application/pkcs7-signature',
+ 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
+ 'crl' => array('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' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
+ '3g2' => 'video/3gpp2',
+ '3gp' => array('video/3gp', 'video/3gpp'),
+ 'mp4' => 'video/mp4',
+ 'm4a' => 'audio/x-m4a',
+ 'f4v' => array('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' => array('video/x-ms-wmv', 'video/x-ms-asf'),
+ 'au' => 'audio/x-au',
+ 'ac3' => 'audio/ac3',
+ 'flac' => 'audio/x-flac',
+ 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
+ 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
+ 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
+ 'ics' => 'text/calendar',
+ 'ical' => 'text/calendar',
+ 'zsh' => 'text/x-scriptzsh',
+ '7zip' => array('application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
+ 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
+ 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
+ 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
+ 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
+ 'vcf' => 'text/x-vcard',
+ 'srt' => array('text/srt', 'text/plain'),
+ 'vtt' => array('text/vtt', 'text/plain'),
+ 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
+ 'odc' => 'application/vnd.oasis.opendocument.chart',
+ 'otc' => 'application/vnd.oasis.opendocument.chart-template',
+ 'odf' => 'application/vnd.oasis.opendocument.formula',
+ 'otf' => 'application/vnd.oasis.opendocument.formula-template',
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
+ 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
+ 'odi' => 'application/vnd.oasis.opendocument.image',
+ 'oti' => 'application/vnd.oasis.opendocument.image-template',
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
+ 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'odm' => 'application/vnd.oasis.opendocument.text-master',
+ 'ott' => 'application/vnd.oasis.opendocument.text-template',
+ 'oth' => 'application/vnd.oasis.opendocument.text-web'
+);
diff --git a/api/application/config/profiler.php b/api/application/config/profiler.php
new file mode 100644
index 0000000..3db22e3
--- /dev/null
+++ b/api/application/config/profiler.php
@@ -0,0 +1,14 @@
+function($username, $password)
+| In other cases override the function _perform_library_auth in your controller
+|
+| For digest authentication the library function should return already a stored
+| md5(username:restrealm:password) for that username
+|
+| e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2'
+|
+*/
+$config['auth_library_class'] = '';
+$config['auth_library_function'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Override auth types for specific class/method
+|--------------------------------------------------------------------------
+|
+| Set specific authentication types for methods within a class (controller)
+|
+| Set as many config entries as needed. Any methods not set will use the default 'rest_auth' config value.
+|
+| e.g:
+|
+| $config['auth_override_class_method']['deals']['view'] = 'none';
+| $config['auth_override_class_method']['deals']['insert'] = 'digest';
+| $config['auth_override_class_method']['accounts']['user'] = 'basic';
+| $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic';
+|
+| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name)
+| Acceptable values are; 'none', 'digest' and 'basic'.
+|
+*/
+$config['auth_override_class_method']['autenticador']['*'] = 'none';
+// $config['auth_override_class_method']['deals']['insert'] = 'digest';
+// $config['auth_override_class_method']['accounts']['user'] = 'basic';
+// $config['auth_override_class_method']['dashboard']['*'] = 'basic';
+
+
+// ---Uncomment list line for the wildard unit test
+// $config['auth_override_class_method']['wildcard_test_cases']['*'] = 'basic';
+
+/*
+|--------------------------------------------------------------------------
+| Override auth types for specfic 'class/method/HTTP method'
+|--------------------------------------------------------------------------
+|
+| example:
+|
+| $config['auth_override_class_method_http']['deals']['view']['get'] = 'none';
+| $config['auth_override_class_method_http']['deals']['insert']['post'] = 'none';
+| $config['auth_override_class_method_http']['deals']['*']['options'] = 'none';
+*/
+
+// ---Uncomment list line for the wildard unit test
+// $config['auth_override_class_method_http']['wildcard_test_cases']['*']['options'] = 'basic';
+
+/*
+|--------------------------------------------------------------------------
+| REST Login Usernames
+|--------------------------------------------------------------------------
+|
+| Array of usernames and passwords for login, if ldap is configured this is ignored
+|
+*/
+$config['rest_valid_logins'] = ['admin' => '1234'];
+
+/*
+|--------------------------------------------------------------------------
+| Global IP Whitelisting
+|--------------------------------------------------------------------------
+|
+| Limit connections to your REST server to whitelisted IP addresses
+|
+| Usage:
+| 1. Set to TRUE and select an auth option for extreme security (client's IP
+| address must be in whitelist and they must also log in)
+| 2. Set to TRUE with auth set to FALSE to allow whitelisted IPs access with no login
+| 3. Set to FALSE but set 'auth_override_class_method' to 'whitelist' to
+| restrict certain methods to IPs in your whitelist
+|
+*/
+$config['rest_ip_whitelist_enabled'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST IP Whitelist
+|--------------------------------------------------------------------------
+|
+| Limit connections to your REST server with a comma separated
+| list of IP addresses
+|
+| e.g: '123.456.789.0, 987.654.32.1'
+|
+| 127.0.0.1 and 0.0.0.0 are allowed by default
+|
+*/
+$config['rest_ip_whitelist'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Global IP Blacklisting
+|--------------------------------------------------------------------------
+|
+| Prevent connections to the REST server from blacklisted IP addresses
+|
+| Usage:
+| 1. Set to TRUE and add any IP address to 'rest_ip_blacklist'
+|
+*/
+$config['rest_ip_blacklist_enabled'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST IP Blacklist
+|--------------------------------------------------------------------------
+|
+| Prevent connections from the following IP addresses
+|
+| e.g: '123.456.789.0, 987.654.32.1'
+|
+*/
+$config['rest_ip_blacklist'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| REST Database Group
+|--------------------------------------------------------------------------
+|
+| Connect to a database group for keys, logging, etc. It will only connect
+| if you have any of these features enabled
+|
+*/
+$config['rest_database_group'] = 'default';
+
+/*
+|--------------------------------------------------------------------------
+| REST API Keys Table Name
+|--------------------------------------------------------------------------
+|
+| The table name in your database that stores API keys
+|
+*/
+$config['rest_keys_table'] = 'keys';
+
+/*
+|--------------------------------------------------------------------------
+| REST Enable Keys
+|--------------------------------------------------------------------------
+|
+| When set to TRUE, the REST API will look for a column name called 'key'.
+| If no key is provided, the request will result in an error. To override the
+| column name see 'rest_key_column'
+|
+| Default table schema:
+| CREATE TABLE `keys` (
+| `id` INT(11) NOT NULL AUTO_INCREMENT,
+| `user_id` INT(11) NOT NULL,
+| `key` VARCHAR(40) NOT NULL,
+| `level` INT(2) NOT NULL,
+| `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0',
+| `is_private_key` TINYINT(1) NOT NULL DEFAULT '0',
+| `ip_addresses` TEXT NULL DEFAULT NULL,
+| `date_created` INT(11) NOT NULL,
+| PRIMARY KEY (`id`)
+| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+|
+*/
+$config['rest_enable_keys'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST Table Key Column Name
+|--------------------------------------------------------------------------
+|
+| If not using the default table schema in 'rest_enable_keys', specify the
+| column name to match e.g. my_key
+|
+*/
+$config['rest_key_column'] = 'key';
+
+/*
+|--------------------------------------------------------------------------
+| REST API Limits method
+|--------------------------------------------------------------------------
+|
+| Specify the method used to limit the API calls
+|
+| Available methods are :
+| $config['rest_limits_method'] = 'IP_ADDRESS'; // Put a limit per ip address
+| $config['rest_limits_method'] = 'API_KEY'; // Put a limit per api key
+| $config['rest_limits_method'] = 'METHOD_NAME'; // Put a limit on method calls
+| $config['rest_limits_method'] = 'ROUTED_URL'; // Put a limit on the routed URL
+|
+*/
+$config['rest_limits_method'] = 'ROUTED_URL';
+
+/*
+|--------------------------------------------------------------------------
+| REST Key Length
+|--------------------------------------------------------------------------
+|
+| Length of the created keys. Check your default database schema on the
+| maximum length allowed
+|
+| Note: The maximum length is 40
+|
+*/
+$config['rest_key_length'] = 40;
+
+/*
+|--------------------------------------------------------------------------
+| REST API Key Variable
+|--------------------------------------------------------------------------
+|
+| Custom header to specify the API key
+
+| Note: Custom headers with the X- prefix are deprecated as of
+| 2012/06/12. See RFC 6648 specification for more details
+|
+*/
+$config['rest_key_name'] = 'X-API-KEY';
+
+/*
+|--------------------------------------------------------------------------
+| REST Enable Logging
+|--------------------------------------------------------------------------
+|
+| When set to TRUE, the REST API will log actions based on the column names 'key', 'date',
+| 'time' and 'ip_address'. This is a general rule that can be overridden in the
+| $this->method array for each controller
+|
+| Default table schema:
+| CREATE TABLE `logs` (
+| `id` INT(11) NOT NULL AUTO_INCREMENT,
+| `uri` VARCHAR(255) NOT NULL,
+| `method` VARCHAR(6) NOT NULL,
+| `params` TEXT DEFAULT NULL,
+| `api_key` VARCHAR(40) NOT NULL,
+| `ip_address` VARCHAR(45) NOT NULL,
+| `time` INT(11) NOT NULL,
+| `rtime` FLOAT DEFAULT NULL,
+| `authorized` VARCHAR(1) NOT NULL,
+| `response_code` smallint(3) DEFAULT '0',
+| PRIMARY KEY (`id`)
+| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+|
+*/
+$config['rest_enable_logging'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST API Logs Table Name
+|--------------------------------------------------------------------------
+|
+| If not using the default table schema in 'rest_enable_logging', specify the
+| table name to match e.g. my_logs
+|
+*/
+$config['rest_logs_table'] = 'logs';
+
+/*
+|--------------------------------------------------------------------------
+| REST Method Access Control
+|--------------------------------------------------------------------------
+| When set to TRUE, the REST API will check the access table to see if
+| the API key can access that controller. 'rest_enable_keys' must be enabled
+| to use this
+|
+| Default table schema:
+| CREATE TABLE `access` (
+| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
+| `key` VARCHAR(40) NOT NULL DEFAULT '',
+| `all_access` TINYINT(1) NOT NULL DEFAULT '0',
+| `controller` VARCHAR(50) NOT NULL DEFAULT '',
+| `date_created` DATETIME DEFAULT NULL,
+| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+| PRIMARY KEY (`id`)
+| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+|
+*/
+$config['rest_enable_access'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST API Access Table Name
+|--------------------------------------------------------------------------
+|
+| If not using the default table schema in 'rest_enable_access', specify the
+| table name to match e.g. my_access
+|
+*/
+$config['rest_access_table'] = 'access';
+
+/*
+|--------------------------------------------------------------------------
+| REST API Param Log Format
+|--------------------------------------------------------------------------
+|
+| When set to TRUE, the REST API log parameters will be stored in the database as JSON
+| Set to FALSE to log as serialized PHP
+|
+*/
+$config['rest_logs_json_params'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST Enable Limits
+|--------------------------------------------------------------------------
+|
+| When set to TRUE, the REST API will count the number of uses of each method
+| by an API key each hour. This is a general rule that can be overridden in the
+| $this->method array in each controller
+|
+| Default table schema:
+| CREATE TABLE `limits` (
+| `id` INT(11) NOT NULL AUTO_INCREMENT,
+| `uri` VARCHAR(255) NOT NULL,
+| `count` INT(10) NOT NULL,
+| `hour_started` INT(11) NOT NULL,
+| `api_key` VARCHAR(40) NOT NULL,
+| PRIMARY KEY (`id`)
+| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+|
+| To specify the limits within the controller's __construct() method, add per-method
+| limits with:
+|
+| $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR];
+|
+| See application/controllers/api/example.php for examples
+*/
+$config['rest_enable_limits'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST API Limits Table Name
+|--------------------------------------------------------------------------
+|
+| If not using the default table schema in 'rest_enable_limits', specify the
+| table name to match e.g. my_limits
+|
+*/
+$config['rest_limits_table'] = 'limits';
+
+/*
+|--------------------------------------------------------------------------
+| REST Ignore HTTP Accept
+|--------------------------------------------------------------------------
+|
+| Set to TRUE to ignore the HTTP Accept and speed up each request a little.
+| Only do this if you are using the $this->rest_format or /format/xml in URLs
+|
+*/
+$config['rest_ignore_http_accept'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST AJAX Only
+|--------------------------------------------------------------------------
+|
+| Set to TRUE to allow AJAX requests only. Set to FALSE to accept HTTP requests
+|
+| Note: If set to TRUE and the request is not AJAX, a 505 response with the
+| error message 'Only AJAX requests are accepted.' will be returned.
+|
+| Hint: This is good for production environments
+|
+*/
+$config['rest_ajax_only'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| REST Language File
+|--------------------------------------------------------------------------
+|
+| Language file to load from the language directory
+|
+*/
+$config['rest_language'] = 'portuguese-brazilian';
+
+/*
+|--------------------------------------------------------------------------
+| CORS Check
+|--------------------------------------------------------------------------
+|
+| Set to TRUE to enable Cross-Origin Resource Sharing (CORS). Useful if you
+| are hosting your API on a different domain from the application that
+| will access it through a browser
+|
+*/
+$config['check_cors'] = true;
+
+/*
+|--------------------------------------------------------------------------
+| CORS Allowable Headers
+|--------------------------------------------------------------------------
+|
+| If using CORS checks, set the allowable headers here
+|
+*/
+$config['allowed_cors_headers'] = [
+ 'Origin',
+ 'X-Requested-With',
+ 'Content-Type',
+ 'Accept',
+ 'Access-Control-Request-Method',
+ 'Authorization'
+];
+
+/*
+|--------------------------------------------------------------------------
+| CORS Allowable Methods
+|--------------------------------------------------------------------------
+|
+| If using CORS checks, you can set the methods you want to be allowed
+|
+*/
+$config['allowed_cors_methods'] = [
+ 'GET',
+ 'POST',
+ 'OPTIONS',
+ 'PUT',
+ 'PATCH',
+ 'DELETE'
+];
+
+/*
+|--------------------------------------------------------------------------
+| CORS Allow Any Domain
+|--------------------------------------------------------------------------
+|
+| Set to TRUE to enable Cross-Origin Resource Sharing (CORS) from any
+| source domain
+|
+*/
+$config['allow_any_cors_domain'] = true;
+
+/*
+|--------------------------------------------------------------------------
+| CORS Allowable Domains
+|--------------------------------------------------------------------------
+|
+| Used if $config['check_cors'] is set to TRUE and $config['allow_any_cors_domain']
+| is set to FALSE. Set all the allowable domains within the array
+|
+| e.g. $config['allowed_origins'] = ['http://www.example.com', 'https://spa.example.com']
+|
+*/
+$config['allowed_cors_origins'] = [];
diff --git a/api/application/config/routes.php b/api/application/config/routes.php
new file mode 100644
index 0000000..15ed7b0
--- /dev/null
+++ b/api/application/config/routes.php
@@ -0,0 +1,264 @@
+ my_controller/index
+| my-controller/my-method -> my_controller/my_method
+*/
+$route['default_controller'] = 'welcome';
+$route['404_override'] = '';
+$route['translate_uri_dashes'] = TRUE;
+
+/*
+| -------------------------------------------------------------------------
+| Sample REST API Routes
+| -------------------------------------------------------------------------
+*/
+$route['autenticadors'] = 'autenticador/index'; // Example 4
+$route['login'] = 'Login_Controller/login';
+// Forget password
+$route['forgetlogin'] = 'Forget_Controller/forgetlogin';
+// branch
+$route['getMasterBranchDetails'] = 'Employee_Controller/getMasterBranchDetails';
+$route['addBranchDetails'] = 'Branch_Controller/addBranchDetails';
+$route['getBranchDetails'] = 'Branch_Controller/getBranchDetails';
+$route['updateBranchDetails'] = 'Branch_Controller/updateBranchDetails';
+// staff
+$route['employee'] = 'Employee_Controller/employee';
+$route['getEmployeeList'] = 'Employee_Controller/getEmployeeList';
+$route['getRoleDetails'] = 'Employee_Controller/getRoleDetails';
+$route['chkEmpExistDetail'] = 'Employee_Controller/check_exist';
+$route['insertEmployee'] = 'Employee_Controller/addEmployee';
+$route['chkUpdateEmpExistDetail'] = 'Employee_Controller/check_update_exist';
+$route['updateEmpExistDetail'] = 'Employee_Controller/updateEmployee';
+$route['getEmpBranchDetails'] = 'Employee_Controller/getEmpBranchDetails';
+$route['updateEmpBranchDetail'] = 'Employee_Controller/updateEmpBranchDetail';
+$route['updateEmpImgExistDetail'] = 'Employee_Controller/updateEmployeeImage';
+$route['insertEmployeeImage'] = 'Employee_Controller/addEmployeeImage';
+$route['employeeGetProf'] = 'Employee_Controller/employeeGetProf';
+$route['addEmpBranchDetail'] = 'Employee_Controller/addEmpBranchDetail';
+// call tracking
+$route['getTrackingLeadDetails'] = 'Call_Tracking_Controller/getTrackingLeadDetails';
+$route['addLeadTrackingDetails'] = 'Call_Tracking_Controller/addLeadTrackingDetails';
+$route['getTrackingDetails'] = 'Call_Tracking_Controller/getTrackingDetails';
+$route['updateFollowupDetails'] = 'Call_Tracking_Controller/updateFollowupDetails';
+$route['loadFollowupDetails'] = 'Call_Tracking_Controller/loadFollowupDetails';
+$route['getRecentLeadDetails'] = 'Call_Tracking_Controller/getRecentLeadDetails';
+$route['getRecentCloseDetails'] = 'Call_Tracking_Controller/getRecentCloseDetails';
+$route['getRecentPendingDetails'] = 'Call_Tracking_Controller/getRecentPendingDetails';
+$route['callAsImportantFlag'] = 'Call_Tracking_Controller/callAsImportantFlag';
+
+
+
+// university
+$route['insertUniversity'] = 'University_Controller/insertUniversity';
+$route['getUniversity'] = 'University_Controller/getUniversity';
+$route['chkUnivIdExistDetail'] = 'University_Controller/chkUnivIdExistDetail';
+$route['updateUniversityDetail'] = 'University_Controller/updateUniversityDetail';
+//course
+$route['getCourseDetails'] = 'Course_Controller/getCourseDetails';
+$route['addCourseDetails'] = 'Course_Controller/addCourseDetails';
+$route['updateCourseDetails'] = 'Course_Controller/updateCourseDetails';
+$route['getCourseUnivFeesDetails'] = 'Course_Controller/getCourseUnivFeesDetails';
+
+// activity
+$route['addActivityDetails'] = 'University_Controller/addActivityDetails';
+$route['getActivityDetails'] = 'University_Controller/getActivityDetails';
+$route['updateActivityDetails'] = 'University_Controller/updateActivityDetails';
+
+$route['changePassword'] = 'Login_Controller/changePassword';
+
+// student
+$route['insertStudent'] = 'Student_Controller/addStudent';
+$route['getStudentUniversity'] = 'Student_Controller/getStudentUniversity';
+$route['getCourseBatchForUniv'] = 'Student_Controller/getCourseBatch';
+$route['chkStudentExistDetail'] = 'Student_Controller/chkStudentExistDetail';
+$route['getStudentList'] = 'Student_Controller/getStudentList';
+$route['updateStudentExistDetail'] = 'Student_Controller/updateStudentExistDetail';
+$route['chkUpdateStuExistDetail'] = 'Student_Controller/chkUpdateStuExistDetail';
+$route['getStudentCourseList'] = 'Student_Controller/getStudentCourseList';
+$route['getStudentCourseDetails'] = 'Student_Controller/getStudentCourseDetails';
+$route['updateStudentCourseDetail'] = 'Student_Controller/updateStudentCourseDetail';
+$route['insertStudentCourse'] = 'Student_Controller/insertStudentCourse';
+$route['insertStudentImg'] = 'Student_Controller/insertStudentImg';
+$route['updateStudentImgDetails'] = 'Student_Controller/updateStudentImgDetails';
+$route['getBranchListDetails'] = 'Student_Controller/getBranchListDetails';
+$route['getBranchActiveStatusforStuAdd'] = 'Student_Controller/getBranchActiveStatusforStuAdd';
+$route['getExistingStudentDetails'] = 'Student_Controller/getExistingStudentDetails';
+$route['addStudentEntrollDocDetails'] = 'Student_Controller/addStudentEntrollDocDetails';
+$route['getListofStuDocDetails'] = 'Student_Controller/getListofStuDocDetails';
+$route['deleteStuDocDetails'] = 'Student_Controller/deleteStuDocDetails';
+$route['getListofStuPendingDocDetails'] = 'Student_Controller/getListofStuPendingDocDetails';
+$route['addStudentEnrollPendingDocDetails'] = 'Student_Controller/addStudentEnrollPendingDocDetails';
+$route['deleteDocPendingDetails'] = 'Student_Controller/deleteDocPendingDetails';
+
+//batch
+$route['addBatchDetails'] = 'Batch_Controller/addBatchDetails';
+$route['updateBatchDetails'] = 'Batch_Controller/updateBatchDetails';
+$route['getBatchDetails'] = 'Batch_Controller/getBatchDetails';
+$route['updateBatchDefault'] = 'Batch_Controller/updateBatchDefault';
+
+/*Announcement*/
+$route['addAnnouncementDetails'] = 'Announcement_Controller/addAnnouncementDetails';
+$route['getAnnouncementDetails'] = 'Announcement_Controller/getAnnouncementDetails';
+$route['updateAnnouncementDetails'] = 'Announcement_Controller/updateAnnouncementDetails';
+
+// dash board
+$route['getDashboardCallTrack'] = 'Call_Tracking_Controller/getDashboardCallTrack';
+$route['getTotalStudent'] = 'Dashboard_Controller/getTotalStudent';
+$route['getTotalEmployee'] = 'Dashboard_Controller/getTotalEmployee';
+$route['getTotalUsers'] = 'Dashboard_Controller/getTotalUsers';
+
+/*login page announcement*/
+$route['getLoginAnnouncementDetails'] = 'Login_Controller/getLoginAnnouncementDetails';
+/* status */
+$route['addStatusDetails'] = 'Status_Controller/addStatusDetails';
+$route['getStatusDetails'] = 'Status_Controller/getStatusDetails';
+$route['updateStatusDetails'] = 'Status_Controller/updateStatusDetails';
+$route['getBranchListStatusUpdate'] = 'Status_Controller/getBranchListStatusUpdate';
+$route['getBranchStatusList'] = 'Status_Controller/getBranchStatusList';
+/*get student list for fees update*/
+$route['getStudentListFees'] = 'Fees_Status_Controller/getStudentList';
+/*get student fees structure for fees update*/
+$route['getStudentFeesStructure'] = 'Fees_Status_Controller/getFeesStructure';
+$route['getStudentFeesAssign'] = 'Fees_Status_Controller/getFeesStructureAssign';
+$route['setFeesForStudent'] = 'Fees_Status_Controller/setFeesForStudent';
+
+/*update fees details for student*/
+$route['updateFeesDetails'] = 'Fees_Status_Controller/updateFeesDetails';
+$route['getUniversityCourseForFees'] = 'Fees_Status_Controller/getUniversityCourseForFees';
+/*
+ * get default activity details
+ * */
+$route['getDefaultActivityDetails'] = 'University_Controller/getDefaultActivityDetails';
+$route['updateDefaultActivityDetails'] = 'University_Controller/updateDefaultActivityDetails';
+// statu updation details studymaterial, answerbooklet, application, certification
+$route['getUniveCourseBratch'] = 'StatusUpdation_Controller/getUniveCourseBratch';
+$route['getSearchAutoDetails'] = 'StatusUpdation_Controller/getSearchDetails';
+$route['getSemYearForCourse'] = 'StatusUpdation_Controller/getSemYearForCourse';
+$route['updateStudentMaterialStatus'] = 'StatusUpdation_Controller/updateStudentMaterialStatus';
+$route['updateAnswerBookLetStatus'] = 'StatusUpdation_Controller/updateAnswerBookLetStatus';
+$route['getCertificateList'] = 'StatusUpdation_Controller/getCertificateList';
+$route['updateCertificationStatus'] = 'StatusUpdation_Controller/updateCertificationStatus';
+$route['updateApplicationStatus'] = 'StatusUpdation_Controller/updateApplicationStatus';
+$route['getStatusListForUpdate'] = 'StatusUpdation_Controller/getStatusListForUpdate';
+$route['getPrevStatusDetailsForStu'] = 'StatusUpdation_Controller/getPrevStatusDetailsForStu';
+
+/*get student view details*/
+$route['getStudentBasicInfo'] = 'StudentView_Controller/getStudentInfo';
+
+
+/*get certificate Details*/
+$route['getCertificateDetails'] = 'Certificate_Controller/getCertificateDetails';
+$route['addCertificateDetails'] = 'Certificate_Controller/addCertificateDetails';
+$route['updateCertificateDetails'] = 'Certificate_Controller/updateCertificateDetails';
+/*
+ * Day Book
+ * */
+$route['deleteDayBookDetails'] = 'DayBook_Controller/deleteDayBookDetails';
+$route['updateDayBookDetails'] = 'DayBook_Controller/updateDayBookDetails';
+$route['getDayBookDetails'] = 'DayBook_Controller/getDayBookDetails';
+$route['getDayBookApprovalDetails'] = 'DayBook_Controller/getDayBookApprovalDetails';
+$route['getIncomeExpenseTypeState'] = 'DayBook_Controller/getIncomeExpenseTypeState';
+$route['addDayBook'] = 'DayBook_Controller/adddaybook';
+$route['updateDayBookStatusAdmin'] = 'DayBook_Controller/updateDayBookStatusAdmin';
+$route['getDayBookDetailsSuperAdmin'] = 'DayBook_Controller/getDayBookDetailsSuperAdmin';
+$route['empDayBookModuleAccessChk'] = 'DayBook_Controller/empDayBookModuleAccessChk';
+$route['deleteDayBookFeePayableDetails'] = 'DayBook_Controller/deleteDayBookFeePayableDetails';
+
+/* * day book master * */
+$route['getDayBookMasterDetails'] = 'DayBookMaster_Controller/getDayBookMasterDetails';
+$route['addDaybookMasterDetails'] = 'DayBookMaster_Controller/addDaybookMasterDetails';
+$route['updateDayBookMasterDetails'] = 'DayBookMaster_Controller/updateDayBookMasterDetails';
+
+/** This is for CRONE JOB*/
+$route['sendStudentNotification'] = 'Fees_Status_Controller/sendStudentNotification';
+
+
+/*
+ * SMS send
+ * */
+$route['getUniveCourseBratchBroadCast'] = 'Broadcast_Controller/getUniveCourseBatch';
+$route['getStuListForBroadcast'] = 'Broadcast_Controller/getStuListForBrodcast';
+$route['sendSMSStudentApi'] = 'Broadcast_Controller/sendSMSStudentApi';
+
+$route['getCronCall'] = 'Broadcast_Controller/getCronCall';
+$route['getSMSSendReportList'] = 'Broadcast_Controller/getSMSSendReportList';
+$route['getSMSGroupDetails'] = 'Broadcast_Controller/getSMSGroupDetails';
+
+//center
+
+$route['addCenterDetails'] = 'Center_Controller/addCenterDetails';
+$route['updateCenterDetails'] = 'Center_Controller/updateCenterDetails';
+$route['getCenterDetails'] = 'Center_Controller/getCenterDetails';
+
+//subject
+$route['getSubjectDetails'] = 'Subject_Controller/getSubjectDetails';
+$route['updateSubjectDetails'] = 'Subject_Controller/updateSubjectDetails';
+$route['addSubjectDetails'] = 'Subject_Controller/addSubjectDetails';
+
+// session mater
+$route['addSessionMaterDetails'] = 'SessionMater_Controller/addSessionMaterDetails';
+$route['getSessionMaterDetails'] = 'SessionMater_Controller/getSessionMaterDetails';
+$route['updateSessionMaterDetails'] = 'SessionMater_Controller/updateSessionMaterDetails';
+
+// session schedule
+$route['addSessionScheduleDetails'] = 'SessionSchedule_Controller/addSessionScheduleDetails';
+$route['getSessionScheduleDetails'] = 'SessionSchedule_Controller/getSessionScheduleDetails';
+$route['updateSessionScheduleDetails'] = 'SessionSchedule_Controller/updateSessionScheduleDetails';
+
+// halltickets
+$route['getCourseSubjectDetails'] = 'HallTickets_Controller/getCourseSubjectDetails';
+
+//Reports
+$route['reportstatus'] = 'Report/status';
+$route['reportbatchlist'] = 'Report/batch';
+$route['reportmstatus'] = 'Report/mstatus';
+$route['reportcert_status'] = 'Report/cert_status';
+$route['reportmark_cert_status'] = 'Report/markcert_status';
+$route['reportexpense'] = 'Report/expense';
+
diff --git a/api/application/config/smileys.php b/api/application/config/smileys.php
new file mode 100644
index 0000000..abf9a89
--- /dev/null
+++ b/api/application/config/smileys.php
@@ -0,0 +1,64 @@
+ array('grin.gif', '19', '19', 'grin'),
+ ':lol:' => array('lol.gif', '19', '19', 'LOL'),
+ ':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
+ ':)' => array('smile.gif', '19', '19', 'smile'),
+ ';-)' => array('wink.gif', '19', '19', 'wink'),
+ ';)' => array('wink.gif', '19', '19', 'wink'),
+ ':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
+ ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
+ ':-S' => array('confused.gif', '19', '19', 'confused'),
+ ':wow:' => array('surprise.gif', '19', '19', 'surprised'),
+ ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
+ ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
+ '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
+ ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
+ ':P' => array('raspberry.gif', '19', '19', 'raspberry'),
+ ':blank:' => array('blank.gif', '19', '19', 'blank stare'),
+ ':long:' => array('longface.gif', '19', '19', 'long face'),
+ ':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
+ ':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
+ ':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
+ '8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
+ ':down:' => array('downer.gif', '19', '19', 'downer'),
+ ':red:' => array('embarrassed.gif', '19', '19', 'red face'),
+ ':sick:' => array('sick.gif', '19', '19', 'sick'),
+ ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
+ ':-/' => array('hmm.gif', '19', '19', 'hmmm'),
+ '>:(' => array('mad.gif', '19', '19', 'mad'),
+ ':mad:' => array('mad.gif', '19', '19', 'mad'),
+ '>:-(' => array('angry.gif', '19', '19', 'angry'),
+ ':angry:' => array('angry.gif', '19', '19', 'angry'),
+ ':zip:' => array('zip.gif', '19', '19', 'zipper'),
+ ':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
+ ':ahhh:' => array('shock.gif', '19', '19', 'shock'),
+ ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
+ ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
+ ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
+ ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
+ ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
+ ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
+ ':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
+ ':snake:' => array('snake.gif', '19', '19', 'snake'),
+ ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
+ ':question:' => array('question.gif', '19', '19', 'question')
+
+);
diff --git a/api/application/config/user_agents.php b/api/application/config/user_agents.php
new file mode 100644
index 0000000..798086b
--- /dev/null
+++ b/api/application/config/user_agents.php
@@ -0,0 +1,214 @@
+ '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'
+);
+
+
+// The order of this array should NOT be changed. Many browsers return
+// multiple browser types so we want to identify the sub-type first.
+$browsers = array(
+ 'OPR' => 'Opera',
+ 'Flock' => 'Flock',
+ 'Edge' => 'Spartan',
+ 'Chrome' => 'Chrome',
+ // Opera 10+ always reports Opera/9.80 and appends 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'
+);
+
+$mobiles = array(
+ // 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'
+);
+
+// There are hundreds of bots but these are the most common.
+$robots = array(
+ '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'
+);
diff --git a/api/application/controllers/Announcement_Controller.php b/api/application/controllers/Announcement_Controller.php
new file mode 100644
index 0000000..3bdf0b7
--- /dev/null
+++ b/api/application/controllers/Announcement_Controller.php
@@ -0,0 +1,134 @@
+methods['addAnnouncementDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addAnnouncementDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addAnnouncementDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getAnnouncementDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateAnnouncementDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('Announcement_model', 'announcement_model');
+
+ }
+
+ /*
+ * This method used to add Announcement Details
+ * created by Surendiran
+ * */
+
+ public function addAnnouncementDetails_post()
+ {
+ $details['Heading'] = $this->post('Heading');
+ $details['Description'] = $this->post('description');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $announcementDetails = $this->announcement_model->addAnnouncement($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($announcementDetails)
+ {
+ $announcementDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($announcementDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * get Announcement Details
+ * created by Surendiran
+ * */
+ public function getAnnouncementDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+
+ $getAnnouncement = $this->announcement_model->getAnnouncement();
+
+ if ($getAnnouncement)
+ {
+ $getAnnouncement['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getAnnouncement, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * update Announcement Details
+ * created by Surendiran
+ * */
+ public function updateAnnouncementDetails_post()
+ {
+ $updateID = $this->post('updateID');
+ // $details['ID'] = $this->post('ID');
+ $details['Heading'] = $this->post('Heading');
+ $details['Description'] = $this->post('description');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('createdBy');
+ $date = date('Y-m-d H:i:s');
+ $details['UpdatedOn'] = $date;
+ $announcementDetails = $this->announcement_model->updateAnnouncement($details,$updateID);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($announcementDetails)
+ {
+ $announcementDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($announcementDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+}
\ No newline at end of file
diff --git a/api/application/controllers/Autenticador.php b/api/application/controllers/Autenticador.php
new file mode 100644
index 0000000..69c76cf
--- /dev/null
+++ b/api/application/controllers/Autenticador.php
@@ -0,0 +1,70 @@
+post('email');
+ $password = $this->post('password');
+
+ $this->db->where('email', $email);
+ // $this->db->where('password', $password);
+ $usuario = $this->db->get('tbl_users')->first_row();
+
+ if ($usuario) {
+ $key = $this->config->item('encryption_key');
+
+ $token = $this->jwt->encode(array(
+ 'id'=>$usuario->email,
+ 'nome'=>$usuario->email,
+ 'email'=>$usuario->email,
+ 'admin'=>TRUE,
+ 'iat'=> strtotime("now"),
+ 'exp'=> strtotime("+2 hours")
+ ), $key);
+
+ $message = ['token' => $token];
+ $this->set_response($message, REST_Controller::HTTP_ACCEPTED);
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'status' => FALSE,
+ 'message' => 'Usuario ou senha errados'
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function sair_get()
+ {
+ try {
+ $key = $this->config->item('encryption_key');
+ $token = $this->input->get_request_header('Authorization');
+ $token = str_replace('Bearer ','',$token);
+ $token = $this->jwt->decode($token, $key);
+ } catch (Exception $e) {
+ $token = FALSE;
+ $erro = 'Erro: '.$e->getMessage();
+ }
+ if ($token == FALSE) {
+ $this->response([
+ 'status' => FALSE,
+ 'message' => $erro
+ ], REST_Controller::HTTP_UNAUTHORIZED);
+ }
+ else{
+ $this->set_response([
+ 'status' => TRUE,
+ 'message' => $token->nome.' saiu com sucesso'], REST_Controller::HTTP_OK);
+ }
+
+ }
+}
+
+/* End of file Autenticador.php */
+/* Location: ./application/controllers/Autenticador.php */
diff --git a/api/application/controllers/Batch_Controller.php b/api/application/controllers/Batch_Controller.php
new file mode 100644
index 0000000..348b13d
--- /dev/null
+++ b/api/application/controllers/Batch_Controller.php
@@ -0,0 +1,160 @@
+methods['addBatchDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addBatchDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addBatchDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getBatchDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateBatchDetails_post']['limit'] = 500;// 500 requests per hour per user/key
+ $this->methods['updateBatchDefault_post']['limit'] = 500;// 500 requests per hour per user/key
+
+ // load the model
+ $this->load->model('Batch_model', 'batch_model');
+
+ }
+
+ /*
+ * This method used to add batch details
+ * created by srk
+ * */
+
+ public function addBatchDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['BatchCode'] = $this->post('batchcode');
+ $details['BatchName'] = $this->post('batcheName');
+ $details['BatchDate'] = $this->post('batcheDate');
+ $details['UniversityID'] = $this->post('universityName');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+ $batchDetails = $this->batch_model->addBatch($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($batchDetails)
+ {
+ $batchDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($batchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get Batch details
+ * created by srk
+ * */
+ public function getBatchDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getBatch = $this->batch_model->getBatch($requestedBy);
+ if ($getBatch)
+ {
+ $getBatch['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getBatch, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update the batch details
+ * created by srk
+ * */
+ public function updateBatchDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['BatchCode'] = $this->post('batchCode');
+ $details['BatchName'] = $this->post('batchName');
+ $details['BatchDate'] = $this->post('batchDate');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+
+ // print_r( $details['UpdatedOn'])
+ //exit();
+ $updateDetails = $this->batch_model->updateBatch($details);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update the default batch details
+ * created by kms
+ * */
+ public function updateBatchDefault_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['BatchCode'] = $this->post('batchCode');
+ $details['UniversityID'] = $this->post('universityID');
+ $details['IsDefault'] = $this->post('IsDefault');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+
+ $updateDetails = $this->batch_model->updateDefaultBatch($details);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
diff --git a/api/application/controllers/Branch_Controller.php b/api/application/controllers/Branch_Controller.php
new file mode 100644
index 0000000..e81191f
--- /dev/null
+++ b/api/application/controllers/Branch_Controller.php
@@ -0,0 +1,162 @@
+methods['addBranchDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addBranchDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addBranchDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getBranchDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateBranchDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('Branch_model', 'branch_model');
+
+ }
+
+ /*
+ * This method used to add branch details
+ * created by kms
+ * */
+
+ public function addBranchDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['BranchCode'] = $this->post('branchCode');
+ $details['BranchName'] = $this->post('branchName');
+ // $details['LogoPath'] = $this->post('logo');
+ $details['MobileNumber'] = $this->post('primaryPhone');
+ $details['AlternateNumber'] = $this->post('secondaryPhone');
+ $details['LandlineNumber'] = $this->post('landLine');
+ $details['Address'] = $this->post('address');
+ $details['EmailID'] = $this->post('email');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status') == "true" ? 1 : 0;
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+ $imageStat = $this->post('imageStatus');
+
+ $imagename = $imageStat == 1 ? $_FILES['logo']['name'] : '';
+ $size = $imageStat == 1 ? $_FILES['logo']['size'] : '';
+ $imageSource = $imageStat == 1 ? $_FILES['logo']['tmp_name'] : '';
+
+ $branchDetails = $this->branch_model->addBranch($details, $imageSource);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($branchDetails)
+ {
+ $branchDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($branchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get branch details
+ * created by kms
+ * */
+ public function getBranchDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getBranch = $this->branch_model->getBranch($requestedBy);
+
+ if ($getBranch)
+ {
+ $getBranch['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getBranch, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update the branch details
+ * created by kms
+ * */
+ public function updateBranchDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $branchCode = $this->post('branchCode');
+ $details['BranchName'] = $this->post('branchName');
+ $details['LogoPath'] = $this->post('logo');
+ $details['MobileNumber'] = $this->post('primaryPhone');
+ $details['AlternateNumber'] = $this->post('secondaryPhone');
+ $details['LandlineNumber'] = $this->post('landLine');
+ $details['Address'] = $this->post('address');
+ $details['EmailID'] = $this->post('email');
+ $details['IsActive'] = $this->post('status') == "true" ? 1 : 0;
+ $details['UpdatedBy'] = $this->post('createdBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+
+ $imageStat = $this->post('imageStatus');
+
+ $imagename = $imageStat == 1 ? $_FILES['logoEdit']['name'] : '';
+ $size = $imageStat == 1 ? $_FILES['logoEdit']['size'] : '';
+ $imageSource = $imageStat == 1 ? $_FILES['logoEdit']['tmp_name'] : '';
+
+ $updateDetails = $this->branch_model->updateBranch($details,$branchCode, $imageSource, $imageStat );// Check if the users data store contains users (in case the database result returns NULL)
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Broadcast_Controller.php b/api/application/controllers/Broadcast_Controller.php
new file mode 100644
index 0000000..573ad4a
--- /dev/null
+++ b/api/application/controllers/Broadcast_Controller.php
@@ -0,0 +1,183 @@
+methods['getUniversity_post']['limit'] = 100;
+ $this->methods['chkUnivIdExistDetail_post']['limit'] = 100;
+ // load the broadcast model
+ $this->load->model('Broadcast_model', 'broadcast_model');
+ }
+
+ // get University, Course, Branch Detailss
+ public function getUniveCourseBatch_post() {
+ $reqData = $this->post('data');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+ $getUniversityListDetails = $this->broadcast_model->get_university_course_batch();// Check if the employee exist
+ if ($getUniversityListDetails)
+ {
+ $getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // ger Result fot searched keyword details
+ public function getStuListForBrodcast_post() {
+ $reqSearchData = $this->post('data');
+ $reqData = $this->post('requestDetails');
+ // print_r($reqSearchData);exit();
+
+ $getSearchDetails = $this->broadcast_model->get_search_result($reqSearchData, $reqData);// Check if the employee exist
+ if ($getSearchDetails)
+ {
+ $getSearchDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSearchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function sendSMSStudentApi_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+ $msg = $this->post('msg');
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+ $count = count($reqData);
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'StudentID' => $reqData[$i]['StudentID']
+ );
+ }
+
+ $sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg, $reqDetails);// Check if the employee exist
+ if ($sendMsgDetails)
+ {
+ $sendMsgDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($sendMsgDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getSMSGroupDetails_post() {
+ $reqData = $this->post('data');
+ $reqDataBy = $this->post('localReqDetails');
+ // print_r($reqData);exit();
+ $getMegDetails = $this->broadcast_model->getSMSGroupDetails($reqData);// Check if the employee exist
+ if ($getMegDetails)
+ {
+ $getMegDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getMegDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getSMSSendReportList_post(){
+
+ $reqData = $this->post('data');
+ $reqDataBy = $this->post('localReqDetails');
+ // $time = date('Y-m-d H:i:s');
+ // $dateTime = $time;
+ // $date1 = $dateTime;
+ // $date2 = $dateTime;
+
+ $getMegCronDetails = $this->broadcast_model->getSmsSendBetweenDate($reqData, $reqDataBy);// Check if the employee exist
+ if ($getMegCronDetails)
+ {
+ $getMegCronDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getCronCall_get() {
+ $getMegCronDetails = $this->broadcast_model->getCronUpdate();// Check if the employee exist
+ // echo $getMegCronDetails;exit();
+ if($getMegCronDetails){
+ echo $getMegCronDetails;
+ }else {
+
+ }
+ // if ($getMegCronDetails)
+ // {
+ // $getMegCronDetails['status'] = REST_Controller::HTTP_OK;
+ // // Set the response and exit
+ // $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ // }
+ // else
+ // {
+ // // Set the response and exit
+ // $this->response([
+ // 'message' => 'No list were found',
+ // 'status' => REST_Controller::HTTP_NOT_FOUND
+ // ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ // }
+ }
+}
diff --git a/api/application/controllers/Call_Tracking_Controller.php b/api/application/controllers/Call_Tracking_Controller.php
new file mode 100644
index 0000000..bb94f8b
--- /dev/null
+++ b/api/application/controllers/Call_Tracking_Controller.php
@@ -0,0 +1,406 @@
+methods['getTrackingLeadDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['getTrackingLeadDetails_post']['limit'] = 1000; // 100 requests per hour per user/key
+ $this->methods['getTrackingLeadDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['addTrackingDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['getTrackingDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['updateFollowupDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['loadFollowupDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['getDashboardCallTrack_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['getRecentLeadDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['getRecentCloseDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['getRecentPendingDetails_post']['limit'] = 1000; // 50 requests per hour per user/key
+ $this->methods['callAsImportantFlag_post']['limit'] = 1000; // 50 requests per hour per user/key
+
+
+ // load the model
+ $this->load->model('Calltracking_model', 'Calltracking_model');
+
+ }
+
+ /*
+ * get lead details with mobile number
+ * created by kms
+ * */
+ public function getTrackingLeadDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $mobileNumber = $this->post('mobileNumber');
+ $branchID = $this->post('branchID');
+ $loginType = $this->post('userType');
+ $getLeadDetails = $this->Calltracking_model->getLeadDetails($requestedBy,$mobileNumber,$branchID,$loginType);
+
+ if ($getLeadDetails)
+ {
+ $getLeadDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getLeadDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * add tracking lead details
+ * created by kms
+ * */
+
+ public function addLeadTrackingDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ //store lead details
+ $lead_details['LeadName'] = $this->post('studentName');
+ $lead_details['MobileNumber'] = $this->post('mobileNumber');
+ $lead_details['IsNewEnquiry'] = $this->post('enquiryStatus');
+ $lead_details['CreatedBy'] = $this->post('createdBy');
+ $lead_details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+ //store tracking details
+ $tracking_details['University'] = $this->post('universityID');
+ $tracking_details['Course'] = $this->post('courseName');
+ $tracking_details['ActivityStatus'] = $this->post('activity');
+ $tracking_details['AssignedTo'] = $this->post('assignedTo');
+ $tracking_details['StatusCode'] = $this->post('status');
+ $tracking_details['ReferredBy'] = $this->post('referedBy');
+ $tracking_details['AlternateMobile'] = $this->post('alterMobile');
+ $tracking_details['Address'] = $this->post('address');
+ $tracking_details['CreatedBy'] = $this->post('createdBy');
+ $tracking_details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $tracking_details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+ $tracking_details['CreatedBranch'] = $this->post('branchId');
+ //store tracking followup details
+ $tracking_followup_details['FollowupOn'] = $this->post('date');
+ $tracking_followup_details['FollowupComments'] = $this->post('comments');
+ $tracking_followup_details['CreatedBy'] = $this->post('createdBy');
+ $tracking_followup_details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+
+
+ $leadDetails = $this->Calltracking_model->addleadDetails($lead_details,$tracking_details,$tracking_followup_details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($leadDetails)
+ {
+ $leadDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($leadDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get tracking details
+ * created by kms
+ * */
+ public function getTrackingDetails_post()
+ {
+ $search['requestedBy'] = $this->post('requestedBy');
+ $search['requestedDept'] = $this->post('requestedDept');
+ // $search['branchID'] = $this->post('branchId');
+ $search['searchDate'] = $this->post('searchDate');
+ $search['CreatedBranch'] = $this->post('branchId');
+ // $search['searchMobileNumber'] = $this->post('searchMobileNumber');
+ // $search['searchName']= $this->post('searchName');
+ $getTrackedDetails = $this->Calltracking_model->getTrackingDetails($search);
+
+ if ($getTrackedDetails)
+ {
+ $getTrackedDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getTrackedDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update tracking followup details
+ * created by kms
+ * */
+ public function updateFollowupDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+
+ //store followup details for update
+ $update_followup_details['TrackingID'] = $this->post('trackingID');
+ $update_followup_details['UpdatedBy'] = $this->post('updatedBy');
+ $update_followup_details['StatusCode'] = $this->post('status');
+ $update_followup_details['AssignedTo'] = $this->post('assignedTo');
+ $update_followup_details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+ $update_followup_details['CreatedBranch'] = $this->post('branchId');
+ $update_followup_details['Address'] = $this->post('address');
+ $update_followup_details['AlternateMobile'] = $this->post('alternateMobile');
+ $update_followup_details['ReferredBy'] = $this->post('referredBy');
+ // store followup details for insert
+ $followup_details['TrackingID'] = $this->post('trackingID');
+ $followup_details['FollowupOn'] = $this->post('date');
+ $followup_details['CreatedBy'] = $this->post('updatedBy');
+ $followup_details['FollowupComments'] = $this->post('comments');
+ $followup_details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+
+
+
+ $updateDetails = $this->Calltracking_model->updateFollowupDetails($update_followup_details,$followup_details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * load followup details
+ * created by kms
+ * */
+
+ public function loadFollowupDetails_post()
+ {
+ $get_details['TrackingID'] = $this->post('trackingID');
+ $get_details['UpdatedBy'] = $this->post('updatedBy');
+ $get_details['CreatedBranch'] = $this->post('branchId');
+ $get_details['requestedDept'] = $this->post('requestedDept');
+
+ $getLoadDetails = $this->Calltracking_model->getLoadFollowupDetails($get_details);
+
+ if ($getLoadDetails)
+ {
+ $getLoadDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getLoadDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get dash board call track details
+ * created by kms
+ * */
+
+ public function getDashboardCallTrack_post()
+ {
+ $search['requestedBy'] = $this->post('requestedBy');
+ $search['BranchID'] = $this->post('branchId');
+ $search['requestedDept'] = $this->post('requestedDept');
+
+ $getdashBoardCallDetails = $this->Calltracking_model->getDashboardTrackingDetails($search);
+ if ($getdashBoardCallDetails)
+ {
+ $getdashBoardCallDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getdashBoardCallDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get recent call lead details
+ * created by kms
+ * */
+
+ public function getRecentLeadDetails_post()
+ {
+ $search['requestedBy'] = $this->post('requestedBy');
+ $search['requestedDept'] = $this->post('requestedDept');
+ $search['loadDate'] = $this->post('loadDate');
+ $search['CreatedBranch'] = $this->post('branchId');
+ // $search['searchDate'] = $this->post('searchDate');
+ // $search['searchMobileNumber'] = $this->post('searchMobileNumber');
+ // $search['searchName']= $this->post('searchName');
+ $getRecentLeadDetails = $this->Calltracking_model->getRecentleadDetails($search);
+
+ if ($getRecentLeadDetails)
+ {
+ $getRecentLeadDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getRecentLeadDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get recent close details
+ * created by kms
+ * */
+ public function getRecentCloseDetails_post()
+ {
+ $search['requestedBy'] = $this->post('requestedBy');
+ $search['requestedDept'] = $this->post('requestedDept');
+ $search['loadDate'] = $this->post('loadDate');
+ $search['CreatedBranch'] = $this->post('branchId');
+ // $search['searchDate'] = $this->post('searchDate');
+ // $search['searchMobileNumber'] = $this->post('searchMobileNumber');
+ // $search['searchName']= $this->post('searchName');
+ $getRecentCloseDetails = $this->Calltracking_model->getRecentCloseDetails($search);
+
+ if ($getRecentCloseDetails)
+ {
+ $getRecentCloseDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getRecentCloseDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * get recent pending details
+ * created by kms
+ * */
+ public function getRecentPendingDetails_post()
+ {
+ $search['requestedBy'] = $this->post('requestedBy');
+ $search['requestedDept'] = $this->post('requestedDept');
+ $search['loadDate'] = $this->post('loadDate');
+ $search['CreatedBranch'] = $this->post('branchId');
+ // $search['searchDate'] = $this->post('searchDate');
+ // $search['searchMobileNumber'] = $this->post('searchMobileNumber');
+ // $search['searchName']= $this->post('searchName');
+ $getRecentPendingDetails = $this->Calltracking_model->getRecentPendingDetails($search);
+
+ if ($getRecentPendingDetails)
+ {
+ $getRecentPendingDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getRecentPendingDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * mark as important for call
+ * created by kms
+ * */
+ public function callAsImportantFlag_post(){
+ $trackID = $this->post('trackId');
+ $flagStatus = $this->post('flag');
+ $updateFlag = $this->Calltracking_model->updateFlagStatus($trackID,$flagStatus);
+
+ if ($updateFlag)
+ {
+ $updateFlag['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateFlag, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Center_Controller.php b/api/application/controllers/Center_Controller.php
new file mode 100644
index 0000000..8b000cd
--- /dev/null
+++ b/api/application/controllers/Center_Controller.php
@@ -0,0 +1,134 @@
+methods['addCenterDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addCenterDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addCenterDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getCenterDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateCenterDetails_post']['limit'] = 500;// 500 requests per hour per user/key
+
+ // load the model
+ $this->load->model('Center_model', 'center_model');
+
+ }
+
+ /*
+ * Add Center details
+ * created by srk
+ * */
+
+ public function addCenterDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['CenterCode'] = $this->post('CenterCode');
+ $details['CenterName'] = $this->post('CenterName');
+ $details['CenterAddress'] = $this->post('Address');
+ $details['Comments'] = $this->post('Comments');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+ $centerDetails = $this->center_model->addCenter($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($centerDetails)
+ {
+ $centerDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($centerDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get Batch details
+ * created by srk
+ */
+ public function getCenterDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getCenter = $this->center_model->getCenter($requestedBy);
+ // print_r($getCenter);
+ // die;
+ if ($getCenter)
+ {
+ $getCenter['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getCenter, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update Center details
+ * created by srk
+ */
+ public function updateCenterDetails_post()
+ {
+
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['CenterCode'] = $this->post('CenterCode');
+ $details['CenterName'] = $this->post('CenterName');
+ $details['CenterAddress'] = $this->post('Address');
+ $details['Comments'] = $this->post('Comments');
+ $CenterID=$this->post('CenterID');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdateBy'] = $this->post('updateBy');
+ $details['UpdateOn'] = $now->format("Y-m-d H:i:s");
+
+
+ $updateDetails = $this->center_model->updateCenter($details,$CenterID);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+
+
+
+
+}
diff --git a/api/application/controllers/Certificate_Controller.php b/api/application/controllers/Certificate_Controller.php
new file mode 100644
index 0000000..fc65c97
--- /dev/null
+++ b/api/application/controllers/Certificate_Controller.php
@@ -0,0 +1,138 @@
+methods['addCertificateDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addCertificateDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addCertificateDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getCertificateDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateCertificateDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('Certificate_model', 'certificate_model');
+
+ }
+
+ /*
+ * This method used to add Certificate details
+ * created by Surendiran
+ * */
+
+ public function addCertificateDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['CertificateName'] = $this->post('certificateName');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $certificateDetails = $this->certificate_model->addcertificate($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($certificateDetails)
+ {
+ $certificateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($certificateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+ /*
+ * get Certificate details
+ * created by Surendiran
+ * */
+ public function getCertificateDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getCertificate = $this->certificate_model->getCertificate($requestedBy);
+
+ if ($getCertificate)
+ {
+ $getCertificate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getCertificate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * update the Certificate details
+ * created by Surendiran
+ * */
+ public function updateCertificateDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $updateID = $this->post('updateID');
+ $details['CertificateName'] = $this->post('certificateName');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+ $certificateDetails = $this->certificate_model->update($details,$updateID);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($certificateDetails)
+
+ {
+ $certificateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($certificateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/api/application/controllers/Course_Controller.php b/api/application/controllers/Course_Controller.php
new file mode 100644
index 0000000..fc35a4d
--- /dev/null
+++ b/api/application/controllers/Course_Controller.php
@@ -0,0 +1,192 @@
+methods['addCourseDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addCourseDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addCourseDetails_delete']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['getCourseDetails_post']['limit'] = 1500; // 50 requests per hour per user/key
+ $this->methods['updateCourseDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('Course_model', 'course_model');
+
+ }
+
+ /*
+ * This method used to add Course details
+ * created by kms
+ * */
+
+ public function addCourseDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['CourseCode'] = $this->post('courseCode');
+ $details['CourseName'] = $this->post('courseName');
+ $details['UniversityID'] = $this->post('universityName');
+ $details['Specilization1'] = $this->post('specilization1');
+ $details['Specilization2'] = $this->post('specilization2');
+
+ //$details['FeesType'] = $this->post('feesType');
+ $details['PC'] = $this->post('provFess');
+ $details['DC'] = $this->post('degreeAmount');
+ $details['TC'] = $this->post('transferAmount');
+ $details['MC'] = $this->post('migrationAmount');
+ $details['OtherFees'] = $this->post('otherAmount');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $details['IsActive'] = $this->post('status');
+ $jsonRegularFeesData=$this->post('regularFeesAmounts');
+ $jsonLateralFeesData=$this->post('lateralFeesAmounts');
+ $jsonSemFeesData=$this->post('semFeesAmounts');
+ // push regular,lateral fees into same array
+ if($jsonRegularFeesData['FeesAmount'] != 0 AND $jsonRegularFeesData['FeesAmount'] != '' AND $jsonRegularFeesData['FeesAmount'] != 'undefined'){
+ array_push($jsonSemFeesData,$jsonRegularFeesData);
+ }
+ if($jsonLateralFeesData['FeesAmount'] != 0 AND $jsonLateralFeesData['FeesAmount'] != '' AND $jsonLateralFeesData['FeesAmount'] != 'undefined'){
+ array_push($jsonSemFeesData,$jsonLateralFeesData);
+ }
+ // get subject details
+ $subjectDetails=$this->post('subjects');
+
+ $courseDetails = $this->course_model->addCourse($details,$jsonSemFeesData,$subjectDetails);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($courseDetails)
+ {
+ $courseDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($courseDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get course details
+ * created by kms
+ * */
+ public function getCourseDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getCourse = $this->course_model->getCourse($requestedBy);
+
+ if ($getCourse)
+ {
+ $getCourse['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ public function getCourseUnivFeesDetails_post() {
+ $requestedBy = $this->post('requestedBy');
+ $getCourseUnivFee = $this->course_model->getCourseUnivFeesTypes($requestedBy);
+
+ if ($getCourseUnivFee)
+ {
+ $getCourseUnivFee['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getCourseUnivFee, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+ /*
+ * update the course details
+ * created by kms
+ * */
+ public function updateCourseDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['CourseID'] = $this->post('courseID');
+ $details['CourseCode'] = $this->post('courseCode');
+ $details['CourseName'] = $this->post('courseName');
+ $details['UniversityID'] = $this->post('universityID');
+ $details['Specilization1'] = $this->post('specilization1');
+ $details['Specilization2'] = $this->post('specilization2');
+ $details['IsActive'] = $this->post('status');
+ $details['PC'] = $this->post('provFess');
+ $details['DC'] = $this->post('degreeAmount');
+ $details['TC'] = $this->post('transferAmount');
+ $details['MC'] = $this->post('migrationAmount');
+ $details['OtherFees'] = $this->post('otherAmount');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+ $existCourseID = $this->post('existCourseID');
+ $jsonRegularFeesData=$this->post('regularFeesAmounts');
+ $jsonLateralFeesData=$this->post('lateralFeesAmounts');
+ $jsonSemFeesData=$this->post('semFeesAmounts');
+ // push regular,lateral fees into same array
+ if($jsonRegularFeesData != '' AND $jsonRegularFeesData != null AND $jsonRegularFeesData != 'undefined'){
+ array_push($jsonSemFeesData,$jsonRegularFeesData);
+
+ }
+ if($jsonLateralFeesData != '' AND $jsonLateralFeesData != null AND $jsonLateralFeesData != 'undefined'){
+ array_push($jsonSemFeesData,$jsonLateralFeesData);
+
+ }
+
+ // update course subject details
+ $subjectDetails['UniversityID'] = $this->post('universityID');
+ $subjectDetails['CourseID'] = $this->post('courseID');
+ $subjectDetails['Subjects'] = $this->post('subjects');
+ $subjectDetails['UpdatedBy'] = $this->post('updatedBy');
+ $subjectDetails['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+
+ $updateDetails = $this->course_model->updateCourse($details,$jsonSemFeesData,$subjectDetails);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Dashboard_Controller.php b/api/application/controllers/Dashboard_Controller.php
new file mode 100644
index 0000000..30cd7d1
--- /dev/null
+++ b/api/application/controllers/Dashboard_Controller.php
@@ -0,0 +1,92 @@
+load->model('Dashboard_model', 'dashboard_model');
+ }
+
+ public function getTotalUsers_post() {
+ $data = $this->post('data');
+ $totalUsers = $this->dashboard_model->get_total_users( $data );// Check if the employee exist
+ if ($totalUsers) {
+ $totalUsers['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($totalUsers, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getTotalStudent_post() {
+ $data = $this->post('data');
+ $totalStudents = $this->dashboard_model->get_total_students( $data );// Check if the employee exist
+ if ($totalStudents) {
+ $totalStudents['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($totalStudents, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getTotalEmployee_post() {
+ $data = $this->post('data');
+ $totalEmployee = $this->dashboard_model->get_total_employee( $data );// Check if the employee exist
+ if ($totalEmployee) {
+ $totalEmployee['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($totalEmployee, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+}
diff --git a/api/application/controllers/DayBookMaster_Controller.php b/api/application/controllers/DayBookMaster_Controller.php
new file mode 100644
index 0000000..5704dc8
--- /dev/null
+++ b/api/application/controllers/DayBookMaster_Controller.php
@@ -0,0 +1,134 @@
+methods['addDaybookMasterDetails_post']['limit'] = 100; // 50 requests per hour per user/key
+ $this->methods['getDayBookMasterDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateDayBookMasterDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('DaybookMaster_model', 'daybookmaster_model');
+
+ }
+
+ /*
+ * This method used to get day book master details
+ * created by kms
+ * */
+
+ public function addDaybookMasterDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['TypeID'] = $this->post('type');
+ $details['TypeName'] = $this->post('name');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $addDetails = $this->daybookmaster_model->addDetails($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($addDetails)
+ {
+ $addDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($addDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * This method used to get day book master details
+ * created by kms
+ * */
+ public function getDayBookMasterDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getdetails = $this->daybookmaster_model->getDayBookDetails($requestedBy);
+
+ if ($getdetails)
+ {
+ $getdetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getdetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * update the day book details
+ * created by kms
+ * */
+ public function updateDayBookMasterDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['ID'] = $this->post('ID');
+ $details['TypeName'] = $this->post('TypeName');
+ $details['TypeID'] = $this->post('TypeID');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+ $updateDetails = $this->daybookmaster_model->updateDayBook($details);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/DayBook_Controller.php b/api/application/controllers/DayBook_Controller.php
new file mode 100644
index 0000000..9407434
--- /dev/null
+++ b/api/application/controllers/DayBook_Controller.php
@@ -0,0 +1,292 @@
+load->model('DayBook_model', 'daybook_model');
+ }
+
+ //get income expese type, name details
+ public function getIncomeExpenseTypeState_post() {
+ $reqData = $this->post('data');
+ $getIncomeExpenseTypeState = $this->daybook_model->get_Income_Expense_typeState();// Check if the employee exist
+ if ($getIncomeExpenseTypeState)
+ {
+ $getIncomeExpenseTypeState['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getIncomeExpenseTypeState, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+
+ public function empDayBookModuleAccessChk_post() {
+ $reqDataBy = $this->post('localReqDetails');
+ // print_r($reqDataBy);exit();
+ $empDayBkAccessChk = $this->daybook_model->emp_day_book_AccessChk($reqDataBy);// Check if the employee exist
+ if ($empDayBkAccessChk)
+ {
+ $empDayBkAccessChk['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($empDayBkAccessChk, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+
+ // {"data":{"date":"22-12-2017"},"localReqDetails":{"localUserID":"137","localBranchID":"001","localType":"R002","localOn":"2017-12-22T12:45:19.688Z","status":"active"}}
+
+ // get all daybook details
+ public function getDayBookDetails_post() {
+ $reqData = $this->post('data');
+ $reqDataBy = $this->post('localReqDetails');
+ $getDayBookDetails = $this->daybook_model->get_Daybook_Details_List($reqData, $reqDataBy);// Check if the employee exist
+ if ($getDayBookDetails)
+ {
+ $getDayBookDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ public function getDayBookApprovalDetails_post() {
+ $reqData = $this->post('data');
+ $reqDataBy = $this->post('localReqDetails');
+ $getDayBookApprovalDetails = $this->daybook_model->get_Daybook_Approval_Details_List($reqData, $reqDataBy);// Check if the employee exist
+ if ($getDayBookApprovalDetails)
+ {
+ $getDayBookApprovalDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getDayBookApprovalDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function deleteDayBookDetails_post() {
+ $reqData = $this->post('data');
+ $reqbyData = $this->post('localReqDetails');
+ $deletedayBookDetails = $this->daybook_model->delete_dayBookDetails($reqData);// Check if the employee exist
+ if ($deletedayBookDetails)
+ {
+ $deletedayBookDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($deletedayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function deleteDayBookFeePayableDetails_post() {
+ $reqData = $this->post('data');
+ $reqbyData = $this->post('requestDetails');
+
+ // print_r($reqbyData);exit();
+ $deletedayBookFeePayableDetails = $this->daybook_model->delete_dayBookFeePayableDetails($reqData);// Check if the employee exist
+ if ($deletedayBookFeePayableDetails)
+ {
+ $deletedayBookFeePayableDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($deletedayBookFeePayableDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function updateDayBookDetails_post() {
+ $reqData = $this->post('data');
+ $reqbyData = $this->post('localReqDetails');
+
+ $updateFor = $reqData['id'];
+ $req['Type'] = $reqData['type'];
+ $req['Amount'] = $reqData['amount'];
+ $req['Description'] = $reqData['description'];
+ $req['UpdatedBy'] = $reqbyData['localUserID'];
+ $req['PaidTo'] = $reqData['paidTo'];
+ $req['PaidDescription'] = $reqData['description_paid'];
+ $req['VoucherNumber'] = $reqData['voucherNumber'];
+ $req['BranchCode'] = $reqData['branch'];
+ $req['Name'] = $reqData['name'];
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+ $updatedayBookDetails = $this->daybook_model->update_dayBookDetails($req , $updateFor);// Check if the employee exist
+ if ($updatedayBookDetails)
+ {
+ $updatedayBookDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updatedayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // add details daybook
+ public function adddaybook_post() {
+
+ $reqData = $this->post('data');
+ $reqbyData = $this->post('localReqDetails');
+
+ $req['Name'] = $reqData['name'];
+ $req['Type'] = $reqData['type'];
+ $req['Amount'] = $reqData['amount'];
+ // $d = new DateTime($reqData['date']);
+ $req['Date'] = $reqData['date'];
+ $req['Status'] = $reqData['status'];
+ $req['Description'] = $reqData['description'];
+ $req['BranchCode'] = $reqbyData['localBranchID'];
+ $req['CreatedBy'] = $reqbyData['localUserID'];
+ $req['PaidTo'] = $reqData['paidTo'];
+ $req['PaidDescription'] = $reqData['description_paid'];
+ $req['VoucherNumber'] = $reqData['voucherNumber'];
+ $date = date('Y-m-d H:i:s');
+ $req['CreatedOn'] = $date;
+ // print_r($req);exit();
+ $addDayBookDetails = $this->daybook_model->add_dayBook($req);// Check if the employee exist
+ if ($addDayBookDetails)
+ {
+ $addDayBookDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($addDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function updateDayBookStatusAdmin_post() {
+
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+
+ $count = count($reqData);
+
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'ID' => $reqData[$i]['dabookListId'],
+ 'Approval_By' => $reqDetails['localUserID'],
+ 'Status' => $reqData[$i]['ListCodeStatus'],
+ 'Approval_Comments' => $reqData[$i]['comments'],
+ 'UpdatedBy' => $reqDetails['localUserID'],
+ 'UpdatedOn' => $dateTime,
+ );
+ }
+
+ $updateStatusAdminDetails = $this->daybook_model->update_status_admin($data);// Check if the employee exist
+ if ($updateStatusAdminDetails)
+ {
+ $updateStatusAdminDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateStatusAdminDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+ public function getDayBookDetailsSuperAdmin_post() {
+ $reqData = $this->post('data');
+ $reqDataBy = $this->post('localReqDetails');
+ $getDayBookDetails = $this->daybook_model->get_Daybook_Details_List_superAdmin($reqData, $reqDataBy);// Check if the employee exist
+ if ($getDayBookDetails)
+ {
+ $getDayBookDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+}
diff --git a/api/application/controllers/Employee_Controller.php b/api/application/controllers/Employee_Controller.php
new file mode 100644
index 0000000..8c2c53e
--- /dev/null
+++ b/api/application/controllers/Employee_Controller.php
@@ -0,0 +1,506 @@
+methods['employee_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['employee_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['employee_delete']['limit'] = 50; // 50 requests per hour per user/key
+
+ $this->methods['getRoleDetails_post']['limit'] = 100;
+ $this->methods['getMasterBranchDetails_post']['limit'] = 100;
+ $this->methods['addEmployee_post']['limit'] = 100;
+ $this->methods['check_exist_post']['limit'] = 100;
+ $this->methods['check_update_exist_post']['limit'] = 100;
+ $this->methods['updateEmployee_post']['limit'] = 100;
+ $this->methods['updateEmpBranchDetail_post']['limit'] = 100;
+ // load the employee model
+ $this->load->model('Employee_model', 'employee_model');
+ }
+
+ // get login employee profile details
+ public function employeeGetProf_post() {
+ $empLoginID = $this->post('employeeLoginID');
+ $employeeDetails = $this->employee_model->get_emp_prof_detail( $empLoginID );// Check if the employee exist
+ if ($employeeDetails)
+ {
+ $employeeDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ //This method used to get employee Details
+ public function employee_post()
+ {
+ $empLoginID = $this->post('employeeLoginID');
+ $employeeDetails = $this->employee_model->get_emp_detail( $empLoginID );// Check if the employee exist
+ if ($employeeDetails)
+ {
+ $employeeDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get all employee details
+ public function getEmployeeList_post() {
+ $reqData = $this->post('data');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+ $employeeListDetails = $this->employee_model->get_employee_list( $loginUserId, $loginUserBranchId, $loginUserType );// Check if the employee exist
+ if ($employeeListDetails)
+ {
+ $employeeListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get role details
+ public function getRoleDetails_post() {
+ $reqRoleID = $this->post('reqRoleID');
+ $resRoleDetails = $this->employee_model->get_req_role_detail( $reqRoleID );// Check if the employee exist
+ if ($resRoleDetails)
+ {
+ $resRoleDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($resRoleDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get branch details
+ public function getMasterBranchDetails_post () {
+ $reqRoleID = $this->post('reqRoleID');
+ $reqUserID = $this->post('reqUserID');
+ $resMasterBranchDetails = $this->employee_model->get_req_master_branch_detail( $reqRoleID, $reqUserID );// Check if the employee exist
+ if ($resMasterBranchDetails)
+ {
+ $resMasterBranchDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($resMasterBranchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // check exist values details
+ public function check_exist_post() {
+ $data = $this->post('data');
+ $checkData = $this->post('check');
+ $checkRes = $this->employee_model->check_exist( $data, $checkData );// Check if the employee exist
+ if ($checkRes)
+ {
+ $checkRes['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkRes, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // add employee without image
+ public function addEmployee_post() {
+ $data = $this->post('data');
+
+ $createdBy = $this->post('createdBy');
+
+ $imagename = '';
+ $size = '';
+ $imageSource = '';
+
+ $req['StaffID'] = $data['employeeId'];
+ $req['Firstname'] = $data['firstname'];
+ $req['Lastname'] = $data['lastname'];
+ $req['Fathername'] = $data['fathername'];
+ $req['EmailID'] = $data['emailId'];
+ $req['MotherName'] = $data['mothername'];
+ $req['MobileNumber'] = $data['primaryPhone'];
+ $req['AlternateNumber'] = $data['secondaryPhone'];
+ $req['Gender'] = $data['gender'];
+ $req['DOB'] = $data['dateofbirth'];
+ // $req['DOB'] = $data['dateofbirth'];
+ $req['PresentAddress'] = $data['address2'];
+ $req['PermanentAddress'] = $data['address1'];
+ $req['AadharNumber'] = $data['aadharNumber'];
+ $req['OtherID'] = $data['otherId'];
+ $req['OtherIDDetails'] = $data['otherIdDetails'];
+ $req['Qualification'] = $data['qualificaion'];
+ $req['BranchCode'] = $data['homeBranch'];
+ $req['IsActive'] = $data['switchsetting'];
+
+ $req['FinanceModuleAccess'] = $data['finaceModuleAccess'];
+
+ $req['DOJ'] = $data['dateofjoining'];
+ $req['JobResponsibility'] = $data['jobResponsibility'];
+ // $req['DOJ'] = $data['dateofjoining'];
+ $req['ListCode'] = $data['role'];
+ $req['CreatedBy'] = $createdBy;
+ // print_r($req);exit();
+ $employeeAdd = $this->employee_model->add_employee( $req, $createdBy, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($employeeAdd)
+ {
+ $employeeAdd['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // add employee with image
+ public function addEmployeeImage_post() {
+ // print_r($this->post('idProof'));exit();
+ $imagename = $_FILES['idProof']['name'];
+
+ $size = $_FILES['idProof']['size'];
+
+ $imageSource = $_FILES['idProof']['tmp_name'];
+ // echo $size;exit();
+ $data= $this->post('data');
+ $createdBy= $this->post('createdBy');
+ $temp = json_decode($data, true);
+
+ $req['StaffID'] = $temp['employeeId'];
+ $req['Firstname'] = $temp['firstname'];
+ $req['Lastname'] = $temp['lastname'];
+ $req['Fathername'] = $temp['fathername'];
+ $req['EmailID'] = $temp['emailId'];
+ $req['MotherName'] = $temp['mothername'];
+ $req['MobileNumber'] = $temp['primaryPhone'];
+ $req['AlternateNumber'] = $temp['secondaryPhone'];
+ $req['Gender'] = $temp['gender'];
+ $req['DOB'] = $temp['dateofbirth'];
+ // $req['DOB'] = $data['dateofbirth'];
+ $req['PresentAddress'] = $temp['address2'];
+ $req['PermanentAddress'] = $temp['address1'];
+ $req['AadharNumber'] = $temp['aadharNumber'];
+ $req['OtherID'] = $temp['otherId'];
+ $req['OtherIDDetails'] = $temp['otherIdDetails'];
+ $req['Qualification'] = $temp['qualificaion'];
+ $req['BranchCode'] = $temp['homeBranch'];
+ $req['IsActive'] = $temp['switchsetting'];
+
+ $req['FinanceModuleAccess'] = $temp['finaceModuleAccess'];
+
+ $req['DOJ'] = $temp['dateofjoining'];
+ $req['JobResponsibility'] = $temp['jobResponsibility'];
+ // $req['DOJ'] = $data['dateofjoining'];
+ $req['ListCode'] = $temp['role'];
+ $req['CreatedBy'] = $createdBy;
+
+ $employeeAdd = $this->employee_model->add_employee( $req, $createdBy, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($employeeAdd)
+ {
+ $employeeAdd['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function check_update_exist_post() {
+ $exceptId = $this->post('exceptId');
+ $datas = $this->post('datas');
+ $checkFor = $this->post('check');
+
+ $checkRes = $this->employee_model->check_update_exist( $exceptId, $datas, $checkFor );// Check if the employee exist
+ if ($checkRes)
+ {
+ $checkRes['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkRes, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // update employee with image
+ public function updateEmployeeImage_post() {
+
+ $imagename = $_FILES['idProof']['name'];
+ $size = $_FILES['idProof']['size'];
+ $imageSource = $_FILES['idProof']['tmp_name'];
+
+ $temp= $this->post('data');
+ $createdBy= $this->post('createdBy');
+ $data = json_decode($temp, true);
+
+ $updatedBy = $this->post('updatedBy');
+ $updateStaff = $data['StaffID'];
+
+ $req['Firstname'] = $data['Firstname'];
+ $req['Lastname'] = $data['Lastname'];
+ $req['Fathername'] = $data['Fathername'];
+ $req['EmailID'] = $data['EmailID'];
+ $req['MotherName'] = $data['MotherName'];
+ $req['MobileNumber'] = $data['MobileNumber'];
+ $req['AlternateNumber'] = $data['AlternateNumber'];
+ $req['Gender'] = $data['Gender'];
+ // $req['DOB'] = date('d-m-Y', strtotime($data['DOB']) );
+ $req['DOB'] = $data['DOB'];
+ $req['PresentAddress'] = $data['PresentAddress'];
+ $req['PermanentAddress'] = $data['PermanentAddress'];
+ $req['AadharNumber'] = $data['AadharNumber'];
+ $req['OtherID'] = $data['OtherID'];
+ $req['OtherIDDetails'] = $data['OtherIDDetails'];
+ $req['Qualification'] = $data['Qualification'];
+ // $req['JobResponsibility'] = $data['JobResponsibility'];
+ $req['ProfilePicPath'] = $data['ProfilePicPath'];
+ // $req['BranchCode'] = $data['BranchCode'];
+ $req['IsActive'] = $data['IsActive'];
+ // $req['DOJ'] = date('d-m-Y', strtotime($data['DOJ']) );
+ $req['DOJ'] = $data['DOJ'];
+ // $req['ListCode'] = $data['ListCode'];
+ $req['UpdatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+ // print_r($req);exit();
+ $employeeUpdate = $this->employee_model->update_employee( $req, $updateStaff, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($employeeUpdate)
+ {
+ $employeeUpdate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // update employee details without image
+ public function updateEmployee_post () {
+ $data = $this->post('data');
+ $updatedBy = $this->post('updatedBy');
+ $updateStaff = $data['StaffID'];
+
+ $imagename = '';
+ $size = '';
+ $imageSource = '';
+
+ $req['Firstname'] = $data['Firstname'];
+ $req['Lastname'] = $data['Lastname'];
+ $req['Fathername'] = $data['Fathername'];
+ $req['EmailID'] = $data['EmailID'];
+ $req['MotherName'] = $data['MotherName'];
+ $req['MobileNumber'] = $data['MobileNumber'];
+ $req['AlternateNumber'] = $data['AlternateNumber'];
+ $req['Gender'] = $data['Gender'];
+ // $req['DOB'] = date('d-m-Y', strtotime($data['DOB']) );
+ $req['DOB'] = $data['DOB'];
+ $req['PresentAddress'] = $data['PresentAddress'];
+ $req['PermanentAddress'] = $data['PermanentAddress'];
+ $req['AadharNumber'] = $data['AadharNumber'];
+ $req['OtherID'] = $data['OtherID'];
+ $req['OtherIDDetails'] = $data['OtherIDDetails'];
+ $req['Qualification'] = $data['Qualification'];
+ // $req['ProfilePicPath'] = $data['ProfilePicPath'];
+ // $req['JobResponsibility'] = $data['JobResponsibility'];
+ // $req['BranchCode'] = $data['BranchCode'];
+ $req['IsActive'] = $data['IsActive'];
+ // $req['DOJ'] = date('d-m-Y', strtotime($data['DOJ']) );
+ $req['DOJ'] = $data['DOJ'];
+ // $req['ListCode'] = $data['ListCode'];
+ $req['UpdatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+ // print_r($req);exit();
+ $employeeUpdate = $this->employee_model->update_employee( $req, $updateStaff, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($employeeUpdate)
+ {
+ $employeeUpdate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // get employee branch details
+ public function getEmpBranchDetails_post() {
+ $staffID = $this->post('staffID');
+ $employeeBranch = $this->employee_model->get_employee_branch( $staffID );// Check if the employee exist
+ if ($employeeBranch)
+ {
+ $employeeBranch['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($employeeBranch, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function addEmpBranchDetail_post() {
+ $req['StaffID'] = $this->post('empFor');
+ $req['BranchCode'] = $this->post('updateBranch');
+ $req['ListCode'] = $this->post('updateRole');
+ $req['JobResponsibility'] = $this->post('JobResponsibility');
+
+ $req['FinanceModuleAccess'] = $this->post('FinanceModuleAccess') == 1 ? '1' : '0';
+ $req['CreatedBy'] = $this->post('updateBy');
+ $date = date('Y-m-d H:i:s');
+ $req['IsActive'] = '1';
+ $req['UpdatedOn'] = $date;
+
+ $addEmpBranch = $this->employee_model->add_employee_branch( $req );// Check if the employee exist
+ if ($addEmpBranch)
+ {
+ $addEmpBranch['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($addEmpBranch, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // update employee branch
+ public function updateEmpBranchDetail_post() {
+ // exit();
+ $req['StaffID'] = $this->post('empFor');
+ $req['BranchCode'] = $this->post('updateBranch');
+ $req['ListCode'] = $this->post('updateRole');
+ $req['JobResponsibility'] = $this->post('JobResponsibility');
+ $req['HomeBranch'] = $this->post('HomeBranch');
+
+ $req['FinanceModuleAccess'] = $this->post('FinanceModuleAccess') == 1 ? '1' : '0';
+ $req['IsActive'] = $this->post('IsActive') == 1 ? '1' : '0';
+ // echo $req['FinanceModuleAccess'];exit();
+ $req['UpdatedBy'] = $this->post('updateBy');
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+
+ $updateFor = $this->post('ID');
+
+ $updateBranch = $this->employee_model->upate_employee_branch( $updateFor, $req );// Check if the employee exist
+ if ($updateBranch)
+ {
+ $updateBranch['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateBranch, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+}
diff --git a/api/application/controllers/Fees_Status_Controller.php b/api/application/controllers/Fees_Status_Controller.php
new file mode 100644
index 0000000..782a303
--- /dev/null
+++ b/api/application/controllers/Fees_Status_Controller.php
@@ -0,0 +1,295 @@
+methods['getStudentList_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['getStudentList_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ $this->methods['getStudentList_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getFeesStructure_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ $this->methods['updateFeesDetails_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ $this->methods['getUniversityCourseForFees_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ $this->methods['getFeesStructureAssign_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ $this->methods['setFeesForStudent_post']['limit'] = 1000; // 1000 requests per hour per user/key
+ // $this->methods['sendStudentNotification_post']['limit'] = 2000; // 2000 requests per hour per user/key
+
+
+ // load the model
+ $this->load->model('Fees_status_model', 'Fees_model');
+
+ }
+
+
+
+ /*
+ * get student list for fees update
+ * created by kms
+ * */
+ public function getStudentList_post()
+ {
+ $search['requestedBy'] = $this->post('requestedtBy');
+ $search['Firstname'] = $this->post('studentName');
+ $search['MobileNumber'] = $this->post('mobileNumber');
+ $search['UniversityID'] = $this->post('university');
+ $search['CourseID'] = $this->post('course');
+ $search['requestedDept'] = $this->post('requestedDept');
+ $search['requestedBranch'] = $this->post('branchId');
+ $getStudentDetails = $this->Fees_model->getStudentList($search);
+ if ($getStudentDetails)
+ {
+ $getStudentDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStudentDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * get student fees structure
+ * created by kms
+ * */
+ public function getFeesStructure_post()
+ {
+ $student['ID'] = $this->post('ID');
+ $student['requestedBy'] = $this->post('requestedtBy');
+ $student['CourseID'] = $this->post('courseID');
+ $student['StudentID'] = $this->post('studentID');
+ $getStudentFeesDetails = $this->Fees_model->getStudentFeesStructure($student);
+ if ($getStudentFeesDetails)
+ {
+ $getStudentFeesDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStudentFeesDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update fees details for student
+ * created by kms
+ * */
+
+
+ public function updateFeesDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ /*for track purpose*/
+
+ /* $trackDetails['MobileNumber'] = $this->post('mobileNumber');
+ $trackDetails['LeadName'] = $this->post('studentName');
+ $trackDetails['University'] = $this->post('university');
+ $trackDetails['Course'] = $this->post('course');
+ $trackDetails['StatusCode'] = $this->post('statusCode');
+ $trackDetails['FollowupOn'] = $now->format('d-m-Y');
+ $trackDetails['FollowupComments'] = $this->post('commentsForStudent');
+ $trackDetails['CreatedBy'] = $this->post('createdBy');
+ $trackDetails['CreatedOn'] = $now->format('Y-m-d H:i:s');*/
+
+ /*track array end*/
+
+ $detailsChild['StudentID'] = $this->post('studID');
+ $detailsChild['FeesId'] = $this->post('feesID');
+ $detailsChild['ReceiptNo'] = $this->post('billNO');
+ $detailsChild['BillDate'] = $this->post('billDate');
+ $detailsChild['BillAmount'] = $this->post('billAmount');
+ $detailsChild['ModeOfPayment'] = $this->post('modeOfPayment');
+ $detailsChild['CommentsForStudent'] = $this->post('commentsForStudent');
+ $detailsChild['InternalComments'] = $this->post('internalComments');
+ $detailsChild['CreatedBy'] = $this->post('createdBy');
+ $detailsChild['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $detailsChild['UpdatedBy'] = $this->post('requestedBranch');
+ $updateDetails = $this->Fees_model->updateFees($detailsChild,$this->post('courseID'));// Check if the users data store contains users (in case the database result returns NULL)
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * get university and course details for fees update
+ * created by kms
+ * */
+ public function getUniversityCourseForFees_post()
+ {
+ $getUnivDetails = $this->Fees_model->getUniversityDetails();
+ if ($getUnivDetails)
+ {
+ $getUnivDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getUnivDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * get student set fees details
+ * created by kms
+ * */
+ /*
+ * get student fees structure
+ * created by kms
+ * */
+ public function getFeesStructureAssign_post()
+ {
+ $student['ID'] = $this->post('ID');
+ $student['requestedBy'] = $this->post('requestedtBy');
+ $student['CourseID'] = $this->post('courseID');
+ $student['StudentID'] = $this->post('studentID');
+ $getStudentFeesDetails = $this->Fees_model->getFeesStructureAssign($student);
+ if ($getStudentFeesDetails)
+ {
+ $getStudentFeesDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStudentFeesDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * set fees for student
+ * created by kms
+ * */
+ public function setFeesForStudent_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['StudentID'] = $this->post('studID');
+ $details['CourseID'] = $this->post('courseID');
+ $details['FeesType'] = $this->post('feesID');
+ $details['CourseFees'] = $this->post('courseAmount');
+ $details['SessionName'] = $this->post('session');
+ $details['ToSessionName'] = $this->post('sessionTo');
+ $details['RollNo'] = $this->post('rollNo');
+ $details['STFOrWR'] = $this->post('STFWR');
+ $details['Waiver'] = $this->post('waiver');
+ $details['Others'] = $this->post('other');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $details['BatchCode'] = $this->post('batchCode');
+
+ $jsonInstallmenData = $this->post('installmentItems');
+
+ $updateDetails = $this->Fees_model->setFees($details,$jsonInstallmenData);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * send notification for student
+ * created by kms
+ * */
+ public function sendStudentNotification_get(){
+
+ $sendMessage = $this->Fees_model->studentNotification();
+
+ if ($sendMessage)
+ {
+ echo "Success";
+ /* $this->response([
+ 'message' => 'Done!',
+ 'status' => REST_Controller::HTTP_OK
+ ], REST_Controller::HTTP_OK); // NOT_FOUND (404) being the HTTP response code*/
+ }
+ else
+ {
+ // Set the response and exit
+ /* $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code*/
+ }
+
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Forget_Controller.php b/api/application/controllers/Forget_Controller.php
new file mode 100644
index 0000000..3da21f7
--- /dev/null
+++ b/api/application/controllers/Forget_Controller.php
@@ -0,0 +1,82 @@
+methods['forgetlogin_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['forgetlogin_post']['limit'] = 500; // 500 requests per hour per user/key
+
+ $this->methods['forgetlogin_delete']['limit'] = 50; // 50 requests per hour per user/key
+
+ $this->load->model('Forgot_model', 'forgot_model');
+
+ }
+
+
+ public function forgetlogin_post()
+ {
+ //$userMobile = $this->post('userMobile');
+ $details['MobileNumber'] = $this->post('userMobile');
+ // $details['Password'] = $this->post('password');
+
+
+ function generateRandomString($length = 8) {
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $charactersLength = strlen($characters);
+ $randomString = '';
+ for ($i = 0; $i < $length; $i++) {
+ $randomString .= $characters[rand(0, $charactersLength - 1)];
+ }
+ return $randomString;
+ }
+ $password= generateRandomString();
+ $details['Password'] = md5($password);
+
+ $loginDetails = $this->forgot_model->forget($details, $password);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($loginDetails)
+ {
+ $loginDetails['status'] = REST_Controller::HTTP_OK;
+ //Set the response and exit
+ $this->response($loginDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+
+ }
+
+
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+}
+
diff --git a/api/application/controllers/HallTickets_Controller.php b/api/application/controllers/HallTickets_Controller.php
new file mode 100644
index 0000000..9a26ca5
--- /dev/null
+++ b/api/application/controllers/HallTickets_Controller.php
@@ -0,0 +1,76 @@
+methods['getCourseSubjectDetails_post']['limit'] = 500; // 500 requests per hour per user/key
+
+ // load the model
+ $this->load->model('Hallticket_model', 'Hallticket_model');
+
+ }
+
+
+
+ /*
+ * get student list for fees update
+ * created by kms
+ * */
+ public function getStudentList_post()
+ {
+ $search['requestedBy'] = $this->post('requestedtBy');
+ $search['Firstname'] = $this->post('studentName');
+ $search['MobileNumber'] = $this->post('mobileNumber');
+ $search['UniversityID'] = $this->post('university');
+ $search['CourseID'] = $this->post('course');
+ $search['requestedDept'] = $this->post('requestedDept');
+ $search['requestedBranch'] = $this->post('branchId');
+ $getStudentDetails = $this->Fees_model->getStudentList($search);
+ if ($getStudentDetails)
+ {
+ $getStudentDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStudentDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Login_Controller.php b/api/application/controllers/Login_Controller.php
new file mode 100644
index 0000000..d7d9655
--- /dev/null
+++ b/api/application/controllers/Login_Controller.php
@@ -0,0 +1,120 @@
+methods['login_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['login_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['login_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->load->model('Login_model', 'login_model');
+ $this->load->model('Announcement_model', 'announcement_model');
+
+ }
+
+ //This method used to get Login
+
+ public function login_post()
+ {
+ $userMobile = $this->post('userMobile');
+ $password = $this->post('password');
+
+
+ $loginDetails = $this->login_model->login( $userMobile, $password);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($loginDetails)
+ {
+ $LoginDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($loginDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // change old password
+ public function changePassword_post() {
+ $oldPassword = $this->post('oldPassword');
+ $newPassword = $this->post('newPassword');
+ $userId = $this->post('UserId');
+ // echo $oldPassword;
+ // echo $newPassword;
+ // echo $userId;
+ // exit();
+ $date = date('Y-m-d H:i:s');
+ $updateOn = $date;
+ $changePassword = $this->login_model->change_Password( $userId, $newPassword, $oldPassword, $updateOn);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($changePassword)
+ {
+ $changePassword['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($changePassword, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No record were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ /*
+ * get Announcement Details
+ * created by Surendiran
+ * */
+ public function getLoginAnnouncementDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+
+
+ $getAnnouncement = $this->announcement_model->getLoginAnnouncement();
+
+ if ($getAnnouncement)
+ {
+ $getAnnouncement['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getAnnouncement, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+}
+
\ No newline at end of file
diff --git a/api/application/controllers/Report.php b/api/application/controllers/Report.php
new file mode 100644
index 0000000..3171b2a
--- /dev/null
+++ b/api/application/controllers/Report.php
@@ -0,0 +1,191 @@
+load->model('Reports_model', 'report_model');
+
+ }
+
+
+
+
+ public function status_post()
+ {
+ $bat = $this->post('bname');
+ $br = $this->post('brname');
+ $u = $this->post('univ');
+ $getStatus = $this->report_model->status($bat,$br,$u);
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ public function mstatus_post()
+ {
+ $bat = $this->post('bname');
+ $br = $this->post('brname');
+ $u = $this->post('univ');
+ $getStatus = $this->report_model->mstatus($bat,$br,$u);
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ public function cert_status_post()
+ {
+ $bat = $this->post('bname');
+ $br = $this->post('brname');
+ $u = $this->post('univ');
+ $getStatus = $this->report_model->certificate_status($bat,$br,$u);
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ public function markcert_status_post()
+ {
+ $bat = $this->post('bname');
+ $br = $this->post('brname');
+ $u = $this->post('univ');
+ $from = $this->post('from');
+ $to = $this->post('to');
+ $getStatus = $this->report_model->mark_cert_status($bat,$br,$u,$from,$to);
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ public function expense_post()
+ {
+
+ $from = $this->post('from');
+ $to = $this->post('to');
+ $getStatus = $this->report_model->expense($from,$to);
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ public function batch_post()
+ {
+
+ $getStatus = $this->report_model->batch();
+ //print_r($getStatus);
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Rest_server.php b/api/application/controllers/Rest_server.php
new file mode 100644
index 0000000..5d44f92
--- /dev/null
+++ b/api/application/controllers/Rest_server.php
@@ -0,0 +1,13 @@
+load->helper('url');
+
+ $this->load->view('rest_server');
+ }
+}
diff --git a/api/application/controllers/SessionMater_Controller.php b/api/application/controllers/SessionMater_Controller.php
new file mode 100644
index 0000000..5fd2eab
--- /dev/null
+++ b/api/application/controllers/SessionMater_Controller.php
@@ -0,0 +1,120 @@
+methods['addSessionMaterDetails_post']['limit'] = 100; // 50 requests per hour per user/key
+ $this->methods['getSessionMaterDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateSessionMaterDetails_post']['limit'] = 500;// 500 requests per hour per user/key
+ // load the model
+ $this->load->model('SeesionMaster_model', 'sessionM_model');
+
+ }
+
+ /*
+ * This method used to add session master details
+ * created by kms
+ * */
+
+ public function addSessionMaterDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SessionName'] = $this->post('sessionName');
+ $details['SessionDate'] = $this->post('sessionDate');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $university['UniversityID'] = $this->post('universityName');
+
+ $sessionDetails = $this->sessionM_model->addSession($details,$university);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($sessionDetails)
+ {
+ $sessionDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($sessionDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get session master details
+ * created by kms
+ * */
+ public function getSessionMaterDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getSession = $this->sessionM_model->getSession($requestedBy);
+ if ($getSession)
+ {
+ $getSession['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSession, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update the session master details
+ * created by kms
+ * */
+ public function updateSessionMaterDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SessionID'] = $this->post('sessionID');
+ $details['SessionDate'] = $this->post('sessionDate');
+ $details['SessionName'] = $this->post('sessionName');
+ $details['IsActive'] = $this->post('status');
+ $universityDetails['University'] = $this->post('university');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+ $updateDetails = $this->sessionM_model->updateSession($details,$universityDetails);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/SessionSchedule_Controller.php b/api/application/controllers/SessionSchedule_Controller.php
new file mode 100644
index 0000000..6ea11b8
--- /dev/null
+++ b/api/application/controllers/SessionSchedule_Controller.php
@@ -0,0 +1,119 @@
+methods['addSessionScheduleDetails_post']['limit'] = 100; // 50 requests per hour per user/key
+ $this->methods['getSessionScheduleDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateSessionMaterDetails_post']['limit'] = 500;// 500 requests per hour per user/key
+ // load the model
+ $this->load->model('SeesionSchedule_model', 'sessionSC_model');
+
+ }
+
+ /*
+ * This method used to add session Schedule details
+ * created by kms
+ * */
+
+ public function addSessionScheduleDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SessionID'] = $this->post('sessionID');
+ $details['SCDate'] = $this->post('date');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $Timings['Timings'] = $this->post('timings');
+ $sessionDetails = $this->sessionSC_model->addSessionScheduel($details,$Timings);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($sessionDetails)
+ {
+ $sessionDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($sessionDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get session Schedule details
+ * created by kms
+ * */
+ public function getSessionScheduleDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getSession = $this->sessionSC_model->getSessionSchedule($requestedBy);
+ if ($getSession)
+ {
+ $getSession['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSession, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update the session Schedule details
+ * created by kms
+ * */
+ public function updateSessionScheduleDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SCID'] = $this->post('scheduleID');
+ $details['SessionID'] = $this->post('sessionID');
+ $details['SCDate'] = $this->post('date');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+ $Timings['Timings'] = $this->post('timings');
+ $updateDetails = $this->sessionSC_model->updateSessionSchedule($details,$Timings);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($updateDetails)
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+ }
\ No newline at end of file
diff --git a/api/application/controllers/StatusUpdation_Controller.php b/api/application/controllers/StatusUpdation_Controller.php
new file mode 100644
index 0000000..d4b31b5
--- /dev/null
+++ b/api/application/controllers/StatusUpdation_Controller.php
@@ -0,0 +1,348 @@
+methods['getUniversity_post']['limit'] = 100;
+ $this->methods['chkUnivIdExistDetail_post']['limit'] = 100;
+ // load the university model
+ $this->load->model('StatusUpdation_model', 'statusupdation_model');
+ }
+
+ // get University, Course, Branch Detailss
+ public function getUniveCourseBratch_post() {
+ $reqData = $this->post('data');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+ $getUniversityListDetails = $this->statusupdation_model->get_university_course_batch();// Check if the employee exist
+ if ($getUniversityListDetails)
+ {
+ $getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // ger Result fot searched keyword details
+ public function getSearchDetails_post() {
+ $reqSearchData = $this->post('data');
+ $reqData = $this->post('requestDetails');
+ // print_r($reqSearchData);exit();
+
+ $getSearchDetails = $this->statusupdation_model->get_search_result($reqSearchData, $reqData);// Check if the employee exist
+ if ($getSearchDetails)
+ {
+ $getSearchDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSearchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get Sem/year for the respective course
+ public function getSemYearForCourse_post() {
+ $reqData = $this->post('data');
+ $stuFor = $this->post('stuFor');
+
+ $getSemYeatList = $this->statusupdation_model->get_semyear_result($reqData, $stuFor);// Check if the employee exist
+ if ($getSemYeatList)
+ {
+ $getSemYeatList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSemYeatList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // update the study material Status
+ public function updateStudentMaterialStatus_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+
+ $count = count($reqData);
+ // echo $reqDetails['localUserID'];exit();
+
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'StudentID' => $reqData[$i]['StudentID'],
+ 'CourseID' => $reqData[$i]['CourseID'],
+ 'BranchCode' => $reqData[$i]['BranchCode'],
+ 'ListCode' => $reqData[$i]['ListCode'],
+ 'SDate' => $reqData[$i]['SDate'],
+ 'Coursedetail' => $reqData[$i]['Coursedetail'],
+ 'Comments' => $reqData[$i]['Comments'],
+ 'Sem' => $reqData[$i]['Sem'],
+ 'CreatedBy' => $reqDetails['localUserID'],
+ 'CreatedOn' => $dateTime,
+ );
+ }
+
+ $updateStudentMaterialSta = $this->statusupdation_model->update_semyear($data);// Check if the employee exist
+ if ($updateStudentMaterialSta)
+ {
+ $updateStudentMaterialSta['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateStudentMaterialSta, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // update Answer booklet status
+ public function updateAnswerBookLetStatus_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+
+ $count = count($reqData);
+ // echo $reqDetails['localUserID'];exit();
+
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'StudentID' => $reqData[$i]['StudentID'],
+ 'CourseID' => $reqData[$i]['CourseID'],
+ 'BranchCode' => $reqData[$i]['BranchCode'],
+ 'ListCode' => $reqData[$i]['ListCode'],
+ 'AnsDate' => $reqData[$i]['SDate'],
+ 'Coursedetail' => $reqData[$i]['Coursedetail'],
+ 'Comments' => $reqData[$i]['Comments'],
+ 'Sem' => $reqData[$i]['Sem'],
+ 'CreatedBy' => $reqDetails['localUserID'],
+ 'CreatedOn' => $dateTime,
+ );
+ }
+
+ $updateAnswerBookletStat = $this->statusupdation_model->update_answerbooklet($data,$reqDetails);// Check if the employee exist
+ if ($updateAnswerBookletStat)
+ {
+ $updateAnswerBookletStat['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateAnswerBookletStat, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get certification type list
+ public function getCertificateList_post() {
+ $reqData = $this->post('data');
+
+ $certificateList = $this->statusupdation_model->get_certificate_list();// Check if the employee exist
+ if ($certificateList)
+ {
+ $certificateList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($certificateList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // update certification status
+ public function updateCertificationStatus_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+
+ $count = count($reqData);
+ // echo $reqDetails['localUserID'];exit();
+
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'StudentID' => $reqData[$i]['StudentID'],
+ 'CourseID' => $reqData[$i]['CourseID'],
+ 'BranchCode' => $reqData[$i]['BranchCode'],
+ 'ListCode' => $reqData[$i]['ListCode'],
+ 'CDate' => $reqData[$i]['SDate'],
+ 'Coursedetail' => $reqData[$i]['Coursedetail'],
+ 'Comments' => $reqData[$i]['Comments'],
+ 'Sem' => $reqData[$i]['Sem'],
+ 'CreatedBy' => $reqDetails['localUserID'],
+ 'CreatedOn' => $dateTime,
+ // 'CertificationType' => $reqData[$i]['CertificateType'],
+ 'CertificationType' => 'MARK CARD',
+ 'CertificationNo' =>$reqData[$i]['CertificateNumber'],
+ );
+ }
+
+ $updateCertificateStatus = $this->statusupdation_model->update_certificateStatus($data);// Check if the employee exist
+ if ($updateCertificateStatus)
+ {
+ $updateCertificateStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateCertificateStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // update application status
+ public function updateApplicationStatus_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('requestDetails');
+
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+
+ $count = count($reqData);
+ // echo $reqDetails['localUserID'];exit();
+
+ for($i=0; $i < $count; $i++) {
+ $data[] = array(
+ 'StudentID' => $reqData[$i]['StudentID'],
+ 'CourseID' => $reqData[$i]['CourseID'],
+ 'BranchCode' => $reqData[$i]['BranchCode'],
+ 'ListCode' => $reqData[$i]['ListCode'],
+ 'AppDate' => $reqData[$i]['SDate'],
+ 'Comments' => $reqData[$i]['Comments'],
+ 'CreatedBy' => $reqDetails['localUserID'],
+ 'CreatedOn' => $dateTime,
+ 'CertificationType' => $reqData[$i]['CertificateType'],
+ 'CertificationNo' =>$reqData[$i]['CertificateNumber'],
+ );
+ }
+
+ $updateApplicationStatus = $this->statusupdation_model->update_applicationStatus($data,$reqDetails);// Check if the employee exist
+ if ($updateApplicationStatus)
+ {
+ $updateApplicationStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateApplicationStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get Status list based on the required activity
+ public function getStatusListForUpdate_post() {
+ $reqData = $this->post('data');
+ $reqDetails = $this->post('statusFor');
+
+ $getStatusList = $this->statusupdation_model->get_status_list($reqData);// Check if the employee exist
+ if ($getStatusList)
+ {
+ $getStatusList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatusList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getPrevStatusDetailsForStu_post() {
+ $reqData = $this->post('data');
+ $reqDetailsFor = $this->post('statusFor');
+ $reqDetails = $this->post('getDetailsFor');
+
+ $getPrevStatusList = $this->statusupdation_model->get_prev_status_list($reqDetailsFor, $reqDetails);// Check if the employee exist
+ if ($getPrevStatusList)
+ {
+ $getPrevStatusList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getPrevStatusList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+}
diff --git a/api/application/controllers/Status_Controller.php b/api/application/controllers/Status_Controller.php
new file mode 100644
index 0000000..54880a4
--- /dev/null
+++ b/api/application/controllers/Status_Controller.php
@@ -0,0 +1,180 @@
+methods['addStatusDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addStatusDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addStatusDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getStatusDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateStatusDetails_post']['limit'] = 500;
+ // load the model
+ $this->load->model('Status_model', 'status_model');
+
+ }
+
+ /*
+ * This method used to add status details
+ * created by Surendiran
+ * */
+
+ public function addStatusDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['ListName'] = $this->post('statusName');
+ $details['ListGroup'] = "1";
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['IsActive'] = $this->post('status');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $statusDetails = $this->status_model->addstatus($details);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($statusDetails)
+ {
+ $statusDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($statusDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get status details
+ * created by Surendiran
+ * */
+ public function getStatusDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getStatus = $this->status_model->getStatus($requestedBy);
+
+ if ($getStatus)
+ {
+ $getStatus['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ /*
+ * update the status details
+ * created by Surendiran
+ * */
+ public function updateStatusDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $ListCode = $this->post('ListCode');
+ $details['ListName'] = $this->post('ListName');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
+ $statusDetails = $this->status_model->update($details,$ListCode);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($statusDetails)
+
+ {
+ $statusDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($statusDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+ public function getBranchListStatusUpdate_post() {
+ $requestedBy = $this->post('requestedBy');
+
+ $getStatusBranchList = $this->status_model->getStatusBranchList($requestedBy);
+ if ($getStatusBranchList)
+ {
+ $getStatusBranchList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getStatusBranchList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getBranchStatusList_post() {
+ $requestedBy = $this->post('requestedBy');
+ $branchCode = $this->post('branchCode');
+
+ $getBranchStatusList = $this->status_model->getBranchStatusList($branchCode);
+ if ($getBranchStatusList)
+ {
+ $getBranchStatusList['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getBranchStatusList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/StudentView_Controller.php b/api/application/controllers/StudentView_Controller.php
new file mode 100644
index 0000000..0f99520
--- /dev/null
+++ b/api/application/controllers/StudentView_Controller.php
@@ -0,0 +1,63 @@
+methods['getStudentInfo_post']['limit'] = 500;
+ // load the employee model
+ $this->load->model('Studentview_model', 'studentview_model');
+
+ }
+
+ /*
+ *get student basic info
+ * created by kms
+ * */
+ public function getStudentInfo_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $requestedFrom = $this->post('requestedFrom');
+
+ $studentListDetails = $this->studentview_model->getStudentInfo($requestedBy,$requestedFrom);// Check if the employee exist
+ if ($studentListDetails) {
+ $studentListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ } else {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+}
diff --git a/api/application/controllers/Student_Controller.php b/api/application/controllers/Student_Controller.php
new file mode 100644
index 0000000..207f2a1
--- /dev/null
+++ b/api/application/controllers/Student_Controller.php
@@ -0,0 +1,781 @@
+methods['addStudent_post']['limit'] = 100;
+ // load the employee model
+ $this->load->model('Student_model', 'student_model');
+
+ }
+
+ // list of branch for admin student add screen
+ public function getBranchListDetails_post() {
+ $reqData = $this->post('data');
+ $branchListDetails = $this->student_model->get_branch_list();// Get Branch list
+ if ($branchListDetails)
+ {
+ $branchListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($branchListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // check the branch active for add a new student
+ public function getBranchActiveStatusforStuAdd_post() {
+ $reqData = $this->post('data');
+ $branchId = $reqData['localBranchID'];
+ // print_r($reqData);exit();
+ $checkBranchActiveStatis = $this->student_model->getBranchActiveStatusforStuAdd($branchId);// Get Branch list
+ if ($checkBranchActiveStatis)
+ {
+ $checkBranchActiveStatis['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkBranchActiveStatis, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getStudentList_post() {
+ $reqData = $this->post('data');
+ $searchReqData = $this->post('search');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+
+ $studentListDetails = $this->student_model->get_student_list( $loginUserId, $loginUserBranchId, $loginUserType, $searchReqData);// Check if the employee exist
+ if ($studentListDetails)
+ {
+ $studentListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ public function getStudentUniversity_post() {
+ $reqData = $this->post('data');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+ $getUniversityListDetails = $this->student_model->get_university_list();// Check if the employee exist
+ if ($getUniversityListDetails)
+ {
+ $getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getStudentCourseList_post() {
+ $studentID = $this->post('studentID');
+ $reqData = $this->post('updatedBy');
+ $studentCourse = $this->student_model->get_student_course_list( $studentID, $reqData );// Check if the employee exist
+ if ($studentCourse)
+ {
+ $studentCourse['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getStudentCourseDetails_post() {
+ $studentCourseID = $this->post('studentcourseId');
+ $studentCourse = $this->student_model->get_student_course( $studentCourseID );// Check if the employee exist
+ if ($studentCourse)
+ {
+ $studentCourse['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function chkUpdateStuExistDetail_post() {
+ $exceptId = $this->post('exceptId');
+ $datas = $this->post('datas');
+ $checkFor = $this->post('check');
+
+ $checkRes = $this->student_model->check_update_exist( $exceptId, $datas, $checkFor );// Check if the employee exist
+ if ($checkRes)
+ {
+ $checkRes['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkRes, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function updateStudentCourseDetail_post() {
+ $data = $this->post('data');
+ $updatedBy = $this->post('updatedBy');
+ $id = $data['ID'];
+
+ $req['StudentID'] = $data['StudentID'];
+ $req['UniversityID'] = $data['UniversityID'];
+ $req['CourseID'] = $data['CourseID'];
+ $req['SessionID'] = $data['SessionID'];
+ $req['DOJ'] = $data['DOJ'];
+ $req['IsActive'] = $data['IsActive'];
+ $req['BranchID'] = $data['BranchID'];
+ $req['EnrollmentID'] = $data['EnrollmentID'];
+ $req['Specilization1'] = $data['Specilization1'];
+ $req['Specilization2'] = $data['Specilization2'];
+ $req['DeactiveComments'] = $data['IsActive'] == 1 ? '': $data['DeactiveComments'];
+ $req['UpdatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+
+ $studentCourseUpdate = $this->student_model->update_student_course( $req, $id );
+ if ($studentCourseUpdate)
+ {
+ $studentCourseUpdate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentCourseUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // get student entrollment document details
+ public function getListofStuDocDetails_post() {
+ $StudentID = $this->post('exceptId');
+ $localdata = $this->post('localData');
+
+ $studentDocDetails = $this->student_model->getStudent_doc_details($StudentID);
+ if ($studentDocDetails)
+ {
+ $studentDocDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentDocDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function deleteStuDocDetails_post() {
+ $StudentID = $this->post('exceptId');
+ $docEntryId = $this->post('docDetailsID');
+ $localdata = $this->post('localData');
+
+ $stuDocDeleteDetails = $this->student_model->deleteStu_doc_details($StudentID, $docEntryId);
+ if ($stuDocDeleteDetails)
+ {
+ $stuDocDeleteDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($stuDocDeleteDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ public function addStudentEntrollDocDetails_post() {
+ // echo $this->post('stuDocProof_Status');exit();
+ $docName = $_FILES['stuDocProof']['name'] ;
+ $docsize = $_FILES['stuDocProof']['size'] ;
+ $docSource = $_FILES['stuDocProof']['tmp_name'];
+
+
+ $temp= $this->post('data');
+ $data = json_decode($temp, true);
+ $updatedBy = $this->post('updatedBy');
+ $studentId = $this->post('studentID');
+
+ $doc_upload_status = $this->post('stuDocProof_Status');
+
+ $req['doc_name'] = $docName;
+ $req['doc_size'] = $docsize;
+ $req['doc_source'] = $docSource;
+
+ $req['document_type_name'] = $data['documentName'];
+ $req['document_status'] = '';
+ $req['document_comments'] = $data['documentComments'];
+
+ $req['student_id'] = $studentId;
+
+ $req['CreatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['CreatedOn'] = $date;
+
+ $studentEntrollDocAdd = $this->student_model->student_entroll_doc_add( $req, $doc_upload_status);// Check if the employee exist
+ if ($studentEntrollDocAdd)
+ {
+ $studentEntrollDocAdd['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentEntrollDocAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ // print_r($temp);
+ // echo $docName, $studentId, $data['documentName'];
+ // exit();
+
+ }
+
+ // get student pending enrollment document details
+ public function getListofStuPendingDocDetails_post() {
+ $StudentID = $this->post('exceptId');
+ $localdata = $this->post('localData');
+ $studentPendingDocDetails = $this->student_model->getStudent_PendingDoc_Details($StudentID);
+ if ($studentPendingDocDetails)
+ {
+ $studentPendingDocDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentPendingDocDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function addStudentEnrollPendingDocDetails_post() {
+ $updateDetails = $this->post('updateDetails');
+ $localdata = $this->post('localData');
+
+ $reqData['StudentID'] = $updateDetails['student'];
+ $reqData['Details'] = $updateDetails['doc_Details'];
+ $reqData['Status'] = $updateDetails['checkTracking'];
+ $reqData['CreatedBy'] = $localdata['localUserID'];
+ $date = date('Y-m-d H:i:s');
+ $reqData['CreatedOn'] = $date;
+
+ $addStudentPendingDocDetails = $this->student_model->addStu_PendingDoc_Details($reqData,$localdata);
+
+ if ($addStudentPendingDocDetails)
+ {
+ $addStudentPendingDocDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($addStudentPendingDocDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // delete pending enrollment document details
+ public function deleteDocPendingDetails_post() {
+ $expID = $this->post('exceptId');
+ $localData = $this->post('localData');
+ // echo $expID;
+ // print_r($localData);exit();
+ $stuEnrollPendingDocDeleteDetails = $this->student_model->deleteStu_entrollPending_doc_details($expID);
+ if ($stuEnrollPendingDocDeleteDetails)
+ {
+ $stuEnrollPendingDocDeleteDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($stuEnrollPendingDocDeleteDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function updateStudentImgDetails_post() {
+
+ $imagename = $_FILES['idStuUpProof']['name'];
+ $size = $_FILES['idStuUpProof']['size'];
+ $imageSource = $_FILES['idStuUpProof']['tmp_name'];
+
+ $temp= $this->post('data');
+ $data = json_decode($temp, true);
+
+ $updatedBy = $this->post('updatedBy');
+ $updateStudent = $data['StudentID'];
+
+ $req['MobileNumber'] = $data['MobileNumber'];
+ $req['Firstname'] = $data['Firstname'];
+ $req['Lastname'] = $data['Lastname'];
+ $req['Fathername'] = $data['Fathername'];
+ $req['EmailID'] = $data['EmailID'];
+ $req['MotherName'] = $data['MotherName'];
+
+ $req['AlternateNumber'] = $data['AlternateNumber'];
+ $req['Gender'] = $data['Gender'];
+ $req['DOB'] = $data['DOB'];
+ $req['PresentAddress'] = $data['PresentAddress'];
+ $req['PermanentAddress'] = $data['PermanentAddress'];
+ $req['AadharNumber'] = $data['AadharNumber'];
+ $req['OtherID'] = $data['OtherID'];
+ $req['OtherIDDetails'] = $data['OtherIDDetails'];
+ $req['Qualification'] = $data['Qualification'];
+
+ $req['PreQualification'] = $data['PreQualification'];
+ $req['Caste'] = $data['Caste'];
+ $req['Category'] = $data['Category'];
+ $req['Religion'] = $data['Religion'];
+ $req['Nationality'] = $data['Nationality'];
+ $req['Occupation'] = $data['Occupation'];
+ $req['Designation'] = $data['Designation'];
+ $req['Companyname'] = $data['Companyname'];
+ $req['ReferredBy'] = $data['ReferredBy'];
+ $req['ReferersMobileNumber'] = $data['ReferersMobileNumber'];
+ $req['ProfilePicPath'] = $data['ProfilePicPath'];
+ $req['Comments'] = $data['Comments'];
+ $req['DeactiveComments'] = $data['IsActive'] == 1 ? '': $data['DeactiveComments'];
+
+ $req['IsActive'] = $data['IsActive'];
+ $req['LoginAccess'] = $data['LoginAccess'] == 1 ? "1" : "0";
+
+ $req['UpdatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+ $studentUpdate = $this->student_model->update_student( $req, $updateStudent, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($studentUpdate)
+ {
+ $studentUpdate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+ public function updateStudentExistDetail_post(){
+ $data = $this->post('data');
+ $updatedBy = $this->post('updatedBy');
+ $updateStudent = $data['StudentID'];
+
+ $imagename = '';
+ $size = '';
+ $imageSource = '';
+
+ $req['MobileNumber'] = $data['MobileNumber'];
+ $req['Firstname'] = $data['Firstname'];
+ $req['Lastname'] = $data['Lastname'];
+ $req['Fathername'] = $data['Fathername'];
+ $req['EmailID'] = $data['EmailID'];
+ $req['MotherName'] = $data['MotherName'];
+
+ $req['AlternateNumber'] = $data['AlternateNumber'];
+ $req['Gender'] = $data['Gender'];
+ $req['DOB'] = $data['DOB'];
+ $req['PresentAddress'] = $data['PresentAddress'];
+ $req['PermanentAddress'] = $data['PermanentAddress'];
+ $req['AadharNumber'] = $data['AadharNumber'];
+ $req['OtherID'] = $data['OtherID'];
+ $req['OtherIDDetails'] = $data['OtherIDDetails'];
+ $req['Qualification'] = $data['Qualification'];
+
+ $req['PreQualification'] = $data['PreQualification'];
+ $req['Caste'] = $data['Caste'];
+ $req['Category'] = $data['Category'];
+ $req['Religion'] = $data['Religion'];
+ $req['Nationality'] = $data['Nationality'];
+ $req['Occupation'] = $data['Occupation'];
+ $req['Designation'] = $data['Designation'];
+ $req['Companyname'] = $data['Companyname'];
+ $req['ReferredBy'] = $data['ReferredBy'];
+ $req['ReferersMobileNumber'] = $data['ReferersMobileNumber'];
+ $req['ProfilePicPath'] = $data['ProfilePicPath'];
+ $req['Comments'] = $data['Comments'];
+ $req['DeactiveComments'] = $data['IsActive'] == 1 ? '': $data['DeactiveComments'];
+
+
+ $req['IsActive'] = $data['IsActive'] == 1 ? "1" : "0";
+ $req['LoginAccess'] = $data['LoginAccess'] == 1 ? "1" : "0";
+
+ $req['UpdatedBy'] = $updatedBy;
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+
+ $studentUpdate = $this->student_model->update_student( $req, $updateStudent, $imagename, $imageSource, $size );// Check if the employee exist
+ if ($studentUpdate)
+ {
+ $studentUpdate['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function getCourseBatch_post() {
+ $data = $this->post('data');
+ $getCourseBatchListDetails = $this->student_model->get_courseBatch_list($data);// Check if the employee exist
+ if ($getCourseBatchListDetails)
+ {
+ $getCourseBatchListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getCourseBatchListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function chkStudentExistDetail_post() {
+ $data = $this->post('data');
+ $checkData = $this->post('check');
+ $checkRes = $this->student_model->check_exist( $data, $checkData );// Check if the employee exist
+ if ($checkRes)
+ {
+ $checkRes['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkRes, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ public function getExistingStudentDetails_post() {
+ $data = $this->post('data');
+ $reqDetails = $this->post('check');
+ $checkExisRes = $this->student_model->get_exist_stu_details( $data, $reqDetails );// Check if the employee exist
+ if ($checkExisRes)
+ {
+ $checkExisRes['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkExisRes, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // add new course for student
+ public function insertStudentCourse_post(){
+
+ $addStudent = $this->post('addStudent');
+ $coursedata = $this->post('coursedata');
+ $createdBy = $this->post('createdBy');
+ $createdBranch = $this->post('loginBranch');
+
+ $reqCourse['StudentID'] = $addStudent;
+ $reqCourse['UniversityID'] = $coursedata['university'];
+ $reqCourse['CourseID'] = $coursedata['course'];
+ $reqCourse['SessionID'] = $coursedata['batch'];
+ $reqCourse['DOJ'] = $coursedata['dateofjoining'];
+ $reqCourse['EnrollmentID'] = $coursedata['enrollmentid'];
+
+ $reqCourse['Specilization1'] = $coursedata['specilization1'];
+ $reqCourse['Specilization2'] = $coursedata['specilization2'];
+
+ $reqCourse['BranchID'] = $createdBranch;
+ $reqCourse['IsActive'] = '1';
+ $reqCourse['CreatedBy'] = $createdBy;
+ $date = date('Y-m-d H:i:s');
+ $reqCourse['CreatedOn'] = $date;
+// print_r($reqCourse);exit();
+ $studentAddCourse = $this->student_model->add_student_course( $addStudent , $reqCourse);// Check if the employee exist
+ if ($studentAddCourse)
+ {
+ $studentAddCourse['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentAddCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ public function insertStudentImg_post() {
+ // print_r($this->post('idProof'));exit();
+ $imagename = $_FILES['idStuProof']['name'];
+ $size = $_FILES['idStuProof']['size'];
+ $imageSource = $_FILES['idStuProof']['tmp_name'];
+ // echo $size;exit();
+ $temp = $this->post('data');
+ $tempBranch = $this->post('coursedata');
+ $data = json_decode($temp, true);
+ $coursedata = json_decode($tempBranch, true);
+
+ $createdBy = $this->post('createdBy');
+ $createdBranch = $this->post('loginBranch');
+
+ $req['Firstname'] = $data['firstname'];
+ $req['Lastname'] = $data['lastname'];
+ $req['Fathername'] = $data['fathername'];
+ $req['EmailID'] = $data['emailId'];
+ $req['MotherName'] = $data['mothername'];
+ $req['MobileNumber'] = $data['primaryPhone'];
+ $req['AlternateNumber'] = $data['secondaryPhone'];
+ $req['Gender'] = $data['gender'];
+ $req['DOB'] = $data['dateofbirth'];
+ $req['PresentAddress'] = $data['address2'];
+ $req['PermanentAddress'] = $data['address1'];
+ $req['AadharNumber'] = $data['aadharNumber'];
+ $req['OtherID'] = $data['otherId'];
+ $req['OtherIDDetails'] = $data['otherIdDetails'];
+ $req['Caste'] = $data['caste'];
+ $req['Category'] = $data['category'];
+ $req['Religion'] = $data['religion'];
+ $req['Nationality'] = $data['nationality'];
+ $req['Occupation'] = $data['occupation'];
+ $req['Designation'] = $data['designation'];
+ $req['Companyname'] = $data['companyname'];
+ $req['ReferredBy'] = $data['referredby'];
+ $req['ReferersMobileNumber'] = $data['referredmobilenumber'];
+ $req['PreQualification'] = $data['prequalification'];
+ $req['IsActive'] = $data['switchsetting'];
+ $req['Comments'] = $data['Comments'];
+ $req['BranchCode'] = $createdBranch;
+
+ $req['DeactiveComments'] = $data['switchsetting'] == 1 ? '': $data['DeactiveComments'];
+
+ $req['CreatedBy'] = $createdBy;
+ $date = date('Y-m-d H:i:s');
+ $req['CreatedOn'] = $date;
+
+ $reqCourse['UniversityID'] = $coursedata['university'];
+ $reqCourse['CourseID'] = $coursedata['course'];
+ $reqCourse['SessionID'] = $coursedata['batch'];
+ $reqCourse['DOJ'] = $coursedata['dateofjoining'];
+ $reqCourse['BranchID'] = $createdBranch;
+ $reqCourse['IsActive'] = $data['switchsetting'];
+ $reqCourse['EnrollmentID'] = $coursedata['enrollmentid'];
+
+ $reqCourse['Specilization1'] = $coursedata['specilization1'];
+ $reqCourse['Specilization2'] = $coursedata['specilization2'];
+
+ $reqCourse['CreatedBy'] = $createdBy;
+ $date = date('Y-m-d H:i:s');
+ $reqCourse['CreatedOn'] = $date;
+
+ $studentAdd = $this->student_model->add_student( $req , $reqCourse, $imagename, $imageSource, $size);// Check if the employee exist
+ if ($studentAdd) {
+ $studentAdd['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ } else {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ // add student
+ public function addStudent_post() {
+
+
+ $imagename = '';
+ $size = '';
+ $imageSource = '';
+
+ $data = $this->post('data');
+ $coursedata = $this->post('coursedata');
+ $createdBy = $this->post('createdBy');
+ $createdBranch = $this->post('loginBranch');
+
+ $req['Firstname'] = $data['firstname'];
+ $req['Lastname'] = $data['lastname'];
+ $req['Fathername'] = $data['fathername'];
+ $req['EmailID'] = $data['emailId'];
+ $req['MotherName'] = $data['mothername'];
+ $req['MobileNumber'] = $data['primaryPhone'];
+ $req['AlternateNumber'] = $data['secondaryPhone'];
+ $req['Gender'] = $data['gender'];
+ $req['DOB'] = $data['dateofbirth'];
+ $req['PresentAddress'] = $data['address2'];
+ $req['PermanentAddress'] = $data['address1'];
+ $req['AadharNumber'] = $data['aadharNumber'];
+ $req['OtherID'] = $data['otherId'];
+ $req['OtherIDDetails'] = $data['otherIdDetails'];
+ $req['Caste'] = $data['caste'];
+ $req['Category'] = $data['category'];
+ $req['Religion'] = $data['religion'];
+ $req['Nationality'] = $data['nationality'];
+ $req['Occupation'] = $data['occupation'];
+ $req['Designation'] = $data['designation'];
+ $req['Companyname'] = $data['companyname'];
+ $req['ReferredBy'] = $data['referredby'];
+ $req['ReferersMobileNumber'] = $data['referredmobilenumber'];
+ $req['PreQualification'] = $data['prequalification'];
+ $req['IsActive'] = $data['switchsetting'];
+ $req['Comments'] = $data['Comments'];
+ $req['BranchCode'] = $createdBranch;
+
+ $req['DeactiveComments'] = $data['switchsetting'] == 1 ? '': $data['DeactiveComments'];
+
+ $req['CreatedBy'] = $createdBy;
+ $date = date('Y-m-d H:i:s');
+ $req['CreatedOn'] = $date;
+
+ $reqCourse['UniversityID'] = $coursedata['university'];
+ $reqCourse['CourseID'] = $coursedata['course'];
+ $reqCourse['SessionID'] = $coursedata['batch'];
+ $reqCourse['DOJ'] = $coursedata['dateofjoining'];
+ $reqCourse['BranchID'] = $createdBranch;
+ $reqCourse['IsActive'] = $data['switchsetting'];
+ $reqCourse['EnrollmentID'] = $coursedata['enrollmentid'];
+
+ $reqCourse['Specilization1'] = $coursedata['specilization1'];
+ $reqCourse['Specilization2'] = $coursedata['specilization2'];
+
+ $reqCourse['CreatedBy'] = $createdBy;
+ $date = date('Y-m-d H:i:s');
+ $reqCourse['CreatedOn'] = $date;
+
+
+ $studentAdd = $this->student_model->add_student( $req , $reqCourse, $imagename, $imageSource, $size);// Check if the employee exist
+ if ($studentAdd) {
+ $studentAdd['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ } else {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No users were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+
+}
diff --git a/api/application/controllers/Subject_Controller.php b/api/application/controllers/Subject_Controller.php
new file mode 100644
index 0000000..0ed2291
--- /dev/null
+++ b/api/application/controllers/Subject_Controller.php
@@ -0,0 +1,134 @@
+methods['addSubjectDetails_get']['limit'] = 500; // 500 requests per hour per user/key
+ $this->methods['addSubjectDetails_post']['limit'] = 100; // 100 requests per hour per user/key
+ $this->methods['addSubjectDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
+ $this->methods['getSubjectDetails_post']['limit'] = 500; // 50 requests per hour per user/key
+ $this->methods['updateSubjectDetails_post']['limit'] = 500;// 500 requests per hour per user/key
+
+ // load the model
+ $this->load->model('Subject_model', 'subject_model');
+
+ }
+
+ /*
+ * This method used to add Subject details
+ *
+ * */
+
+ public function addSubjectDetails_post()
+ {
+
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SubjectCode'] = $this->post('SubjectCode');
+ $details['SubjectName'] = $this->post('SubjectName');
+ $details['IsActive'] = $this->post('Status');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+
+ $subjectDetails = $this->subject_model->addSubject($details);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($subjectDetails)
+ {
+ $subjectDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($subjectDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get Subject details
+ *
+ * */
+ public function getSubjectDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+
+ $getSubject = $this->subject_model->getSubject($requestedBy);
+
+
+
+ if ($getSubject)
+ {
+ $getSubject['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getSubject, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * update Subject details
+ *
+ * */
+ public function updateSubjectDetails_post()
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['SubjectCode'] = $this->post('SubjectCode');
+ $details['SubjectName'] = $this->post('SubjectName');
+ $SubjectID = $this->post('SubjectID');
+ $details['IsActive'] = $this->post('Status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+
+ // print_r($SubjectID);die();
+
+
+ $updateDetails = $this->subject_model->updateSubject($details,$SubjectID);// Check if the users data store contains users (in case the database result returns NULL)
+ // print_r($details,$SubjectID);die();
+ if ($updateDetails)
+
+ {
+ $updateDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/Teste.php b/api/application/controllers/Teste.php
new file mode 100644
index 0000000..f394f4d
--- /dev/null
+++ b/api/application/controllers/Teste.php
@@ -0,0 +1,64 @@
+db->where('email', $email);
+ $this->db->where('senha', $senha);
+ $usuario = $this->db->get('admin')->first_row();
+
+ $key = $this->config->item('encryption_key');
+ $exp = strtotime("-2 hours");
+ $iat = strtotime("now");
+ $nbf = strtotime("+3 hours");
+ $token = $this->jwt->encode(array(
+ 'id'=>$usuario->id,
+ 'name'=>$usuario->nome,
+ 'admin'=>true,
+ 'iat'=>$iat,
+ 'exp'=>$exp
+ ), $key);
+ echo "";
+ echo $token;
+ echo "
";
+ echo 'time: '.time();
+ echo "
";
+ echo 'iate: '.$iat;
+ echo "
";
+ echo 'nbf : '.$nbf;
+ echo "
";
+ echo 'exp : '.$exp;
+ echo "
";
+ echo "
";
+
+ // if ($iat > time()) {
+ // echo 'Não é possível lidar com token antes de ' . date(DateTime::ISO8601, time());
+ // echo "
";
+ // }
+ if (time() >= $exp) {
+ echo "Expired token";
+ echo "
";
+ }
+
+
+ echo "";
+ print_r ($usuario);
+ echo "
";
+ echo "
";
+ var_dump( $this->jwt->decode($token,$key) );
+ echo "
";
+ }
+
+ public function sair(){
+ $this->session->sess_destroy();
+ redirect('','refresh');
+ }
+}
+
+/* End of file Teste.php */
+/* Location: ./application/controllers/Teste.php */
\ No newline at end of file
diff --git a/api/application/controllers/University_Controller.php b/api/application/controllers/University_Controller.php
new file mode 100644
index 0000000..a2ec438
--- /dev/null
+++ b/api/application/controllers/University_Controller.php
@@ -0,0 +1,298 @@
+methods['getUniversity_post']['limit'] = 100;
+ $this->methods['chkUnivIdExistDetail_post']['limit'] = 100;
+ $this->methods['getDefaultActivityDetails_post']['limit'] = 100;
+ $this->methods['updateDefaultActivityDetails_post']['limit'] = 100;
+
+ // load the university model
+ $this->load->model('University_model', 'university_model');
+ }
+
+ // get university details
+ public function getUniversity_post() {
+ $reqData = $this->post('data');
+ $loginUserId = $reqData['localUserID'];
+ $loginUserBranchId = $reqData['localBranchID'];
+ $loginUserType = $reqData['localType'];
+ $getUniversityListDetails = $this->university_model->get_university_list();// Check if the employee exist
+ if ($getUniversityListDetails)
+ {
+ $getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ //update university details
+ public function updateUniversityDetail_post() {
+
+ $reqData = $this->post('data');
+ $req['UpdatedBy'] = $this->post('updatedBy');
+ $date = date('Y-m-d H:i:s');
+ $req['UpdatedOn'] = $date;
+ $req['UniversityName']= $reqData['UniversityName'];
+ $req['UniversityShortName']= $reqData['UniversityShortName'];
+ $req['MobileNumber']= $reqData['MobileNumber'];
+ $req['EmailID']= $reqData['EmailID'];
+ $req['Address']= $reqData['Address'];
+ $req['IsActive']= $reqData['IsActive'];
+
+ $updateFor = $reqData['UniversityID'];
+
+ $updateUniversityDetail = $this->university_model->update_university_details($updateFor, $req);// Check if the employee exist
+ if ($updateUniversityDetail)
+ {
+ $updateUniversityDetail['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($updateUniversityDetail, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // check university details exist
+ public function chkUnivIdExistDetail_post() {
+
+ $data = $this->post('data');
+ $check = $this->post('check');
+
+ $checkUnivExist = $this->university_model->check_Univ_Exist($data, $check);// Check if the employee exist
+ if ($checkUnivExist)
+ {
+ $checkUnivExist['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($checkUnivExist, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ // insert university details
+ public function insertUniversity_post() {
+ $reqData = $this->post('data');
+ $req['CreatedBy'] = $this->post('createdBy');
+ $date = date('Y-m-d H:i:s');
+ $req['CreatedOn'] = $date;
+ $req['UniversityName']= $reqData['UniversityName'];
+ $req['UniversityShortName']= $reqData['UniversityShortName'];
+ $req['MobileNumber']= $reqData['MobileNumber'];
+ $req['EmailID']= $reqData['EmailID'];
+ $req['Address']= $reqData['Address'];
+ $req['IsActive']= $reqData['switchsetting'];
+ $req['UniversityID']= $reqData['UniversityID'];
+
+ $insertUniv = $this->university_model->insert_Univ($req);// Check if the employee exist
+ if ($insertUniv)
+ {
+ $insertUniv['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($insertUniv, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'No list were found',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+ }
+
+ /*
+ * add activity details
+ * created Surendiran
+ * */
+
+ public function addActivityDetails_post() {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['ActivityID'] = $this->post('activityID');
+ $details['ActivityName'] = $this->post('activityName');
+ $details['Description'] = $this->post('description');
+ $details['CreatedBy'] = $this->post('createdBy');
+ $details['CreatedOn'] = $now->format('Y-m-d H:i:s');
+ $details['IsActive'] = $this->post('status');
+ $jsonData=$this->post('activityStatus');
+ $activityDetails = $this->university_model->addActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
+ if ($activityDetails) {
+ $activityDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($activityDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ } else
+ { // Set the response and exit
+ $this->response([ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ /*
+ * get activity details
+ * created by Surendiran
+ * */
+ public function getActivityDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getActivity = $this->university_model->getActivity($requestedBy);
+ if ($getActivity)
+ {
+ $getActivity['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getActivity, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ { // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+
+ /*
+ * update activity details
+ * created by Surendiran
+ * */
+ public function updateActivityDetails_post()
+ {
+
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['ActivityID'] = $this->post('activityID');
+ $details['ActivityName'] = $this->post('activityName');
+ $details['Description'] = $this->post('description');
+ $details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+ $jsonData=$this->post('activityStatus');
+ $activityDetails = $this->university_model->updateActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($activityDetails)
+ {
+ $activityDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($activityDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+ /*
+ * get default activity details
+ * created by kms
+ * */
+ public function getDefaultActivityDetails_post()
+ {
+ $requestedBy = $this->post('requestedBy');
+ $getDefaultActivity = $this->university_model->getDefaultActivity($requestedBy);
+ if ($getDefaultActivity)
+ {
+ $getDefaultActivity['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($getDefaultActivity, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ { // Set the response and exit
+ $this->response([
+ 'message' => 'No records found!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+ }
+ /*
+ * update default activity status
+ * created by kms
+ * */
+
+ public function updateDefaultActivityDetails_post()
+ {
+
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $details['StudentActivityCode'] = $this->post('activityID');
+ $details['StatusCode'] = $this->post('activityName');
+ //$details['IsActive'] = $this->post('status');
+ $details['UpdatedBy'] = $this->post('updatedBy');
+ $details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
+ $jsonData=$this->post('activityStatus');
+ $activityDetails = $this->university_model->updateDefaultActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
+
+ if ($activityDetails)
+ {
+ $activityDetails['status'] = REST_Controller::HTTP_OK;
+ // Set the response and exit
+ $this->response($activityDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
+ }
+ else
+ {
+ // Set the response and exit
+ $this->response([
+ 'message' => 'Something went wrong.please try again!',
+ 'status' => REST_Controller::HTTP_NOT_FOUND
+ ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
+ }
+
+
+ }
+
+
+}
diff --git a/api/application/controllers/Welcome.php b/api/application/controllers/Welcome.php
new file mode 100644
index 0000000..59818c7
--- /dev/null
+++ b/api/application/controllers/Welcome.php
@@ -0,0 +1,27 @@
+
+ * @see https://codeigniter.com/user_guide/general/urls.html
+ */
+ public function index()
+ {
+ $this->load->helper('url');
+
+ $this->load->view('welcome_message');
+ }
+}
diff --git a/api/application/controllers/index.html b/api/application/controllers/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/controllers/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/core/MY_Controller.php b/api/application/core/MY_Controller.php
new file mode 100644
index 0000000..6c1e6d8
--- /dev/null
+++ b/api/application/core/MY_Controller.php
@@ -0,0 +1,41 @@
+config->item('encryption_key');
+ $token = $this->input->get_request_header('Authorization');
+ $token = str_replace('Bearer ','',$token);
+ $token = $this->jwt->decode($token, $key);
+ $this->userdata = $token;
+ } catch (Exception $e) {
+ $token = FALSE;
+ $erro = 'Erro: '.$e->getMessage();
+ }
+ if ($token == FALSE && $this->debug == false) {
+ $this->response([
+ 'status' => FALSE,
+ 'message' => $erro
+ ], REST_Controller::HTTP_UNAUTHORIZED);
+ }
+ }
+
+}
+
+/* End of file MY_Controller.php */
+/* Location: ./application/core/MY_Controller.php */
diff --git a/api/application/core/index.html b/api/application/core/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/core/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/helpers/index.html b/api/application/helpers/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/helpers/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/hooks/index.html b/api/application/hooks/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/hooks/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/index.html b/api/application/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/bulgarian/index.html b/api/application/language/bulgarian/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/language/bulgarian/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/bulgarian/rest_controller_lang.php b/api/application/language/bulgarian/rest_controller_lang.php
new file mode 100644
index 0000000..4ba134d
--- /dev/null
+++ b/api/application/language/bulgarian/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/dutch/rest_controller_lang.php b/api/application/language/dutch/rest_controller_lang.php
new file mode 100644
index 0000000..182ca61
--- /dev/null
+++ b/api/application/language/dutch/rest_controller_lang.php
@@ -0,0 +1,16 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/english/rest_controller_lang.php b/api/application/language/english/rest_controller_lang.php
new file mode 100644
index 0000000..06bf4b9
--- /dev/null
+++ b/api/application/language/english/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/french/rest_controller_lang.php b/api/application/language/french/rest_controller_lang.php
new file mode 100644
index 0000000..f8c0d13
--- /dev/null
+++ b/api/application/language/french/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/german/rest_controller_lang.php b/api/application/language/german/rest_controller_lang.php
new file mode 100644
index 0000000..4230c3c
--- /dev/null
+++ b/api/application/language/german/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/indonesia/index.html b/api/application/language/indonesia/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/language/indonesia/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/indonesia/rest_controller_lang.php b/api/application/language/indonesia/rest_controller_lang.php
new file mode 100644
index 0000000..771c683
--- /dev/null
+++ b/api/application/language/indonesia/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/italian/rest_controller_lang.php b/api/application/language/italian/rest_controller_lang.php
new file mode 100644
index 0000000..783f16a
--- /dev/null
+++ b/api/application/language/italian/rest_controller_lang.php
@@ -0,0 +1,16 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/portuguese-brazilian/rest_controller_lang.php b/api/application/language/portuguese-brazilian/rest_controller_lang.php
new file mode 100644
index 0000000..84dc9e0
--- /dev/null
+++ b/api/application/language/portuguese-brazilian/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/romanian/rest_controller_lang.php b/api/application/language/romanian/rest_controller_lang.php
new file mode 100644
index 0000000..f151d52
--- /dev/null
+++ b/api/application/language/romanian/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/serbian_cyr/rest_controller_lang.php b/api/application/language/serbian_cyr/rest_controller_lang.php
new file mode 100644
index 0000000..4d249c4
--- /dev/null
+++ b/api/application/language/serbian_cyr/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/serbian_lat/rest_controller_lang.php b/api/application/language/serbian_lat/rest_controller_lang.php
new file mode 100644
index 0000000..057ab93
--- /dev/null
+++ b/api/application/language/serbian_lat/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/simplified-chinese/rest_controller_lang.php b/api/application/language/simplified-chinese/rest_controller_lang.php
new file mode 100644
index 0000000..f32e9e7
--- /dev/null
+++ b/api/application/language/simplified-chinese/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/spanish/rest_controller_lang.php b/api/application/language/spanish/rest_controller_lang.php
new file mode 100644
index 0000000..2ca8105
--- /dev/null
+++ b/api/application/language/spanish/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/traditional-chinese/rest_controller_lang.php b/api/application/language/traditional-chinese/rest_controller_lang.php
new file mode 100644
index 0000000..b1f80ca
--- /dev/null
+++ b/api/application/language/traditional-chinese/rest_controller_lang.php
@@ -0,0 +1,18 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/language/turkish/rest_controller_lang.php b/api/application/language/turkish/rest_controller_lang.php
new file mode 100644
index 0000000..589b28c
--- /dev/null
+++ b/api/application/language/turkish/rest_controller_lang.php
@@ -0,0 +1,18 @@
+_CI = &get_instance();
+
+ // Load the inflector helper
+ $this->_CI->load->helper('inflector');
+
+ // If the provided data is already formatted we should probably convert it to an array
+ if ($from_type !== NULL)
+ {
+ if (method_exists($this, '_from_'.$from_type))
+ {
+ $data = call_user_func([$this, '_from_'.$from_type], $data);
+ }
+ else
+ {
+ throw new Exception('Format class does not support conversion from "'.$from_type.'".');
+ }
+ }
+
+ // Set the member variable to the data passed
+ $this->_data = $data;
+ }
+
+ /**
+ * Create an instance of the format class
+ * e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();
+ *
+ * @param mixed $data Data to convert/parse
+ * @param string $from_type Type to convert from e.g. json, csv, html
+ *
+ * @return object Instance of the format class
+ */
+ public function factory($data, $from_type = NULL)
+ {
+ // $class = __CLASS__;
+ // return new $class();
+
+ return new static($data, $from_type);
+ }
+
+ // FORMATTING OUTPUT ---------------------------------------------------------
+
+ /**
+ * Format data as an array
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @return array Data parsed as an array; otherwise, an empty array
+ */
+ public function to_array($data = NULL)
+ {
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ // Cast as an array if not already
+ if (is_array($data) === FALSE)
+ {
+ $data = (array) $data;
+ }
+
+ $array = [];
+ foreach ((array) $data as $key => $value)
+ {
+ if (is_object($value) === TRUE || is_array($value) === TRUE)
+ {
+ $array[$key] = $this->to_array($value);
+ }
+ else
+ {
+ $array[$key] = $value;
+ }
+ }
+
+ return $array;
+ }
+
+ /**
+ * Format data as XML
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @param NULL $structure
+ * @param string $basenode
+ * @return mixed
+ */
+ public function to_xml($data = NULL, $structure = NULL, $basenode = 'xml')
+ {
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ if ($structure === NULL)
+ {
+ $structure = simplexml_load_string("<$basenode />");
+ }
+
+ // Force it to be something useful
+ if (is_array($data) === FALSE && is_object($data) === FALSE)
+ {
+ $data = (array) $data;
+ }
+
+ foreach ($data as $key => $value)
+ {
+
+ //change false/true to 0/1
+ if (is_bool($value))
+ {
+ $value = (int) $value;
+ }
+
+ // no numeric keys in our xml please!
+ if (is_numeric($key))
+ {
+ // make string key...
+ $key = (singular($basenode) != $basenode) ? singular($basenode) : 'item';
+ }
+
+ // replace anything not alpha numeric
+ $key = preg_replace('/[^a-z_\-0-9]/i', '', $key);
+
+ if ($key === '_attributes' && (is_array($value) || is_object($value)))
+ {
+ $attributes = $value;
+ if (is_object($attributes))
+ {
+ $attributes = get_object_vars($attributes);
+ }
+
+ foreach ($attributes as $attribute_name => $attribute_value)
+ {
+ $structure->addAttribute($attribute_name, $attribute_value);
+ }
+ }
+ // if there is another array found recursively call this function
+ elseif (is_array($value) || is_object($value))
+ {
+ $node = $structure->addChild($key);
+
+ // recursive call.
+ $this->to_xml($value, $node, $key);
+ }
+ else
+ {
+ // add single node.
+ $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
+
+ $structure->addChild($key, $value);
+ }
+ }
+
+ return $structure->asXML();
+ }
+
+ /**
+ * Format data as HTML
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @return mixed
+ */
+ public function to_html($data = NULL)
+ {
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ // Cast as an array if not already
+ if (is_array($data) === FALSE)
+ {
+ $data = (array) $data;
+ }
+
+ // Check if it's a multi-dimensional array
+ if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE))
+ {
+ // Multi-dimensional array
+ $headings = array_keys($data[0]);
+ }
+ else
+ {
+ // Single array
+ $headings = array_keys($data);
+ $data = [$data];
+ }
+
+ // Load the table library
+ $this->_CI->load->library('table');
+
+ $this->_CI->table->set_heading($headings);
+
+ foreach ($data as $row)
+ {
+ // Suppressing the "array to string conversion" notice
+ // Keep the "evil" @ here
+ $row = @array_map('strval', $row);
+
+ $this->_CI->table->add_row($row);
+ }
+
+ return $this->_CI->table->generate();
+ }
+
+ /**
+ * @link http://www.metashock.de/2014/02/create-csv-file-in-memory-php/
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @param string $delimiter The optional delimiter parameter sets the field
+ * delimiter (one character only). NULL will use the default value (,)
+ * @param string $enclosure The optional enclosure parameter sets the field
+ * enclosure (one character only). NULL will use the default value (")
+ * @return string A csv string
+ */
+ public function to_csv($data = NULL, $delimiter = ',', $enclosure = '"')
+ {
+ // Use a threshold of 1 MB (1024 * 1024)
+ $handle = fopen('php://temp/maxmemory:1048576', 'w');
+ if ($handle === FALSE)
+ {
+ return NULL;
+ }
+
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ // If NULL, then set as the default delimiter
+ if ($delimiter === NULL)
+ {
+ $delimiter = ',';
+ }
+
+ // If NULL, then set as the default enclosure
+ if ($enclosure === NULL)
+ {
+ $enclosure = '"';
+ }
+
+ // Cast as an array if not already
+ if (is_array($data) === FALSE)
+ {
+ $data = (array) $data;
+ }
+
+ // Check if it's a multi-dimensional array
+ if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE))
+ {
+ // Multi-dimensional array
+ $headings = array_keys($data[0]);
+ }
+ else
+ {
+ // Single array
+ $headings = array_keys($data);
+ $data = [$data];
+ }
+
+ // Apply the headings
+ fputcsv($handle, $headings, $delimiter, $enclosure);
+
+ foreach ($data as $record)
+ {
+ // If the record is not an array, then break. This is because the 2nd param of
+ // fputcsv() should be an array
+ if (is_array($record) === FALSE)
+ {
+ break;
+ }
+
+ // Suppressing the "array to string conversion" notice.
+ // Keep the "evil" @ here.
+ $record = @ array_map('strval', $record);
+
+ // Returns the length of the string written or FALSE
+ fputcsv($handle, $record, $delimiter, $enclosure);
+ }
+
+ // Reset the file pointer
+ rewind($handle);
+
+ // Retrieve the csv contents
+ $csv = stream_get_contents($handle);
+
+ // Close the handle
+ fclose($handle);
+
+ return $csv;
+ }
+
+ /**
+ * Encode data as json
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @return string Json representation of a value
+ */
+ public function to_json($data = NULL)
+ {
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ // Get the callback parameter (if set)
+ $callback = $this->_CI->input->get('callback');
+
+ if (empty($callback) === TRUE)
+ {
+ return json_encode($data);
+ }
+
+ // We only honour a jsonp callback which are valid javascript identifiers
+ elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback))
+ {
+ // Return the data as encoded json with a callback
+ return $callback.'('.json_encode($data).');';
+ }
+
+ // An invalid jsonp callback function provided.
+ // Though I don't believe this should be hardcoded here
+ $data['warning'] = 'INVALID JSONP CALLBACK: '.$callback;
+
+ return json_encode($data);
+ }
+
+ /**
+ * Encode data as a serialized array
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @return string Serialized data
+ */
+ public function to_serialized($data = NULL)
+ {
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ return serialize($data);
+ }
+
+ /**
+ * Format data using a PHP structure
+ *
+ * @param mixed|NULL $data Optional data to pass, so as to override the data passed
+ * to the constructor
+ * @return mixed String representation of a variable
+ */
+ public function to_php($data = NULL)
+ {
+ // If no data is passed as a parameter, then use the data passed
+ // via the constructor
+ if ($data === NULL && func_num_args() === 0)
+ {
+ $data = $this->_data;
+ }
+
+ return var_export($data, TRUE);
+ }
+
+ // INTERNAL FUNCTIONS
+
+ /**
+ * @param string $data XML string
+ * @return array XML element object; otherwise, empty array
+ */
+ protected function _from_xml($data)
+ {
+ return $data ? (array) simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA) : [];
+ }
+
+ /**
+ * @param string $data CSV string
+ * @param string $delimiter The optional delimiter parameter sets the field
+ * delimiter (one character only). NULL will use the default value (,)
+ * @param string $enclosure The optional enclosure parameter sets the field
+ * enclosure (one character only). NULL will use the default value (")
+ * @return array A multi-dimensional array with the outer array being the number of rows
+ * and the inner arrays the individual fields
+ */
+ protected function _from_csv($data, $delimiter = ',', $enclosure = '"')
+ {
+ // If NULL, then set as the default delimiter
+ if ($delimiter === NULL)
+ {
+ $delimiter = ',';
+ }
+
+ // If NULL, then set as the default enclosure
+ if ($enclosure === NULL)
+ {
+ $enclosure = '"';
+ }
+
+ return str_getcsv($data, $delimiter, $enclosure);
+ }
+
+ /**
+ * @param string $data Encoded json string
+ * @return mixed Decoded json string with leading and trailing whitespace removed
+ */
+ protected function _from_json($data)
+ {
+ return json_decode(trim($data));
+ }
+
+ /**
+ * @param string $data Data to unserialize
+ * @return mixed Unserialized data
+ */
+ protected function _from_serialize($data)
+ {
+ return unserialize(trim($data));
+ }
+
+ /**
+ * @param string $data Data to trim leading and trailing whitespace
+ * @return string Data with leading and trailing whitespace removed
+ */
+ protected function _from_php($data)
+ {
+ return trim($data);
+ }
+}
diff --git a/api/application/libraries/JWT.php b/api/application/libraries/JWT.php
new file mode 100644
index 0000000..f84f4f9
--- /dev/null
+++ b/api/application/libraries/JWT.php
@@ -0,0 +1,194 @@
+
+ * @minor changes for codeigniter
+ */
+class JWT
+{
+ public static $timestamp = null;
+
+ /**
+ * @param string $jwt The JWT
+ * @param string|null $key The secret key
+ * @param bool $verify Don't skip verification process
+ *
+ * @return object The JWT's payload as a PHP object
+ */
+ public function decode($jwt, $key = null, $verify = true)
+ {
+ $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
+
+ $tks = explode('.', $jwt);
+ if (count($tks) != 3) {
+ throw new UnexpectedValueException('Wrong number of segments');
+ }
+ list($headb64, $payloadb64, $cryptob64) = $tks;
+ if (null === ($header = $this->jsonDecode($this->urlsafeB64Decode($headb64)))
+ ) {
+ throw new UnexpectedValueException('Invalid segment encoding');
+ }
+ if (null === $payload = $this->jsonDecode($this->urlsafeB64Decode($payloadb64))
+ ) {
+ throw new UnexpectedValueException('Invalid segment encoding');
+ }
+ $sig = $this->urlsafeB64Decode($cryptob64);
+ if ($verify) {
+ if (empty($header->alg)) {
+ throw new DomainException('Empty algorithm');
+ }
+ if ($sig != $this->sign("$headb64.$payloadb64", $key, $header->alg)) {
+ throw new UnexpectedValueException('Signature verification failed');
+ }
+ }
+
+ // Check if the nbf if it is defined. This is the time that the
+ // token can actually be used. If it's not yet that time, abort.
+ if (isset($payload->nbf) && $payload->nbf > $timestamp) {
+ throw new UnexpectedValueException(
+ 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
+ );
+ }
+
+ // Check that this token has been created before 'now'. This prevents
+ // using tokens that have been created for later use (and haven't
+ // correctly used the nbf claim).
+ if (isset($payload->iat) && $payload->iat > $timestamp) {
+ throw new UnexpectedValueException(
+ 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
+ );
+ }
+ // Check if this token has expired.
+ if (isset($payload->exp) && $timestamp >= $payload->exp) {
+ throw new UnexpectedValueException('Expired token');
+ }
+
+ return $payload;
+ }
+
+ /**
+ * @param object|array $payload PHP object or array
+ * @param string $key The secret key
+ * @param string $algo The signing algorithm
+ *
+ * @return string A JWT
+ */
+ public function encode($payload, $key, $algo = 'HS256')
+ {
+ $header = array('typ' => 'jwt', 'alg' => $algo);
+
+ $segments = array();
+ $segments[] = $this->urlsafeB64Encode($this->jsonEncode($header));
+ $segments[] = $this->urlsafeB64Encode($this->jsonEncode($payload));
+ $signing_input = implode('.', $segments);
+
+ $signature = $this->sign($signing_input, $key, $algo);
+ $segments[] = $this->urlsafeB64Encode($signature);
+
+ return implode('.', $segments);
+ }
+
+ /**
+ * @param string $msg The message to sign
+ * @param string $key The secret key
+ * @param string $method The signing algorithm
+ *
+ * @return string An encrypted message
+ */
+ public function sign($msg, $key, $method = 'HS256')
+ {
+ $methods = array(
+ 'HS256' => 'sha256',
+ 'HS384' => 'sha384',
+ 'HS512' => 'sha512',
+ );
+ if (empty($methods[$method])) {
+ throw new DomainException('Algorithm not supported');
+ }
+ return hash_hmac($methods[$method], $msg, $key, true);
+ }
+
+ /**
+ * @param string $input JSON string
+ *
+ * @return object Object representation of JSON string
+ */
+ public function jsonDecode($input)
+ {
+ $obj = json_decode($input);
+ if (function_exists('json_last_error') && $errno = json_last_error()) {
+ $this->handleJsonError($errno);
+ }
+ else if ($obj === null && $input !== 'null') {
+ throw new DomainException('Null result with non-null input');
+ }
+ return $obj;
+ }
+
+ /**
+ * @param object|array $input A PHP object or array
+ *
+ * @return string JSON representation of the PHP object or array
+ */
+ public function jsonEncode($input)
+ {
+ $json = json_encode($input);
+ if (function_exists('json_last_error') && $errno = json_last_error()) {
+ $this->handleJsonError($errno);
+ }
+ else if ($json === 'null' && $input !== null) {
+ throw new DomainException('Null result with non-null input');
+ }
+ return $json;
+ }
+
+ /**
+ * @param string $input A base64 encoded string
+ *
+ * @return string A decoded string
+ */
+ public function urlsafeB64Decode($input)
+ {
+ $remainder = strlen($input) % 4;
+ if ($remainder) {
+ $padlen = 4 - $remainder;
+ $input .= str_repeat('=', $padlen);
+ }
+ return base64_decode(strtr($input, '-_', '+/'));
+ }
+
+ /**
+ * @param string $input Anything really
+ *
+ * @return string The base64 encode of what you passed in
+ */
+ public function urlsafeB64Encode($input)
+ {
+ return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
+ }
+
+ /**
+ * @param int $errno An error number from json_last_error()
+ *
+ * @return void
+ */
+ private function handleJsonError($errno)
+ {
+ $messages = array(
+ JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
+ JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
+ JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
+ );
+ throw new DomainException(isset($messages[$errno])
+ ? $messages[$errno]
+ : 'Unknown JSON error: ' . $errno
+ );
+ }
+
+}
+
diff --git a/api/application/libraries/REST_Controller.php b/api/application/libraries/REST_Controller.php
new file mode 100644
index 0000000..de6ae6c
--- /dev/null
+++ b/api/application/libraries/REST_Controller.php
@@ -0,0 +1,2257 @@
+ 'application/json',
+ 'array' => 'application/json',
+ 'csv' => 'application/csv',
+ 'html' => 'text/html',
+ 'jsonp' => 'application/javascript',
+ 'php' => 'text/plain',
+ 'serialized' => 'application/vnd.php.serialized',
+ 'xml' => 'application/xml'
+ ];
+
+ /**
+ * Information about the current API user
+ *
+ * @var object
+ */
+ protected $_apiuser;
+
+ /**
+ * Whether or not to perform a CORS check and apply CORS headers to the request
+ *
+ * @var bool
+ */
+ protected $check_cors = NULL;
+
+ /**
+ * Enable XSS flag
+ * Determines whether the XSS filter is always active when
+ * GET, OPTIONS, HEAD, POST, PUT, DELETE and PATCH data is encountered
+ * Set automatically based on config setting
+ *
+ * @var bool
+ */
+ protected $_enable_xss = FALSE;
+
+ /**
+ * HTTP status codes and their respective description
+ * Note: Only the widely used HTTP status codes are used
+ *
+ * @var array
+ * @link http://www.restapitutorial.com/httpstatuscodes.html
+ */
+ protected $http_status_codes = [
+ self::HTTP_OK => 'OK',
+ self::HTTP_CREATED => 'CREATED',
+ self::HTTP_NO_CONTENT => 'NO CONTENT',
+ self::HTTP_NOT_MODIFIED => 'NOT MODIFIED',
+ self::HTTP_BAD_REQUEST => 'BAD REQUEST',
+ self::HTTP_UNAUTHORIZED => 'UNAUTHORIZED',
+ self::HTTP_FORBIDDEN => 'FORBIDDEN',
+ self::HTTP_NOT_FOUND => 'NOT FOUND',
+ self::HTTP_METHOD_NOT_ALLOWED => 'METHOD NOT ALLOWED',
+ self::HTTP_NOT_ACCEPTABLE => 'NOT ACCEPTABLE',
+ self::HTTP_CONFLICT => 'CONFLICT',
+ self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR',
+ self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED'
+ ];
+
+ /**
+ * Extend this function to apply additional checking early on in the process
+ *
+ * @access protected
+ * @return void
+ */
+ protected function early_checks()
+ {
+ }
+
+ /**
+ * Constructor for the REST API
+ *
+ * @access public
+ * @param string $config Configuration filename minus the file extension
+ * e.g: my_rest.php is passed as 'my_rest'
+ */
+ public function __construct($config = 'rest')
+ {
+ parent::__construct();
+
+ $this->preflight_checks();
+
+ // Set the default value of global xss filtering. Same approach as CodeIgniter 3
+ $this->_enable_xss = ($this->config->item('global_xss_filtering') === TRUE);
+
+ // Don't try to parse template variables like {elapsed_time} and {memory_usage}
+ // when output is displayed for not damaging data accidentally
+ $this->output->parse_exec_vars = FALSE;
+
+ // Start the timer for how long the request takes
+ $this->_start_rtime = microtime(TRUE);
+
+ // Load the rest.php configuration file
+ $this->load->config($config);
+
+ // At present the library is bundled with REST_Controller 2.5+, but will eventually be part of CodeIgniter (no citation)
+ $this->load->library('format');
+
+ // Determine supported output formats from configuration
+ $supported_formats = $this->config->item('rest_supported_formats');
+
+ // Validate the configuration setting output formats
+ if (empty($supported_formats))
+ {
+ $supported_formats = [];
+ }
+
+ if ( ! is_array($supported_formats))
+ {
+ $supported_formats = [$supported_formats];
+ }
+
+ // Add silently the default output format if it is missing
+ $default_format = $this->_get_default_output_format();
+ if (!in_array($default_format, $supported_formats))
+ {
+ $supported_formats[] = $default_format;
+ }
+
+ // Now update $this->_supported_formats
+ $this->_supported_formats = array_intersect_key($this->_supported_formats, array_flip($supported_formats));
+
+ // Get the language
+ $language = $this->config->item('rest_language');
+ if ($language === NULL)
+ {
+ $language = 'english';
+ }
+
+ // Load the language file
+ $this->lang->load('rest_controller', $language);
+
+ // Initialise the response, request and rest objects
+ $this->request = new stdClass();
+ $this->response = new stdClass();
+ $this->rest = new stdClass();
+
+ // Check to see if the current IP address is blacklisted
+ if ($this->config->item('rest_ip_blacklist_enabled') === TRUE)
+ {
+ $this->_check_blacklist_auth();
+ }
+
+ // Determine whether the connection is HTTPS
+ $this->request->ssl = is_https();
+
+ // How is this request being made? GET, POST, PATCH, DELETE, INSERT, PUT, HEAD or OPTIONS
+ $this->request->method = $this->_detect_method();
+
+ // Check for CORS access request
+ $check_cors = $this->config->item('check_cors');
+ if ($check_cors === TRUE)
+ {
+ $this->_check_cors();
+ }
+
+ // Create an argument container if it doesn't exist e.g. _get_args
+ if (isset($this->{'_'.$this->request->method.'_args'}) === FALSE)
+ {
+ $this->{'_'.$this->request->method.'_args'} = [];
+ }
+
+ // Set up the query parameters
+ $this->_parse_query();
+
+ // Set up the GET variables
+ $this->_get_args = array_merge($this->_get_args, $this->uri->ruri_to_assoc());
+
+ // Try to find a format for the request (means we have a request body)
+ $this->request->format = $this->_detect_input_format();
+
+ // Not all methods have a body attached with them
+ $this->request->body = NULL;
+
+ $this->{'_parse_' . $this->request->method}();
+
+ // Now we know all about our request, let's try and parse the body if it exists
+ if ($this->request->format && $this->request->body)
+ {
+ $this->request->body = $this->format->factory($this->request->body, $this->request->format)->to_array();
+ // Assign payload arguments to proper method container
+ $this->{'_'.$this->request->method.'_args'} = $this->request->body;
+ }
+
+ //get header vars
+ $this->_head_args = $this->input->request_headers();
+
+ // Merge both for one mega-args variable
+ $this->_args = array_merge(
+ $this->_get_args,
+ $this->_options_args,
+ $this->_patch_args,
+ $this->_head_args,
+ $this->_put_args,
+ $this->_post_args,
+ $this->_delete_args,
+ $this->{'_'.$this->request->method.'_args'}
+ );
+
+ // Which format should the data be returned in?
+ $this->response->format = $this->_detect_output_format();
+
+ // Which language should the data be returned in?
+ $this->response->lang = $this->_detect_lang();
+
+ // Extend this function to apply additional checking early on in the process
+ $this->early_checks();
+
+ // Load DB if its enabled
+ if ($this->config->item('rest_database_group') && ($this->config->item('rest_enable_keys') || $this->config->item('rest_enable_logging')))
+ {
+ $this->rest->db = $this->load->database($this->config->item('rest_database_group'), TRUE);
+ }
+
+ // Use whatever database is in use (isset returns FALSE)
+ elseif (property_exists($this, 'db'))
+ {
+ $this->rest->db = $this->db;
+ }
+
+ // Check if there is a specific auth type for the current class/method
+ // _auth_override_check could exit so we need $this->rest->db initialized before
+ $this->auth_override = $this->_auth_override_check();
+
+ // Checking for keys? GET TO WorK!
+ // Skip keys test for $config['auth_override_class_method']['class'['method'] = 'none'
+ if ($this->config->item('rest_enable_keys') && $this->auth_override !== TRUE)
+ {
+ $this->_allow = $this->_detect_api_key();
+ }
+
+ // Only allow ajax requests
+ if ($this->input->is_ajax_request() === FALSE && $this->config->item('rest_ajax_only'))
+ {
+ // Display an error response
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ajax_only')
+ ], self::HTTP_NOT_ACCEPTABLE);
+ }
+
+ // When there is no specific override for the current class/method, use the default auth value set in the config
+ if ($this->auth_override === FALSE &&
+ (! ($this->config->item('rest_enable_keys') && $this->_allow === TRUE) ||
+ ($this->config->item('allow_auth_and_keys') === TRUE && $this->_allow === TRUE)))
+ {
+ $rest_auth = strtolower($this->config->item('rest_auth'));
+ switch ($rest_auth)
+ {
+ case 'basic':
+ $this->_prepare_basic_auth();
+ break;
+ case 'digest':
+ $this->_prepare_digest_auth();
+ break;
+ case 'session':
+ $this->_check_php_session();
+ break;
+ }
+ if ($this->config->item('rest_ip_whitelist_enabled') === TRUE)
+ {
+ $this->_check_whitelist_auth();
+ }
+ }
+ }
+
+ /**
+ * Deconstructor
+ *
+ * @author Chris Kacerguis
+ * @access public
+ * @return void
+ */
+ public function __destruct()
+ {
+ // Get the current timestamp
+ $this->_end_rtime = microtime(TRUE);
+
+ // Log the loading time to the log table
+ if ($this->config->item('rest_enable_logging') === TRUE)
+ {
+ $this->_log_access_time();
+ }
+ }
+
+ /**
+ * Checks to see if we have everything we need to run this library.
+ *
+ * @access protected
+ * @@throws Exception
+ */
+ protected function preflight_checks()
+ {
+ // Check to see if PHP is equal to or greater than 5.4.x
+ if (is_php('5.4') === FALSE)
+ {
+ // CodeIgniter 3 is recommended for v5.4 or above
+ throw new Exception('Using PHP v'.PHP_VERSION.', though PHP v5.4 or greater is required');
+ }
+
+ // Check to see if this is CI 3.x
+ if (explode('.', CI_VERSION, 2)[0] < 3)
+ {
+ throw new Exception('REST Server requires CodeIgniter 3.x');
+ }
+ }
+
+ /**
+ * Requests are not made to methods directly, the request will be for
+ * an "object". This simply maps the object and method to the correct
+ * Controller method
+ *
+ * @access public
+ * @param string $object_called
+ * @param array $arguments The arguments passed to the controller method
+ */
+ public function _remap($object_called, $arguments = [])
+ {
+ // Should we answer if not over SSL?
+ if ($this->config->item('force_https') && $this->request->ssl === FALSE)
+ {
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unsupported')
+ ], self::HTTP_FORBIDDEN);
+ }
+
+ // Remove the supported format from the function name e.g. index.json => index
+ $object_called = preg_replace('/^(.*)\.(?:'.implode('|', array_keys($this->_supported_formats)).')$/', '$1', $object_called);
+
+ $controller_method = $object_called.'_'.$this->request->method;
+ // Does this method exist? If not, try executing an index method
+ if (!method_exists($this, $controller_method)) {
+ $controller_method = "index_" . $this->request->method;
+ array_unshift($arguments, $object_called);
+ }
+
+ // Do we want to log this method (if allowed by config)?
+ $log_method = ! (isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE);
+
+ // Use keys for this method?
+ $use_key = ! (isset($this->methods[$controller_method]['key']) && $this->methods[$controller_method]['key'] === FALSE);
+
+ // They provided a key, but it wasn't valid, so get them out of here
+ if ($this->config->item('rest_enable_keys') && $use_key && $this->_allow === FALSE)
+ {
+ if ($this->config->item('rest_enable_logging') && $log_method)
+ {
+ $this->_log_request();
+ }
+
+ // fix cross site to option request error
+ if($this->request->method == 'options') {
+ exit;
+ }
+
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => sprintf($this->lang->line('text_rest_invalid_api_key'), $this->rest->key)
+ ], self::HTTP_FORBIDDEN);
+ }
+
+ // Check to see if this key has access to the requested controller
+ if ($this->config->item('rest_enable_keys') && $use_key && empty($this->rest->key) === FALSE && $this->_check_access() === FALSE)
+ {
+ if ($this->config->item('rest_enable_logging') && $log_method)
+ {
+ $this->_log_request();
+ }
+
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_unauthorized')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+
+ // Sure it exists, but can they do anything with it?
+ if (! method_exists($this, $controller_method))
+ {
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unknown_method')
+ ], self::HTTP_METHOD_NOT_ALLOWED);
+ }
+
+ // Doing key related stuff? Can only do it if they have a key right?
+ if ($this->config->item('rest_enable_keys') && empty($this->rest->key) === FALSE)
+ {
+ // Check the limit
+ if ($this->config->item('rest_enable_limits') && $this->_check_limit($controller_method) === FALSE)
+ {
+ $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_time_limit')];
+ $this->response($response, self::HTTP_UNAUTHORIZED);
+ }
+
+ // If no level is set use 0, they probably aren't using permissions
+ $level = isset($this->methods[$controller_method]['level']) ? $this->methods[$controller_method]['level'] : 0;
+
+ // If no level is set, or it is lower than/equal to the key's level
+ $authorized = $level <= $this->rest->level;
+ // IM TELLIN!
+ if ($this->config->item('rest_enable_logging') && $log_method)
+ {
+ $this->_log_request($authorized);
+ }
+ if($authorized === FALSE)
+ {
+ // They don't have good enough perms
+ $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_permissions')];
+ $this->response($response, self::HTTP_UNAUTHORIZED);
+ }
+ }
+
+ //check request limit by ip without login
+ elseif ($this->config->item('rest_limits_method') == "IP_ADDRESS" && $this->config->item('rest_enable_limits') && $this->_check_limit($controller_method) === FALSE)
+ {
+ $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_address_time_limit')];
+ $this->response($response, self::HTTP_UNAUTHORIZED);
+ }
+
+ // No key stuff, but record that stuff is happening
+ elseif ($this->config->item('rest_enable_logging') && $log_method)
+ {
+ $this->_log_request($authorized = TRUE);
+ }
+
+ // Call the controller method and passed arguments
+ try
+ {
+ call_user_func_array([$this, $controller_method], $arguments);
+ }
+ catch (Exception $ex)
+ {
+ // If the method doesn't exist, then the error will be caught and an error response shown
+ $_error = &load_class('Exceptions', 'core');
+ $_error->show_exception($ex);
+ }
+ }
+
+ /**
+ * Takes mixed data and optionally a status code, then creates the response
+ *
+ * @access public
+ * @param array|NULL $data Data to output to the user
+ * @param int|NULL $http_code HTTP status code
+ * @param bool $continue TRUE to flush the response to the client and continue
+ * running the script; otherwise, exit
+ */
+ public function response($data = NULL, $http_code = NULL, $continue = FALSE)
+ {
+ ob_start();
+ // If the HTTP status is not NULL, then cast as an integer
+ if ($http_code !== NULL)
+ {
+ // So as to be safe later on in the process
+ $http_code = (int) $http_code;
+ }
+
+ // Set the output as NULL by default
+ $output = NULL;
+
+ // If data is NULL and no HTTP status code provided, then display, error and exit
+ if ($data === NULL && $http_code === NULL)
+ {
+ $http_code = self::HTTP_NOT_FOUND;
+ }
+
+ // If data is not NULL and a HTTP status code provided, then continue
+ elseif ($data !== NULL)
+ {
+ // If the format method exists, call and return the output in that format
+ if (method_exists($this->format, 'to_' . $this->response->format))
+ {
+ // Set the format header
+ $this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset')));
+ $output = $this->format->factory($data)->{'to_' . $this->response->format}();
+
+ // An array must be parsed as a string, so as not to cause an array to string error
+ // Json is the most appropriate form for such a datatype
+ if ($this->response->format === 'array')
+ {
+ $output = $this->format->factory($output)->{'to_json'}();
+ }
+ }
+ else
+ {
+ // If an array or object, then parse as a json, so as to be a 'string'
+ if (is_array($data) || is_object($data))
+ {
+ $data = $this->format->factory($data)->{'to_json'}();
+ }
+
+ // Format is not supported, so output the raw data as a string
+ $output = $data;
+ }
+ }
+
+ // If not greater than zero, then set the HTTP status code as 200 by default
+ // Though perhaps 500 should be set instead, for the developer not passing a
+ // correct HTTP status code
+ $http_code > 0 || $http_code = self::HTTP_OK;
+
+ $this->output->set_status_header($http_code);
+
+ // JC: Log response code only if rest logging enabled
+ if ($this->config->item('rest_enable_logging') === TRUE)
+ {
+ $this->_log_response_code($http_code);
+ }
+
+ // Output the data
+ $this->output->set_output($output);
+
+ if ($continue === FALSE)
+ {
+ // Display the data and exit execution
+ $this->output->_display();
+ exit;
+ }
+ else
+ {
+ ob_end_flush();
+ }
+
+ // Otherwise dump the output automatically
+ }
+
+ /**
+ * Takes mixed data and optionally a status code, then creates the response
+ * within the buffers of the Output class. The response is sent to the client
+ * lately by the framework, after the current controller's method termination.
+ * All the hooks after the controller's method termination are executable
+ *
+ * @access public
+ * @param array|NULL $data Data to output to the user
+ * @param int|NULL $http_code HTTP status code
+ */
+ public function set_response($data = NULL, $http_code = NULL)
+ {
+ $this->response($data, $http_code, TRUE);
+ }
+
+ /**
+ * Get the input format e.g. json or xml
+ *
+ * @access protected
+ * @return string|NULL Supported input format; otherwise, NULL
+ */
+ protected function _detect_input_format()
+ {
+ // Get the CONTENT-TYPE value from the SERVER variable
+ $content_type = $this->input->server('CONTENT_TYPE');
+
+ if (empty($content_type) === FALSE)
+ {
+ // If a semi-colon exists in the string, then explode by ; and get the value of where
+ // the current array pointer resides. This will generally be the first element of the array
+ $content_type = (strpos($content_type, ';') !== FALSE ? current(explode(';', $content_type)) : $content_type);
+
+ // Check all formats against the CONTENT-TYPE header
+ foreach ($this->_supported_formats as $type => $mime)
+ {
+ // $type = format e.g. csv
+ // $mime = mime type e.g. application/csv
+
+ // If both the mime types match, then return the format
+ if ($content_type === $mime)
+ {
+ return $type;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ /**
+ * Gets the default format from the configuration. Fallbacks to 'json'
+ * if the corresponding configuration option $config['rest_default_format']
+ * is missing or is empty
+ *
+ * @access protected
+ * @return string The default supported input format
+ */
+ protected function _get_default_output_format()
+ {
+ $default_format = (string) $this->config->item('rest_default_format');
+ return $default_format === '' ? 'json' : $default_format;
+ }
+
+ /**
+ * Detect which format should be used to output the data
+ *
+ * @access protected
+ * @return mixed|NULL|string Output format
+ */
+ protected function _detect_output_format()
+ {
+ // Concatenate formats to a regex pattern e.g. \.(csv|json|xml)
+ $pattern = '/\.('.implode('|', array_keys($this->_supported_formats)).')($|\/)/';
+ $matches = [];
+
+ // Check if a file extension is used e.g. http://example.com/api/index.json?param1=param2
+ if (preg_match($pattern, $this->uri->uri_string(), $matches))
+ {
+ return $matches[1];
+ }
+
+ // Get the format parameter named as 'format'
+ if (isset($this->_get_args['format']))
+ {
+ $format = strtolower($this->_get_args['format']);
+
+ if (isset($this->_supported_formats[$format]) === TRUE)
+ {
+ return $format;
+ }
+ }
+
+ // Get the HTTP_ACCEPT server variable
+ $http_accept = $this->input->server('HTTP_ACCEPT');
+
+ // Otherwise, check the HTTP_ACCEPT server variable
+ if ($this->config->item('rest_ignore_http_accept') === FALSE && $http_accept !== NULL)
+ {
+ // Check all formats against the HTTP_ACCEPT header
+ foreach (array_keys($this->_supported_formats) as $format)
+ {
+ // Has this format been requested?
+ if (strpos($http_accept, $format) !== FALSE)
+ {
+ if ($format !== 'html' && $format !== 'xml')
+ {
+ // If not HTML or XML assume it's correct
+ return $format;
+ }
+ elseif ($format === 'html' && strpos($http_accept, 'xml') === FALSE)
+ {
+ // HTML or XML have shown up as a match
+ // If it is truly HTML, it wont want any XML
+ return $format;
+ }
+ else if ($format === 'xml' && strpos($http_accept, 'html') === FALSE)
+ {
+ // If it is truly XML, it wont want any HTML
+ return $format;
+ }
+ }
+ }
+ }
+
+ // Check if the controller has a default format
+ if (empty($this->rest_format) === FALSE)
+ {
+ return $this->rest_format;
+ }
+
+ // Obtain the default format from the configuration
+ return $this->_get_default_output_format();
+ }
+
+ /**
+ * Get the HTTP request string e.g. get or post
+ *
+ * @access protected
+ * @return string|NULL Supported request method as a lowercase string; otherwise, NULL if not supported
+ */
+ protected function _detect_method()
+ {
+ // Declare a variable to store the method
+ $method = NULL;
+
+ // Determine whether the 'enable_emulate_request' setting is enabled
+ if ($this->config->item('enable_emulate_request') === TRUE)
+ {
+ $method = $this->input->post('_method');
+ if ($method === NULL)
+ {
+ $method = $this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE');
+ }
+
+ $method = strtolower($method);
+ }
+
+ if (empty($method))
+ {
+ // Get the request method as a lowercase string
+ $method = $this->input->method();
+ }
+
+ return in_array($method, $this->allowed_http_methods) && method_exists($this, '_parse_' . $method) ? $method : 'get';
+ }
+
+ /**
+ * See if the user has provided an API key
+ *
+ * @access protected
+ * @return bool
+ */
+ protected function _detect_api_key()
+ {
+ // Get the api key name variable set in the rest config file
+ $api_key_variable = $this->config->item('rest_key_name');
+
+ // Work out the name of the SERVER entry based on config
+ $key_name = 'HTTP_' . strtoupper(str_replace('-', '_', $api_key_variable));
+
+ $this->rest->key = NULL;
+ $this->rest->level = NULL;
+ $this->rest->user_id = NULL;
+ $this->rest->ignore_limits = FALSE;
+
+ // Find the key from server or arguments
+ if (($key = isset($this->_args[$api_key_variable]) ? $this->_args[$api_key_variable] : $this->input->server($key_name)))
+ {
+ if ( ! ($row = $this->rest->db->where($this->config->item('rest_key_column'), $key)->get($this->config->item('rest_keys_table'))->row()))
+ {
+ return FALSE;
+ }
+
+ $this->rest->key = $row->{$this->config->item('rest_key_column')};
+
+ isset($row->user_id) && $this->rest->user_id = $row->user_id;
+ isset($row->level) && $this->rest->level = $row->level;
+ isset($row->ignore_limits) && $this->rest->ignore_limits = $row->ignore_limits;
+
+ $this->_apiuser = $row;
+
+ /*
+ * If "is private key" is enabled, compare the ip address with the list
+ * of valid ip addresses stored in the database
+ */
+ if (empty($row->is_private_key) === FALSE)
+ {
+ // Check for a list of valid ip addresses
+ if (isset($row->ip_addresses))
+ {
+ // multiple ip addresses must be separated using a comma, explode and loop
+ $list_ip_addresses = explode(',', $row->ip_addresses);
+ $found_address = FALSE;
+
+ foreach ($list_ip_addresses as $ip_address)
+ {
+ if ($this->input->ip_address() === trim($ip_address))
+ {
+ // there is a match, set the the value to TRUE and break out of the loop
+ $found_address = TRUE;
+ break;
+ }
+ }
+
+ return $found_address;
+ }
+ else
+ {
+ // There should be at least one IP address for this private key
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ // No key has been sent
+ return FALSE;
+ }
+
+ /**
+ * Preferred return language
+ *
+ * @access protected
+ * @return string|NULL The language code
+ */
+ protected function _detect_lang()
+ {
+ $lang = $this->input->server('HTTP_ACCEPT_LANGUAGE');
+ if ($lang === NULL)
+ {
+ return NULL;
+ }
+
+ // It appears more than one language has been sent using a comma delimiter
+ if (strpos($lang, ',') !== FALSE)
+ {
+ $langs = explode(',', $lang);
+
+ $return_langs = [];
+ foreach ($langs as $lang)
+ {
+ // Remove weight and trim leading and trailing whitespace
+ list($lang) = explode(';', $lang);
+ $return_langs[] = trim($lang);
+ }
+
+ return $return_langs;
+ }
+
+ // Otherwise simply return as a string
+ return $lang;
+ }
+
+ /**
+ * Add the request to the log table
+ *
+ * @access protected
+ * @param bool $authorized TRUE the user is authorized; otherwise, FALSE
+ * @return bool TRUE the data was inserted; otherwise, FALSE
+ */
+ protected function _log_request($authorized = FALSE)
+ {
+ // Insert the request into the log table
+ $is_inserted = $this->rest->db
+ ->insert(
+ $this->config->item('rest_logs_table'), [
+ 'uri' => $this->uri->uri_string(),
+ 'method' => $this->request->method,
+ 'params' => $this->_args ? ($this->config->item('rest_logs_json_params') === TRUE ? json_encode($this->_args) : serialize($this->_args)) : NULL,
+ 'api_key' => isset($this->rest->key) ? $this->rest->key : '',
+ 'ip_address' => $this->input->ip_address(),
+ 'time' => time(),
+ 'authorized' => $authorized
+ ]);
+
+ // Get the last insert id to update at a later stage of the request
+ $this->_insert_id = $this->rest->db->insert_id();
+
+ return $is_inserted;
+ }
+
+ /**
+ * Check if the requests to a controller method exceed a limit
+ *
+ * @access protected
+ * @param string $controller_method The method being called
+ * @return bool TRUE the call limit is below the threshold; otherwise, FALSE
+ */
+ protected function _check_limit($controller_method)
+ {
+ // They are special, or it might not even have a limit
+ if (empty($this->rest->ignore_limits) === FALSE)
+ {
+ // Everything is fine
+ return TRUE;
+ }
+
+ $api_key = isset($this->rest->key) ? $this->rest->key : '';
+
+ switch ($this->config->item('rest_limits_method'))
+ {
+ case 'IP_ADDRESS':
+ $limited_uri = 'ip-address:' .$this->input->ip_address();
+ $api_key = $this->input->ip_address();
+ break;
+
+ case 'API_KEY':
+ $limited_uri = 'api-key:' . $api_key;
+ break;
+
+ case 'METHOD_NAME':
+ $limited_uri = 'method-name:' . $controller_method;
+ break;
+
+ case 'ROUTED_URL':
+ default:
+ $limited_uri = $this->uri->ruri_string();
+ if (strpos(strrev($limited_uri), strrev($this->response->format)) === 0)
+ {
+ $limited_uri = substr($limited_uri,0, -strlen($this->response->format) - 1);
+ }
+ $limited_uri = 'uri:'.$limited_uri.':'.$this->request->method; // It's good to differentiate GET from PUT
+ break;
+ }
+
+ if (isset($this->methods[$controller_method]['limit']) === FALSE )
+ {
+ // Everything is fine
+ return TRUE;
+ }
+
+ // How many times can you get to this method in a defined time_limit (default: 1 hour)?
+ $limit = $this->methods[$controller_method]['limit'];
+
+ $time_limit = (isset($this->methods[$controller_method]['time']) ? $this->methods[$controller_method]['time'] : 3600); // 3600 = 60 * 60
+
+ // Get data about a keys' usage and limit to one row
+ $result = $this->rest->db
+ ->where('uri', $limited_uri)
+ ->where('api_key', $api_key)
+ ->get($this->config->item('rest_limits_table'))
+ ->row();
+
+ // No calls have been made for this key
+ if ($result === NULL)
+ {
+ // Create a new row for the following key
+ $this->rest->db->insert($this->config->item('rest_limits_table'), [
+ 'uri' => $limited_uri,
+ 'api_key' =>$api_key,
+ 'count' => 1,
+ 'hour_started' => time()
+ ]);
+ }
+
+ // Been a time limit (or by default an hour) since they called
+ elseif ($result->hour_started < (time() - $time_limit))
+ {
+ // Reset the started period and count
+ $this->rest->db
+ ->where('uri', $limited_uri)
+ ->where('api_key', $api_key)
+ ->set('hour_started', time())
+ ->set('count', 1)
+ ->update($this->config->item('rest_limits_table'));
+ }
+
+ // They have called within the hour, so lets update
+ else
+ {
+ // The limit has been exceeded
+ if ($result->count >= $limit)
+ {
+ return FALSE;
+ }
+
+ // Increase the count by one
+ $this->rest->db
+ ->where('uri', $limited_uri)
+ ->where('api_key', $api_key)
+ ->set('count', 'count + 1', FALSE)
+ ->update($this->config->item('rest_limits_table'));
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Check if there is a specific auth type set for the current class/method/HTTP-method being called
+ *
+ * @access protected
+ * @return bool
+ */
+ protected function _auth_override_check()
+ {
+ // Assign the class/method auth type override array from the config
+ $auth_override_class_method = $this->config->item('auth_override_class_method');
+
+ // Check to see if the override array is even populated
+ if ( ! empty($auth_override_class_method))
+ {
+ // Check for wildcard flag for rules for classes
+ if ( ! empty($auth_override_class_method[$this->router->class]['*'])) // Check for class overrides
+ {
+ // No auth override found, prepare nothing but send back a TRUE override flag
+ if ($auth_override_class_method[$this->router->class]['*'] === 'none')
+ {
+ return TRUE;
+ }
+
+ // Basic auth override found, prepare basic
+ if ($auth_override_class_method[$this->router->class]['*'] === 'basic')
+ {
+ $this->_prepare_basic_auth();
+
+ return TRUE;
+ }
+
+ // Digest auth override found, prepare digest
+ if ($auth_override_class_method[$this->router->class]['*'] === 'digest')
+ {
+ $this->_prepare_digest_auth();
+
+ return TRUE;
+ }
+
+ // Session auth override found, check session
+ if ($auth_override_class_method[$this->router->class]['*'] === 'session')
+ {
+ $this->_check_php_session();
+
+ return TRUE;
+ }
+
+ // Whitelist auth override found, check client's ip against config whitelist
+ if ($auth_override_class_method[$this->router->class]['*'] === 'whitelist')
+ {
+ $this->_check_whitelist_auth();
+
+ return TRUE;
+ }
+ }
+
+ // Check to see if there's an override value set for the current class/method being called
+ if ( ! empty($auth_override_class_method[$this->router->class][$this->router->method]))
+ {
+ // None auth override found, prepare nothing but send back a TRUE override flag
+ if ($auth_override_class_method[$this->router->class][$this->router->method] === 'none')
+ {
+ return TRUE;
+ }
+
+ // Basic auth override found, prepare basic
+ if ($auth_override_class_method[$this->router->class][$this->router->method] === 'basic')
+ {
+ $this->_prepare_basic_auth();
+
+ return TRUE;
+ }
+
+ // Digest auth override found, prepare digest
+ if ($auth_override_class_method[$this->router->class][$this->router->method] === 'digest')
+ {
+ $this->_prepare_digest_auth();
+
+ return TRUE;
+ }
+
+ // Session auth override found, check session
+ if ($auth_override_class_method[$this->router->class][$this->router->method] === 'session')
+ {
+ $this->_check_php_session();
+
+ return TRUE;
+ }
+
+ // Whitelist auth override found, check client's ip against config whitelist
+ if ($auth_override_class_method[$this->router->class][$this->router->method] === 'whitelist')
+ {
+ $this->_check_whitelist_auth();
+
+ return TRUE;
+ }
+ }
+ }
+
+ // Assign the class/method/HTTP-method auth type override array from the config
+ $auth_override_class_method_http = $this->config->item('auth_override_class_method_http');
+
+ // Check to see if the override array is even populated
+ if ( ! empty($auth_override_class_method_http))
+ {
+ // check for wildcard flag for rules for classes
+ if ( ! empty($auth_override_class_method_http[$this->router->class]['*'][$this->request->method]))
+ {
+ // None auth override found, prepare nothing but send back a TRUE override flag
+ if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'none')
+ {
+ return TRUE;
+ }
+
+ // Basic auth override found, prepare basic
+ if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'basic')
+ {
+ $this->_prepare_basic_auth();
+
+ return TRUE;
+ }
+
+ // Digest auth override found, prepare digest
+ if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'digest')
+ {
+ $this->_prepare_digest_auth();
+
+ return TRUE;
+ }
+
+ // Session auth override found, check session
+ if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'session')
+ {
+ $this->_check_php_session();
+
+ return TRUE;
+ }
+
+ // Whitelist auth override found, check client's ip against config whitelist
+ if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'whitelist')
+ {
+ $this->_check_whitelist_auth();
+
+ return TRUE;
+ }
+ }
+
+ // Check to see if there's an override value set for the current class/method/HTTP-method being called
+ if ( ! empty($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method]))
+ {
+ // None auth override found, prepare nothing but send back a TRUE override flag
+ if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'none')
+ {
+ return TRUE;
+ }
+
+ // Basic auth override found, prepare basic
+ if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'basic')
+ {
+ $this->_prepare_basic_auth();
+
+ return TRUE;
+ }
+
+ // Digest auth override found, prepare digest
+ if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'digest')
+ {
+ $this->_prepare_digest_auth();
+
+ return TRUE;
+ }
+
+ // Session auth override found, check session
+ if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'session')
+ {
+ $this->_check_php_session();
+
+ return TRUE;
+ }
+
+ // Whitelist auth override found, check client's ip against config whitelist
+ if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'whitelist')
+ {
+ $this->_check_whitelist_auth();
+
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ /**
+ * Parse the GET request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_get()
+ {
+ // Merge both the URI segments and query parameters
+ $this->_get_args = array_merge($this->_get_args, $this->_query_args);
+ }
+
+ /**
+ * Parse the POST request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_post()
+ {
+ $this->_post_args = $_POST;
+
+ if ($this->request->format)
+ {
+ $this->request->body = $this->input->raw_input_stream;
+ }
+ }
+
+ /**
+ * Parse the PUT request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_put()
+ {
+ if ($this->request->format)
+ {
+ $this->request->body = $this->input->raw_input_stream;
+ if ($this->request->format === 'json')
+ {
+ $this->_put_args = json_decode($this->input->raw_input_stream);
+ }
+ }
+ else if ($this->input->method() === 'put')
+ {
+ // If no filetype is provided, then there are probably just arguments
+ $this->_put_args = $this->input->input_stream();
+ }
+ }
+
+ /**
+ * Parse the HEAD request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_head()
+ {
+ // Parse the HEAD variables
+ parse_str(parse_url($this->input->server('REQUEST_URI'), PHP_URL_QUERY), $head);
+
+ // Merge both the URI segments and HEAD params
+ $this->_head_args = array_merge($this->_head_args, $head);
+ }
+
+ /**
+ * Parse the OPTIONS request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_options()
+ {
+ // Parse the OPTIONS variables
+ parse_str(parse_url($this->input->server('REQUEST_URI'), PHP_URL_QUERY), $options);
+
+ // Merge both the URI segments and OPTIONS params
+ $this->_options_args = array_merge($this->_options_args, $options);
+ }
+
+ /**
+ * Parse the PATCH request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_patch()
+ {
+ // It might be a HTTP body
+ if ($this->request->format)
+ {
+ $this->request->body = $this->input->raw_input_stream;
+ }
+ else if ($this->input->method() === 'patch')
+ {
+ // If no filetype is provided, then there are probably just arguments
+ $this->_patch_args = $this->input->input_stream();
+ }
+ }
+
+ /**
+ * Parse the DELETE request arguments
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_delete()
+ {
+ // These should exist if a DELETE request
+ if ($this->input->method() === 'delete')
+ {
+ $this->_delete_args = $this->input->input_stream();
+ }
+ }
+
+ /**
+ * Parse the query parameters
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _parse_query()
+ {
+ $this->_query_args = $this->input->get();
+ }
+
+ // INPUT FUNCTION --------------------------------------------------------------
+
+ /**
+ * Retrieve a value from a GET request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the GET request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the GET request; otherwise, NULL
+ */
+ public function get($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_get_args;
+ }
+
+ return isset($this->_get_args[$key]) ? $this->_xss_clean($this->_get_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a OPTIONS request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the OPTIONS request.
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the OPTIONS request; otherwise, NULL
+ */
+ public function options($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_options_args;
+ }
+
+ return isset($this->_options_args[$key]) ? $this->_xss_clean($this->_options_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a HEAD request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the HEAD request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the HEAD request; otherwise, NULL
+ */
+ public function head($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_head_args;
+ }
+
+ return isset($this->_head_args[$key]) ? $this->_xss_clean($this->_head_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a POST request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the POST request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the POST request; otherwise, NULL
+ */
+ public function post($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_post_args;
+ }
+
+ return isset($this->_post_args[$key]) ? $this->_xss_clean($this->_post_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a PUT request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the PUT request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the PUT request; otherwise, NULL
+ */
+ public function put($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_put_args;
+ }
+
+ return isset($this->_put_args[$key]) ? $this->_xss_clean($this->_put_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a DELETE request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the DELETE request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the DELETE request; otherwise, NULL
+ */
+ public function delete($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_delete_args;
+ }
+
+ return isset($this->_delete_args[$key]) ? $this->_xss_clean($this->_delete_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from a PATCH request
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the PATCH request
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the PATCH request; otherwise, NULL
+ */
+ public function patch($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_patch_args;
+ }
+
+ return isset($this->_patch_args[$key]) ? $this->_xss_clean($this->_patch_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Retrieve a value from the query parameters
+ *
+ * @access public
+ * @param NULL $key Key to retrieve from the query parameters
+ * If NULL an array of arguments is returned
+ * @param NULL $xss_clean Whether to apply XSS filtering
+ * @return array|string|NULL Value from the query parameters; otherwise, NULL
+ */
+ public function query($key = NULL, $xss_clean = NULL)
+ {
+ if ($key === NULL)
+ {
+ return $this->_query_args;
+ }
+
+ return isset($this->_query_args[$key]) ? $this->_xss_clean($this->_query_args[$key], $xss_clean) : NULL;
+ }
+
+ /**
+ * Sanitizes data so that Cross Site Scripting Hacks can be
+ * prevented
+ *
+ * @access protected
+ * @param string $value Input data
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return string
+ */
+ protected function _xss_clean($value, $xss_clean)
+ {
+ is_bool($xss_clean) || $xss_clean = $this->_enable_xss;
+
+ return $xss_clean === TRUE ? $this->security->xss_clean($value) : $value;
+ }
+
+ /**
+ * Retrieve the validation errors
+ *
+ * @access public
+ * @return array
+ */
+ public function validation_errors()
+ {
+ $string = strip_tags($this->form_validation->error_string());
+
+ return explode(PHP_EOL, trim($string, PHP_EOL));
+ }
+
+ // SECURITY FUNCTIONS ---------------------------------------------------------
+
+ /**
+ * Perform LDAP Authentication
+ *
+ * @access protected
+ * @param string $username The username to validate
+ * @param string $password The password to validate
+ * @return bool
+ */
+ protected function _perform_ldap_auth($username = '', $password = NULL)
+ {
+ if (empty($username))
+ {
+ log_message('debug', 'LDAP Auth: failure, empty username');
+ return FALSE;
+ }
+
+ log_message('debug', 'LDAP Auth: Loading configuration');
+
+ $this->config->load('ldap.php', TRUE);
+
+ $ldap = [
+ 'timeout' => $this->config->item('timeout', 'ldap'),
+ 'host' => $this->config->item('server', 'ldap'),
+ 'port' => $this->config->item('port', 'ldap'),
+ 'rdn' => $this->config->item('binduser', 'ldap'),
+ 'pass' => $this->config->item('bindpw', 'ldap'),
+ 'basedn' => $this->config->item('basedn', 'ldap'),
+ ];
+
+ log_message('debug', 'LDAP Auth: Connect to ' . (isset($ldaphost) ? $ldaphost : '[ldap not configured]'));
+
+ // Connect to the ldap server
+ $ldapconn = ldap_connect($ldap['host'], $ldap['port']);
+ if ($ldapconn)
+ {
+ log_message('debug', 'Setting timeout to '.$ldap['timeout'].' seconds');
+
+ ldap_set_option($ldapconn, LDAP_OPT_NETWORK_TIMEOUT, $ldap['timeout']);
+
+ log_message('debug', 'LDAP Auth: Binding to '.$ldap['host'].' with dn '.$ldap['rdn']);
+
+ // Binding to the ldap server
+ $ldapbind = ldap_bind($ldapconn, $ldap['rdn'], $ldap['pass']);
+
+ // Verify the binding
+ if ($ldapbind === FALSE)
+ {
+ log_message('error', 'LDAP Auth: bind was unsuccessful');
+ return FALSE;
+ }
+
+ log_message('debug', 'LDAP Auth: bind successful');
+ }
+
+ // Search for user
+ if (($res_id = ldap_search($ldapconn, $ldap['basedn'], "uid=$username")) === FALSE)
+ {
+ log_message('error', 'LDAP Auth: User '.$username.' not found in search');
+ return FALSE;
+ }
+
+ if (ldap_count_entries($ldapconn, $res_id) !== 1)
+ {
+ log_message('error', 'LDAP Auth: Failure, username '.$username.'found more than once');
+ return FALSE;
+ }
+
+ if (($entry_id = ldap_first_entry($ldapconn, $res_id)) === FALSE)
+ {
+ log_message('error', 'LDAP Auth: Failure, entry of search result could not be fetched');
+ return FALSE;
+ }
+
+ if (($user_dn = ldap_get_dn($ldapconn, $entry_id)) === FALSE)
+ {
+ log_message('error', 'LDAP Auth: Failure, user-dn could not be fetched');
+ return FALSE;
+ }
+
+ // User found, could not authenticate as user
+ if (($link_id = ldap_bind($ldapconn, $user_dn, $password)) === FALSE)
+ {
+ log_message('error', 'LDAP Auth: Failure, username/password did not match: ' . $user_dn);
+ return FALSE;
+ }
+
+ log_message('debug', 'LDAP Auth: Success '.$user_dn.' authenticated successfully');
+
+ $this->_user_ldap_dn = $user_dn;
+
+ ldap_close($ldapconn);
+
+ return TRUE;
+ }
+
+ /**
+ * Perform Library Authentication - Override this function to change the way the library is called
+ *
+ * @access protected
+ * @param string $username The username to validate
+ * @param string $password The password to validate
+ * @return bool
+ */
+ protected function _perform_library_auth($username = '', $password = NULL)
+ {
+ if (empty($username))
+ {
+ log_message('error', 'Library Auth: Failure, empty username');
+ return FALSE;
+ }
+
+ $auth_library_class = strtolower($this->config->item('auth_library_class'));
+ $auth_library_function = strtolower($this->config->item('auth_library_function'));
+
+ if (empty($auth_library_class))
+ {
+ log_message('debug', 'Library Auth: Failure, empty auth_library_class');
+ return FALSE;
+ }
+
+ if (empty($auth_library_function))
+ {
+ log_message('debug', 'Library Auth: Failure, empty auth_library_function');
+ return FALSE;
+ }
+
+ if (is_callable([$auth_library_class, $auth_library_function]) === FALSE)
+ {
+ $this->load->library($auth_library_class);
+ }
+
+ return $this->{$auth_library_class}->$auth_library_function($username, $password);
+ }
+
+ /**
+ * Check if the user is logged in
+ *
+ * @access protected
+ * @param string $username The user's name
+ * @param bool|string $password The user's password
+ * @return bool
+ */
+ protected function _check_login($username = NULL, $password = FALSE)
+ {
+ if (empty($username))
+ {
+ return FALSE;
+ }
+
+ $auth_source = strtolower($this->config->item('auth_source'));
+ $rest_auth = strtolower($this->config->item('rest_auth'));
+ $valid_logins = $this->config->item('rest_valid_logins');
+
+ if ( ! $this->config->item('auth_source') && $rest_auth === 'digest')
+ {
+ // For digest we do not have a password passed as argument
+ return md5($username.':'.$this->config->item('rest_realm').':'.(isset($valid_logins[$username]) ? $valid_logins[$username] : ''));
+ }
+
+ if ($password === FALSE)
+ {
+ return FALSE;
+ }
+
+ if ($auth_source === 'ldap')
+ {
+ log_message('debug', "Performing LDAP authentication for $username");
+
+ return $this->_perform_ldap_auth($username, $password);
+ }
+
+ if ($auth_source === 'library')
+ {
+ log_message('debug', "Performing Library authentication for $username");
+
+ return $this->_perform_library_auth($username, $password);
+ }
+
+ if (array_key_exists($username, $valid_logins) === FALSE)
+ {
+ return FALSE;
+ }
+
+ if ($valid_logins[$username] !== $password)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Check to see if the user is logged in with a PHP session key
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _check_php_session()
+ {
+ // Get the auth_source config item
+ $key = $this->config->item('auth_source');
+
+ // If falsy, then the user isn't logged in
+ if ( ! $this->session->userdata($key))
+ {
+ // Display an error response
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+ }
+
+ /**
+ * Prepares for basic authentication
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _prepare_basic_auth()
+ {
+ // If whitelist is enabled it has the first chance to kick them out
+ if ($this->config->item('rest_ip_whitelist_enabled'))
+ {
+ $this->_check_whitelist_auth();
+ }
+
+ // Returns NULL if the SERVER variables PHP_AUTH_USER and HTTP_AUTHENTICATION don't exist
+ $username = $this->input->server('PHP_AUTH_USER');
+ $http_auth = $this->input->server('HTTP_AUTHENTICATION');
+
+ $password = NULL;
+ if ($username !== NULL)
+ {
+ $password = $this->input->server('PHP_AUTH_PW');
+ }
+ elseif ($http_auth !== NULL)
+ {
+ // If the authentication header is set as basic, then extract the username and password from
+ // HTTP_AUTHORIZATION e.g. my_username:my_password. This is passed in the .htaccess file
+ if (strpos(strtolower($http_auth), 'basic') === 0)
+ {
+ // Search online for HTTP_AUTHORIZATION workaround to explain what this is doing
+ list($username, $password) = explode(':', base64_decode(substr($this->input->server('HTTP_AUTHORIZATION'), 6)));
+ }
+ }
+
+ // Check if the user is logged into the system
+ if ($this->_check_login($username, $password) === FALSE)
+ {
+ $this->_force_login();
+ }
+ }
+
+ /**
+ * Prepares for digest authentication
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _prepare_digest_auth()
+ {
+ // If whitelist is enabled it has the first chance to kick them out
+ if ($this->config->item('rest_ip_whitelist_enabled'))
+ {
+ $this->_check_whitelist_auth();
+ }
+
+ // We need to test which server authentication variable to use,
+ // because the PHP ISAPI module in IIS acts different from CGI
+ $digest_string = $this->input->server('PHP_AUTH_DIGEST');
+ if ($digest_string === NULL)
+ {
+ $digest_string = $this->input->server('HTTP_AUTHORIZATION');
+ }
+
+ $unique_id = uniqid();
+
+ // The $_SESSION['error_prompted'] variable is used to ask the password
+ // again if none given or if the user enters wrong auth information
+ if (empty($digest_string))
+ {
+ $this->_force_login($unique_id);
+ }
+
+ // We need to retrieve authentication data from the $digest_string variable
+ $matches = [];
+ preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches);
+ $digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]);
+
+ // For digest authentication the library function should return already stored md5(username:restrealm:password) for that username see rest.php::auth_library_function config
+ $username = $this->_check_login($digest['username'], TRUE);
+ if (array_key_exists('username', $digest) === FALSE || $username === FALSE)
+ {
+ $this->_force_login($unique_id);
+ }
+
+ $md5 = md5(strtoupper($this->request->method).':'.$digest['uri']);
+ $valid_response = md5($username.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$md5);
+
+ // Check if the string don't compare (case-insensitive)
+ if (strcasecmp($digest['response'], $valid_response) !== 0)
+ {
+ // Display an error response
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_invalid_credentials')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+ }
+
+ /**
+ * Checks if the client's ip is in the 'rest_ip_blacklist' config and generates a 401 response
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _check_blacklist_auth()
+ {
+ // Match an ip address in a blacklist e.g. 127.0.0.0, 0.0.0.0
+ $pattern = sprintf('/(?:,\s*|^)\Q%s\E(?=,\s*|$)/m', $this->input->ip_address());
+
+ // Returns 1, 0 or FALSE (on error only). Therefore implicitly convert 1 to TRUE
+ if (preg_match($pattern, $this->config->item('rest_ip_blacklist')))
+ {
+ // Display an error response
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_denied')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+ }
+
+ /**
+ * Check if the client's ip is in the 'rest_ip_whitelist' config and generates a 401 response
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _check_whitelist_auth()
+ {
+ $whitelist = explode(',', $this->config->item('rest_ip_whitelist'));
+
+ array_push($whitelist, '127.0.0.1', '0.0.0.0');
+
+ foreach ($whitelist as &$ip)
+ {
+ // As $ip is a reference, trim leading and trailing whitespace, then store the new value
+ // using the reference
+ $ip = trim($ip);
+ }
+
+ if (in_array($this->input->ip_address(), $whitelist) === FALSE)
+ {
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_unauthorized')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+ }
+
+ /**
+ * Force logging in by setting the WWW-Authenticate header
+ *
+ * @access protected
+ * @param string $nonce A server-specified data string which should be uniquely generated
+ * each time
+ * @return void
+ */
+ protected function _force_login($nonce = '')
+ {
+ $rest_auth = $this->config->item('rest_auth');
+ $rest_realm = $this->config->item('rest_realm');
+ if (strtolower($rest_auth) === 'basic')
+ {
+ // See http://tools.ietf.org/html/rfc2617#page-5
+ header('WWW-Authenticate: Basic realm="'.$rest_realm.'"');
+ }
+ elseif (strtolower($rest_auth) === 'digest')
+ {
+ // See http://tools.ietf.org/html/rfc2617#page-18
+ header(
+ 'WWW-Authenticate: Digest realm="'.$rest_realm
+ .'", qop="auth", nonce="'.$nonce
+ .'", opaque="' . md5($rest_realm).'"');
+ }
+
+ // Display an error response
+ $this->response([
+ $this->config->item('rest_status_field_name') => FALSE,
+ $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized')
+ ], self::HTTP_UNAUTHORIZED);
+ }
+
+ /**
+ * Updates the log table with the total access time
+ *
+ * @access protected
+ * @author Chris Kacerguis
+ * @return bool TRUE log table updated; otherwise, FALSE
+ */
+ protected function _log_access_time()
+ {
+ $payload['rtime'] = $this->_end_rtime - $this->_start_rtime;
+
+ return $this->rest->db->update(
+ $this->config->item('rest_logs_table'), $payload, [
+ 'id' => $this->_insert_id
+ ]);
+ }
+
+ /**
+ * Updates the log table with HTTP response code
+ *
+ * @access protected
+ * @author Justin Chen
+ * @param $http_code int HTTP status code
+ * @return bool TRUE log table updated; otherwise, FALSE
+ */
+ protected function _log_response_code($http_code)
+ {
+ $payload['response_code'] = $http_code;
+
+ return $this->rest->db->update(
+ $this->config->item('rest_logs_table'), $payload, [
+ 'id' => $this->_insert_id
+ ]);
+ }
+
+ /**
+ * Check to see if the API key has access to the controller and methods
+ *
+ * @access protected
+ * @return bool TRUE the API key has access; otherwise, FALSE
+ */
+ protected function _check_access()
+ {
+ // If we don't want to check access, just return TRUE
+ if ($this->config->item('rest_enable_access') === FALSE)
+ {
+ return TRUE;
+ }
+
+ //check if the key has all_access
+ $accessRow = $this->rest->db
+ ->where('key', $this->rest->key)
+ ->get($this->config->item('rest_access_table'))->row_array();
+
+ if (!empty($accessRow) && !empty($accessRow['all_access']))
+ {
+ return TRUE;
+ }
+
+ // Fetch controller based on path and controller name
+ $controller = implode(
+ '/', [
+ $this->router->directory,
+ $this->router->class
+ ]);
+
+ // Remove any double slashes for safety
+ $controller = str_replace('//', '/', $controller);
+
+ // Query the access table and get the number of results
+ return $this->rest->db
+ ->where('key', $this->rest->key)
+ ->where('controller', $controller)
+ ->get($this->config->item('rest_access_table'))
+ ->num_rows() > 0;
+ }
+
+ /**
+ * Checks allowed domains, and adds appropriate headers for HTTP access control (CORS)
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _check_cors()
+ {
+ // Convert the config items into strings
+ $allowed_headers = implode(' ,', $this->config->item('allowed_cors_headers'));
+ $allowed_methods = implode(' ,', $this->config->item('allowed_cors_methods'));
+
+ // If we want to allow any domain to access the API
+ if ($this->config->item('allow_any_cors_domain') === TRUE)
+ {
+ header('Access-Control-Allow-Origin: *');
+ header('Access-Control-Allow-Headers: '.$allowed_headers);
+ header('Access-Control-Allow-Methods: '.$allowed_methods);
+ }
+ else
+ {
+ // We're going to allow only certain domains access
+ // Store the HTTP Origin header
+ $origin = $this->input->server('HTTP_ORIGIN');
+ if ($origin === NULL)
+ {
+ $origin = '';
+ }
+
+ // If the origin domain is in the allowed_cors_origins list, then add the Access Control headers
+ if (in_array($origin, $this->config->item('allowed_cors_origins')))
+ {
+ header('Access-Control-Allow-Origin: '.$origin);
+ header('Access-Control-Allow-Headers: '.$allowed_headers);
+ header('Access-Control-Allow-Methods: '.$allowed_methods);
+ }
+ }
+
+ // If the request HTTP method is 'OPTIONS', kill the response and send it to the client
+ if ($this->input->method() === 'options')
+ {
+ exit;
+ }
+ }
+}
diff --git a/api/application/libraries/index.html b/api/application/libraries/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/libraries/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/logs/index.html b/api/application/logs/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/logs/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/models/Admin_model.php b/api/application/models/Admin_model.php
new file mode 100644
index 0000000..01a9277
--- /dev/null
+++ b/api/application/models/Admin_model.php
@@ -0,0 +1,67 @@
+db->count_all($tabela);
+ }
+
+ public function getAll_usuarios($tipo)
+ {
+ $this->db->select('*');
+ $this->db->from('usuarios');
+ $this->db->join('tipo_usuario', 'tipo_usuario.id = usuarios.id_tipo');
+ $this->db->where('tipo_usuario.descricao',$tipo);
+ return $this->db->count_all_results();
+ }
+
+ public function getUsuariosInscritos()
+ {
+ $this->db->select('DISTINCT(`id_usuario`)');
+ $this->db->from('eventos_usuario');
+ return $this->db->get()->num_rows();
+ }
+
+ public function getEventos($id = null)
+ {
+ $this->db->select('DISTINCT(e.id), e.descricao, e.vagas, e.inscritos, e.palestrante, e.sala, e.titulo, a.descricao as area, h.descricao as horario, d.descricao as data, t.descricao as tipo, c.descricao as campus');
+ $this->db->from('eventos e');
+ $this->db->join('areas a', 'a.id = e.id_area', 'inner');
+ $this->db->join('horario h', 'h.id = e.id_horario', 'inner');
+ $this->db->join('dia d', 'd.id = e.id_data', 'inner');
+ $this->db->join('tipo_evento t', 't.id = e.id_tipo', 'inner');
+ $this->db->join('campus c', 'c.id = e.id_unidade', 'inner');
+ if ( $id != null ){
+ $this->db->where('e.id', $id);
+ return $this->db->get('eventos')->first_row();
+ } else {
+ return $this->db->get('eventos')->result();
+ }
+
+ }
+
+ public function getTotalCurso($curso)
+ {
+ $this->db->select('DISTINCT(u.id)');
+ $this->db->from('usuarios u');
+ $this->db->join('cursos c', 'c.id = u.id_curso', 'inner');
+ $this->db->where('c.descricao', $curso);
+ return $this->db->count_all_results();
+ }
+
+ public function lista_usuarios_evento($id_evento)
+ {
+ $this->db->select('DISTINCT(b.cpf),b.nome, b.email, b.id as id_usuario, a.presenca, a.id_evento as id_evento');
+ $this->db->from('eventos_usuario a');
+ $this->db->join('usuarios b','b.id = a.id_usuario','inner');
+ $this->db->where('a.id_evento', $id_evento);
+ $this->db->order_by('nome','ASC');
+ $query = $this->db->get();
+ return $query->result();
+ }
+}
+
+/* End of file Admin_model.php */
+/* Location: ./application/models/Admin_model.php */
diff --git a/api/application/models/Announcement_model.php b/api/application/models/Announcement_model.php
new file mode 100644
index 0000000..346ebc9
--- /dev/null
+++ b/api/application/models/Announcement_model.php
@@ -0,0 +1,104 @@
+db->insert(ANNOUNCEMENT, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+
+ $result['AnnouncementStatus'] = true;
+ $result['message'] = "Successfully Announcement details added";
+ }
+
+ else {
+ $result['AnnouncementStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+
+ }
+ public function getAnnouncement()
+ {
+ $this->db->select('Heading,description,CreatedOn,IsActive,ID');
+ $this->db->order_by('CreatedOn','DESC');
+ $announcementDetails = $this->db->get(ANNOUNCEMENT);
+
+ if($announcementDetails->result()){
+
+ $result['AnnouncementStatus'] = true;
+ $result['details'] = $announcementDetails->result();
+ }
+ else {
+ $result['AnnouncementStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+
+ /*
+ * update announcement details
+ * created by Surendiran
+ * */
+
+ public function updateAnnouncement($arrayDetails=null,$updateID=null)
+ {
+ $this->db->where('ID',$updateID);
+ $updateStatus=$this->db->update(ANNOUNCEMENT, $arrayDetails);
+
+ if($updateStatus){
+
+ $result['AnnouncementStatus'] = true;
+ $result['message'] = "Successfully Announcement details updated";
+ }
+
+ else {
+ $result['AnnouncementStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+ return $result;
+
+ }
+
+ /*
+ * get announcement details
+ * created by Surendiran
+ * */
+ public function getLoginAnnouncement()
+ {
+ $this->db->select('Heading,description');
+ $this->db->from(ANNOUNCEMENT);
+ $this->db->where('IsActive',1);
+ $this->db->order_by('CreatedOn','DESC');
+ $announcementDetails = $this->db->get();
+ if($announcementDetails->result()){
+ $result['AnnouncementStatus'] = true;
+ $result['details'] = $announcementDetails->result();
+ }
+ else {
+ $result['AnnouncementStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+ return $result;
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Batch_model.php b/api/application/models/Batch_model.php
new file mode 100644
index 0000000..9353c76
--- /dev/null
+++ b/api/application/models/Batch_model.php
@@ -0,0 +1,141 @@
+db->select('BatchCode');
+ $this->db->where('BatchCode', $arrayDetails['BatchCode']);
+ if($this->db->get(BATCH)->first_row()){
+ $result['batchStatus'] = false;
+ $result['message'] = "This batch code is already exist.";
+ } else {
+ $this->db->insert(BATCH, $arrayDetails);
+ if ($this->db->affected_rows() == '1') {
+
+ $result['batchStatus'] = true;
+ $result['message'] = "Successfully Batch details added";
+ } else {
+ $result['batchStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+
+ }
+
+
+ /*
+ * Get batch details
+ * parama id
+ * created by srk
+ * */
+
+ public function getBatch()
+ {
+ $this->db->select('CU.BatchCode,CU.BatchName,CU.IsActive,CU.BatchDate,CU.IsDefault,US.UniversityID,US.UniversityName');
+ $this->db->from(BATCH.' as CU');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
+ $this->db->order_by('CU.CreatedOn','DESC');
+ $batchDetails = $this->db->get();
+
+ if($batchDetails->result()){
+
+ $result['batchStatus'] = true;
+ $result['details'] = $batchDetails->result();
+ }
+ else {
+ $result['batchStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ $result['universityDetails'] = $this->getUniversityDetails();
+
+ return $result;
+
+ }
+
+ /*
+ * update batch details
+ * created by Srk
+ * */
+ public function updateBatch($arrayDetails=null)
+ {
+ $this->db->where('BatchCode',$arrayDetails['BatchCode']);
+ $upateStatus=$this->db->update(BATCH, $arrayDetails);
+ if($upateStatus){
+
+ $result['batchStatus'] = true;
+ $result['message'] = "Successfully Batch details updated";
+ }
+
+ else {
+ $result['batchStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+
+
+ return $result;
+
+ }
+ /*
+ * Get university details
+ * created by Srk
+ * */
+ public function getUniversityDetails()//doubt
+ {
+ $this->db->select('UniversityID,UniversityName');
+ $this->db->order_by('UniversityID','ASC');
+ $this->db->where('IsActive','1');
+ // $this->db->where_not_in('ID', $id);
+ $universityDetails = $this->db->get(UNIVERSITY);
+ return $universityDetails->result();
+ }
+ /*
+ * update default batch
+ * created by kms
+ * */
+
+ public function updateDefaultBatch($details=null){
+
+ $setDefaultBatch['IsDefault']=false;
+ $setDefaultBatch['UpdatedBy'] = $details['UpdatedBy'];
+ $setDefaultBatch['UpdatedOn'] = $details['UpdatedOn'];
+ // $this->db->where('BatchCode',$details['BatchCode']);
+ $this->db->where('UniversityID',$details['UniversityID']);
+ $upateStatus=$this->db->update(BATCH, $setDefaultBatch);
+ if($upateStatus){
+ $this->db->where('BatchCode',$details['BatchCode']);
+ $this->db->where('UniversityID',$details['UniversityID']);
+ $upateAfterStatus=$this->db->update(BATCH, $details);
+ $result['batchStatus'] = true;
+ $result['message'] = "Successfully Batch details updated";
+ }
+
+ else {
+ $result['batchStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+ return $result;
+
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/Branch_model.php b/api/application/models/Branch_model.php
new file mode 100644
index 0000000..97976bc
--- /dev/null
+++ b/api/application/models/Branch_model.php
@@ -0,0 +1,136 @@
+ upload_image($imageSource, $target);
+ $imageNameDb = $getUploadStatus['imageName'];
+ $arrayDetails['LogoPath'] = $getUploadStatus == true ? "logo/".$imageNameDb : '';
+// print_r($arrayDetails['IsActive']);exit();
+ $this->db->select('BranchCode');
+ $this->db->where('BranchCode', $arrayDetails['BranchCode']);
+ if($this->db->get(BRANCH)->first_row()){
+ $result['BranchStatus'] = false;
+ $result['message'] = "This branch code is already exist!";
+ } else {
+ $this->db->select('BranchName');
+ $this->db->where('BranchName', $arrayDetails['BranchName']);
+ if($this->db->get(BRANCH)->first_row()){
+ $result['BranchStatus'] = false;
+ $result['message'] = "This branch name is already exist!";
+ } else{
+ $this->db->insert(BRANCH, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+
+ $result['branchStatus'] = true;
+ $result['message'] = "Successfully branch details added";
+ }
+
+ else {
+ $result['branchStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+
+ }
+
+
+
+ return $result;
+
+ }
+ /*
+ * get branch details
+ * parama id
+ * created by kms
+ * */
+
+ public function getBranch()
+ {
+ $this->db->select('BranchCode,BranchName,LogoPath,MobileNumber,AlternateNumber,LandlineNumber,Address,EmailID,CreatedOn,IsActive');
+ $this->db->order_by('CreatedOn','DESC');
+ $branchDetails = $this->db->get(BRANCH);
+
+ if($branchDetails->result()){
+
+ $result['branchStatus'] = true;
+ $result['details'] = $branchDetails->result();
+ }
+ else {
+ $result['branchStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+ /*
+ * update branch details
+ * created by kms
+ * */
+
+ public function updateBranch($arrayDetails=null,$branchCode=null, $imageSource, $imageStat)
+ {
+ if( $imageStat == 1 ) {
+ $target = "../images/logo/";
+ $getUploadStatus = $this-> upload_image($imageSource, $target);
+ $imageNameDb = $getUploadStatus['imageName'];
+ $arrayDetails['LogoPath'] = $getUploadStatus == true ? "logo/".$imageNameDb : null;
+ } else {
+
+ }
+
+// print_r($arrayDetails['IsActive']);exit();
+
+ $this->db->where('BranchCode',$branchCode);
+ $upateStatus=$this->db->update(BRANCH, $arrayDetails);
+ if($upateStatus){
+ $result['branchStatus'] = true;
+ $result['message'] = "Successfully branch details updated";
+ }
+
+ else {
+ $result['branchStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+
+
+ return $result;
+
+ }
+
+ // image upload in taget path
+ public function upload_image( $imageSource, $target ) {
+ $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 12);
+ $new_regNo = "Dri_" . $key2 . "." . 'jpeg';
+ $targetPlace = $target . $new_regNo;
+ // echo $targetPlace;exit();
+ if(!move_uploaded_file($imageSource , $targetPlace))
+ {
+ return $result['status'] = false;
+ } else {
+ $result['status'] = true;
+ $result['imageName'] = $new_regNo;
+ return $result;
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/Broadcast_model.php b/api/application/models/Broadcast_model.php
new file mode 100644
index 0000000..d7bad9c
--- /dev/null
+++ b/api/application/models/Broadcast_model.php
@@ -0,0 +1,366 @@
+db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ($University != '' && $Course != '' && $Batch == '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ( $University != '' && $Course == '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ( $University != '' && $Course != '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ }
+ // $subQuery = "SELECT S.* , SC.CourseID , C.CourseName , U.UniversityName
+ // FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ // LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ // SC.CourseID = C.CourseID
+ // WHERE
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ // AND S.IsActive = '1'
+ // AND SC.IsActive = '1'";
+
+ // $queryDetails = $this->db->query($subQuery);
+ // $results['searchResult'] = true;
+ // $results['search_result_details'] = $queryDetails->result();
+
+ return $results;
+ }
+
+ // get list of universities, course, batch
+ public function get_university_course_batch() {
+ $this->db->select('t1.UniversityID, t1.UniversityName');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(''.UNIVERSITY. ' as t1');
+ $this->db->where('IsActive', 1);
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $univDetails = $this->db->get();
+ $universityDetails = $univDetails->result();
+ $endResult = [];
+ foreach($universityDetails as $clip){
+ // University Details
+ $resultArr['UniversityID'] = $clip->UniversityID;
+ $resultArr['UniversityName'] = $clip->UniversityName;
+
+ // Course Details
+ $this->db->select('t2.CourseID, t2.CourseName');
+ $this->db->from(''.COURSE. ' as t2');
+ $this->db->where('t2.UniversityID', $clip->UniversityID);
+ $this->db->where('t2.IsActive', 1);
+ $courDetails = $this->db->get();
+ $courseDetails = $courDetails->result();
+ $resultArr['Course'] =$courseDetails;
+
+ // Batch Details
+ $this->db->select('t3.BatchName, t3.BatchCode');
+ $this->db->from(''.BATCH. ' as t3');
+ $this->db->where('t3.UniversityID', $clip->UniversityID);
+ $this->db->where('t3.IsActive', 1);
+ $batDetails = $this->db->get();
+ $batchDetails = $batDetails->result();
+ $resultArr['Batch'] =$batchDetails;
+ array_push($endResult, $resultArr);
+ }
+ $results['univList'] = true;
+ $results['university_details'] = $endResult;
+ return $results;
+ }
+
+ public function getSMSGroupDetails($reqData) {
+ $querys = "SELECT t1.*, t2.DeliveredStatus, t2.DeliveredOn FROM T_BroadcastStatus as t1
+ LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
+ WHERE t1.MsgGroup = '$reqData' ORDER BY t1.CreatedOn DESC";
+
+ $smsSendGroupDetails = $this->db->query($querys);
+ $smsSendGroupDetailsList = $smsSendGroupDetails->result();
+ $results['smsSendGroupDetailsListStatus'] = true;
+ $results['smsSendGroupDetailsList'] = $smsSendGroupDetailsList;
+ return $results;
+ }
+
+ public function getSmsSendBetweenDate($reqData, $reqDataBy) {
+
+ if($reqData['date'] != '' && $reqData['dateTo'] != '') {
+ $d = new DateTime($reqData['date']);
+ $dTo = new DateTime($reqData['dateTo']);
+ $fromDate = $d->format('Y-m-d');
+ $toDate = $dTo->format('Y-m-d');
+
+ // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
+ // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
+ // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
+ // AND '$toDate' ORDER BY t1.CreatedOn DESC";
+
+ $querys = "SELECT t1.*, COUNT(t1.MsgGroup) as MSG_SEND_CNT FROM T_BroadcastStatus as t1
+ LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
+ WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
+ AND '$toDate' GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC";
+
+ $smsSendDetails = $this->db->query($querys);
+ $smsSendDetailsList = $smsSendDetails->result();
+ $results['smsSendDetailsListStatus'] = true;
+ $results['smsSendDetailsList'] = $smsSendDetailsList;
+
+ } else {
+ // $d = new DateTime($d1);
+ // $dTo = new DateTime($d2);
+ // $fromDate = $d->format('Y-m-d');
+ // $toDate = $dTo->format('Y-m-d');
+
+ // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
+ // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
+ // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
+ // AND '$toDate' ORDER BY t1.CreatedOn DESC";
+
+ $querys = "SELECT t1.*, COUNT(t1.MsgGroup) FROM T_BroadcastStatus as t1
+ LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
+ GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC";
+
+ $smsSendDetails = $this->db->query($querys);
+ $smsSendDetailsList = $smsSendDetails->result();
+ $results['smsSendDetailsListStatus'] = true;
+ $results['smsSendDetailsList'] = $smsSendDetailsList;
+ $results['smsSendDetailsListStatus'] = true;
+ $results['smsSendDetailsList'] = $smsSendDetailsList;
+ }
+ return $results;
+ }
+
+
+ public function send_msg_students($arr, $msg, $reqDetails) {
+ $msg_body = $msg['content'];
+ $sender = $reqDetails['localUserID'];
+ $mesg = "$msg_body";
+ // $mesg = "Status Update : check - check check.";
+ // $mesg = "Check";
+ $resp = $this->smssend($arr, $mesg);
+ // echo $resp ;exit();
+ $arrss = explode('
', $resp);
+ // Array
+ // (
+ // [0] => MsgID
+ // [1] => 4fad03cf13734a869307b19fcc293570
+ // [2] => 919942080003
+ // [3] => 201801191700328088
+ // [4] => success
+ // )
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+ $msgGroup = date('YmdHis');
+
+ for($i=0, $c = count($arrss) ; $i< $c; $i++){
+ // echo $arrss[$i];exit();
+ if( $arrss[$i] === '') {
+ break;
+ } else {
+ $a = explode(':', $arrss[$i]);
+ $msgIdState = $a[0];
+ $msgId = $a[1];
+ $msgNumb = $a[2];
+ $msgStatus = $a[4];
+ $data[] = array(
+ 'MsgId' => $msgId,
+ 'MobileNumber' => $msgNumb,
+ 'MsgBody' => $mesg,
+ 'Status' => $msgStatus,
+ 'CreatedOn' => $dateTime,
+ 'CreatedBy' => $sender,
+ 'MsgGroup' => $msgGroup
+ );
+ continue;
+ }
+ }
+ $this->db->insert_batch('T_BroadcastStatus', $data);
+ if ($this->db->affected_rows() >= 1) {
+ $result['msgStatus'] = true;
+ $result['message'] = "Successfully Messages Sended!!";
+ } else {
+ $result['msgStatus'] = false;
+ $result['message'] = "error!!";
+ }
+ // print_r($data);
+ // exit();
+ // $msgID = $arrss[1];
+ // $msgSendTime = $arrss[2];
+ // $msgDeleveredNum = $arrss[3];
+ // $msgSendStatus = $arrss[3];
+
+ // print_r($data);exit();
+ return $result;
+ }
+
+ // self function for getting registered mobile for sms
+ public function get_registered_mobile($num) {
+ $this->db->select('MobileNumber');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $num);
+ $roleDetails = $this->db->get()->first_row();
+ return $roleDetails->MobileNumber;
+ }
+
+ // http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf
+ // API Key : xegCdYUIMf3
+
+ // Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login.
+ // This is the template to be used.
+
+ public function smssend($arr, $msg)
+ {
+ $number =array();
+ foreach($arr as $ar){
+ $mobi = $this->get_registered_mobile($ar['StudentID']);
+ array_push($number, "91$mobi");
+ }
+ $mobile = implode(',', $number);
+ // $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
+ // $mobile = "91$mobile";
+
+ $message = urlencode($msg);
+ // echo $mobile , $message;
+ $ch=curl_init();
+ curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=PROMOTIONAL_HIGH");
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ $output =curl_exec($ch);
+
+ // print_r($output);exit();
+ curl_close($ch);
+ return $output;
+ }
+
+ public function getCronUpdate() {
+ $date2 = date('Y-m-d');
+
+ $quw = "SELECT * FROM T_BroadcastDeliveryCron ORDER BY id DESC LIMIT 1";
+ $myext = $this->db->query($quw)->first_row();
+ // print_r($this->db->query($quw)->first_row());exit();
+ if($myext){
+ if($myext->CreatedOn){
+ $arrsss = explode(' ', $myext->CreatedOn);
+ }
+ $date1 = $myext->CreatedOn != '' ? $arrsss[0] : $date2;
+ } else {
+ $date1 = $date2;
+ }
+
+ $ch=curl_init();
+ curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/GetReports.aspx?APIKEY=xegCdYUIMf3&StartDate=".$date1."&EndDate=".$date2."");
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ $output =curl_exec($ch);
+// print_r($output);exit();
+ curl_close($ch);
+
+ $arrss = explode('
', $output);
+ array_pop($arrss);
+ // Array
+ // (
+ // [0] => MsgID
+ // [1] => 4fad03cf13734a869307b19fcc293570
+ // [2] => 919942080003
+ // [3] => 201801191700328088
+ // [4] => success
+ // )
+ $time = date('Y-m-d H:i:s');
+ $dateTime = $time;
+ $c = count($arrss);
+ for($i=0 ; $i < $c; $i++){
+ // echo $arrss[$i];exit();
+ if( $i == $c-1) {
+ break;
+ } else {
+ $a = explode('|', $arrss[$i]);
+ $msgId = $a[0];
+ $msgNumb = $a[1];
+ $delvStatus = $a[2];
+ $delvOn = $a[3];
+ $qury1 = "SELECT * FROM T_BroadcastDeliveryCron WHERE MsgId = '$msgId'";
+ $choe = $this->db->query($qury1)->first_row();
+
+ if($this->db->query($qury1)->first_row()){
+ $qury2 = "UPDATE T_BroadcastDeliveryCron SET DeliveredStatus = '$delvStatus', DeliveredOn = '$delvOn' WHERE MsgId = '$msgId'";
+
+ $choe2 = $this->db->query($qury2);
+ // continue;
+ } else {
+ $qury3 = " INSERT INTO T_BroadcastDeliveryCron (MsgId, MobileNumber, DeliveredStatus, DeliveredOn, CreatedOn) VALUES('$msgId', '$msgNumb', '$delvStatus', '$delvOn', '$dateTime')";
+
+ $choe3 = $this->db->query($qury3);
+ // continue;
+ }
+ }
+ }
+ return 'records updated!!';
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Calltracking_model.php b/api/application/models/Calltracking_model.php
new file mode 100644
index 0000000..93cb063
--- /dev/null
+++ b/api/application/models/Calltracking_model.php
@@ -0,0 +1,1273 @@
+db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->where('LD.MobileNumber',$mobileNumber);
+ $leadDet=$this->db->get()->last_row();
+ $result_array = [];
+ if($leadDet){
+ $result_array['existLeadDetails']=$leadDet;
+ }
+ else{
+ $this->db->select('ST.MobileNumber,ST.Firstname,ST.AlternateNumber,ST.PresentAddress,US.UniversityName,CU.CourseName');
+ $this->db->from(STUDENTS.' as ST');
+ $this->db->join(STUDENTCOURSE.' as STC', 'ST.StudentID = STC.StudentID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ $this->db->where('ST.MobileNumber',$mobileNumber);
+ $enrolledStudDet=$this->db->get()->last_row();
+ if($enrolledStudDet) {
+ $leadDet['LeadName'] = $enrolledStudDet->Firstname;
+ $leadDet['MobileNumber'] = $enrolledStudDet->MobileNumber;
+ $leadDet['IsNewEnquiry'] = "1";
+ $leadDet['University'] = $enrolledStudDet->UniversityName;
+ $leadDet['Course'] = $enrolledStudDet->CourseName;
+ $leadDet['ActivityStatus'] = "";
+ $leadDet['AssignedTo'] = "";
+ $leadDet['StatusCode'] = "";
+ $leadDet['AlternateMobile'] = $enrolledStudDet->AlternateNumber;
+ $leadDet['Address'] = $enrolledStudDet->PresentAddress;
+ $result_array['existLeadDetails'] = $leadDet;
+ }
+ else{
+ $leadDet['LeadName'] = "";
+ $leadDet['MobileNumber'] = "";
+ $leadDet['IsNewEnquiry'] = "1";
+ $leadDet['University'] = "";
+ $leadDet['Course'] = "";
+ $leadDet['ActivityStatus'] = "";
+ $leadDet['AssignedTo'] = "";
+ $leadDet['StatusCode'] = "";
+ $leadDet['AlternateMobile'] = "";
+ $leadDet['Address'] = "";
+ $result_array['existLeadDetails'] = $leadDet;
+ }
+ }
+ // store lead,university and course details in comman array
+ //$result_array['universityDetails']=$this->getUniversityDetails();
+ $result_array['activityDetails']=$this->getActivityDetails($mobileNumber);
+ // $result_array['statusDetails']=$this->getStatus();
+ $result_array['staffDetails']=$this->getStaff("1",$branchID,$userType,$requestedBy);
+ return $result_array;
+
+ }
+
+ /*
+ * get university details
+ * created by kms
+ * */
+ public function getUniversityDetails()
+ {
+ $this->db->select('UniversityID,UniversityName');
+ $this->db->where('IsActive','1');
+ $this->db->order_by('UniversityID','ASC');
+ $unviversityDetails = $this->db->get(UNIVERSITY);
+
+ if($unviversityDetails->result()){
+ $result_university = array();
+ foreach ($unviversityDetails->result() as $row)
+ {
+ $university_array['universityStatus'] = true;
+ $university_array['universityID'] = $row->UniversityID;
+ $university_array['universityName'] = $row->UniversityName;
+ $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID);
+ $result_university[]=$university_array;
+ }
+ }
+ else {
+ $university_array['universityStatus'] = false;
+ $university_array['message'] = "No records found!";
+ $university_array['universityID'] = "";
+ $university_array['universityName'] = "";
+ $university_array['courseDetails']= "";
+ $result_university[]=$university_array;
+ }
+
+
+ return $result_university;
+
+ }
+ /*
+ * get course details
+ * @params university id
+ * created by kms
+ * */
+ public function getCourseDetails($universityID=null)
+ {
+ $this->db->select('CourseID,CourseName');
+ $this->db->where('UniversityID',$universityID);
+ $this->db->where('IsActive','1');
+ $this->db->order_by('CourseID','ASC');
+ $courseDetails = $this->db->get(COURSE);
+ return $courseDetails->result();
+ }
+
+ /*
+ * get activity details
+ * created by kms
+ * */
+
+ public function getActivityDetails($mobileNo=null)
+ {
+ $this->db->distinct();
+ $this->db->select('LT.ActivityStatus,LT.ActivityStatus');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'LT.StatusCode = PLD.ListCode');
+ $this->db->where('PLD.ListName !=','CLOSE');
+ $this->db->where('LD.MobileNumber',$mobileNo);
+ $getExistActivity=$this->db->get();
+ $existArrayActivity=array();
+ if($getExistActivity->result()){
+ foreach ($getExistActivity->result() as $ActRow){
+
+ array_push($existArrayActivity,$ActRow->ActivityStatus);
+ }
+
+
+ }
+ else{
+ $existArrayActivity=array();
+ }
+
+ $this->db->select('ActivityID,ActivityName');
+ $this->db->where('IsActive','1');
+ if($existArrayActivity){
+ $this->db->where_not_in('ActivityID',$existArrayActivity);
+ }
+ $this->db->order_by('ActivityID','ASC');
+ $activity = $this->db->get(ACTIVITY);
+ if($activity->result()){
+ $result_activity = array();
+ foreach ($activity->result() as $row)
+ {
+ $activity_array['activityStatus'] = true;
+ $activity_array['activityID'] = $row->ActivityID;
+ $activity_array['activityName'] = $row->ActivityName;
+ $activity_array['activityStatus']= $this->getStatus($row->ActivityID);
+ $result_activity[]=$activity_array;
+ }
+
+ }
+ else{
+ $activity_array['activityStatus'] = false;
+ $activity_array['activityID'] = "";
+ $activity_array['activityName'] = "No activity";
+ $activity_array['activityStatus']= "";
+ $result_activity[]=$activity_array;
+
+ }
+
+ return $result_activity;
+ }
+
+ /*
+ * get activity status details
+ * created by kms
+ * */
+
+ public function getStatus($activityID=null)
+ {
+ $this->db->select('AVS.StatusID,PLD.ListCode,PLD.ListName');
+ $this->db->from(ACTIVITY_STATUS .' as AVS');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AVS.StatusName');
+ $this->db->where('AVS.ActivityID',$activityID);
+ $this->db->where('AVS.IsActive','1');
+ $this->db->where('PLD.IsActive','1');
+ $status = $this->db->get();
+ return $status->result();
+ }
+
+ /*
+ * get staff details
+ * created by kms
+ *
+ * */
+
+ public function getStaff($status=null,$branchID=null,$userType=null,$requestedBy)
+ {
+ if($userType != SUPER_ADMIN){
+
+ $this->db->select('LO.ID,ST.StaffID,ST.Firstname');
+ $this->db->from(LOGIN.' as LO');
+ $this->db->join(STAFF_BRANCH.' as STB', 'STB.StaffID = LO.StaffID');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(BRANCH.' as BR', 'BR.BranchCode = STB.BranchCode');
+ $this->db->where('ST.IsActive',$status);
+ $this->db->where('BR.IsActive',$status);
+ if($userType== ADMIN){
+ $this->db->where('STB.BranchCode',$branchID);
+ $this->db->where('LO.ListCode !=',SUPER_ADMIN);
+ }
+ if($userType== EMPLOYEE){
+ $this->db->where('STB.BranchCode',$branchID);
+ $this->db->where('LO.ID',$requestedBy);
+ }
+ $staffDetails=$this->db->get();
+ if($staffDetails){
+ $result_staff = array();
+ foreach ($staffDetails->result() as $row)
+ {
+ $university_array['loginId'] = $row->ID;
+ $university_array['staffName'] = $row->Firstname.'-'.$row->StaffID;
+ $result_staff[]=$university_array;
+ }
+
+ }
+ else{
+ $result_staff[]="";
+ }
+ }
+ else{
+ $this->db->select('BR.BranchCode,BR.BranchName');
+ $this->db->from(BRANCH.' as BR');
+ $this->db->where('BR.IsActive',$status);
+ $branchDetails=$this->db->get();
+
+ if($branchDetails->result()){
+ foreach ($branchDetails->result() as $branchRow){
+ $branch_array['BranchCode'] = $branchRow->BranchCode;
+ $branch_array['BranchName'] = $branchRow->BranchName.'-'.$branchRow->BranchCode;
+ $branch_array['staffDetails'] = $this->superAdminBranch($branchRow->BranchCode,$status);
+ $result_staff[]=$branch_array;
+ }
+
+ }
+ else{
+ $result_staff[]="";
+ }
+
+
+ }
+
+ return $result_staff;
+ }
+
+ /*
+ * get staff details based on branch id
+ * created by kms
+ * */
+ public function superAdminBranch($branchID,$status){
+
+ $this->db->select('LO.ID,ST.StaffID,ST.Firstname');
+ $this->db->from(LOGIN.' as LO');
+ $this->db->join(STAFF_BRANCH.' as STB', 'STB.StaffID = LO.StaffID');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->where('ST.IsActive',$status);
+ $this->db->where('STB.BranchCode',$branchID);
+ $staffDetails=$this->db->get();
+ if($staffDetails){
+ $result_staff = array();
+ foreach ($staffDetails->result() as $row)
+ {
+ $university_array['loginId'] = $row->ID;
+ $university_array['staffName'] = $row->Firstname.'-'.$row->StaffID;
+ $result_staff[]=$university_array;
+ }
+
+ }
+ else{
+ $result_staff[]="";
+ }
+
+ return $result_staff;
+
+ }
+
+
+ /*
+ * add lead details
+ * created by kms
+ * */
+
+ public function addleadDetails($lead_Details=null,$track_Details=null,$followup_Details=null)
+ {
+ $this->db->insert(LEAD_DETAILS, $lead_Details);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $followup_Details['TrackingID']=$this->db->insert_id();
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
+ // this if for insert follow up details
+ if($this->db->affected_rows() == '1'){
+ $result['leadStatus'] = true;
+ $result['message'] = "Successfully lead details added";
+ }
+ else{
+ $result['leadStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+ else{
+ $result['leadStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+ else {
+ $result['leadStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ return $result;
+
+ }
+
+ /*
+ * get all tracked details
+ * created by kms
+ * */
+
+ public function getTrackingDetails($search=null)
+ {
+ $this->db->select('LTF.FollowupOn,LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID');
+ $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.IsActive', '1');
+ if($search['CreatedBranch'] !='All' AND $search['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ if ($search['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $search['requestedBy']);
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ if($search['searchDate']!='' OR $search['searchDate']!=null){
+ /* if(sizeof($search['searchDate']) == '1'){
+ $this->db->where('LTF.FollowupOn <= ', $search['searchDate'][0]);
+ $this->db->where('PLD1.ListName !=', 'CLOSE');
+
+ }*/
+
+ $this->db->where_in('LTF.FollowupOn', $search['searchDate']);
+ $this->db->order_by('LTF.FollowupOn','DESC');
+ $this->db->group_by('LT.TrackingID');
+
+ }
+ else{
+ $this->db->order_by('LTF.FollowupOn','DESC');
+ $this->db->group_by('LT.TrackingID');
+ }
+
+ // $this->db->group_by('LD.MobileNumber');
+ $leadDet=$this->db->get();
+
+ if($this->db->affected_rows()==0){
+ $result_array['trackingStatus']=false;
+ $result_array['trackingDetails']="";
+ }
+ else{
+ if($leadDet){
+ $result_array = array();
+ $result_array['trackingStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["Flag"]=$row->Flag;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ // $followupDetails=$this->getTrackingFollowup($row->TrackingID);
+
+ // $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn;
+ $tracking_array["followupDetails"]=$row->FollowupOn;
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+ // $result_array['statusDetails']=$this->getStatus();
+
+
+ }
+ }
+ $result_array['pendingTrackingDetails'] = $this->getPrevPendingTrackingDetails($search);
+
+
+ return $result_array;
+
+ }
+
+ public function getPrevPendingTrackingDetails($search=null)
+ {
+ $this->db->select('LTF.FollowupOn,LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID');
+ $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.IsActive', '1');
+ if($search['CreatedBranch'] !='All' AND $search['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ if ($search['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $search['requestedBy']);
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ if(($search['searchDate']!='' OR $search['searchDate']!=null) AND sizeof($search['searchDate']) == '1'){
+
+ // $this->db->where('LTF.FollowupOn <= ', $search['searchDate'][0]);
+ $this->db->where('PLD1.ListName !=', 'CLOSE');
+ $leadDet=$this->db->get();
+
+ if($leadDet->result()){
+
+ $result_array['trackingStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["Flag"]=$row->Flag;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ // $followupDetails=$this->getTrackingFollowup($row->TrackingID);
+
+ // $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn;
+ $tracking_array["followupDetails"]=$row->FollowupOn;
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+
+
+ }
+ else{
+ $result_array['trackingStatus']=false;
+ }
+ }
+ else{
+ $result_array['trackingStatus']=false;
+ }
+
+
+
+
+
+ return $result_array;
+
+
+
+
+ }
+ /*
+ * get never closed tracking list by current date
+ * created by kms
+ * */
+
+
+ /*
+ * get tracking followup Details
+ * @params tracking id
+ * created by kms
+ * */
+
+ public function getTrackingFollowup($trackingId=null)
+ {
+ $this->db->select('LTF.InteractionId,LTF.TrackingID,LTF.FollowupOn,LTF.FollowupComments,DATE_FORMAT(LTF.CreatedOn, "%d-%m-%Y %h:%i %p") AS CreatedOn,ST.FirstName');
+
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LTF.CreatedBy');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->where('TrackingID',$trackingId);
+ $this->db->order_by('InteractionId','DESC');
+ $trackingDetails = $this->db->get();
+ return $trackingDetails->result();
+ }
+
+ /*
+ * update followup details
+ * created by kms
+ * */
+
+ public function updateFollowupDetails($updateDetails=null,$insertDetails=null)
+ {
+ $deactivateStatus['IsActive']=false;
+ $this->db->where('TrackingID',$updateDetails['TrackingID']);
+ $this->db->update(LEAD_TRACKING_FOLLOWUP, $deactivateStatus);
+ if($this->db->affected_rows() > '0') {
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertDetails);
+ // this if for insert follow up details
+ if ($this->db->affected_rows() == '1') {
+ $this->db->where('TrackingID', $updateDetails['TrackingID']);
+ $upateStatus = $this->db->update(LEAD_TRACKING, $updateDetails);
+ $result['followupStatus'] = true;
+ $result['trackingID'] = $updateDetails['TrackingID'];
+ $result['message'] = "Successfully followup details updated";
+ } else {
+ $result['followupStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else{
+ $activateStatus['IsActive']=true;
+ $this->db->where('TrackingID',$updateDetails['TrackingID']);
+ $this->db->update(LEAD_TRACKING_FOLLOWUP, $activateStatus);
+ $result['followupStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+
+
+ return $result;
+
+ }
+
+
+ /*
+ * get tracking information when page is loading
+ * created by kms
+ * */
+
+
+ public function getLoadFollowupDetails($trackingID)
+ {
+ $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.CreatedBranch,BR.BranchName,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.ReferredBy,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->join(BRANCH.' as BR', 'BR.BranchCode = LT.CreatedBranch');
+
+ $this->db->where('LT.TrackingID',$trackingID['TrackingID']);
+ if($trackingID['CreatedBranch'] !='All' AND $trackingID['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $trackingID['CreatedBranch']);
+
+ }
+ if ($trackingID['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $trackingID['UpdatedBy']);
+ $this->db->where('LT.CreatedBranch', $trackingID['CreatedBranch']);
+
+ }
+
+ $leadDet=$this->db->get();
+
+ if($leadDet){
+ $result_array = array();
+ $result_array['followupStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+ $activityID = $row->ActivityStatus;
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["CreatedBranch"]=$row->CreatedBranch;
+ $tracking_array["CreatedBranchName"]=$row->BranchName;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StaffID"]=$row->StaffID;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ $tracking_array["ReferredBy"]=$row->ReferredBy;
+ $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ $tracking_array["collectTrackedID"]=$this->getStudentTrackedID($row->MobileNumber,$trackingID['CreatedBranch'],$trackingID['requestedDept'],$trackingID['UpdatedBy']);
+
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+ $result_array['statusDetails']=$this->getStatus($activityID);
+ $result_array['staffDetails']=$this->getStaff("1",$trackingID['CreatedBranch'],$trackingID['requestedDept'],$trackingID['UpdatedBy']);
+
+
+ $result_array['trackingDetails']=$result;
+
+ }
+ else{
+ $result_array['followupStatus']=false;
+ $result_array['trackingDetails']="";
+ }
+
+
+ return $result_array;
+
+ }
+
+ /*
+ * get student tracked id
+ * @params mobile number
+ * created by kms
+ * */
+ public function getStudentTrackedID($stuMobile=null,$branchId=null,$reqDept=null,$updatedBy=null)
+ {
+ $this->db->distinct();
+ $this->db->select('LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,PLD.ListName');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = LT.StatusCode');
+ $this->db->where('LD.MobileNumber',$stuMobile);
+
+ if($branchId !='All' AND $reqDept != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $branchId);
+
+ }
+ if ($reqDept == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $updatedBy);
+ $this->db->where('LT.CreatedBranch', $branchId);
+
+
+ }
+
+ $this->db->order_by('LT.TrackingID','ASC');
+ $studeTrackID = $this->db->get();
+ return $studeTrackID->result();
+ }
+ /*
+ * used to get dash board call track details
+ * created by kms
+ * */
+ public function getDashboardTrackingDetails($serach=null)
+ {
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $todayFollowupDate=$now->format('d-m-Y');
+
+ $todayDateTime=$now->format('Y-m-d');
+
+
+
+ // $follouwpDetails=$this->todayFollowupDetails($todayFollowupDate,CLOSE,'1');
+ $follouwpDetails=$this->todayFollowUp($todayFollowupDate,$serach);
+ if($follouwpDetails){
+ $result_array['todayStatus']=true;
+ $result_array['todayFolloupDetails']=$follouwpDetails;
+ }
+ else{
+ $result_array['todayStatus']=false;
+ $result_array['todayFolloupDetails']="";
+
+ }
+ // $follouwpPendingDetails=$this->todayFollowupDetails($todayFollowupDate,CLOSE,'2');
+ $follouwpPendingDetails=$this->tillPendingTrackingDetails(CLOSE,$serach);
+
+ if($follouwpPendingDetails){
+ $result_array['todayPendingStatus']=true;
+ $result_array['PendingFolloupDetails']=$follouwpPendingDetails;
+ }
+ else{
+ $result_array['todayPendingStatus']=false;
+ $result_array['PendingFolloupDetails']="";
+
+ }
+ // $todayLeadDetails=$this->todayFollowupDetails($todayDateTime,OPEN,'3');
+ $todayLeadDetails=$this->todayCreatedLead($todayDateTime,$serach);
+ if($todayLeadDetails){
+ $result_array['todayLeadStatus']=true;
+ $result_array['todayLeadDetails']=$todayLeadDetails;
+ }
+ else{
+ $result_array['todayLeadStatus']=false;
+ $result_array['todayLeadDetails']="";
+
+ }
+
+ return $result_array;
+
+ }
+
+ /*
+ * get dash board today followupdetails
+ * created by kms
+ * */
+ public function todayFollowUp($todayDate,$search=null){
+ $this->db->distinct();
+ $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID');
+ $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ if ($search['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $search['requestedBy']);
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ $this->db->where('LTF.FollowupOn',$todayDate);
+ $trackDetails=$this->db->get();
+
+ if($trackDetails->result()){
+ foreach ($trackDetails->result() as $row1)
+ {
+
+ $tracking_array["LeadID"]=$row1->LeadID;
+ $tracking_array["LeadName"]=$row1->LeadName;
+ $tracking_array["MobileNumber"]=$row1->MobileNumber;
+ $tracking_array["TrackingID"]=$row1->TrackingID;
+ $tracking_array["FollowupOn"]=$row1->FollowupOn;
+ $tracking_array["StatusCode"]=$row1->StatusCode;
+ $tracking_array["statusName"]=$row1->statusListName;
+ $tracking_array["ActivityID"]=$row1->ActivityID;
+ $tracking_array["ActivityName"]=$row1->ActivityName;
+ $result[]=$tracking_array;
+
+ }
+ $result_array['trackingDetails']=$result;
+ return $result_array;
+ }
+ else {
+ return false;
+ }
+
+ }
+ /*
+ * get today lead details
+ * created by kms
+ * */
+ public function todayCreatedLead($todayDate,$search=null){
+ $this->db->distinct();
+ $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID');
+ $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.IsActive', '1');
+ if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ if ($search['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $search['requestedBy']);
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ $this->db->like('LD.CreatedOn', $todayDate, 'after');
+ $trackDetails=$this->db->get();
+
+ if($trackDetails->result()){
+ foreach ($trackDetails->result() as $row1)
+ {
+
+ $tracking_array["LeadID"]=$row1->LeadID;
+ $tracking_array["LeadName"]=$row1->LeadName;
+ $tracking_array["MobileNumber"]=$row1->MobileNumber;
+ $tracking_array["TrackingID"]=$row1->TrackingID;
+ $tracking_array["FollowupOn"]=$row1->FollowupOn;
+ $tracking_array["StatusCode"]=$row1->StatusCode;
+ $tracking_array["statusName"]=$row1->statusListName;
+ $tracking_array["ActivityID"]=$row1->ActivityID;
+ $tracking_array["ActivityName"]=$row1->ActivityName;
+ $result[]=$tracking_array;
+
+ }
+ $result_array['trackingDetails']=$result;
+ return $result_array;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /*
+ * get till pending tracking details
+ * created by kms
+ * */
+ public function tillPendingTrackingDetails($status,$search=null){
+ $this->db->distinct();
+ $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID');
+ $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.IsActive', '1');
+ $this->db->where('PLD1.ListName !=', $status);
+ if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ if ($search['requestedDept'] == EMPLOYEE){
+
+ $this->db->where('LT.AssignedTo', $search['requestedBy']);
+ $this->db->where('LT.CreatedBranch', $search['BranchID']);
+
+ }
+ $trackDetails=$this->db->get();
+
+ if($trackDetails->result()){
+ foreach ($trackDetails->result() as $row1)
+ {
+
+ $tracking_array["LeadID"]=$row1->LeadID;
+ $tracking_array["LeadName"]=$row1->LeadName;
+ $tracking_array["MobileNumber"]=$row1->MobileNumber;
+ $tracking_array["TrackingID"]=$row1->TrackingID;
+ $tracking_array["FollowupOn"]=$row1->FollowupOn;
+ $tracking_array["StatusCode"]=$row1->StatusCode;
+ $tracking_array["statusName"]=$row1->statusListName;
+ $tracking_array["ActivityID"]=$row1->ActivityID;
+ $tracking_array["ActivityName"]=$row1->ActivityName;
+ $result[]=$tracking_array;
+
+ }
+ $result_array['trackingDetails']=$result;
+ return $result_array;
+ }
+ else {
+ return false;
+ }
+ }
+
+
+ /*
+ * get date wise followup details
+ * @params date and status and check status
+ * */
+ public function todayFollowupDetails($todayDate=null,$status=null,$check=null)
+ {
+ $this->db->distinct();
+ $this->db->select('LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->from(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->order_by('LT.TrackingID','ASC');
+ /* if($check!='3'){
+ $this->db->where('LT.StatusCode !=',$status);
+ }
+ else if($check=='2'){
+ $this->db->where('LT.StatusCode !=',$status);
+ }*/
+ if($check=='3'){
+ $this->db->like('LD.CreatedOn', $todayDate, 'after');
+ }
+
+ $leadDetails=$this->db->get();
+ if($leadDetails->result()){
+ $result_array = array();
+ foreach ($leadDetails->result() as $row){
+ $this->db->select('LTF.TrackingID,LTF.InteractionId');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->where('LTF.TrackingID',$row->TrackingID);
+ $lastFollowpID=$this->db->get()->last_row();
+ // get last followup details date wise
+ $this->db->distinct();
+ $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LEAD_TRACKING_FOLLOWUP.' as LTF', 'LTF.TrackingID = LT.TrackingID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.InteractionId',$lastFollowpID->InteractionId);
+
+ // check today date based follwup details
+ if($check=='1'){
+ $this->db->where('LTF.FollowupOn',$todayDate);
+ // $this->db->where('LT.StatusCode !=',$status);
+ }
+ // check today date based pending followp details
+ /* else if($check=='2'){
+ // $this->db->where('LTF.FollowupOn >',$todayDate);
+ $this->db->where('LT.StatusCode !=',$status);
+ }*/
+ else if($check=='3'){
+ $this->db->like('LD.CreatedOn', $todayDate, 'after');
+ }
+ $trackDetails=$this->db->get();
+
+ if($trackDetails->result()){
+ foreach ($trackDetails->result() as $row1)
+ {
+
+ $tracking_array["LeadID"]=$row1->LeadID;
+ $tracking_array["LeadName"]=$row1->LeadName;
+ $tracking_array["MobileNumber"]=$row1->MobileNumber;
+ $tracking_array["TrackingID"]=$row1->TrackingID;
+ $tracking_array["FollowupOn"]=$row1->FollowupOn;
+ $tracking_array["StatusCode"]=$row1->StatusCode;
+ $tracking_array["statusName"]=$row1->statusListName;
+ $tracking_array["ActivityID"]=$row1->ActivityID;
+ $tracking_array["ActivityName"]=$row1->ActivityName;
+ $result[]=$tracking_array;
+
+ }
+ $result_array['trackingDetails']=$result;
+ }
+
+
+ }
+
+ return $result_array;
+
+ }
+
+ else{
+ return false;
+ }
+
+ }
+
+
+ /*
+ * get all followup details
+ * created by kms
+ * */
+
+ public function getDashboardFollowupDetails($search=null)
+ {
+ $this->db->distinct();
+ $this->db->select('LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->from(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->order_by('LT.TrackingID','ASC');
+ $leadDetails=$this->db->get();
+ if($leadDetails->result()){
+ foreach ($leadDetails->result() as $row){
+ $this->db->select('LTF.TrackingID,LTF.InteractionId');
+ $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF');
+ $this->db->where('LTF.TrackingID',$row->TrackingID);
+ $lastFollowpID=$this->db->get()->last_row();
+ // get last followup details date wise
+ $this->db->distinct();
+ $this->db->select('DATE_FORMAT(LTF.CreatedOn, "%d-%m-%Y") AS CreatedOn,LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LEAD_TRACKING_FOLLOWUP.' as LTF', 'LTF.TrackingID = LT.TrackingID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ $this->db->where('LTF.InteractionId',$lastFollowpID->InteractionId);
+
+ $result[]=$this->db->get()->result();
+
+ }
+ $result_array['details']=$result;
+ $result_array['followupStatus']=true;
+
+ return $result_array;
+
+ }
+
+ else{
+ $result_array['details']="";
+ $result_array['followupStatus']=false;
+ }
+ return $result_array;
+
+ }
+ /*
+ * get recent lead details
+ * params: date
+ * created by kms
+ * */
+
+ public function getRecentleadDetails($search=null)
+ {
+
+ $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ if($search['loadDate'] !='' ) {
+ $this->db->like('LD.CreatedOn', $search['loadDate'], 'after');
+ }
+ if($search['CreatedBranch'] !='All'){
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ $this->db->order_by('LT.TrackingID', 'DESC');
+ $leadDet=$this->db->get();
+ if($this->db->affected_rows()==0){
+ $result_array['trackingStatus']=false;
+ $result_array['trackingDetails']="";
+ }
+ else{
+ if($leadDet){
+ $result_array = array();
+ $result_array['trackingStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["Flag"]=$row->Flag;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ $tracking_array["CreatedOn"]=$row->CreatedOn;
+ $tracking_array["UpdatedOn"]=$row->UpdatedOn;
+ // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ $followupDetails=$this->getTrackingFollowup($row->TrackingID);
+
+ $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn;
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+ // $result_array['statusDetails']=$this->getStatus();
+ $result_array['trackingDetails']=$result;
+
+ }
+ }
+ return $result_array;
+
+ }
+ /*
+ * get recent track close details
+ * created by kms
+ * */
+ public function getRecentCloseDetails($search=null)
+ {
+ $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ if($search['loadDate'] !='' ) {
+ $this->db->like('LT.UpdatedOn', $search['loadDate'], 'after');
+ }
+ if($search['CreatedBranch'] !='All'){
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ $this->db->like('PLD1.ListName', 'CLOSE', 'after');
+ $this->db->order_by('LT.TrackingID', 'DESC');
+ $leadDet=$this->db->get();
+ if($this->db->affected_rows()==0){
+ $result_array['trackingStatus']=false;
+ $result_array['trackingDetails']="";
+ }
+ else{
+ if($leadDet){
+ $result_array = array();
+ $result_array['trackingStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["Flag"]=$row->Flag;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ $tracking_array["CreatedOn"]=$row->CreatedOn;
+ $tracking_array["UpdatedOn"]=$row->UpdatedOn;
+ // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ $followupDetails=$this->getTrackingFollowup($row->TrackingID);
+
+ $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn;
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+ // $result_array['statusDetails']=$this->getStatus();
+ $result_array['trackingDetails']=$result;
+
+ }
+ }
+ return $result_array;
+
+ }
+ /*
+ * get recent pending details
+ * created by kms
+ * */
+ public function getRecentPendingDetails($search=null)
+ {
+ $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo');
+ $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID');
+ $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode');
+ if($search['loadDate'] !='' ){
+ $this->db->like('LT.UpdatedOn', $search['loadDate'], 'after');
+
+ }
+ if($search['CreatedBranch'] !='All'){
+ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']);
+
+ }
+ $this->db->where('PLD1.ListName !=', 'CLOSE');
+ $this->db->order_by('LT.TrackingID', 'DESC');
+ $leadDet=$this->db->get();
+ if($this->db->affected_rows()==0){
+ $result_array['trackingStatus']=false;
+ $result_array['trackingDetails']="";
+ }
+ else{
+ if($leadDet){
+ $result_array = array();
+ $result_array['trackingStatus']=true;
+
+ foreach ($leadDet->result() as $row)
+ {
+
+ $tracking_array["LeadID"]=$row->LeadID;
+ $tracking_array["LeadName"]=$row->LeadName;
+ $tracking_array["MobileNumber"]=$row->MobileNumber;
+ $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry;
+ $tracking_array["TrackingID"]=$row->TrackingID;
+ $tracking_array["Flag"]=$row->Flag;
+ $tracking_array["ActivityStatus"]=$row->ActivityStatus;
+ $tracking_array["AssignedTo"]=$row->AssignedTo;
+ $tracking_array["Firstname"]=$row->Firstname;
+ $tracking_array["StatusCode"]=$row->StatusCode;
+ $tracking_array["statusName"]=$row->statusListName;
+ $tracking_array["UniversityName"]=$row->University;
+ $tracking_array["CourseName"]=$row->Course;
+ $tracking_array["ActivityID"]=$row->ActivityID;
+ $tracking_array["ActivityName"]=$row->ActivityName;
+ $tracking_array["AlternateMobile"]=$row->AlternateMobile;
+ $tracking_array["Address"]=$row->Address;
+ $tracking_array["CreatedOn"]=$row->CreatedOn;
+ $tracking_array["UpdatedOn"]=$row->UpdatedOn;
+ // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID);
+ $followupDetails=$this->getTrackingFollowup($row->TrackingID);
+
+ $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn;
+ $result[]=$tracking_array;
+
+
+ }
+ $result_array['trackingDetails']=$result;
+ // $result_array['statusDetails']=$this->getStatus();
+ $result_array['trackingDetails']=$result;
+
+ }
+ }
+ return $result_array;
+
+ }
+ /*
+ * update call track as important
+ * created by kms
+ * */
+ public function updateFlagStatus($trackID=null,$flagStatus=null){
+ $updateDetails['Flag']= $flagStatus;
+ $this->db->where('TrackingID',$trackID);
+ $this->db->update(LEAD_TRACKING, $updateDetails);
+ if($this->db->affected_rows() > '0') {
+ $result['updatedStatus']=true;
+
+ }
+ else{
+ $result['updatedStatus']=false;
+
+ }
+ return $result;
+
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Center_model.php b/api/application/models/Center_model.php
new file mode 100644
index 0000000..02d085d
--- /dev/null
+++ b/api/application/models/Center_model.php
@@ -0,0 +1,110 @@
+db->select('CenterCode');
+ $this->db->where('CenterCode', $arrayDetails['CenterCode']);
+ if($this->db->get(CENTER)->first_row()){
+ $result['centerStatus'] = false;
+ $result['message'] = "This center Code is already exist!";
+ } else {
+ $this->db->insert(CENTER, $arrayDetails);
+ if ($this->db->affected_rows() == '1') {
+
+ $result['centerStatus'] = true;
+ $result['message'] = "Successfully center details added";
+ } else {
+ $result['centerStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+
+ }
+
+
+ /*
+ * Get center details
+ * created by srk
+ */
+
+
+
+ public function getCenter()
+ {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn','DESC');
+ $centerDetails = $this->db->get(CENTER);
+ // print_r($centerDetails);
+ // die;
+
+ if($centerDetails->result()){
+
+ $result['centerStatus'] = true;
+ $result['details'] = $centerDetails->result();
+ }
+ else {
+ $result['centerStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+
+ /*
+ * update Center details
+ * created by Srk
+ */
+ public function updateCenter($arrayDetails=null,$CenterID=null)
+ {
+
+ $this->db->select('CenterCode');
+ $this->db->where('CenterCode',$arrayDetails['CenterCode']);
+ //$this->db->where('SubjectCode !=', $arrayDetails['SubjectCode']);
+ $this->db->where('CenterCode !=',$arrayDetails['CenterCode']);
+ if($this->db->get(CENTER)->first_row()){
+ $result['centerStatus']=false;
+ $result['message']= " This Center code already exist";
+ }
+ else{
+ $this->db->where('CenterID',$CenterID);
+ $updateStatus=$this->db->update(CENTER, $arrayDetails);
+ if($updateStatus){
+
+ $result['centerStatus'] = true;
+ $result['message'] = "Successfully Center details updated";
+ }
+
+ else {
+ $result['centerStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+ }
+
+
+ return $result;
+
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/Certificate_model.php b/api/application/models/Certificate_model.php
new file mode 100644
index 0000000..807e15c
--- /dev/null
+++ b/api/application/models/Certificate_model.php
@@ -0,0 +1,107 @@
+db->select('CertificateName');
+ $this->db->where('CertificateName', $arrayDetails['CertificateName']);
+ if($this->db->get(CERTIFICATION_MASTER)->first_row()){
+ $result['certificateStatus'] = false;
+ $result['message'] = "Certificate name is already exist!";
+ } else {
+ $this->db->insert(CERTIFICATION_MASTER, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['certificateStatus'] = true;
+ $result['message'] = "Successfully Certificate name is added";
+ }
+ else {
+ $result['certificateStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+
+
+
+
+ return $result;
+
+ }
+ /*
+ * get Certificate details
+ * parama id
+ * created by Surendiran
+ * */
+ public function getCertificate()
+ {
+ $this->db->select('CertificationID,CertificateName,CreatedOn,IsActive');
+ $this->db->order_by('CertificationID','DESC');
+ $certificateDetails = $this->db->get(CERTIFICATION_MASTER);
+ if($certificateDetails->result()){
+
+ $result['certificateStatus'] = true;
+ $result['details'] = $certificateDetails->result();
+ }
+ else {
+ $result['certificateStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+
+
+ /*
+ * update Certificate details
+ * created by Surendiran
+ * */
+
+ public function update($arrayDetails=null,$CertificationID=null)
+ {
+ $this->db->select('CertificateName');
+
+ $this->db->where('CertificateName', $arrayDetails['CertificateName']);
+ $this->db->where_not_in('CertificationID', $CertificationID);
+ if($this->db->get(CERTIFICATION_MASTER)->first_row()){
+ $result['certificateStatus'] = false;
+ $result['message'] = "Certificate name is already exist!";
+ } else {
+ $this->db->where('CertificationID',$CertificationID);
+ $this->db->update(CERTIFICATION_MASTER, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['certificateStatus'] = true;
+ $result['message'] = "Successfully Certificate name is updated";
+ }
+ else {
+ $result['certificateStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+
+
+ return $result;
+
+ }
+
+}
+
+
+
diff --git a/api/application/models/Course_model.php b/api/application/models/Course_model.php
new file mode 100644
index 0000000..3b91345
--- /dev/null
+++ b/api/application/models/Course_model.php
@@ -0,0 +1,373 @@
+db->select('CourseCode');
+ $this->db->where('CourseCode', $arrayDetails['CourseCode']);
+ $this->db->where('UniversityID', $arrayDetails['UniversityID']);
+ if($this->db->get(COURSE)->first_row()){
+ $result['courseStatus'] = false;
+ $result['message'] = "This course id is already exist in same university";
+ } else {
+ $this->db->insert(COURSE, $arrayDetails);
+ if ($this->db->affected_rows() == '1') {
+ $insert_id = $this->db->insert_id();
+ if($jsonSemFeesData){
+ foreach($jsonSemFeesData as $row){
+
+ $insertFeesArray['CourseID'] =$insert_id;
+ $insertFeesArray['ProgramType'] =$row['program'];
+ $insertFeesArray['FeesType'] =$row['FeesType'];
+ $insertFeesArray['FeesAmount'] =$row['FeesAmount'];
+ $insertFeesArray['Sem_Year'] =$row['programName'];
+ $insertFeesArray['UpdatedOn'] =$arrayDetails['CreatedOn'];
+ $insertFeesArray['UpdatedBy'] =$arrayDetails['CreatedBy'];
+ $this->db->insert(COURSE_FEES, $insertFeesArray);
+ }
+
+ if($subjectDetails){
+ $this->insertCourseSubjects($arrayDetails,$insert_id,$subjectDetails);
+ }
+
+ $result['courseStatus'] = true;
+ $result['message'] = "Successfully course details added";
+ }
+ else{
+ $this -> db -> where('CourseCode', $arrayDetails['CourseCode']);
+ $this -> db -> delete('COURSE');
+ $result['courseStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+
+ } else {
+ $result['courseStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+
+ }
+
+
+ /*
+ * get branch details
+ * parama id
+ * created by kms
+ * */
+
+ public function getCourse()
+ {
+ $this->db->select('CU.CourseID,CU.CourseCode,CU.CourseName,CU.FeesType,CU.Specilization1,CU.Specilization2,CU.PC,CU.DC,CU.TC,CU.MC,CU.OtherFees,CU.IsActive,US.UniversityID,US.UniversityName');
+ $this->db->from(COURSE.' as CU');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
+ $this->db->order_by('CU.CreatedOn','DESC');
+ $courseDetails = $this->db->get();
+
+ if($courseDetails->result()){
+
+ $result['courseStatus'] = true;
+
+ foreach ($courseDetails->result() as $row){
+ $fetchData['CourseID']=$row->CourseID;
+ $fetchData['CourseCode']=$row->CourseCode;
+ $fetchData['CourseName']=$row->CourseName;
+ $fetchData['FeesType']=$row->FeesType;
+ $fetchData['Specilization1']=$row->Specilization1;
+ $fetchData['Specilization2']=$row->Specilization2;
+ $fetchData['PC']=$row->PC;
+ $fetchData['DC']=$row->DC;
+ $fetchData['TC']=$row->TC;
+ $fetchData['MC']=$row->MC;
+ $fetchData['OtherFees']=$row->OtherFees;
+ $fetchData['IsActive']=$row->IsActive;
+ $fetchData['UniversityID']=$row->UniversityID;
+ $fetchData['UniversityName']=$row->UniversityName;
+ $fetchData['feesStructures'] = $this->getCourseFeesDetails($row->CourseID);
+ $fetchData['existSubjects'] = $this->getExistCourseSubjectDetails($row->CourseID);
+ // print_r($fetchData);exit();
+ $storeCourseArray[]=$fetchData;
+ }
+ $result['details'] = $storeCourseArray;
+ // print_r($storeCourseArray);exit();
+ }
+ else {
+ $result['courseStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ // print_r($result);exit();
+ return $result;
+
+ }
+
+ public function getCourseUnivFeesTypes() {
+ $result['universityDetails'] = $this->getUniversityDetails();
+ $result['feesDetails'] = $this->getFeesDetails();
+ $result['subjectetails'] = $this->getSubjectDetails();
+ $result['courseStatus'] = true;
+ return $result;
+ }
+
+ /*
+ * update course details
+ * created by kms
+ * */
+ public function updateCourse($arrayDetails=null,$jsonData=null,$subjectDetails=null)
+ {
+ $this->db->select('CourseCode');
+ $this->db->where('CourseCode', $arrayDetails['CourseCode']);
+ $this->db->where('UniversityID', $arrayDetails['UniversityID']);
+ $this->db->where('CourseID !=', $arrayDetails['CourseID']);
+ if($this->db->get(COURSE)->first_row()){
+ $result['courseStatus'] = false;
+ $result['message'] = "This course id is already exist in same university";
+ }
+ else{
+ $this->db->where('CourseID',$arrayDetails['CourseID']);
+ $upateStatus=$this->db->update(COURSE, $arrayDetails);
+ if($upateStatus) {
+
+ if ($jsonData) {
+ foreach ($jsonData as $row) {
+ $feesID = $row['ID'];
+
+ $updateFeesArray['CourseID'] = $arrayDetails['CourseID'];
+ $updateFeesArray['FeesAmount'] = $row['FeesAmount'];
+ $updateFeesArray['Sem_Year'] = $row['programName'];
+ $updateFeesArray['UpdatedOn'] = $arrayDetails['UpdatedOn'];
+ $updateFeesArray['UpdatedBy'] = $arrayDetails['UpdatedBy'];
+
+ $updateFeesArray['ProgramType'] =$row['program'];
+ $updateFeesArray['FeesType'] =$row['FeesType'];
+ if($feesID!='' OR $feesID!=null){
+ $this->db->where('ID', $feesID);
+ $this->db->update(COURSE_FEES, $updateFeesArray);
+ }
+ else{
+ $this->db->insert(COURSE_FEES, $updateFeesArray);
+ }
+
+ }
+ // update course subject details
+ $this->updateCourseSubjcetDetails($subjectDetails);
+
+
+ $result['courseStatus'] = true;
+ $result['message'] = "Successfully course details updated";
+ }
+ }
+
+ else {
+ $result['courseStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+ }
+
+
+
+ return $result;
+
+ }
+ /*
+ * get university details
+ * created by kms
+ * */
+ public function getUniversityDetails()
+ {
+ $this->db->select('UniversityID,UniversityName');
+ $this->db->order_by('UniversityID','ASC');
+ $this->db->where('IsActive','1');
+ $universityDetails = $this->db->get(UNIVERSITY);
+ return $universityDetails->result();
+ }
+ /*
+ * get fees details
+ * created by kms
+ * */
+ public function getFeesDetails()
+ {
+
+ $this->db->select('ListCode,ListName');
+ $this->db->order_by('ListCode','ASC');
+ $this->db->where('IsActive','1');
+ $this->db->where('ListGroup','3');
+ $feesDetails = $this->db->get(PICK_LIST_DETAILS);
+
+ if($feesDetails){
+ $result_fees = array();
+ foreach ($feesDetails->result() as $row)
+ {
+ $list_array['ListCode'] = $row->ListCode;
+ $list_array['ListName'] = $row->ListName;
+ if($row->ListCode=='F001'){
+ $list_array['programType']=$this->getFeesProgram('4');
+
+ }
+ else if($row->ListCode=='F002'){
+ $list_array['programType']=$this->getFeesProgram('5');
+ }
+ else{
+ $list_array['programType']="";
+ }
+ $result_fees[]=$list_array;
+ }
+
+ }
+ else{
+ $result_fees[]="";
+ }
+ return $result_fees;
+ }
+ /*
+ * get fees type
+ * created by kms
+ * */
+ public function getFeesProgram($programType=null)
+ {
+ $this->db->select('ListCode,ListName');
+ $this->db->order_by('ListCode','ASC');
+ $this->db->where('IsActive','1');
+ $this->db->where('ListGroup',$programType);
+ $feesDetails = $this->db->get(PICK_LIST_DETAILS);
+ return $feesDetails->result();
+ }
+
+ /*
+ * get course fees details
+ * created by kms
+ * */
+
+ public function getCourseFeesDetails($courseID=null){
+
+ $this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year,PLD.ListName as programName');
+ $this->db->order_by('ID','ASC');
+ $this->db->where('CourseID',$courseID);
+ $this->db->from(COURSE_FEES.' as CF');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = CF.ProgramType');
+ $feesDetails = $this->db->get();
+ return $feesDetails->result();
+ }
+
+ /*
+ * get subject details
+ * created by kms
+ * */
+ public function getSubjectDetails(){
+ $this->db->select('SubjectID,SubjectCode,SubjectName');
+ $this->db->order_by('SubjectID','DESC');
+ $this->db->where('IsActive','1');
+ $subjectDetails = $this->db->get(SUBJECTMASTER);
+ return $subjectDetails->result();
+ }
+
+ /*
+ *Insert course sujects
+ * created by kms
+ * */
+ public function insertCourseSubjects($details=null,$courseID=null,$subjects=null){
+ $insertSubject['UniversityID'] = $details['UniversityID'];
+ $insertSubject['CourseID'] = $courseID;
+ if ($subjects){
+ foreach ($subjects as $row){
+ $insertSubject['SubjectID'] = $row['SubjectID'];
+ $insertSubject['IsActive'] = true;
+ $insertSubject['CreatedBy'] = $details['CreatedBy'];
+ $insertSubject['CreatedOn'] = $details['CreatedOn'];
+ $this->db->insert(COURSESUBJECT, $insertSubject);
+
+ }
+ }
+ return true;
+ }
+
+ /*
+ * get exist Course subject details
+ * created by kms
+ * */
+ public function getExistCourseSubjectDetails($courseID=null){
+ $this->db->select('CSU.SubjectID,SM.SubjectCode,SM.SubjectName');
+ $this->db->order_by('CSID','ASC');
+ $this->db->where('CSU.CourseID',$courseID);
+ $this->db->where('CSU.IsActive','1');
+ // $this->db->where('SM.IsActive','1');
+ $this->db->from(COURSESUBJECT.' as CSU');
+ $this->db->join(SUBJECTMASTER.' as SM', 'SM.SubjectID = CSU.SubjectID');
+ $subDetails = $this->db->get();
+ return $subDetails->result();
+ }
+
+ /*
+ * update course subject details
+ * created by kms
+ * */
+ public function updateCourseSubjcetDetails($sujects=null){
+ $deactiveStatus['IsActive']=false;
+ $deactiveStatus['UpdatedBy']=$sujects['UpdatedBy'];
+ $deactiveStatus['UpdatedOn']=$sujects['UpdatedOn'];
+ $this->db->where('CourseID ',$sujects['CourseID']);
+ $this->db->where('UniversityID ',$sujects['UniversityID']);
+ $updateCourseSubjectDeactive = $this->db->update(COURSESUBJECT, $deactiveStatus);
+
+ if($updateCourseSubjectDeactive){
+
+ if($sujects['Subjects']){
+
+ foreach ($sujects['Subjects'] as $srow){
+ $this->db->select('CSID');
+ $this->db->where('CourseID',$sujects['CourseID']);
+ $this->db->where('UniversityID',$sujects['UniversityID']);
+ $this->db->where('SubjectID',$srow);
+ if($this->db->get(COURSESUBJECT)->first_row()){
+ $existStatusUpdate['IsActive']=true;
+ $existStatusUpdate['UpdatedBy']=$sujects['UpdatedBy'];
+ $existStatusUpdate['UpdatedOn']=$sujects['UpdatedOn'];
+ $this->db->where('CourseID',$sujects['CourseID']);
+ $this->db->where('UniversityID',$sujects['UniversityID']);
+ $this->db->where('SubjectID',$srow);
+ $this->db->update(COURSESUBJECT, $existStatusUpdate);
+ }
+ else{
+ $update_array["UniversityID"]=$sujects['UniversityID'];
+ $update_array["CourseID"]=$sujects['CourseID'];
+ $update_array["SubjectID"]=$srow;
+
+ $update_array["IsActive"]=true;
+ $update_array["CreatedBy"]=$sujects['UpdatedBy'];
+ $update_array["CreatedOn"]=$sujects['UpdatedOn'];
+ $this->db->insert(COURSESUBJECT, $update_array);
+
+ }
+
+ }
+ }
+ /* else{
+ $activateStatus['IsActive']=true;
+ $this->db->where('CourseID ',$sujects['CourseID']);
+ $this->db->where('UniversityID ',$sujects['UniversityID']);
+ $this->db->update(COURSESUBJECT, $activateStatus);
+
+ }*/
+
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Dashboard_model.php b/api/application/models/Dashboard_model.php
new file mode 100644
index 0000000..94b5af7
--- /dev/null
+++ b/api/application/models/Dashboard_model.php
@@ -0,0 +1,74 @@
+db->query($sql1);
+ $sql2 = "SELECT * from ".STAFF."";
+ $count2 = $this->db->query($sql2);
+
+ if( $count2->num_rows() > 0) {
+ $result['status'] = true;
+ $result['total_student'] = $count1->num_rows();
+ $result['total_staff'] = $count2->num_rows();
+ $result['message'] = "Total Number of Users";
+ } else {
+ $result['status'] = true;
+ $result['total_student'] = $count1->num_rows();
+ $result['total_staff'] = $count2->num_rows();
+ $result['message'] = "No student Users";
+ }
+ return $result;
+ }
+
+ // get total number of students
+ public function get_total_students($data) {
+ // print_r($data);exit();
+ $sql = "SELECT * from ".STUDENTS."";
+ $count = $this->db->query($sql);
+ if( $count->num_rows() > 0) {
+ $result['status'] = true;
+ $result['total_student'] = $count->num_rows();
+ $result['message'] = "Total Number of Students";
+ } else {
+ $result['status'] = true;
+ $result['total_student'] = $count->num_rows();
+ $result['message'] = "No student exist";
+ }
+ return $result;
+ }
+
+ // get total number of employees
+ public function get_total_employee($data) {
+ // print_r($data);exit();
+ $sql = "SELECT * from ".STAFF."";
+ $count = $this->db->query($sql);
+ if( $count->num_rows() > 0) {
+ $result['status'] = true;
+ $result['total_employee'] = $count->num_rows();
+ $result['message'] = "Total Number of Employee";
+ } else {
+ $result['status'] = true;
+ $result['total_employee'] = $count->num_rows();
+ $result['message'] = "No Employee exist";
+ }
+ return $result;
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/DayBook_model.php b/api/application/models/DayBook_model.php
new file mode 100644
index 0000000..ed51135
--- /dev/null
+++ b/api/application/models/DayBook_model.php
@@ -0,0 +1,568 @@
+db->select('t1.ListCode, t1.ListName');
+ $this->db->from(''.PICK_LIST_DETAILS. ' as t1');
+ $this->db->where('t1.ListGroup', 10);
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $typeDetails = $this->db->get();
+ $typeStateDetails = $typeDetails->result();
+ // TypeName details
+ $this->db->select('t2.TypeName, t2.TypeID, t2.ID');
+ $this->db->from(''.INCOMEOUTCOMEMASTER. ' as t2');
+ $this->db->where('t2.IsActive', 1);
+
+ $typeNaDetails = $this->db->get();
+ $typeNameDetails = $typeNaDetails->result();
+
+ $results['typeNameStatus'] = true;
+ $results['typeList'] = $typeStateDetails;
+ $results['typeNameList'] = $typeNameDetails;
+ return $results;
+ }
+
+
+ public function emp_day_book_AccessChk($arr) {
+ $id = $arr['localUserID'];
+ $sql1 = "SELECT t1.FinanceModuleAccess FROM ".STAFF." as t1 LEFT JOIN ".LOGIN." as t2 ON t2.StaffID = t1.StaffID WHERE t2.id = $id";
+ // update branch to staff_branch table
+ $dayBookAccDetails = $this->db->query($sql1);
+ $dayBkAcesDetail = $dayBookAccDetails->result();
+ $result['dayBkAccessChkStatus'] = true;
+ $result['dayBkAccessChk_Value'] = $dayBkAcesDetail[0]->FinanceModuleAccess;
+ // echo $result['dayBkAccessChk_Value'];exit();
+ return $result;
+ }
+
+ // get the daybook details list
+ public function get_Daybook_Details_List($reqData, $reqDataBy) {
+
+ if($reqData['date'] != '' && $reqData['dateTo'] != '') {
+ // $this->db->select('t1.*, t2.ListName, t3.TypeName');
+ // $this->db->from(''.DAYBOOKMASTER. ' as t1');
+ // $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
+ // $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
+
+ $d = new DateTime($reqData['date']);
+ $dTo = new DateTime($reqData['dateTo']);
+ $fromDate = $d->format('Y-m-d');
+ $toDate = $dTo->format('Y-m-d');
+ $reqpayType = $reqDataBy['localBranchID'];
+
+ $querys = "SELECT t1.ID as ORDER_ID, t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
+ LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
+ WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate'
+ AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY ORDER_ID DESC";
+// echo $querys;exit();
+ // $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $fromDate);
+ // $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $toDate);
+ // $this->db->where('t1.Date', $reqData['date']);
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']);
+
+ } else {
+ // $this->db->select('t1.*, t2.ListName, t3.TypeName');
+ // $this->db->from(''.DAYBOOKMASTER. ' as t1');
+ // $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
+ // $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
+ // // $this->db->where('t1.Date', $reqData['date']);
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']);
+ $reqpayType = $reqDataBy['localBranchID'];
+ $querys = "SELECT t1.ID as ORDER_ID, t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
+ LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
+ WHERE t1.BranchCode = '$reqpayType' ORDER BY ORDER_ID DESC";
+
+ }
+
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $dayBookDetails = $this->db->query($querys);
+ $dayBookDetailsList = $dayBookDetails->result();
+ $results['dayBookListStatus'] = true;
+ $results['dayBookListDetails'] = $dayBookDetailsList;
+ return $results;
+ }
+
+ public function get_Daybook_Approval_Details_List($reqData, $reqDataBy) {
+ if($reqData['date'] != '' && $reqData['dateTo'] != '') {
+ $d = new DateTime($reqData['date']);
+ $dTo = new DateTime($reqData['dateTo']);
+ $fromDate = $d->format('Y-m-d');
+ $toDate = $dTo->format('Y-m-d');
+ $reqpayType = $reqDataBy['localBranchID'];
+
+ $querys = "SELECT t1.ID as ORDER_ID, t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
+ LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
+ WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate'
+ AND '$toDate' AND t1.BranchCode = '$reqpayType' AND t1.Status NOT IN ('Approved', 'Cancel') ORDER BY ORDER_ID DESC";
+ }
+ else { $reqpayType = $reqDataBy['localBranchID'];
+ $querys = "SELECT t1.ID as ORDER_ID, t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
+ LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
+ WHERE t1.BranchCode = '$reqpayType' AND t1.Status NOT IN ('Approved', 'Cancel') ORDER BY ORDER_ID DESC";
+
+ }
+ $dayBookDetails = $this->db->query($querys);
+ $dayBookDetailsList = $dayBookDetails->result();
+ $results['dayBookListStatus'] = true;
+ $results['dayBookListDetails'] = $dayBookDetailsList;
+ return $results;
+ }
+
+ // delete the daybook details
+ public function delete_dayBookDetails($id) {
+ // echo $id;exit();
+
+ $mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$id'";
+ $deleteDetails = $this->db->query($mysql);
+ $deleteDataDetails = $deleteDetails->result();
+ $branch = $deleteDataDetails[0]->BranchCode;
+
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$id')
+ ORDER BY ID DESC
+ LIMIT 1 ";
+
+ $currBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+ $currBalance = $latestUpdateDetails[0]->Balance;
+ $currID = $latestUpdateDetails[0]->ID;
+
+ // $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'";
+ $sql1 = "UPDATE ".DAYBOOKMASTER." SET Status ='Cancel' WHERE ID ='$id'";
+
+ // update branch to staff_branch table
+ if ($this->db->query($sql1) == '1') {
+
+ $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$currID')
+ ORDER BY ID ASC";
+ $latestUpdate2 = $this->db->query($sql2);
+ $latestUpdateDetails2 = $latestUpdate2->result();
+
+ foreach( $latestUpdateDetails2 as $clip){
+ if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Income
+ $currBalance = $currBalance + $clip->Amount;
+ }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Expense
+ $currBalance = $currBalance - $clip->Amount;
+ } else {
+ }
+ $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ $this->db->query($updateSql);
+ }
+
+ $result['deletedStatus'] = true;
+ $result['message'] = "Entry is Deleted";
+
+ } else {
+ $result['deletedStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ // print_r($latestUpdateDetails);exit();
+ return $result;
+ }
+
+ // delete the daybook fees entry details
+ public function delete_dayBookFeePayableDetails($id) {
+ $this->db->select('FeesPaymentID, BranchCode');
+ $this->db->from(DAYBOOKMASTER);
+ $this->db->where('ID', $id);
+ $typeDetails = $this->db->get();
+ $typeStateDetails = $typeDetails->result();
+ $getID = $typeStateDetails[0]->FeesPaymentID;
+ $branch = $typeStateDetails[0]->BranchCode;
+ // echo $id;exit();
+ try {
+ $sql1 = " DELETE FROM ".STUDENTS_FEES_PAID." WHERE ID ='$getID'";
+ $this->db->query($sql1);
+ } catch(Exception $e) {
+ echo 'error';
+ } finally {
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$id')
+ ORDER BY ID DESC
+ LIMIT 1 ";
+
+ $currBalance = 0;
+ $currID = $id;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+ If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
+ {
+ $currBalance = $latestUpdateDetails[0]->Balance;
+ $currID = $latestUpdateDetails[0]->ID;
+ }else{
+ }
+ // $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE FeesPaymentID ='$getID'";
+ // $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE FeesPaymentID ='$getID'";
+ $sql1 = "UPDATE ".DAYBOOKMASTER." SET Status ='Cancel' WHERE FeesPaymentID ='$getID'";
+
+ // update branch to staff_branch table
+ if ($this->db->query($sql1) == '1') {
+
+ $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$currID')
+ ORDER BY ID ASC";
+ $latestUpdate2 = $this->db->query($sql2);
+ $latestUpdateDetails2 = $latestUpdate2->result();
+
+ foreach( $latestUpdateDetails2 as $clip){
+ if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Income
+ $currBalance = $currBalance + $clip->Amount;
+ }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Expense
+ $currBalance = $currBalance - $clip->Amount;
+ } else {
+ }
+ $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ $this->db->query($updateSql);
+ }
+
+ $result['deletedStatus'] = true;
+ $result['message'] = "Entry is Deleted";
+ } else {
+ $result['deletedStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+ }
+
+ // update existing daybook details
+ public function update_dayBookDetails($Arr, $upFor) {
+
+ $branch = $Arr['BranchCode'];
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$upFor')
+ ORDER BY ID DESC
+ LIMIT 1 ";
+ $prevBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+ If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
+ {
+ $prevBalance = $latestUpdateDetails[0]->Balance;
+ }else{
+ }
+
+ if($Arr['Name'] == 'I002') {
+ //Income
+ $Arr['Balance'] = $prevBalance + $Arr['Amount'];
+ }else if ($Arr['Name'] == 'I001') {
+ //Expense
+ $Arr['Balance'] = $prevBalance - $Arr['Amount'];
+ } else {
+ $Arr['Balance'] = 0;
+ }
+
+ $this->db->where('ID', $upFor);
+ $this->db->update(DAYBOOKMASTER, $Arr);
+ if ($this->db->affected_rows() == '1') {
+
+ $currBalance = 0;
+ $sql1 = "SELECT * FROM ".DAYBOOKMASTER." WHERE BranchCode = '$branch' AND ID = '$upFor'";
+ $latestUpdate1 = $this->db->query($sql1);
+ $latestUpdateDetails1 = $latestUpdate1->result();
+ $currBalance = $latestUpdateDetails1[0]->Balance;
+
+ $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$upFor')
+ ORDER BY ID ASC";
+ $latestUpdate2 = $this->db->query($sql2);
+ $latestUpdateDetails2 = $latestUpdate2->result();
+
+ foreach( $latestUpdateDetails2 as $clip){
+ if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Income
+ $currBalance = $currBalance + $clip->Amount;
+ }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Expense
+ $currBalance = $currBalance - $clip->Amount;
+ } else {
+ }
+ $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ $this->db->query($updateSql);
+ }
+ $result['updateDetailsStatus'] = true;
+ $result['message'] = "Successfully Details Updated";
+ } else {
+ $result['updateDetailsStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ // add dayBook
+ public function add_dayBook($Arr)
+ {
+ $voucherNo = $Arr['VoucherNumber'];
+ $sqlCheck = "SELECT * FROM ".DAYBOOKMASTER." WHERE VoucherNumber = '$voucherNo'";
+ // print_r($this->db->query($sqlCheck));exit();
+ $checkAdd = $this->db->query($sqlCheck);
+ $checkAddDetails = $checkAdd->result();
+ if(count( $checkAddDetails ) > 0){
+ $result['addDayBookStatus'] = false;
+ $result['message'] = "This Voucher Number Already Exist.";
+ }else{
+ $branch = $Arr['BranchCode'];
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE BranchCode = '$branch'
+ ORDER BY ID DESC
+ LIMIT 1";
+ $prevBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+
+ If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
+ {
+ $prevBalance = $latestUpdateDetails[0]->Balance;
+ }else{
+ }
+
+ if($Arr['Name'] == 'I002') {
+ //Income
+ $Arr['Balance'] = $prevBalance + $Arr['Amount'];
+ }else if ($Arr['Name'] == 'I001') {
+ //Expense
+ $Arr['Balance'] = $prevBalance - $Arr['Amount'];
+ } else {
+ $Arr['Balance'] = 0;
+ }
+
+ $this->db->insert(DAYBOOKMASTER, $Arr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addDayBookStatus'] = true;
+ $result['message'] = "Successfully DayBook Details Added";
+ } else {
+ $result['addDayBookStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+}
+
+ return $result;
+ }
+
+ // approve/reject status updation for the daybook expense details
+ public function update_status_admin($arr) {
+
+ $Approval_By = $arr[0]['Approval_By'];
+ $Approval_Comments = $arr[0]['Approval_Comments'];
+ $UpdatedBy = $arr[0]['UpdatedBy'];
+ $UpdatedOn = $arr[0]['UpdatedOn'];
+ $status = $arr[0]['Status'];
+ // $number = array();
+ // foreach($arr as $ar){
+ // array_push($number, $ar['ID']);
+ // }
+ // $updateFor = implode(',', $number);
+ $updateFor = $arr[0]['ID'];
+ if( $status == "Pending" || $status == "Approved" || $status == "approved" || $status == "pending"){
+
+ $mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$updateFor'";
+ $updateDetails = $this->db->query($mysql);
+ $updateDataDetails = $updateDetails->result();
+ $branch = $updateDataDetails[0]->BranchCode;
+ $Amount = 0;
+ $Amount = $updateDataDetails[0]->Amount;
+
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor')
+ ORDER BY ID DESC
+ LIMIT 1 ";
+
+ $currBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+ if($updateDataDetails[0]->Name == 'I002' ) {
+ //Income
+ $currBalance = $latestUpdateDetails[0]->Balance + $Amount;
+ }else if ($updateDataDetails[0]->Name == 'I001') {
+ //Expense
+ $currBalance = $latestUpdateDetails[0]->Balance - $Amount;
+ } else {
+ }
+ // $currBalance = $latestUpdateDetails[0]->Balance + $Amount;
+
+ $sql = "UPDATE ".DAYBOOKMASTER."
+ SET Status = '$status', Approval_By = '$Approval_By' ,
+ Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance'
+ WHERE id = '$updateFor' ";
+ $mBranchDetails = $this->db->query($sql);
+ // echo $mBranchDetails;
+ // echo $this->db->affected_rows(); exit();
+ if ($this->db->affected_rows() >= 1) {
+ $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor')
+ ORDER BY ID ASC";
+ $latestUpdate2 = $this->db->query($sql2);
+ $latestUpdateDetails2 = $latestUpdate2->result();
+ foreach( $latestUpdateDetails2 as $clip){
+ if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Income
+ $currBalance = $currBalance + $clip->Amount;
+ }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Expense
+ $currBalance = $currBalance - $clip->Amount;
+ } else {
+ }
+ $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ $this->db->query($updateSql);
+ }
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Details Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else if( $status == "Rejected" || $status == "rejected" ) {
+ $mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$updateFor'";
+ $updateDetails = $this->db->query($mysql);
+ $updateDataDetails = $updateDetails->result();
+ $branch = $updateDataDetails[0]->BranchCode;
+ $Amount = 0;
+ $Amount = $updateDataDetails[0]->Amount;
+ if($updateDataDetails[0]->PaymentStatus === '1' || $updateDataDetails[0]->PaymentStatus === '0'){
+
+
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor')
+ ORDER BY ID DESC
+ LIMIT 1 ";
+
+ $currBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+ $currBalance = $latestUpdateDetails[0]->Balance;
+
+ $sql = "UPDATE ".DAYBOOKMASTER."
+ SET Status = '$status', Approval_By = '$Approval_By' ,
+ Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance'
+ WHERE id = '$updateFor' ";
+ $mBranchDetails = $this->db->query($sql);
+ // echo $mBranchDetails;
+ // echo $this->db->affected_rows(); exit();
+ if ($this->db->affected_rows() >= 1) {
+ $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor')
+ ORDER BY ID ASC";
+ $latestUpdate2 = $this->db->query($sql2);
+ $latestUpdateDetails2 = $latestUpdate2->result();
+ foreach( $latestUpdateDetails2 as $clip){
+ if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Income
+ $currBalance = $currBalance + $clip->Amount;
+ }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ //Expense
+ $currBalance = $currBalance - $clip->Amount;
+ } else {
+ }
+ $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ $this->db->query($updateSql);
+ }
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Details Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ // else if($updateDataDetails[0]->PaymentStatus === '0') {
+ // $currentVoucheNumber = $updateDataDetails[0]->VoucherNumber;
+ // $mySql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND VoucherNumber = '$currentVoucheNumber')
+ // ORDER BY ID ASC
+ // LIMIT 1 ";
+ // $mySqlUpdate = $this->db->query($mySql);
+ // $mySqlUpdateDetails = $mySqlUpdate->result();
+ // $mySqlUpdateDetailsID = $mySqlUpdateDetails[0]->ID;
+
+ // $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$mySqlUpdateDetailsID')
+ // ORDER BY ID DESC
+ // LIMIT 1 ";
+ // $currBalance = 0;
+ // $latestUpdate = $this->db->query($sql);
+ // $latestUpdateDetails = $latestUpdate->result();
+ // If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
+ // {
+ // $currBalance = $latestUpdateDetails[0]->Balance;
+ // }else{
+ // }
+ // $sql = "UPDATE ".DAYBOOKMASTER."
+ // SET Status = '$status', Approval_By = '$Approval_By' ,
+ // Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance'
+ // WHERE VoucherNumber = '$currentVoucheNumber' ";
+ // $mBranchDetails = $this->db->query($sql);
+ // if ($this->db->affected_rows() >= 1) {
+ // $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor')
+ // ORDER BY ID ASC";
+ // $latestUpdate2 = $this->db->query($sql2);
+ // $latestUpdateDetails2 = $latestUpdate2->result();
+ // foreach( $latestUpdateDetails2 as $clip){
+ // if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ // //Income
+ // $currBalance = $currBalance + $clip->Amount;
+ // }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) {
+ // //Expense
+ // $currBalance = $currBalance - $clip->Amount;
+ // } else {
+ // }
+ // $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
+ // $this->db->query($updateSql);
+ // }
+ // $result['addStatus'] = true;
+ // $result['message'] = "Successfully Details Updated";
+ // } else {
+ // $result['addStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+
+ // }
+ }
+ return $result;
+ }
+
+ // daybook full details for super admin view
+ public function get_Daybook_Details_List_superAdmin($reqData, $reqDataBy){
+
+ if($reqData['date'] != '' && $reqData['dateTo'] != '') {
+ $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name ');
+ $this->db->from(''.DAYBOOKMASTER. ' as t1');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
+ $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
+ $this->db->join('' . BRANCH . ' as t4', 't4.BranchCode = t1.BranchCode', 'LEFT');
+ $this->db->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT');
+ $this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', 'LEFT');
+ $this->db->where('t1.Date >=', $reqData['date']);
+ $this->db->where('t1.Date <=', $reqData['dateTo']);
+ $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $dayBookDetails = $this->db->get();
+ $dayBookDetailsList = $dayBookDetails->result();
+ } else {
+ $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name ');
+ $this->db->from(''.DAYBOOKMASTER. ' as t1');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
+ $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
+ $this->db->join('' . BRANCH . ' as t4', 't4.BranchCode = t1.BranchCode', 'LEFT');
+ $this->db->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT');
+ $this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', 'LEFT');
+ // $this->db->where('t1.Date', $reqData['date']);
+ $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $dayBookDetails = $this->db->get();
+ $dayBookDetailsList = $dayBookDetails->result();
+ }
+
+ $results['dayBookListStatus'] = true;
+ $results['dayBookListDetails'] = $dayBookDetailsList;
+ return $results;
+ }
+}
\ No newline at end of file
diff --git a/api/application/models/DaybookMaster_model.php b/api/application/models/DaybookMaster_model.php
new file mode 100644
index 0000000..5f17816
--- /dev/null
+++ b/api/application/models/DaybookMaster_model.php
@@ -0,0 +1,116 @@
+db->select('TypeName');
+ $this->db->where('TypeName', $arrayDetails['TypeName']);
+ $this->db->where('TypeID', $arrayDetails['TypeID']);
+ if($this->db->get(INCOMEOUTCOMEMASTER)->first_row()){
+ $result['addStatus'] = false;
+ $result['message'] = "Name is already exist!";
+ } else {
+ $this->db->insert(INCOMEOUTCOMEMASTER, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Day Book Master Details Added";
+ }
+ else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+
+
+
+ return $result;
+
+ }
+
+
+
+ /*
+ * get day book details
+ * created by kms
+ * */
+
+ public function getDayBookDetails($requestedBy=null)
+ {
+ $this->db->select('IOM.ID,IOM.TypeName,IOM.TypeID,IOM.IsActive,PLD.ListName');
+
+ $this->db->from(INCOMEOUTCOMEMASTER .' as IOM');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = IOM.TypeID');
+ $this->db->order_by('IOM.ID','DESC');
+ $details = $this->db->get();
+ if($details->result()){
+
+ $result['daybookStatus'] = true;
+ $result['details'] = $details->result();
+ }
+ else {
+ $result['daybookStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+ $result['getDayBooktype'] = $this->getDayBookType('10');
+
+ return $result;
+
+ }
+ /*
+ * get day book type
+ * created by kms
+ * */
+ public function getDayBookType($typeID=null){
+ $this->db->select('ListCode,ListName');
+ $this->db->where('ListGroup', $typeID);
+ $typeDetails=$this->db->get(PICK_LIST_DETAILS);
+ return $typeDetails->result();
+ }
+ /*
+ * update day book details
+ * created by kms
+ * */
+
+ public function updateDayBook($arrayDetails=null)
+ {
+ $this->db->select('TypeName');
+ $this->db->where('TypeName', $arrayDetails['TypeName']);
+ $this->db->where('TypeID', $arrayDetails['TypeID']);
+ $this->db->where_not_in('ID', $arrayDetails['ID']);
+ if($this->db->get(INCOMEOUTCOMEMASTER)->first_row()){
+ $result['updateStatus'] = false;
+ $result['message'] = "Name is already exist!";
+ } else {
+ $this->db->where('ID',$arrayDetails['ID']);
+ $this->db->update(INCOMEOUTCOMEMASTER, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['updateStatus'] = true;
+ $result['message'] = "Successfully Day Book Details Updated";
+ }
+ else {
+ $result['updateStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+ return $result;
+
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Employee_model.php b/api/application/models/Employee_model.php
new file mode 100644
index 0000000..73b4bb1
--- /dev/null
+++ b/api/application/models/Employee_model.php
@@ -0,0 +1,815 @@
+db->select('StaffID');
+ $this->db->from(LOGIN);
+ $this->db->where('ID', $empLoginID);
+ $loginEmpDetail = $this->db->get()->first_row();
+ if ($loginEmpDetail) {
+ $EmpId = $loginEmpDetail->StaffID;
+ $this->db->select('t1.*');
+ $this->db->from('' . STAFF . ' as t1');
+ $this->db->where('t1.StaffID', $EmpId);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $responseDetails = $this->db->get()->first_row();
+ $result['empStatus'] = true;
+ // print_r($responseDetails->ListCode);exit();
+
+ if ($responseDetails->ListCode == SUPER_ADMIN) {
+ // print_r($result['details']->ListCode);exit();
+ // get branch details for super admin
+ $responseDetails->BranchCode = 'All';
+ $result['details'] = $responseDetails;
+ // print_r($result['details']);exit();
+ $this->db->select('t3.BranchCode, t3.BranchName');
+ $this->db->from('' . STAFF_BRANCH . ' as t2');
+ $this->db->where('t2.StaffID', $EmpId);
+ $this->db->where('t2.IsActive', 1);
+ $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT');
+ $this->db->where('t3.IsActive', 1);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $branchDetails = $this->db->get();
+ $getArrs = $branchDetails->result();
+ $SS['BranchCode'] = 'All';
+ $SS['BranchName'] = 'All';
+
+ array_push($getArrs, $SS);
+ // print_r($getArrs);exit();
+ $result['branchStatus'] = true;
+ $result['branch_details'] = $getArrs;
+ $result['work_State'] = 'Super Admin';
+
+ } else {
+ // get branch details for admin & staff
+ $result['details'] = $responseDetails;
+ $this->db->select('t3.BranchCode, t3.BranchName, ');
+ $this->db->from('' . STAFF_BRANCH . ' as t2');
+ $this->db->where('t2.StaffID', $EmpId);
+ $this->db->where('t2.IsActive', 1);
+ $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT');
+ $this->db->where('t3.IsActive', 1);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $branchDetails = $this->db->get();
+ $result['branchStatus'] = true;
+ $result['work_State'] = $responseDetails->ListCode == ADMIN ? 'Admin' : 'Staff';
+ $result['branch_details'] = $branchDetails->result();
+ }
+ } else {
+ $result['empStatus'] = false;
+ $result['message'] = "Something Went Wrong, Please try Again !!";
+ }
+ return $result;
+ }
+
+ // get single employee details
+ public function get_emp_detail($empLoginID = null)
+ {
+ $this->db->select('StaffID,ListCode');
+ $this->db->from(LOGIN);
+ $this->db->where('ID', $empLoginID);
+ $loginEmpDetail = $this->db->get()->first_row();
+ if ($loginEmpDetail) {
+ $EmpId = $loginEmpDetail->StaffID;
+ if($loginEmpDetail->ListCode != STUDENT){
+ $this->db->select('t1.*');
+ $this->db->from('' . STAFF . ' as t1');
+ $this->db->where('t1.StaffID', $EmpId);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $responseDetails = $this->db->get()->first_row();
+ $result['empStatus'] = true;
+ // print_r($result['details']);exit();
+
+ if ($responseDetails->ListCode == SUPER_ADMIN) {
+ // print_r($result['details']->ListCode);exit();
+ // get branch details for super admin
+ $responseDetails->BranchCode = 'All';
+ $result['details'] = $responseDetails;
+ // print_r($result['details']);exit();
+ $this->db->select('t3.BranchCode, t3.BranchName');
+ $this->db->from('' . STAFF_BRANCH . ' as t2');
+ $this->db->where('t2.StaffID', $EmpId);
+ $this->db->where('t2.IsActive', 1);
+ $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT');
+ $this->db->where('t3.IsActive', 1);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $branchDetails = $this->db->get();
+ $getArrs = $branchDetails->result();
+ $SS['BranchCode'] = 'All';
+ $SS['BranchName'] = 'All';
+ array_push($getArrs, $SS);
+ // print_r($getArrs);exit();
+ $result['branchStatus'] = true;
+ $result['branch_details'] = $getArrs;
+
+ } else {
+ // get branch details for admin & staff
+ $result['details'] = $responseDetails;
+ $this->db->select('t3.BranchCode, t3.BranchName, t2.ListCode , t4.ListName, t2.FinanceModuleAccess');
+ $this->db->from('' . STAFF_BRANCH . ' as t2');
+ $this->db->where('t2.StaffID', $EmpId);
+ $this->db->where('t2.IsActive', 1);
+ $this->db->order_by('t2.CreatedOn', 'ACS');
+ $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t4', 't4.ListCode = t2.ListCode', 'LEFT');
+ // $this->db->where('t3.IsActive', 1);STAFF_BRANCH
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $branchDetails = $this->db->get();
+ $result['branchStatus'] = true;
+ $result['branch_details'] = $branchDetails->result();
+ }
+ }
+ elseif ($loginEmpDetail->ListCode == STUDENT){
+ $this->db->select('ST.*');
+ $this->db->from('' . STUDENTS . ' as ST');
+ $this->db->where('ST.StudentID', $EmpId);
+ // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $responseDetails = $this->db->get()->first_row();
+ $result['empStatus'] = true;
+ $result['details'] = $responseDetails;
+ $result['branch_details'] = "";
+
+ }
+
+ } else {
+ $result['empStatus'] = false;
+ $result['message'] = "Something Went Wrong, Please try Again !!";
+ }
+ return $result;
+
+ }
+
+ // get employee list based on login user
+ public function get_employee_list($loginUserId, $loginUserBranchId, $loginUserType)
+ {
+ // echo $loginUserId, $loginUserBranchId, $loginUserType; exit();
+ if ($loginUserType == SUPER_ADMIN) {
+ // list for super admin
+ if ($loginUserBranchId == 'All') {
+ // for getting all branch details
+ $staffId = $this->selfGetEmpId($loginUserId);
+ $this->db->select('t1.*');
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $this->db->from('' . STAFF . ' as t1');
+ // $this->db->join('' . STAFF_BRANCH . ' as t3', 't3.StaffID = t1.StaffID', 'LEFT');
+ // not for SuperAdmin and Student Role code
+ $this->db->where_not_in('t1.StaffID', $staffId);
+ // $this->db->group_by('t3.StaffID');
+ // $this->db->where('BranchCode', $loginUserBranchId);
+ $empDetails = $this->db->get();
+ $checkArr = $empDetails->result();
+ if (count($checkArr) > 0) {
+ $results['employeeList'] = true;
+ $results['employees_details'] = $empDetails->result();
+ } else {
+ $results['employeeList'] = false;
+ $results['message'] = 'No record found';
+ }
+ } else {
+ $staffId = $this->selfGetEmpId($loginUserId);
+ $this->db->select('t2.*');
+ $this->db->from('' . STAFF_BRANCH . ' as t1');
+
+ $this->db->join('' . STAFF . ' as t2', 't2.StaffID = t1.StaffID', 'LEFT');
+
+ // not for SuperAdmin and Student Role code
+ $this->db->where_not_in('t1.StaffID', $staffId);
+ $this->db->group_by('t1.StaffID');
+ $this->db->where('t1.BranchCode', $loginUserBranchId);
+ $this->db->where('t1.ListCode', EMPLOYEE);
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $empDetails = $this->db->get();
+ $checkArr = $empDetails->result();
+ if (count($checkArr) > 0) {
+ $results['employeeList'] = true;
+ $results['employees_details'] = $empDetails->result();
+ } else {
+ $results['employeeList'] = false;
+ $results['message'] = 'No record found';
+ }
+
+ }
+
+ } else if ($loginUserType == ADMIN) {
+ // list for admin
+ $staffId = $this->selfGetEmpId($loginUserId);
+ $this->db->select('t2.*');
+ $this->db->from('' . STAFF_BRANCH . ' as t1');
+
+ $this->db->join('' . STAFF . ' as t2', 't2.StaffID = t1.StaffID', 'LEFT');
+
+ // not for SuperAdmin and Student Role code
+ $this->db->where_not_in('t1.StaffID', $staffId);
+ $this->db->group_by('t1.StaffID');
+ $this->db->where('t1.BranchCode', $loginUserBranchId);
+ $this->db->where('t1.ListCode', EMPLOYEE);
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $empDetails = $this->db->get();
+ $checkArr = $empDetails->result();
+ if (count($checkArr) > 0) {
+ $results['employeeList'] = true;
+ $results['employees_details'] = $empDetails->result();
+ } else {
+ $results['employeeList'] = false;
+ }
+ } else {
+ $results['employeeList'] = false;
+ }
+ return $results;
+ }
+
+ // get role details based on login user
+ public function get_req_role_detail($reqRoleId)
+ {
+ // echo $reqRoleId;exit();
+ if ($reqRoleId == SUPER_ADMIN) {
+ // res for SuperAdmin
+ $this->db->select('ListCode, ListName');
+ $this->db->from(PICK_LIST_DETAILS);
+ // not for SuperAdmin and Student Role code
+ $this->db->where_not_in('ListCode', $reqRoleId);
+ $this->db->where_not_in('ListCode', 'R001');
+ // end : not for SuperAdmin and Student Role code
+ $this->db->where('ListGroup', 0);
+ $this->db->where('IsActive', 1);
+ $roleDetails = $this->db->get();
+ $result['RoleDetailStatus'] = true;
+ $result['role_details'] = $roleDetails->result();
+ } else {
+ // res for Admin
+ $this->db->select('ListCode, ListName');
+ $this->db->from(PICK_LIST_DETAILS);
+ // not for SuperAdmin and Admin and Student Role code
+ $this->db->where_not_in('ListCode', $reqRoleId);
+ $this->db->where_not_in('ListCode', 'R001');
+ $this->db->where_not_in('ListCode', 'R004');
+ // end : not for SuperAdmin and Admin and Student Role code
+ $this->db->where('ListGroup', 0);
+ $this->db->where('IsActive', 1);
+ $roleDetails = $this->db->get();
+ $result['RoleDetailStatus'] = true;
+ $result['role_details'] = $roleDetails->result();
+ }
+ return $result;
+ }
+
+ // get branch details based on login user
+ public function get_req_master_branch_detail($reqRoleId, $reqUserID)
+ {
+ if ($reqRoleId == SUPER_ADMIN) {
+ // res for SuperAdmin
+ $this->db->select('BranchCode, BranchName');
+ $this->db->from(BRANCH);
+ $this->db->where('IsActive', 1);
+ $mBranchDetails = $this->db->get();
+ $results['MeasterBranchDetailStatus'] = true;
+ $results['branch_details'] = $mBranchDetails->result();
+ } else {
+ // res for Admin
+ $staffId = $this->selfGetEmpId($reqUserID);
+ $subQuery = "SELECT t1.BranchCode, t1.BranchName
+ FROM T_BranchMaster as t1
+ LEFT JOIN T_Staff_BranchAccess as t2 ON t2.StaffID = '$staffId'
+ WHERE t2.BranchCode = t1.BranchCode
+ AND t1.IsActive = 1
+ AND t2.IsActive = 1";
+ $mBranchDetails = $this->db->query($subQuery);
+ $results['MeasterBranchDetailStatus'] = true;
+ $results['branch_details'] = $mBranchDetails->result();
+ }
+ return $results;
+
+ }
+
+ // check exist
+ public function check_exist($data, $checkData)
+ {
+ if ($checkData == 'employeeId') {
+ // check for employee id
+ $this->db->select('*');
+ $this->db->from(STAFF);
+ $this->db->where('StaffID', $data);
+ if ($this->db->get()->first_row()) {
+ $result['existEmpId'] = true;
+ $result['message'] = "This Employee ID is already exist!";
+ } else {
+ $result['existEmpId'] = false;
+ }
+
+ } else if ($checkData == 'mobileNumber') {
+ // check for mobile number
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $data);
+ if ($this->db->get()->first_row()) {
+ $result['existMobile'] = true;
+ $result['message'] = "This Mobile Number is already exist!";
+ } else {
+ $result['existMobile'] = false;
+ }
+
+ } else if ($checkData == 'emailId') {
+ // check for email id
+ $this->db->select('*');
+ $this->db->from(STAFF);
+ $this->db->where('EmailID', $data);
+ if ($this->db->get()->first_row()) {
+ $result['existEmailId'] = true;
+ $result['message'] = "This EmailId is already exist!";
+ } else {
+ $result['existEmailId'] = false;
+ }
+ } else {
+ }
+ return $result;
+ }
+
+ // add employee
+ public function add_employee($empArr, $createdBy, $imageName, $imageSource, $imageSize)
+ {
+ // print_r($empArr);exit();
+ if( $imageSource == '') { // add employee without image
+ $imageNameDb = 'default.jpeg';
+ $empArr['ProfilePicPath'] = "employee/".$imageNameDb;
+ $this->db->insert(STAFF, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $branchArr['StaffID'] = $empArr['StaffID'];
+ $branchArr['BranchCode'] = $empArr['BranchCode'];
+ $branchArr['IsActive'] = $empArr['IsActive'];
+ $branchArr['CreatedBy'] = $createdBy;
+ $branchArr['ListCode'] = $empArr['ListCode'];
+ $branchArr['JobResponsibility'] = $empArr['JobResponsibility'];
+ $branchArr['FinanceModuleAccess'] = $empArr['FinanceModuleAccess'];
+ $branchArr['HomeBranch'] = 1;
+ $this->db->insert(STAFF_BRANCH, $branchArr);
+ if ($this->db->affected_rows() == '1') {
+ $loginArr['StaffID'] = $empArr['StaffID'];
+ $loginArr['ListCode'] = $empArr['ListCode'];
+ // $loginArr['MobileNumber'] = $empArr['MobileNumber'];
+ $loginArr['MobileNumber'] = $empArr['StaffID'];
+ $loginArr['EmailId'] = $empArr['EmailID'];
+ $loginArr['IsActive'] = $empArr['IsActive'];
+ $loginArr['CreatedBy'] = $createdBy;
+ $loginArr['Password'] = ENCR_PASSWORD;
+ $this->db->insert(LOGIN, $loginArr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addEmpStatus'] = true;
+ $result['message'] = "Successfully employee details added";
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else { // add employee with image
+ $target = "../images/employee/";
+ $getUploadStatus = $this->upload_image($imageSource, $imageSize, $target);
+ $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
+ $empArr['ProfilePicPath'] = "employee/".$imageNameDb;
+ $this->db->insert(STAFF, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $branchArr['StaffID'] = $empArr['StaffID'];
+ $branchArr['BranchCode'] = $empArr['BranchCode'];
+ $branchArr['IsActive'] = $empArr['IsActive'];
+ $branchArr['CreatedBy'] = $createdBy;
+ $branchArr['ListCode'] = $empArr['ListCode'];
+ $branchArr['JobResponsibility'] = $empArr['JobResponsibility'];
+ $branchArr['FinanceModuleAccess'] = $empArr['FinanceModuleAccess'];
+ $branchArr['HomeBranch'] = 1;
+ $this->db->insert(STAFF_BRANCH, $branchArr);
+ if ($this->db->affected_rows() == '1') {
+ $loginArr['StaffID'] = $empArr['StaffID'];
+ $loginArr['ListCode'] = $empArr['ListCode'];
+ // $loginArr['MobileNumber'] = $empArr['MobileNumber'];
+ $loginArr['MobileNumber'] = $empArr['StaffID'];
+ $loginArr['EmailId'] = $empArr['EmailID'];
+ $loginArr['IsActive'] = $empArr['IsActive'];
+ $loginArr['CreatedBy'] = $createdBy;
+ $loginArr['Password'] = ENCR_PASSWORD;
+ $this->db->insert(LOGIN, $loginArr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addEmpStatus'] = true;
+ $result['message'] = "Successfully employee details added";
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['addEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+ }
+
+ // check existing data while update
+ public function check_update_exist($exceptId, $datas, $checkFor)
+ {
+ if ($checkFor == 'mobileNumber') {
+ // check update for mobile number
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $datas);
+ $this->db->where_not_in('StaffID', $exceptId);
+ if ($this->db->get()->first_row()) {
+ $result['existMobile'] = true;
+ $this->db->select('MobileNumber');
+ $this->db->from(STAFF);
+ $this->db->where('StaffID', $exceptId);
+ $result['resetValue'] = $this->db->get()->first_row();
+ $result['message'] = "This Mobile Number is already exist!";
+ } else {
+ $result['existMobile'] = false;
+ }
+
+ } else if ($checkFor == 'emailId') {
+ // check update for email
+ $this->db->select('*');
+ $this->db->from(STAFF);
+ $this->db->where('EmailID', $datas);
+ $this->db->where_not_in('StaffID', $exceptId);
+ if ($this->db->get()->first_row()) {
+ $result['existEmailId'] = true;
+ $this->db->select('EmailID');
+ $this->db->from(STAFF);
+ $this->db->where('StaffID', $exceptId);
+ $result['resetValue'] = $this->db->get()->first_row();
+ $result['message'] = "This EmailId is already exist!";
+ } else {
+ $result['existEmailId'] = false;
+ }
+ } else {
+ }
+ return $result;
+ }
+
+ // update employee personal details
+ public function update_employee($empArr, $updateFor, $imageName, $imageSource, $imageSize)
+ {
+ if( $imageSource == '') { // update Employee without image
+ // $this->db->select('*');
+ // $this->db->from(STAFF);
+ // $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ // $this->db->where_not_in('StaffID', $updateFor);
+ // if ($this->db->get()->first_row()) {
+ // $result['updateEmpStatus'] = false;
+ // $result['message'] = "This Mobile Number Already Exist";
+ // }else {
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $updateFor);
+ $this->db->where_not_in('StaffID', $updateFor);
+ if($this->db->get()->first_row()) {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ } else {
+ $this->db->where('StaffID', $updateFor);
+ $this->db->update(STAFF, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $mobile = $empArr['MobileNumber'];
+ $email = $empArr['EmailID'];
+ $active = $empArr['IsActive'];
+ $updatedBy = $empArr['UpdatedBy'];
+ $updatedOn = $empArr['UpdatedOn'];
+ $sql = "UPDATE ".LOGIN." SET EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'";
+ if($this->db->query($sql) == '1'){
+ $result['updateEmpStatus'] = true;
+ $result['message'] = "Successfully employee details Updated";
+ } else {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ // }
+ }
+ else { // update employee with image
+
+ // $this->db->select('*');
+ // $this->db->from(STAFF);
+ // $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ // $this->db->where_not_in('StaffID', $updateFor);
+ // if ($this->db->get()->first_row()) {
+ // $result['updateEmpStatus'] = false;
+ // $result['message'] = "This Mobile Number Already Exist";
+ // }else {
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ $this->db->where_not_in('StaffID', $updateFor);
+ if($this->db->get()->first_row()) {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ } else {
+ $target = "../images/employee/";
+ $getUploadStatus = $this->upload_image($imageSource, $imageSize, $target);
+ $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
+ $empArr['ProfilePicPath'] = "employee/".$imageNameDb;
+ $this->db->select('ProfilePicPath');
+ $this->db->from(STAFF);
+ $this->db->where('StaffID', $updateFor);
+ $roleDetails = $this->db->get()->first_row();
+ // echo $roleDetails->ProfilePicPath;
+ // exit();
+ if( $roleDetails->ProfilePicPath != '' && $roleDetails->ProfilePicPath != 'employee/default.jpeg'){
+ unlink('../images/'.$roleDetails->ProfilePicPath);
+ } else {
+ }
+ $this->db->where('StaffID', $updateFor);
+ $this->db->update(STAFF, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $mobile = $empArr['MobileNumber'];
+ $email = $empArr['EmailID'];
+ $active = $empArr['IsActive'];
+ $updatedBy = $empArr['UpdatedBy'];
+ $updatedOn = $empArr['UpdatedOn'];
+ $sql = "UPDATE ".LOGIN." SET EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'";
+ if($this->db->query($sql) == '1'){
+ $result['updateEmpStatus'] = true;
+ $result['message'] = "Successfully employee details Updated";
+ } else {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ } else {
+ $result['updateEmpStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ // }
+ }
+ return $result;
+ }
+
+ // get employee branch details
+ public function get_employee_branch($staffId)
+ {
+ // $this->db->select('t3.ListCode, t3.ListName, t4.JobResponsibility, t4.FinanceModuleAccess');
+ // $this->db->from('' . PICK_LIST_DETAILS . ' as t3');
+ // $this->db->join('' . STAFF . ' as t4', 't4.ListCode = t3.ListCode', 'LEFT');
+ // $this->db->where('t4.StaffID', $staffId);
+ // $roleDetails = $this->db->get();
+ // $checkArr = $roleDetails->result();
+ // if (count($checkArr) > 0) {
+ $this->db->select('t1.*, t2.BranchName, t3.ListName');
+ $this->db->from('' . STAFF_BRANCH . ' as t1');
+ $this->db->join('' . BRANCH . ' as t2', 't2.BranchCode = t1.BranchCode', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t3', 't3.ListCode = t1.ListCode', 'LEFT');
+ $this->db->where('t1.StaffID', $staffId);
+ // $this->db->where('t2.IsActive', 1);
+ // $this->db->where('t1.IsActive', 1);
+ $branchDetails = $this->db->get();
+ $branchArr = $branchDetails->result();
+ if( count($branchArr) > 0 ) {
+ $result['empBranchDetails'] = true;
+ $result['branch_details'] = $branchArr;
+ } else {
+ $result['empBranchDetails'] = false;
+ $result['message'] = "No Employee Branch Details";
+ }
+ // } else {
+ // $result['empBranchDetails'] = false;
+ // }
+ // print_r($result);exit();
+ return $result;
+ }
+
+ public function get_branch_code($name) {
+ $this->db->select('BranchCode');
+ $this->db->from(BRANCH);
+ $this->db->where('BranchName', $name);
+ $roleDetails = $this->db->get()->first_row();
+ return $roleDetails->BranchCode;
+ }
+
+
+ public function add_employee_branch($req) {
+ $staffID = $req['StaffID'];
+ $BranchCode = $req['BranchCode'];
+ $this->db->select('*');
+ $this->db->from(STAFF_BRANCH);
+ $this->db->where('StaffID', $staffID);
+ $this->db->where('BranchCode', $BranchCode);
+ $roleDetails = $this->db->get()->first_row();
+ if(count($roleDetails) > 0) {
+ $result['addEmpbranchStatus'] = false;
+ $result['message'] = "Already Employee Exist for this Branch.";
+ } else {
+ $req['HomeBranch'] = 0;
+ $this->db->insert(STAFF_BRANCH, $req);
+ if ($this->db->affected_rows() == '1') {
+ $result['addEmpbranchStatus'] = true;
+ $result['message'] = "Successfully employee branch details Added";
+
+ } else {
+ $result['addEmpbranchStatus'] = false;
+ $result['message'] = "Something went wrong.";
+ }
+ }
+ return $result;
+ }
+
+
+ // update employee branch details
+ public function upate_employee_branch($updateFor, $req)
+ {
+ // print_r($req);
+ // echo $updateFor;exit();
+ $staffID = $req['StaffID'];
+ $BranchCode = $req['BranchCode'];
+ $this->db->select('*');
+ $this->db->from(STAFF_BRANCH);
+ $this->db->where('ID', $updateFor);
+ $this->db->where_not_in('BranchCode', $BranchCode);
+ $roleDetails = $this->db->get()->first_row();
+ // print_r($roleDetails);exit();
+ if(count($roleDetails) > 0) {
+ $result['updateEmpbranchStatus'] = false;
+ $result['message'] = "Already Employee Exist for this Branch.";
+ } else {
+ if($req['HomeBranch'] == 1) {
+ $this->db->where('ID', $updateFor);
+ $this->db->update( STAFF_BRANCH , $req);
+ if ($this->db->affected_rows() == '1') {
+ $listCode = $req['ListCode'];
+ $empFor = $req['StaffID'];
+ $branchCode = $req['BranchCode'];
+ $roleResponsibility = $req['JobResponsibility'];
+ $FinanceModuleAccess = $req['FinanceModuleAccess'];
+ $sql = "UPDATE ".LOGIN." SET ListCode ='$listCode' WHERE StaffID='$empFor'";
+ if ($this->db->query($sql) == '1') {
+ $sql1 = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility', FinanceModuleAccess= '$FinanceModuleAccess' WHERE StaffID='$empFor'";
+ if ($this->db->query($sql1) == '1') {
+ $result['updateEmpbranchStatus'] = true;
+ $result['message'] = "Successfully employee branch details Updated";
+ } else {
+ $result['updateEmpbranchStatus'] = false;
+ $result['message'] = "Something Went Wrong.";
+ }
+ } else {
+ $result['updateEmpbranchStatus'] = false;
+ $result['message'] = "Something Went Wrong.";
+ }
+ } else {
+ $result['updateEmpbranchStatus'] = false;
+ $result['message'] = "Something Went Wrong.";
+ }
+ } else {
+ $this->db->where('ID', $updateFor);
+ $this->db->update( STAFF_BRANCH , $req);
+ if ($this->db->affected_rows() == '1') {
+ $result['updateEmpbranchStatus'] = true;
+ $result['message'] = "Successfully employee branch details Updated";
+ } else {
+ $result['updateEmpbranchStatus'] = false;
+ $result['message'] = "Something Went Wrong.";
+ }
+ }
+ }
+ return $result;
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->update($req['StaffID'] , $req);
+ // // update role to staff table
+ // if ($this->db->affected_rows() == '1') {
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->update(LOGIN, $req);
+ // // echo $this->db->affected_rows();exit();
+ // // update role to login table
+ // if ($this->db->affected_rows() == '1') {
+ // // $branchCode = $this->get_branch_code($reqBanch['BranchCode'][0]);
+ // $branchCode = $reqBanch['BranchCode'][0];
+ // $roleResponsibility = $reqJOBRES['JobResponsibility'];
+ // $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility', FinanceModuleAccess=$FinanceModuleAccess WHERE StaffID='$empFor'";
+ // // update branch to staff table
+ // if ($this->db->query($sql) == '1') {
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->delete(STAFF_BRANCH);
+ // foreach($reqBanch['BranchCode'] as $something) {
+ // // $branchCode = $this->get_branch_code($something);
+ // $branchCode = $something;
+ // $sql1 = "INSERT INTO ".STAFF_BRANCH." (StaffID, BranchCode, IsActive, CreatedBy, CreatedOn, UpdatedBy, UpdatedOn)
+ // VALUES ('$empFor', '$branchCode', '1','$createby', '$createon', '$createby', '$createon')";
+ // // update branch to staff_branch table
+ // if ($this->db->query($sql1) == '1') {
+ // $result['updateEmpbranchStatus'] = true;
+ // $result['message'] = "Successfully employee branch details Updated";
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // return $result;
+
+ // } else {
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->update(STAFF, $req);
+ // // update role to staff table
+ // if ($this->db->affected_rows() == '1') {
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->update(LOGIN, $req);
+ // // echo $this->db->affected_rows();exit();
+ // // update role to login table
+ // if ($this->db->affected_rows() == '1') {
+ // // $branchCode = $this->get_branch_code($reqBanch['BranchCode'][0]);
+ // $branchCode = $reqBanch['BranchCode'][0];
+ // $roleResponsibility = $reqJOBRES['JobResponsibility'];
+ // $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility', FinanceModuleAccess=$FinanceModuleAccess WHERE StaffID='$empFor'";
+ // // update branch to staff table
+ // if ($this->db->query($sql) == '1') {
+ // $this->db->where('StaffID', $empFor);
+ // $this->db->delete(STAFF_BRANCH);
+ // $sql1 = "INSERT INTO ".STAFF_BRANCH." (StaffID, BranchCode, IsActive, CreatedBy, CreatedOn)
+ // VALUES ('$empFor', '$branchCode', '1','$createby', '$createon')";
+ // // update branch to staff_branch table
+ // if ($this->db->query($sql1) == '1') {
+ // $result['updateEmpbranchStatus'] = true;
+ // $result['message'] = "Successfully employee branch details Updated";
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // } else {
+ // $result['updateEmpbranchStatus'] = false;
+ // $result['message'] = "Something went wrong.please try again";
+ // }
+ // return $result;
+ // }
+
+ }
+
+ public function selfGetEmpId($sID)
+ {
+ $this->db->select('StaffID');
+ $this->db->from(LOGIN);
+ $this->db->where('ID', $sID);
+ $roleDetails = $this->db->get()->first_row();
+ return $roleDetails->StaffID;
+ }
+
+ // image upload in taget path
+ public function upload_image( $imageSource, $size, $target ) {
+ $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 12);
+ $new_regNo = "Dri_" . $key2 . "." . 'jpeg';
+ $targetPlace = $target . $new_regNo;
+ // echo $targetPlace;exit();
+ if(!move_uploaded_file($imageSource , $targetPlace))
+ {
+ return $result['status'] = false;
+ } else {
+ $result['status'] = true;
+ $result['imageName'] = $new_regNo;
+ return $result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/api/application/models/Fees_status_model.php b/api/application/models/Fees_status_model.php
new file mode 100644
index 0000000..67a82e0
--- /dev/null
+++ b/api/application/models/Fees_status_model.php
@@ -0,0 +1,1763 @@
+db->select('ST.StudentID,ST.MobileNumber,ST.Firstname,ST.Fathername,ST.EmailID,STC.ID,US.UniversityID,US.UniversityName,CU.CourseID,CU.CourseName');
+ $this->db->from(STUDENTS.' as ST');
+ $this->db->join(STUDENTCOURSE.' as STC', 'STC.StudentID = ST.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ // $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = STC.SessionID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
+ $this->db->where('ST.IsActive','1');
+ $this->db->where('STC.IsActive','1');
+ if($search['requestedBranch']!='All'){
+ $this->db->where('STC.BranchID',$search['requestedBranch']);
+ }
+ if($search['MobileNumber']!=''){
+ $this->db->where('ST.MobileNumber',$search['MobileNumber']);
+ }
+ if($search['Firstname']!=''){
+ $this->db->like('ST.Firstname',$search['Firstname'],'after');
+ }
+ if($search['UniversityID']!=''){
+ $this->db->where('STC.UniversityID',$search['UniversityID']);
+ }
+ if($search['CourseID']!=''){
+ $this->db->where('STC.CourseID',$search['CourseID']);
+ }
+ /* if($search['MobileNumber']!='' AND $search['Firstname']==''){
+ $this->db->where('ST.MobileNumber',$search['MobileNumber']);
+ }
+ else if($search['MobileNumber']=='' AND $search['Firstname']!=''){
+ $this->db->where('ST.Firstname',$search['Firstname']);
+ }
+ else if($search['MobileNumber']!='' AND $search['Firstname']!=''){
+ $this->db->where('ST.MobileNumber',$search['MobileNumber']);
+ $this->db->where('ST.Firstname',$search['Firstname']);
+ }*/
+ $searchDetails = $this->db->get();
+
+ if($searchDetails->result()) {
+ $result_array['studentStatus'] = true;
+ $result_array['details'] = $searchDetails->result();
+
+
+ }
+ else{
+ $result_array['studentStatus'] = false;
+ $result_array['details'] = "No records found!";
+ }
+ }
+ else{
+ $result_array['studentStatus'] = false;
+ $result_array['details'] = "No records found!";
+ }
+
+ return $result_array;
+
+ }
+
+ /*
+ * get student fees structure for fees update
+ * @params student ID
+ * created by kms
+ * */
+ public function getStudentFeesStructure($student=null){
+ $this->db->select('CF.ID,CF.Sem_Year,CF.ProgramType,SFS.FeesID,SFS.CourseID,SFS.CourseFees,SFS.STFOrWR,SFS.Waiver,SFS.Others,SFS.RollNo,CU.PC,CU.TC,CU.DC,CU.MC,CU.OtherFees,SM.SessionName as SessionName,SM1.SessionName as ToSessionName,BA.BatchCode,BA.BatchName');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
+ $this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
+ $this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode');
+ $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = CF.CourseID');
+ $this->db->where('SFS.CourseID',$student['CourseID']);
+ $this->db->where('SFS.StudentID',$student['StudentID']);
+ $enrolledFeesDetails = $this->db->get();
+ if($enrolledFeesDetails->result()){
+ $result_array['feesStatus']=true;
+ foreach ($enrolledFeesDetails->result() as $row) {
+ $fetchData['ID'] = $row->ID;
+ $fetchData['FeesID'] = $row->FeesID;
+ $fetchData['CourseID'] = $row->CourseID;
+ $fetchData['Sem_Year'] = $row->Sem_Year;
+ $fetchData['ProgramType'] = $row->ProgramType;
+ $fetchData['ActualFees'] = $row->CourseFees;
+ $fetchData['STFOrWR'] = $row->STFOrWR;
+ $fetchData['Waiver'] = $row->Waiver;
+ $fetchData['Others'] = $row->Others;
+ $fetchData['SessionName'] = $row->SessionName;
+ $fetchData['BatchName'] = $row->BatchName;
+ if($row->ToSessionName=='' OR $row->ToSessionName==null){
+ $fetchData['ToSessionName'] = "Not Applicable";
+ }
+ else{
+ $fetchData['ToSessionName'] = $row->ToSessionName;
+ }
+
+ $fetchData['RollNo'] = $row->RollNo;
+ $fetchData['PayableFees']=$row->CourseFees+$row->STFOrWR+$row->Others-$row->Waiver;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId',$row->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+ if($paidBillAmount[0]->PaidBillAmount > $fetchData['PayableFees']){
+ $fetchData['BalanceAmount']=0;
+
+ }
+ else{
+ $fetchData['BalanceAmount']=$fetchData['PayableFees'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+ $fetchData['PC'] = $row->PC;
+ $fetchData['TC'] = $row->TC;
+ $fetchData['DC'] = $row->DC;
+ $fetchData['MC'] = $row->MC;
+ $fetchData['OtherFees'] = $row->OtherFees;
+
+ $CourseFeesArray[]=$fetchData;
+ }
+
+ $getDefaultCourseFees = $this->getDefaultCourseFees($student);
+ if($getDefaultCourseFees!=false){
+ $result_array['feesDetails']=array_merge($CourseFeesArray,$getDefaultCourseFees);
+ }
+ else{
+ $result_array['feesDetails']=$CourseFeesArray;
+ }
+
+
+ // $result_array['getFeesUpdateStatus']=$this->getFeesUpdateStatus(FEESUPDATE);
+ $result_array['getExistStudentFeesDetails']=$this->existStudentFeesDetails($student);
+
+ }
+ else{
+ $result_array['feesStatus']=false;
+ $result_array['message']="This student don't have fees details";
+
+ }
+ return $result_array;
+
+ }
+ /*
+ * get fees update status
+ * created by kms
+ * */
+
+ public function getFeesUpdateStatus($feesID=null)
+ {
+ $this->db->select('PLD.ListCode,PLD.ListName');
+ $this->db->from(DEFAULTACTIVITY.' as DA');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = DA.StatusCode');
+ $this->db->where('StudentActivityCode',$feesID);
+ $this->db->where('DA.IsActive','1');
+ $this->db->where('PLD.IsActive','1');
+ $this->db->order_by('ListCode','ASC');
+ $status = $this->db->get();
+ return $status->result();
+ }
+ /*
+ * get default course fees for bill
+ * creted by kms
+ * */
+ public function getDefaultCourseFees($student=null)
+ {
+ $serachArray = ["PC","TC","DC","MC","OTHER"];
+
+ $this->db->select('SFS.FeesID,SFS.FeesType,SFS.CourseID,SFS.CourseFees,SFS.STFOrWR,SFS.Waiver,SFS.Others,SFS.SessionName,SFS.RollNo,CU.PC,CU.TC,CU.DC,CU.MC,CU.OtherFees');
+ $this->db->from(STUDENTS_FEES_STATUS . ' as SFS');
+ //$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->join(COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
+ $this->db->where('SFS.CourseID', $student['CourseID']);
+ $this->db->where('SFS.StudentID', $student['StudentID']);
+ $this->db->where_in('SFS.FeesType', $serachArray);
+ $enrolledFeesDetails = $this->db->get();
+
+ if ($enrolledFeesDetails->result()) {
+ $result_array['feesStatus'] = true;
+ foreach ($enrolledFeesDetails->result() as $row) {
+ $fetchData['ID'] = $row->FeesType;
+ $fetchData['FeesID'] = $row->FeesID;
+ $fetchData['CourseID'] = $row->CourseID;
+ $fetchData['Sem_Year'] = $row->FeesType;
+ $fetchData['ProgramType'] = $row->FeesType;
+ $fetchData['ActualFees'] = $row->CourseFees;
+ $fetchData['STFOrWR'] = $row->STFOrWR;
+ $fetchData['Waiver'] = $row->Waiver;
+ $fetchData['Others'] = $row->Others;
+ $fetchData['SessionName'] = "Not Applicable";
+ $fetchData['ToSessionName'] = "Not Applicable";
+ $fetchData['BatchName'] = "Not Applicable";
+ $fetchData['RollNo'] = $row->RollNo;
+ $fetchData['PayableFees'] = $row->CourseFees + $row->STFOrWR + $row->Others - $row->Waiver;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId', $row->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+ if ($paidBillAmount[0]->PaidBillAmount > $fetchData['PayableFees']) {
+ $fetchData['BalanceAmount'] = 0;
+
+ } else {
+ $fetchData['BalanceAmount'] = $fetchData['PayableFees'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+ $fetchData['PC'] = $row->PC;
+ $fetchData['TC'] = $row->TC;
+ $fetchData['DC'] = $row->DC;
+ $fetchData['MC'] = $row->MC;
+ $fetchData['OtherFees'] = $row->OtherFees;
+
+ $CourseFeesArray[] = $fetchData;
+ }
+
+ return $CourseFeesArray;
+
+ }
+ else{
+ return false;
+
+ }
+ }
+ /*
+ * get exist student fees details
+ * created by kms
+ * */
+
+ public function existStudentFeesDetails($student=null){
+ $serachArray=[WAIVER,REFERRAL];
+
+ $this->db->distinct();
+ $this->db->select('SFS.FeesID,SFS.FeesType,SFS.RollNo,ifnull(SFS.CourseFees,0) as CourseFees,ifnull(SFS.STFOrWR,0) as STFOrWR,ifnull(SFS.Waiver,0) as Waiver,ifnull(SFS.Others,0) as Others,ST.Firstname,ST.MobileNumber,ST.Fathername,CU.CourseName,CU.CourseID,CF.Sem_Year,STC.EnrollmentID,US.UniversityName,US.UniversityShortName,SM.SessionName,SM1.SessionName as ToSessionName,CF.ProgramType,BA.BatchCode,BA.BatchName');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS','SFP.FeesId = SFS.FeesID');
+ $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
+ $this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
+ $this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = SFS.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = SFS.CourseID');
+ $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->join(STUDENTCOURSE.' as STC', 'STC.CourseID = SFS.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('SFS.CourseID', $student['CourseID']);
+ $this->db->where('SFS.StudentID', $student['StudentID']);
+ $this->db->where('STC.StudentID', $student['StudentID']);
+ $this->db->where('SFP.StudentID', $student['StudentID']);
+ $this->db->order_by('SFP.ID', 'DESC');
+ $getFeeDetails = $this->db->get();
+ if($getFeeDetails->result()){
+ foreach ($getFeeDetails->result() as $feeRow){
+ $storePaidDetails['FeesID'] = $feeRow->FeesID;
+ $storePaidDetails['FeesName'] = $feeRow->Sem_Year;
+ $storePaidDetails['CourseFees'] = $feeRow->CourseFees;
+ $storePaidDetails['ProgramType'] = $feeRow->ProgramType;
+ $storePaidDetails['SessionName'] = $feeRow->SessionName;
+ if($feeRow->ToSessionName=='' OR $feeRow->ToSessionName==null){
+ $storePaidDetails['ToSessionName'] = "Not Applicable";
+ }
+ else{
+ $storePaidDetails['ToSessionName'] = $feeRow->ToSessionName;
+ }
+ $storePaidDetails['BatchName'] = $feeRow->BatchName;
+
+ $storePaidDetails['RollNo'] = $feeRow->RollNo;
+ $storePaidDetails['STFOrWR'] = $feeRow->STFOrWR;
+ $storePaidDetails['Waiver'] = $feeRow->Waiver;
+ $storePaidDetails['Others'] = $feeRow->Others;
+ $storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver;
+ $storePaidDetails['Firstname'] = $feeRow->Firstname;
+ $storePaidDetails['MobileNumber'] = $feeRow->MobileNumber;
+ $storePaidDetails['Fathername'] = $feeRow->Fathername;
+ $storePaidDetails['EnrollmentID'] = $feeRow->EnrollmentID;
+ $storePaidDetails['CourseName'] = $feeRow->CourseName;
+ $storePaidDetails['UniversityName'] = $feeRow->UniversityName;
+ $storePaidDetails['UniveShortName'] = $feeRow->UniversityShortName;
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+
+ $storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
+
+ if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
+ $storePaidDetails['BalanceAmount']=0;
+
+ }
+ else{
+ $storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+
+ // sepearte for student waiver and referral bill list
+ $this->db->select('ifnull(SUM((BillAmount)),0) as StudentWaiverRefAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $this->db->where_in('ModeOfPayment',$serachArray);
+ $studentWaiverRefAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+
+ $storePaidDetails['StudentWaiverRefAmount']=$studentWaiverRefAmount[0]->StudentWaiverRefAmount;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as StudentPaidAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $this->db->where('ModeOfPayment !=',WAIVER);
+ $this->db->where('ModeOfPayment !=',REFERRAL);
+ $studentPaidAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+
+ $storePaidDetails['StudentPaidAmount']=$studentPaidAmount[0]->StudentPaidAmount;
+
+ // for get paid bill details
+ $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO,BillDate,ModeOfPayment,ReceiptNo,BR.BranchName,BR.Address,BR.LogoPath,STF.Firstname as ReceivedBy');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
+ $this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
+ $this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
+ $this->db->where('SFP.FeesId',$feeRow->FeesID);
+ $this->db->order_by('SFP.ID',"ASC");
+ $this->db->group_by('SFP.BillNO');
+ $storePaidDetails['paidDetails']=$this->db->get()->result();
+ $mergeResult[]=$storePaidDetails;
+
+ }
+ $existDefaultFees = $this->existStudentCourseDefaultFees($student);
+ if($existDefaultFees != false){
+ return array_merge($mergeResult,$existDefaultFees);
+ }
+ else{
+ return $mergeResult;
+ }
+
+ }
+ else {
+ return false;
+ }
+
+ }
+
+ /*
+ * get exist student default fees details
+ * created by kms
+ * */
+
+ public function existStudentCourseDefaultFees($student=null){
+ $serachArray = ["PC","TC","DC","MC","OTHER"];
+ $this->db->distinct();
+ $this->db->select('SFS.FeesID,SFS.FeesType,SFS.SessionName,SFS.ToSessionName,SFS.RollNo,ifnull(SFS.CourseFees,0) as CourseFees,ifnull(SFS.STFOrWR,0) as STFOrWR,ifnull(SFS.Waiver,0) as Waiver,ifnull(SFS.Others,0) as Others,ST.Firstname,ST.MobileNumber,ST.Fathername,CU.CourseName,CU.CourseID,STC.EnrollmentID,US.UniversityName,US.UniversityShortName');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS','SFP.FeesId = SFS.FeesID');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = SFS.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = SFS.CourseID');
+ //$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->join(STUDENTCOURSE.' as STC', 'STC.CourseID = SFS.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('SFS.CourseID', $student['CourseID']);
+ $this->db->where('SFS.StudentID', $student['StudentID']);
+ $this->db->where('STC.StudentID', $student['StudentID']);
+ $this->db->where('SFP.StudentID', $student['StudentID']);
+ $this->db->where_in('SFS.FeesType', $serachArray);
+ $this->db->order_by('SFP.ID', 'DESC');
+ $getFeeDetails = $this->db->get();
+ if($getFeeDetails->result()){
+ foreach ($getFeeDetails->result() as $feeRow){
+ $storePaidDetails['FeesID'] = $feeRow->FeesID;
+ $storePaidDetails['FeesName'] = $feeRow->FeesType;
+ $storePaidDetails['ProgramType'] = $feeRow->FeesType;
+ $storePaidDetails['CourseFees'] = $feeRow->CourseFees;
+ $storePaidDetails['SessionName'] = "Not Applicable";
+ $storePaidDetails['ToSessionName'] = "Not Applicable";
+ $storePaidDetails['BatchName'] = "Not Applicable";
+ $storePaidDetails['RollNo'] = $feeRow->RollNo;
+ $storePaidDetails['STFOrWR'] = $feeRow->STFOrWR;
+ $storePaidDetails['Waiver'] = $feeRow->Waiver;
+ $storePaidDetails['Others'] = $feeRow->Others;
+ $storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver;
+ $storePaidDetails['Firstname'] = $feeRow->Firstname;
+ $storePaidDetails['MobileNumber'] = $feeRow->MobileNumber;
+ $storePaidDetails['Fathername'] = $feeRow->Fathername;
+ $storePaidDetails['EnrollmentID'] = $feeRow->EnrollmentID;
+ $storePaidDetails['CourseName'] = $feeRow->CourseName;
+ $storePaidDetails['UniversityName'] = $feeRow->UniversityName;
+ $storePaidDetails['UniveShortName'] = $feeRow->UniversityShortName;
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+ $storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
+ if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
+ $storePaidDetails['BalanceAmount']=0;
+
+ }
+ else{
+ $storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+
+ // for get paid bill details
+ $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO,BillDate,ModeOfPayment,ReceiptNo,BR.BranchName,BR.Address,BR.LogoPath,STF.Firstname as ReceivedBy');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
+ $this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
+ $this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
+ $this->db->where('SFP.FeesId',$feeRow->FeesID);
+ $this->db->order_by('SFP.ID',"ASC");
+ $this->db->group_by('SFP.BillNO');
+ $storePaidDetails['paidDetails']=$this->db->get()->result();
+ $mergeResult[]=$storePaidDetails;
+
+ }
+
+ return $mergeResult;
+ }
+ else {
+ return false;
+ }
+ }
+
+
+ /*
+ * update fees details
+ * created by kms
+ * */
+
+ public function updateFees($feesPaidDetails=null,$courseID=null)
+ {
+ if($feesPaidDetails['UpdatedBy']=='All'){
+ $this->db->select('BranchID');
+ $this->db->where('FeesID', $feesPaidDetails['FeesId']);
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(STUDENTCOURSE.' as SC', 'SC.CourseID = SFS.CourseID');
+ $getStudentBranch=$this->db->get()->result();
+ $feesPaidDetails['UpdatedBy'] = $getStudentBranch[0]->BranchID;
+
+ }
+ $this->db->select('BillNO');
+ $this->db->where('UpdatedBy', $feesPaidDetails['UpdatedBy']);
+
+ $getLastBillNo=$this->db->get(STUDENTS_FEES_PAID)->last_row();
+ if($getLastBillNo){
+ $strExplode= explode("-", $getLastBillNo->BillNO);
+
+ $n=$strExplode[1];
+ $n2 = str_pad($n + 1, 5, 0, STR_PAD_LEFT);
+ $splitString = substr($feesPaidDetails['UpdatedBy'], 0, 3);
+ $feesPaidDetails['BillNO']=$splitString.'-'.$n2;
+ }
+ else{
+ $n='00000';
+ $n2 = str_pad($n + 1, 5, 0, STR_PAD_LEFT);
+ $splitString = substr($feesPaidDetails['UpdatedBy'], 0, 3);
+ $feesPaidDetails['BillNO']=$splitString.'-'.$n2;
+ }
+ $this->db->select('BillNO');
+ $this->db->where('BillNO', $feesPaidDetails['BillNO']);
+ if($this->db->get(STUDENTS_FEES_PAID)->first_row()){
+ $result['paidStatus'] = false;
+ $result['message'] = "This bill number is already exist!";
+ } else {
+
+ $this->db->select('ReceiptNo');
+ $this->db->where('ReceiptNo', $feesPaidDetails['ReceiptNo']);
+ if($this->db->get(STUDENTS_FEES_PAID)->first_row() AND $feesPaidDetails['ReceiptNo']!=''){
+ $result['paidStatus'] = false;
+ $result['message'] = "This receipt number is already exist!";
+ }
+ else{
+ $this->db->insert(STUDENTS_FEES_PAID, $feesPaidDetails);
+ if ($this->db->affected_rows() == '1') {
+
+ $result['paidStatus'] = true;
+ $result['message'] = "Successfully fees details added";
+ $feesPayedID = $this->db->insert_id();
+ // $entryOfCallTrack = $this->updateInCallTrack($trackDetails);
+ // day book entry
+
+ if($feesPaidDetails['BillAmount']!='0'){
+
+ $dayBookEntry = $this->insertDayBookMaster($feesPaidDetails,$feesPayedID);
+ }
+
+ // Entry for all status screen except fees
+ $this->entryForAllStatus($feesPaidDetails,$courseID);
+
+
+
+ }
+ else{
+ $result['paidStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+
+
+
+
+ }
+
+ return $result;
+
+
+ }
+
+ /*
+ * update followup details
+ * created by kms
+ * */
+ public function updateInCallTrack($arrayDetails=null){
+ // create activity in call tracking
+ $this->db->select('ActivityID,ActivityName');
+ $this->db->like('ActivityName', 'Fees', 'after');
+ $this->db->where('IsActive', '1');
+ $activityDetails=$this->db->get(ACTIVITY)->last_row();
+ if($activityDetails){
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ // hide tracking updated sepaerate code
+
+ /* $this->db->select('LD.LeadID,LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']);
+ $this->db->where('LT.ActivityStatus',$activityDetails->ActivityID);
+ $this->db->like('LT.University',$arrayDetails['University'],'after');
+ $this->db->like('LT.Course',$arrayDetails['Course'],'after');
+ $leadDet=$this->db->get()->last_row();
+
+ if($leadDet){
+ $this->db->select('FollowupOn');
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $this->db->order_by('InteractionId','DESC');
+ $existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row();
+ // upate tracking status
+ $changeStatusCode['StatusCode'] = $arrayDetails['StatusCode'];
+ $changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy'];
+ $changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $this->db->update(LEAD_TRACKING, $changeStatusCode);
+ // end update status
+ $updateTrackDetails['TrackingID'] = $leadDet->TrackingID;
+ $updateTrackDetails['FollowupOn'] = $existFollowupOn->FollowupOn;
+ $updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments'];
+ $updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails);
+
+ }
+
+ else{
+ $this->db->select('LeadID');
+ $this->db->where('MobileNumber',$arrayDetails['MobileNumber']);
+ $checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row();
+ if($checkLeadDet){
+ $updateLeadDetails['LeadID'] = $checkLeadDet->LeadID;
+ $updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID;
+ $updateLeadDetails['University'] = $arrayDetails['University'];
+ $updateLeadDetails['Course'] = $arrayDetails['Course'];
+ $updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode'];
+ $updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING, $updateLeadDetails);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $followup_Details['TrackingID']=$this->db->insert_id();
+ $followup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $followup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $followup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $followup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
+ // this if for insert follow up details
+
+ }
+
+ }
+ else{
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ }
+
+
+ }*/
+
+
+ }
+
+ return true;
+ }
+
+ /*
+ * get university details
+ * created by kms
+ * */
+ public function getUniversityDetails()
+ {
+ $this->db->select('UniversityID,UniversityName');
+ $this->db->where('IsActive','1');
+ $this->db->order_by('UniversityID','ASC');
+ $unviversityDetails = $this->db->get(UNIVERSITY);
+
+ if($unviversityDetails->result()){
+ $result_university = array();
+ $result_university['universityStatus'] = true;
+ foreach ($unviversityDetails->result() as $row)
+ {
+
+ $university_array['universityID'] = $row->UniversityID;
+ $university_array['universityName'] = $row->UniversityName;
+ $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID);
+ $result_array[]=$university_array;
+ }
+ $result_university['univerSityDetails']= $result_array;
+ }
+ else {
+ $result_university['universityStatus'] = false;
+ $result_university['message'] = "No records found!";
+ $result_university['universityID'] = "";
+ $result_university['universityName'] = "";
+ $result_university['courseDetails']= "";
+ }
+
+
+ return $result_university;
+
+ }
+ /*
+ * get course details
+ * @params university id
+ * created by kms
+ * */
+ public function getCourseDetails($universityID=null)
+ {
+ $this->db->select('CourseID,CONCAT(CourseName, "(",CourseCode,")") AS CourseName');
+ $this->db->where('UniversityID',$universityID);
+ $this->db->where('IsActive','1');
+ $this->db->order_by('CourseID','ASC');
+ $courseDetails = $this->db->get(COURSE);
+ return $courseDetails->result();
+ }
+ /*
+ * get fees details assign for student
+ * created by kms
+ * */
+ public function getFeesStructureAssign($student=null){
+
+ $this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year');
+ $this->db->where('CourseID',$student['CourseID']);
+ $this->db->order_by('ProgramType');
+ $feesDetails = $this->db->get(COURSE_FEES);
+ $SNoValue=0;
+ if($feesDetails->result()){
+
+ $result_array['feesStatus']=true;
+ foreach ($feesDetails->result() as $row){
+ $SNoValue=$SNoValue+1;
+ $this->db->select('SFS.FeesID,SFS.CourseFees,SFS.STFOrWR,SFS.Waiver,SFS.Others,SFS.SessionName,SFS.ToSessionName,SFS.RollNo,SFS.BatchCode,SM.SessionName as MasterSessionName,SM1.SessionName as MasterToSessionName');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
+ $this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
+ $this->db->where('StudentID',$student['StudentID']);
+ $this->db->where('CourseID',$student['CourseID']);
+ $this->db->where('FeesType',$row->ID);
+ $existFeesDetails = $this->db->get();
+ if($existData=$existFeesDetails->result()){
+ $fetchData['SNo']=$SNoValue;
+ $fetchData['ExistValue']=1;
+ $fetchData['ID']=$row->ID;
+ $fetchData['CourseID']=$row->CourseID;
+ $fetchData['ProgramType']=$row->ProgramType;
+ $fetchData['Sem_Year']=$row->Sem_Year;
+ $fetchData['ActualFees']=$existData[0]->CourseFees;
+ $fetchData['BatchCode']=$existData[0]->BatchCode;
+ $fetchData['STFOrWR']=$existData[0]->STFOrWR;
+ $fetchData['Waiver']=$existData[0]->Waiver;
+ $fetchData['Others']=$existData[0]->Others;
+ $fetchData['SessionName']=$existData[0]->SessionName;
+ $fetchData['ToSessionName']=$existData[0]->ToSessionName;
+ $fetchData['MasterSessionName']=$existData[0]->MasterSessionName;
+ if($existData[0]->MasterToSessionName=='' OR $existData[0]->MasterToSessionName==null){
+ $fetchData['MasterToSessionName']="Not Applicable";
+ }
+ else{
+ $fetchData['MasterToSessionName']=$existData[0]->MasterToSessionName;
+ }
+
+ $fetchData['RollNo']=$existData[0]->RollNo;
+ $fetchData['PayableFees']=$existData[0]->CourseFees+$existData[0]->STFOrWR+$existData[0]->Others-$existData[0]->Waiver;
+ // for installment details
+ $InstallemtResult = $this->getInstallmentDetails($existData[0]->FeesID);
+
+ if($InstallemtResult != false){
+ $fetchData['InstallmentDetails']=$InstallemtResult;
+ }
+ else{
+
+ $fetchData['InstallmentDetails']="";
+
+
+ }
+ $batchDetails = $this->getBatchDetails($existData[0]->BatchCode,$student['CourseID'],$student['StudentID'],$row->ID);
+ if($batchDetails!=false){
+ $fetchData['batchDetails']=$batchDetails;
+ }
+ else{
+ $fetchData['batchDetails']="";
+ }
+
+ $CourseFeesArray[]=$fetchData;
+
+ }
+ else{
+ $fetchData['SNo']=$SNoValue;
+ $fetchData['ExistValue']=0;
+ $fetchData['ID']=$row->ID;
+ $fetchData['CourseID']=$row->CourseID;
+ $fetchData['ProgramType']=$row->ProgramType;
+ $fetchData['Sem_Year']=$row->Sem_Year;
+ $fetchData['ActualFees']=$row->FeesAmount;
+ $fetchData['BatchCode']="";
+ $fetchData['STFOrWR']="";
+ $fetchData['Waiver']="";
+ $fetchData['Others']="";
+ $fetchData['SessionName']="";
+ $fetchData['ToSessionName']="";
+ $fetchData['MasterSessionName']="Not Applicable";
+ $fetchData['MasterToSessionName']="Not Applicable";
+ $fetchData['RollNo']="";
+ $fetchData['PayableFees']=$row->FeesAmount;
+ // for installment details
+ $fetchData['InstallmentDetails']="";
+ $batchDetails = $this->getBatchDetails('',$student['CourseID'],$student['StudentID'],'');
+ if($batchDetails!=false){
+ $fetchData['batchDetails']=$batchDetails;
+ }
+ else{
+ $fetchData['batchDetails']="";
+ }
+
+ $CourseFeesArray[]=$fetchData;
+
+ }
+
+ }
+
+ $defaultCourseDetails = $this->defaultCourseFeesDetails($student);
+ if($defaultCourseDetails!=false){
+ $result_array['feesDetails']=array_merge($CourseFeesArray,$defaultCourseDetails);
+ }
+ else{
+ $result_array['feesDetails']=$CourseFeesArray;
+ }
+
+
+
+ }
+
+ else{
+ $result_array['feesStatus']=false;
+ }
+
+ $result_array['sessionDetails'] = $this->getSession($student);
+
+ return $result_array;
+
+ }
+ /*
+ * get installment details
+ * created by kms
+ * */
+ public function getInstallmentDetails($installment=null){
+ $this->db->select('ID,FeesID,Name,Amount,DueDate');
+ $this->db->where('FeesID',$installment);
+ $this->db->order_by('ID','ASC');
+ $installmentDetails = $this->db->get(FEES_INSTALLMENT);
+ if($installmentDetails->result()){
+ return $installmentDetails->result();
+ }
+ else{
+ return false;
+ }
+
+ }
+
+ /*
+ * get batch details
+ * created by kms
+ * */
+ public function getBatchDetails($batchCode=null,$courseID=null,$studentID=null,$feesType=null){
+ if($batchCode=='' OR $batchCode==null){
+ $this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,BA.IsDefault,US.UniversityID,US.UniversityName,BA.IsActive');
+ $this->db->from(COURSE.' as CU');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
+ $this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID');
+ $this->db->order_by('BA.CreatedOn','DESC');
+ $this->db->where('CU.CourseID',$courseID);
+ $this->db->where('BA.IsActive','1');
+ $batchDetails = $this->db->get();
+ if($batchDetails->result()){
+
+ return $batchDetails->result();
+ }
+ else {
+ return false;
+ }
+ }
+ else{
+
+
+ $this->db->distinct();
+ $this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,BA.IsDefault,US.UniversityID,US.UniversityName,BA.IsActive');
+ $this->db->from(COURSE.' as CU');
+ $this->db->join(STUDENTS_FEES_STATUS.' as STF', 'STF.CourseID = CU.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
+ $this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID');
+ $this->db->order_by('BA.CreatedOn','DESC');
+ $this->db->where('CU.CourseID',$courseID);
+ $this->db->where('STF.StudentID',$studentID);
+ $this->db->where('STF.FeesType',$feesType);
+ $batchDetails = array();
+
+ /* $this->db->or_where('BA.IsActive','1');
+ $this->db->or_where('STF.BatchCode =',$batchCode);*/
+ $existDetails = $this->db->get();
+ if($existDetails->result()){
+ foreach ($existDetails->result() as $row){
+ if($row->IsActive=='1' || $row->BatchCode==$batchCode){
+ array_push($batchDetails,$row);
+ }
+
+ }
+ }
+ if($batchDetails){
+
+ return $batchDetails;
+ }
+ else {
+ return false;
+ }
+
+
+
+ }
+
+ }
+
+ /*
+ * get default pc,tc,dc,mc,other fees
+ * created by kms
+ * */
+ public function defaultCourseFeesDetails($student=null){
+
+ // check student fees paid details for get default course fees
+
+ $this->db->select('ifnull(SUM((SFS.CourseFees)),0) as CourseFees,ifnull(SUM((SFS.STFOrWR)),0) as STFOrWR,ifnull(SUM((SFS.Others)),0) as Others,ifnull(SUM((SFS.Waiver)),0) as Waiver');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->where('SFS.CourseID',$student['CourseID']);
+ $this->db->where('SFS.StudentID',$student['StudentID']);
+ $feesAmount = $this->db->get()->result();
+
+ $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as PaidAmount');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
+ $this->db->where('SFS.CourseID',$student['CourseID']);
+ $this->db->where('SFS.StudentID',$student['StudentID']);
+ $paidAmount = $this->db->get()->result();
+
+ if($feesAmount[0]->CourseFees+$feesAmount[0]->STFOrWR+$feesAmount[0]->Others-$feesAmount[0]->Waiver <= $paidAmount[0]->PaidAmount AND $feesAmount[0]->CourseFees !='0'){
+ $valid=1;
+ }
+ else{
+ $valid=0;
+ }
+ // get default course fees with paid
+ $this->db->select('CourseID,CourseName,PC,TC,DC,MC,OtherFees');
+ $this->db->where('CourseID',$student['CourseID']);
+ $endFeesDetails = $this->db->get(COURSE);
+ $myArray = array();
+ if($endFeesDetails->result()){
+ foreach ($endFeesDetails->result() as $value ){
+ $pc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'PC', 'ActualFees'=>$value->PC);
+ $tc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'TC', 'ActualFees'=>$value->TC);
+ $dc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'DC', 'ActualFees'=>$value->DC);
+ $mc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'MC', 'ActualFees'=>$value->MC);
+ $other_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'OTHER', 'ActualFees'=>$value->OtherFees);
+
+ array_push($myArray,$pc_array);
+ array_push($myArray,$tc_array);
+ array_push($myArray,$dc_array);
+ array_push($myArray,$mc_array);
+ array_push($myArray,$other_array);
+ }
+
+ // default course fees details in student status
+ foreach ($myArray as $row1){
+ $this->db->select('FeesID,CourseFees,STFOrWR,Waiver,Others,SessionName,ToSessionName,RollNo');
+ $this->db->where('StudentID',$student['StudentID']);
+ $this->db->where('CourseID',$student['CourseID']);
+ $this->db->where('FeesType',$row1['Sem_Year']);
+ $existFeesDetails = $this->db->get(STUDENTS_FEES_STATUS);
+
+ if($existData=$existFeesDetails->result()){
+ $fetchData['Valid']=$valid;
+ $fetchData['ExistValue']=1;
+ $fetchData['ID']=$row1['Sem_Year'];
+ $fetchData['CourseID']=$row1['CourseID'];
+ $fetchData['ProgramType']=$row1['Sem_Year'];
+ $fetchData['Sem_Year']=$row1['Sem_Year'];
+ $fetchData['ActualFees']=$existData[0]->CourseFees;
+ $fetchData['STFOrWR']=$existData[0]->STFOrWR;
+ $fetchData['Waiver']=$existData[0]->Waiver;
+ $fetchData['Others']=$existData[0]->Others;
+ $fetchData['SessionName']=$existData[0]->SessionName;
+ $fetchData['ToSessionName']=$existData[0]->ToSessionName;
+ $fetchData['MasterSessionName']="Not applicable";
+ $fetchData['MasterToSessionName']="Not applicable";
+ $fetchData['RollNo']=$existData[0]->RollNo;
+ $fetchData['PayableFees']=$existData[0]->CourseFees+$existData[0]->STFOrWR+$existData[0]->Others-$existData[0]->Waiver;
+ // for installment details
+ $InstallemtResult = $this->getInstallmentDetails($existData[0]->FeesID);
+ if($InstallemtResult != false){
+ $fetchData['InstallmentDetails']=$InstallemtResult;
+ }
+ else{
+
+ $fetchData['InstallmentDetails']="";
+
+
+ }
+
+ $CourseFeesArray1[]=$fetchData;
+
+ }
+ else{
+
+ $fetchData['Valid']=$valid;
+
+ $fetchData['ExistValue']=0;
+
+ $fetchData['ID']=$row1['Sem_Year'];
+
+ $fetchData['CourseID']=$row1['CourseID'];
+ $fetchData['Sem_Year']=$row1['Sem_Year'];
+ $fetchData['ActualFees']=$row1['ActualFees'];
+ $fetchData['STFOrWR']="";
+ $fetchData['Waiver']="";
+ $fetchData['Others']="";
+ $fetchData['SessionName']="Not applicable";
+ $fetchData['ToSessionName']="Not applicable";
+ $fetchData['MasterSessionName']="Not applicable";
+ $fetchData['MasterToSessionName']="Not applicable";
+ $fetchData['RollNo']="";
+ $fetchData['PayableFees']=$row1['ActualFees'];
+ $fetchData['InstallmentDetails']="";
+ $CourseFeesArray1[]=$fetchData;
+
+ }
+
+ }
+
+ return $CourseFeesArray1;
+ }
+ else {
+ return false;
+ }
+ /* }
+ else{
+ return false;
+ }*/
+
+
+
+ }
+
+ /*
+ * set fees for student
+ * created by kms
+ * */
+ public function setFees($details=null,$jsonData=null){
+ $this->db->select('FeesID');
+ $this->db->where('CourseID', $details['CourseID']);
+ $this->db->where('StudentID', $details['StudentID']);
+ $this->db->where('FeesType', $details['FeesType']);
+ $checkExist=$this->db->get(STUDENTS_FEES_STATUS);
+ if($checkExist->result()){
+ $feesId = $checkExist->result();
+ $updateDetails['SessionName'] = $details['SessionName'];
+ $updateDetails['ToSessionName'] = $details['ToSessionName'];
+ $updateDetails['BatchCode'] = $details['BatchCode'];
+ $updateDetails['RollNo'] = $details['RollNo'];
+ $updateDetails['STFOrWR'] = $details['STFOrWR'];
+ $updateDetails['Waiver'] = $details['Waiver'];
+ $updateDetails['Others'] = $details['Others'];
+ $updateDetails['UpdatedOn'] = $details['CreatedOn'];
+ $updateDetails['UpdatedBy'] = $details['CreatedBy'];
+
+ $installmentFeesID = $feesId[0]->FeesID;
+ foreach ($jsonData as $jrow){
+
+ $insertInstallment['FeesID'] = $installmentFeesID;
+ $insertInstallment['Name'] = $jrow['Name'];
+ $insertInstallment['Amount'] = $jrow['Amount'];
+ $insertInstallment['DueDate'] = $jrow['DueDate'];
+ $insertInstallment['CreatedBy'] = $details['CreatedBy'];
+ $insertInstallment['CreatedOn'] = $details['CreatedOn'];
+ if($jrow['ID'] =='' OR $jrow['ID'] =='undefined'){
+ $this->db->insert(FEES_INSTALLMENT, $insertInstallment);
+ }
+ else{
+ $updateInstallment['FeesID'] = $installmentFeesID;
+ $updateInstallment['Name'] = $jrow['Name'];
+ $updateInstallment['Amount'] = $jrow['Amount'];
+ $updateInstallment['DueDate'] = $jrow['DueDate'];
+ $updateInstallment['UpdatedBy'] = $details['CreatedBy'];
+ $updateInstallment['UpdatedOn'] = $details['CreatedOn'];
+ $this->db->where('ID',$jrow['ID']);
+ $this->db->update(FEES_INSTALLMENT, $updateInstallment);
+
+
+ }
+
+
+ }
+
+ $this->db->where('FeesID', $feesId[0]->FeesID);
+ $this->db->update(STUDENTS_FEES_STATUS, $updateDetails);
+ $result['setStatus'] = true;
+ $result['message'] = "Successfully fees details is updated.";
+
+ }
+ else{
+ $this->db->insert(STUDENTS_FEES_STATUS, $details);
+
+ $this->db->select('FeesID');
+ $this->db->where('CourseID', $details['CourseID']);
+ $this->db->where('StudentID', $details['StudentID']);
+ $this->db->where('FeesType', $details['FeesType']);
+ $existDb=$this->db->get(STUDENTS_FEES_STATUS)->last_row();
+ if($existDb){
+ $rowId = $existDb;
+ $installmentFeesID = $rowId->FeesID;
+ foreach ($jsonData as $jrow){
+ $insertInstallment['FeesID'] = $installmentFeesID;
+ $insertInstallment['Name'] = $jrow['Name'];
+ $insertInstallment['Amount'] = $jrow['Amount'];
+ $insertInstallment['DueDate'] = $jrow['DueDate'];
+ $insertInstallment['CreatedBy'] = $details['CreatedBy'];
+ $insertInstallment['CreatedOn'] = $details['CreatedOn'];
+ if($jrow['ID'] =='' OR $jrow['ID'] =='undefined'){
+ $this->db->insert(FEES_INSTALLMENT, $insertInstallment);
+ }
+ else{
+ $updateInstallment['FeesID'] = $installmentFeesID;
+ $updateInstallment['Name'] = $jrow['Name'];
+ $updateInstallment['Amount'] = $jrow['Amount'];
+ $updateInstallment['DueDate'] = $jrow['DueDate'];
+ $updateInstallment['UpdatedBy'] = $details['CreatedBy'];
+ $updateInstallment['UpdatedOn'] = $details['CreatedOn'];
+
+ $this->db->where('ID',$jrow['ID']);
+ $this->db->update(FEES_INSTALLMENT, $updateInstallment);
+
+
+ }
+
+
+ }
+
+
+ }
+
+ $result['setStatus'] = true;
+ $result['message'] = "Successfully fees details is added.";
+
+ }
+ return $result;
+
+ }
+ /*
+ * insert day book master while fees update
+ * created by kms
+ * */
+ public function insertDayBookMaster($data=null,$paymentID){
+ $this->db->select('Firstname');
+ $this->db->where('StudentID', $data['StudentID']);
+ $getStudentName=$this->db->get(STUDENTS)->result();
+ if($getStudentName){
+ // this is for income entry
+ $insertArray['Date'] = $data['BillDate'];
+ $insertArray['CreatedBy'] = $data['CreatedBy'];
+ $insertArray['CreatedOn'] = $data['CreatedOn'];
+ $insertArray['Description'] = $data['InternalComments'];
+ $insertArray['PaidDescription'] = "";
+ $insertArray['Amount'] = $data['BillAmount'];
+ $insertArray['Status'] = 'Approved';
+ $insertArray['PaymentStatus'] = false;
+ $insertArray['FeesPaymentID'] = $paymentID;
+ $insertArray['VoucherNumber'] = $data['BillNO'];
+ $insertArray['PaidTo'] = $getStudentName[0]->Firstname;
+ $insertArray['BranchCode'] = $data['UpdatedBy'];
+ $insertArray['ModeOfPayment'] = $data['ModeOfPayment'];
+
+ $this->db->select('ID,TypeID');
+ $this->db->where('TypeID', 'I002');
+ $this->db->where('TypeName', 'FEES');
+ $getIncome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row();
+
+ if($getIncome){
+ $insertArray['Name'] = $getIncome->TypeID;
+ $insertArray['Type'] = $getIncome->ID;
+ $checkInsertIn=$this->add_dayBook($insertArray);
+ if($checkInsertIn['addDayBookStatus']==true AND $data['ModeOfPayment']!='CASH'){
+ // this is for expense come entry
+ $now1 = new DateTime();
+ $now1->setTimezone(new DateTimezone('Asia/Kolkata'));
+
+ $expenseArray['Date'] = $data['BillDate'];
+ $expenseArray['CreatedBy'] = $data['CreatedBy'];
+ $expenseArray['CreatedOn'] = $now1->format('Y-m-d H:i:s');;
+ $expenseArray['Description'] = $data['InternalComments'];
+ $expenseArray['PaidDescription'] = "";
+ $expenseArray['Amount'] = $data['BillAmount'];
+ $expenseArray['Status'] = 'Pending';
+ $expenseArray['PaymentStatus'] = false;
+ $expenseArray['FeesPaymentID'] = $paymentID;
+ $expenseArray['VoucherNumber'] = $data['BillNO'];
+ $expenseArray['PaidTo'] = $getStudentName[0]->Firstname;
+ $expenseArray['BranchCode'] = $data['UpdatedBy'];
+ $expenseArray['ModeOfPayment'] = $data['ModeOfPayment'];
+ $this->db->select('ID,TypeID');
+ $this->db->where('TypeID', 'I001');
+ $this->db->where('TypeName', 'FEES');
+ $getOutcome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row();
+
+ if($getOutcome){
+ $expenseArray['Name'] = $getOutcome->TypeID;
+ $expenseArray['Type'] = $getOutcome->ID;
+ /* $this->db->insert(DAYBOOKMASTER, $expenseArray);*/
+ $checkInsertOut=$this->add_dayBook($expenseArray);
+
+ }
+
+ }
+
+
+ }
+
+ return true;
+ }
+ else{
+ return false;
+ }
+
+
+
+
+
+ }
+ /*
+ * send notification for student
+ * created by kms
+ * */
+ public function studentNotification(){
+ $date = new DateTime(date("d-m-Y"));
+ $date->modify('+2 day');
+ $tomorrowDATE = $date->format('d-m-Y');
+
+ $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
+ $this->db->from(FEES_INSTALLMENT.' as FIN');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
+ $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
+ $this->db->where('FIN.DueDate',$tomorrowDATE);
+ $getStudentDetails = $this->db->get();
+
+ if ($getStudentDetails->result()){
+ foreach ($getStudentDetails->result() as $row){
+ $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
+ $this->db->where('SFS.CourseID',$row->CourseID);
+ $this->db->where('SFS.StudentID',$row->StudentID);
+ $getStudentPaiDetails = $this->db->get()->result();
+
+ if($row->Amount > $getStudentPaiDetails[0]->BillAmount){
+ $this->smssend($row->StudentID,$row->DueDate);
+ }
+
+ }
+ }
+ $date1 = new DateTime(date("d-m-Y"));
+ $date1->modify('+7 day');
+ $afterFiveDays = $date1->format('d-m-Y');
+ $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
+ $this->db->from(FEES_INSTALLMENT.' as FIN');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
+ $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
+ $this->db->where('FIN.DueDate',$afterFiveDays);
+ $getStudentDetails1 = $this->db->get();
+ if ($getStudentDetails1->result()){
+ foreach ($getStudentDetails1->result() as $row1){
+ $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
+ $this->db->where('SFS.CourseID',$row1->CourseID);
+ $this->db->where('SFS.StudentID',$row1->StudentID);
+ $getStudentPaiDetails1 = $this->db->get()->result();
+ if($row1->Amount < $getStudentPaiDetails1[0]->BillAmount){
+ $this->smssend($row1->StudentID,$row1->DueDate);
+ }
+
+ }
+ }
+
+ // this is for update details in call track after due date
+ $yesterdayDate = new DateTime(date("d-m-Y"));
+ $yesterdayDate->modify('-1 day');
+ $preDATE = $yesterdayDate->format('d-m-Y');
+ $this->db->distinct();
+ $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
+ $this->db->from(FEES_INSTALLMENT.' as FIN');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
+ $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
+ $this->db->where('FIN.DueDate',$preDATE);
+ $getStudentDetails2 = $this->db->get();
+ if ($getStudentDetails2->result()){
+ foreach ($getStudentDetails2->result() as $row2){
+ $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
+ $this->db->where('SFS.CourseID',$row2->CourseID);
+ $this->db->where('SFS.StudentID',$row2->StudentID);
+ $getStudentPaiDetails2 = $this->db->get()->result();
+
+ if($row2->Amount > $getStudentPaiDetails2[0]->BillAmount){
+
+
+ $this->updateFeesStatusInCallTrack($row2->StudentID,$row2->CourseID);
+ }
+
+
+ }
+ }
+
+
+
+ return true;
+ }
+
+ /*
+ * this is for sms send
+ * created by kms
+ * */
+ public function smssend($studentID=null,$date=null)
+ {
+
+ $studentDetails = $this->get_registered_mobile($studentID);
+ $msg ="Dear $studentDetails->Firstname, Fees Payment for your course is falling due on $date. Please ignore if already paid.";
+
+ $mobile = "91$studentDetails->MobileNumber";
+ // $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
+ // $mobile = "91$mobile";
+
+ $message = urlencode($msg);
+ $ch=curl_init();
+ curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED");
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ $output =curl_exec($ch);
+
+ // print_r($output);exit();
+ curl_close($ch);
+ return $output;
+ }
+
+ // self function for getting registered mobile for sms
+ public function get_registered_mobile($num) {
+ $this->db->select('MobileNumber,Firstname');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $num);
+ $roleDetails = $this->db->get()->first_row();
+ return $roleDetails;
+ }
+ /*
+ * update followup details for fees pending in call tracking
+ * created by kms
+ * */
+ public function updateFeesStatusInCallTrack($studentID=null,$courseID=null){
+ $now = new DateTime();
+ $now->setTimezone(new DateTimezone('Asia/Kolkata'));
+ $currentDate = new DateTime(date("d-m-Y"));
+ $afterFormatedDate = $currentDate->format('d-m-Y');
+ // get student details
+
+ $this->db->select('PLD.ListCode');
+ $this->db->from(PICK_LIST_DETAILS.' as PLD');
+ $this->db->where('PLD.ListName','PENDING');
+ $this->db->where('PLD.IsActive','1');
+ $checkStatus=$this->db->get()->last_row();
+ if($checkStatus){
+
+
+ $studentDetails = $this->studentInfoForFeesStatus($studentID,$courseID);
+
+ if($studentDetails){
+ $arrayDetails['MobileNumber']=$studentDetails->MobileNumber;
+ $arrayDetails['LeadName']=$studentDetails->Firstname;
+ $arrayDetails['University']=$studentDetails->UniversityName;
+ $arrayDetails['Course']=$studentDetails->CourseName;
+ $arrayDetails['StatusCode']=$checkStatus->ListCode;
+ $arrayDetails['CreatedBranch']=$studentDetails->BranchID;
+ $arrayDetails['CreatedOn']=$now->format('Y-m-d H:i:s');
+ $arrayDetails['FollowupOn']=$afterFormatedDate;
+ $arrayDetails['FollowupComments']="Fees payment for your course is falling.";
+ // get created by with branch id
+
+ $this->db->select('LO.ID');
+ $this->db->from(STAFF_BRANCH.' as STB');
+ $this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID');
+ $this->db->where('STB.BranchCode',$studentDetails->BranchID);
+ $this->db->where('LO.ListCode',ADMIN);
+ $this->db->where('STB.IsActive','1');
+ $this->db->where('LO.IsActive','1');
+ $assignDet=$this->db->get()->last_row();
+ if($assignDet){
+ $arrayDetails['CreatedBy']=$assignDet->ID;
+ }
+ else{
+ $arrayDetails['CreatedBy']='';
+ }
+
+ // create activity in call tracking
+ $this->db->select('ActivityID,ActivityName');
+ $this->db->like('ActivityName', 'Fees', 'after');
+ $this->db->where('IsActive', '1');
+ $activityDetails=$this->db->get(ACTIVITY)->last_row();
+ if($activityDetails){
+
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ // hide call track update code
+
+ /*$this->db->select('LD.LeadID,LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']);
+ $this->db->where('LT.ActivityStatus',$activityDetails->ActivityID);
+ $this->db->like('LT.University',$arrayDetails['University'],'after');
+ $this->db->like('LT.Course',$arrayDetails['Course'],'after');
+ $leadDet=$this->db->get()->last_row();
+
+ if($leadDet){
+
+ $this->db->select('FollowupOn');
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row();
+
+ // upate tracking status
+ $changeStatusCode['StatusCode'] = $arrayDetails['StatusCode'];
+ $changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy'];
+ $changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn'];
+ $changeStatusCode['CreatedBranch']=$arrayDetails['CreatedBranch'];
+
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $this->db->update(LEAD_TRACKING, $changeStatusCode);
+ // end update status
+ $updateTrackDetails['TrackingID'] = $leadDet->TrackingID;
+ $updateTrackDetails['FollowupOn'] = $arrayDetails['FollowupOn'];
+ $updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments'];
+ $updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails);
+
+ }
+
+ else{
+ $this->db->select('LeadID');
+ $this->db->where('MobileNumber',$arrayDetails['MobileNumber']);
+ $checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row();
+ if($checkLeadDet){
+ $updateLeadDetails['LeadID'] = $checkLeadDet->LeadID;
+ $updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID;
+ $updateLeadDetails['University'] = $arrayDetails['University'];
+ $updateLeadDetails['Course'] = $arrayDetails['Course'];
+ $updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode'];
+ $updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $updateLeadDetails['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $updateLeadDetails);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $followup_Details['TrackingID']=$this->db->insert_id();
+ $followup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $followup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $followup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $followup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
+ // this if for insert follow up details
+
+ }
+
+ }
+ else{
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ }
+
+
+ }*/
+
+
+ }
+ }
+
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ /*
+ * get student info for fees due updates
+ * created by kms
+ * */
+ public function studentInfoForFeesStatus($studentID=null,$courseID=null){
+
+ $this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName,STC.BranchID');
+ $this->db->from(STUDENTCOURSE.' as STC');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('ST.StudentID',$studentID);
+ $this->db->where('STC.CourseID',$courseID);
+ $leadDet=$this->db->get()->last_row();
+ if($leadDet){
+ return $leadDet;
+ }
+ else{
+ return false;
+ }
+
+ }
+
+ /*
+ * Get session master details
+ * created by kms
+ * */
+
+ public function getSession($details=null)
+ {
+ $this->db->select('SM.SessionID,SM.SessionDate,SM.SessionName,SM.IsActive');
+ $this->db->from(SESSIONMASTER.' as SM');
+ $this->db->join(SESSIONDETAILS.' as SD', 'SM.SessionID = SD.SessionID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = SD.UniversityID');
+ $this->db->join(COURSE.' as CU', 'CU.UniversityID = US.UniversityID');
+ // $this->db->where('SD.IsActive','1');
+ $this->db->order_by('CU.CreatedOn','DESC');
+ $this->db->where('CU.CourseID',$details['CourseID']);
+ // $this->db->group_by('SM.SessionName','DESC');
+ $sessionDetails = $this->db->get();
+ if($sessionDetails->result()){
+
+ return $sessionDetails->result();
+ }
+ else {
+ return false;
+ }
+
+ }
+ /*
+ * Entry for all status update
+ * created by kms
+ * */
+ public function entryForAllStatus($feesDetails=null,$courseID=null){
+ $singleFeesDetails=["SEM 1","SEM 2","SEM 3","SEM 4","SEM 5","SEM 6","SEM 7","SEM 8"];
+ // get pick list expected status
+ $this->db->select('ListCode,ListName');
+ $this->db->where('ListName','EXPECTED');
+ $this->db->where('IsActive','1');
+ $existStatusDetails = $this->db->get(PICK_LIST_DETAILS)->last_row();
+ if($existStatusDetails){
+ //check if exist
+ $this->db->select('SFS.FeesID,SFS.FeesType');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
+ $this->db->where('SFS.CourseID',$courseID);
+ $this->db->where('SFS.StudentID',$feesDetails['StudentID']);
+ $this->db->where('SFP.FeesId',$feesDetails['FeesId']);
+ $existDetails = $this->db->get();
+ if($existDetails->num_rows()>1){
+ return true;
+ }
+ else{
+ $fetchData = $existDetails->result();
+ if($fetchData[0]->FeesType!=PC AND $fetchData[0]->FeesType!=DC AND $fetchData[0]->FeesType!=TC AND $fetchData[0]->FeesType!=MC AND $fetchData[0]->FeesType!=OTHER) {
+ $this->db->select('SFS.FeesType,CF.Sem_Year,CF.ProgramType');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->where('SFS.CourseID',$courseID);
+ $this->db->where('SFS.StudentID',$feesDetails['StudentID']);
+ $this->db->where('SFS.FeesID',$feesDetails['FeesId']);
+ $getFeesTypeDetails = $this->db->get();
+
+ if($getFeesTypeDetails->result()){
+ $insertDetails=array();
+
+ foreach ($getFeesTypeDetails->result() as $row){
+
+ // this array for study material and answer booklet update
+ $insertStudyBook['StudentID']=$feesDetails['StudentID'];
+ $insertStudyBook['CourseID']=$row->FeesType;
+ $insertStudyBook['BranchCode']=$feesDetails['UpdatedBy'];
+ $insertStudyBook['ListCode']=$existStatusDetails->ListCode;
+ $insertStudyBook['Comments']=$feesDetails['CommentsForStudent'];
+ $insertStudyBook['Coursedetail']=$feesDetails['StudentID'];
+ $insertStudyBook['CreatedBy']=$feesDetails['CreatedBy'];
+ $insertStudyBook['CreatedOn']=$feesDetails['CreatedOn'];
+ // this array for mark card updates
+ $insertMark['StudentID']=$feesDetails['StudentID'];
+ $insertMark['CourseID']=$row->FeesType;
+ $insertMark['BranchCode']=$feesDetails['UpdatedBy'];
+ $insertMark['ListCode']=$existStatusDetails->ListCode;
+ $insertMark['Comments']=$feesDetails['CommentsForStudent'];
+ $insertMark['Coursedetail']=$feesDetails['StudentID'];
+ $insertMark['CreatedBy']=$feesDetails['CreatedBy'];
+ $insertMark['CreatedOn']=$feesDetails['CreatedOn'];
+ $insertMark['CertificationType']="MARK CARD";
+
+ if($row->ProgramType==REGULARFEES OR $row->ProgramType==LATERALFEES){
+ foreach ($singleFeesDetails as $Fees){
+
+ $insertStudyBook['Sem']=$Fees;
+ // insert study material details
+ $this->db->insert(STUDY_MATERIAL_STATUS, $insertStudyBook);
+ // insert answer booklet details
+ $this->db->insert(ANSWER_BOOKLET, $insertStudyBook);
+
+ // insert mark card details
+ $insertMark['Sem']=$Fees;
+ $this->db->insert(CERTIFICATION_STATUS, $insertMark);
+ }
+
+
+ }
+ else{
+ $insertStudyBook['Sem']=$row->Sem_Year;
+ // insert study material details
+ $this->db->insert(STUDY_MATERIAL_STATUS, $insertStudyBook);
+ // insert answer booklet details
+ $this->db->insert(ANSWER_BOOKLET, $insertStudyBook);
+ // insert mark card details
+ $insertMark['Sem']=$row->Sem_Year;
+ $this->db->insert(CERTIFICATION_STATUS, $insertMark);
+
+ }
+
+ }
+
+ }
+ }
+
+ else{
+ $this->db->select('CertificationID');
+ $this->db->where('CertificateName',$fetchData[0]->FeesType);
+ $this->db->where('IsActive','1');
+ $getEndFeesDetails = $this->db->get(CERTIFICATION_MASTER)->last_row();
+ if($getEndFeesDetails){
+ // this array for document update
+ $insertDocs['StudentID']=$feesDetails['StudentID'];
+ $insertDocs['CourseID']=$courseID;
+ $insertDocs['BranchCode']=$feesDetails['UpdatedBy'];
+ $insertDocs['ListCode']=$existStatusDetails->ListCode;
+ $insertDocs['Comments']=$feesDetails['CommentsForStudent'];
+ $insertDocs['CreatedBy']=$feesDetails['CreatedBy'];
+ $insertDocs['CreatedOn']=$feesDetails['CreatedOn'];
+ $insertDocs['CertificationType']=$getEndFeesDetails->CertificationID;
+ // insert application details
+ $this->db->insert(APPLICATION_STATUS,$insertDocs);
+
+ }
+
+
+
+ }
+
+
+
+ }
+
+ return true;
+ }
+
+ else{
+ return false;
+ }
+ }
+
+ // add dayBook
+ public function add_dayBook($Arr)
+ {
+ $branch = $Arr['BranchCode'];
+ $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE BranchCode = '$branch'
+ ORDER BY ID DESC
+ LIMIT 1";
+ $prevBalance = 0;
+ $latestUpdate = $this->db->query($sql);
+ $latestUpdateDetails = $latestUpdate->result();
+
+ If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
+ {
+ $prevBalance = $latestUpdateDetails[0]->Balance;
+ }else{
+ }
+
+ if($Arr['Name'] == 'I002') {
+ //Income
+ $Arr['Balance'] = $prevBalance + $Arr['Amount'];
+ }else if ($Arr['Name'] == 'I001') {
+ //Expense
+ $Arr['Balance'] = $prevBalance - $Arr['Amount'];
+ } else {
+ $Arr['Balance'] = 0;
+ }
+
+ $this->db->insert(DAYBOOKMASTER, $Arr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addDayBookStatus'] = true;
+ $result['message'] = "Successfully DayBook Details Added";
+ } else {
+ $result['addDayBookStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/Forgot_model.php b/api/application/models/Forgot_model.php
new file mode 100644
index 0000000..cbeada8
--- /dev/null
+++ b/api/application/models/Forgot_model.php
@@ -0,0 +1,77 @@
+ 7594aacdb21d8a9b29f71ea9163a5730
+ */
+ //
+ function forget($user=null, $password)
+ {
+ $this->db->select('ID,Emailid,MobileNumber,Password');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $user['MobileNumber']);
+ $forgotDetails1 = $this->db->get()->first_row();
+ // echo $forgotDetails->MobileNumber;exit();
+ // $result = $query->result_array();
+ if($forgotDetails1){
+ $this->db->select('ID,Emailid,MobileNumber,Password');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $user['MobileNumber']);
+ $this->db->where('IsActive', 1);
+ $forgotDetails = $this->db->get()->first_row();
+ if($forgotDetails) {
+ $existUserID=$forgotDetails->ID;
+ $this->db->where('ID', $existUserID);
+ $upatePassword=$this->db->update('T_Login', $user);
+ // print_r ($upatePassword) ;
+ //exit();
+ if($upatePassword) {
+ $this->smssend($user['MobileNumber'], $password);
+ $result['forgotstatus'] = true;
+ $result['resPass'] = "Check your registered Mobile Number!!";
+ $result['message'] = "Password updated successfully";
+ }
+ else{
+ $result['forgotstatus'] = false;
+ $result['message'] = "Something went wrong!";
+ }
+ } else {
+ $result['forgotstatus'] = false;
+ $result['message'] = "This user in InActive state!";
+ }
+ }
+ else {
+ $result['forgotstatus'] = false;
+ $result['message'] = "User is not exist!";
+ }
+ return $result;
+ }
+
+ // http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf
+ // API Key : xegCdYUIMf3
+
+ // Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login.
+ // This is the template to be used.
+
+ public function smssend($mobile,$messa)
+ {
+ $message ="Your new password for logging into Apollo student portal is $messa. Please change the password as soon as you login.";
+ $mobile = "91$mobile";
+
+ $message = urlencode($message);
+ $ch=curl_init();
+ curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED");
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ $output =curl_exec($ch);
+
+ // print_r($output);exit();
+ curl_close($ch);
+ return $output;
+ }
+}
\ No newline at end of file
diff --git a/api/application/models/Hallticket_model.php b/api/application/models/Hallticket_model.php
new file mode 100644
index 0000000..3b86a25
--- /dev/null
+++ b/api/application/models/Hallticket_model.php
@@ -0,0 +1,7 @@
+ e99a18c428cb38d5f260853678922e03
+ */
+
+ public function login($mobile = null, $password = null)
+ {
+ $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode');
+ $this->db->from('' . LOGIN . ' as t1');
+ $this->db->where('t1.MobileNumber', $mobile);
+ // $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $this->db->where('t1.IsActive', 1);
+ //$this->db->where('t2.IsActive', 1);
+ $loginDetails = $this->db->get(LOGIN)->first_row();
+ // print_r($loginDetails);exit();
+ if ($loginDetails) {
+ if ($mobile == $loginDetails->MobileNumber) {
+
+ if ($password == $loginDetails->Password) {
+ if($loginDetails->ListCode == SUPER_ADMIN){
+ //print_r($loginDetails);exit();
+ $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess');
+ $this->db->from('' . LOGIN . ' as t1');
+ $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $this->db->where('t1.MobileNumber', $mobile);
+ $this->db->where('t2.IsActive', 1);
+ $responseDetails = $this->db->get()->first_row();
+ if($responseDetails){
+ if ($responseDetails->ListCode == SUPER_ADMIN) {
+ // For First time Super admin login, will set all branch detail
+ $result['loginStatus'] = true;
+ $responseDetails->BranchCode = 'All';
+ $result['details'] = $responseDetails;
+ } else {
+ $result['loginStatus'] = true;
+ $result['details'] = $responseDetails;
+ }
+ }
+ else{
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated.";
+ }
+ } else if ($loginDetails->ListCode == ADMIN || $loginDetails->ListCode == EMPLOYEE) {
+ //print_r($loginDetails);exit();
+ $this->db->select('t1.MobileNumber, t3.ListCode, t1.ID, t3.BranchCode, t3.FinanceModuleAccess');
+ $this->db->from('' . LOGIN . ' as t1');
+ $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT');
+ $this->db->join('' . STAFF_BRANCH . ' as t3', 't3.StaffID = t2.StaffID', 'LEFT');
+ $this->db->where('t1.MobileNumber', $mobile);
+ $this->db->where('t2.IsActive', 1);
+ $this->db->where('t3.IsActive', 1);
+ $this->db->order_by('t3.CreatedOn', 'ASC');
+ $this->db->group_by('t3.StaffID');
+ $responseDetails = $this->db->get()->first_row();
+ if($responseDetails){
+ $result['loginStatus'] = true;
+ $result['details'] = $responseDetails;
+ }
+ else{
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated.";
+ }
+ }
+ else if($loginDetails->ListCode == STUDENT){
+ $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess');
+ $this->db->from('' . LOGIN . ' as LO');
+ $this->db->join('' . STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID');
+ $this->db->where('LO.MobileNumber', $mobile);
+ $this->db->where('ST.IsActive', 1);
+ $responseDetails = $this->db->get()->first_row();
+
+ if($responseDetails){
+ if($responseDetails->LoginAccess == 1){
+ $result['loginStatus'] = true;
+ $result['details'] = $responseDetails;
+ } else {
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated.";
+ }
+ }
+ else{
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated.";
+ }
+ }
+ else{
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated or don't have login.";
+ }
+ } else {
+ $result['loginStatus'] = false;
+ $result['message'] = "Please Enter Valid Password !!";
+ }
+ } else {
+ $result['loginStatus'] = false;
+ $result['message'] = "Please Enter Register Mobile Number !!";
+ }
+ } else {
+ $result['loginStatus'] = false;
+ $result['message'] = "Your login is de-activated or don't have login.";
+ }
+
+ /*$this->db->join('areas a', 'a.id = e.id_area', 'inner');
+ $this->db->join('horario h', 'h.id = e.id_horario', 'inner');
+ $this->db->join('dia d', 'd.id = e.id_data', 'inner');
+ $this->db->join('tipo_evento t', 't.id = e.id_tipo', 'inner');
+ $this->db->join('campus c', 'c.id = e.id_unidade', 'inner');
+ if ( $id != null ){
+ $this->db->where('e.id', $id);
+ return $this->db->get('eventos')->first_row();
+ } else {
+ return $this->db->get('eventos')->result();
+ }*/
+ return $result;
+
+ }
+
+ public function change_Password( $userId, $newPassword, $oldPassword, $updateOn) {
+ $this->db->select('Password');
+ $this->db->from(LOGIN);
+ $this->db->where('ID', $userId);
+ $loginDetails = $this->db->get()->first_row();
+ if ($loginDetails->Password == $oldPassword) {
+ $sql = "UPDATE ".LOGIN." SET Password='$newPassword', UpdatedBy='$userId', UpdatedOn='$updateOn' WHERE ID='$userId'";
+ if($this->db->query($sql) == '1'){
+ $result['changePassStatus'] = true;
+ $result['message'] = "Your Password Successfully changed !!";
+ } else {
+ $result['changePassStatus'] = false;
+ $result['message'] = "Please try Again !!";
+ }
+ } else {
+ $result['changePassStatus'] = false;
+ $result['message'] = "Your Current Password miss match, Please try Again !!";
+ }
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/api/application/models/Reports_model.php b/api/application/models/Reports_model.php
new file mode 100644
index 0000000..c1e7012
--- /dev/null
+++ b/api/application/models/Reports_model.php
@@ -0,0 +1,338 @@
+db->query($sql);
+ $statusDetails = $leadDet->result();
+ if (count($statusDetails) > 0) {
+ $results['statusList'] = true;
+ $results['statusr'] = $statusDetails;
+ } else {
+ $results['statusList'] = false;
+ $results['message'] = 'No record found';
+ }
+
+ return $results;
+
+ }
+ public function batch(){
+
+
+ $sql = "SELECT BatchCode as batch,BatchName as bname FROM T_BatchMaster
+ group by batch;";
+ $b=$this->db->query($sql);
+ $batch = $b->result();
+ if (count($batch) > 0) {
+ $results['batchlist'] = true;
+ $results['batch'] = $batch;
+ } else {
+ $results['batchlist'] = false;
+ $results['message'] = 'No record found';
+ }
+ $sql = "SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster";
+ $b=$this->db->query($sql);
+ $batch = $b->result();
+ if (count($batch) > 0) {
+ $results['branchlist'] = true;
+ $results['branch'] = $batch;
+ } else {
+ $results['branchlist'] = false;
+ $results['message'] = 'No record found';
+ }
+ $sql = "SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster";
+ $b=$this->db->query($sql);
+ $batch = $b->result();
+ if (count($batch) > 0) {
+ $results['univlist'] = true;
+ $results['univ'] = $batch;
+ } else {
+ $results['univlist'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+
+ }
+ public function mstatus($bat=null,$br=null,$u=null){
+
+ $sql = "select @s:=@s+1 sl,sms.sid as ssid,std.name as name,std.father as father,br.bname as bname,ifnull(b.batch,'-') as batch,std.phone as phone,sms.cid as scid,sfp.bdate as bdate,list.status as status,u.uname as uname,cm.course as course,sms.sem as sem,sms.cdate as cdate,sfs.batch as fbatch,sfs.cid as fcid,cfd.syear as syear,sum(sfs.cf) as crsfee,sum(sfs.stf) as stf,sum(sfs.others) as others,(sum(sfs.cf) + sum(sfs.stf) + sum(sfs.others)) as total,ifnull(sfp.bamount,0) as bamount,(sum(sfs.cf) + (sum(sfs.stf) + sum(sfs.others)) - ifnull(sfp.bamount,0)) as balance
+ from
+ (SELECT StudentID as sid,CourseID as cid,BranchCode as branch,CDate as cdate,ListCode as lcode,Comments as cmts,Sem as sem FROM T_CertificationStatus) as sms
+ left join
+ (SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others FROM T_Students_Fees_Status
+ group by sid,batch) as sfs on sfs.sid=sms.sid
+ left join
+ (SELECT StudentID as sid,FeesId as fid,BillDate as bdate,sum(BillAmount) as bamount
+ FROM T_Students_Fees_PaidDetails, (SELECT @s:= 0) AS s
+ group by sid,fid,bdate) as sfp on sfp.sid=sfs.sid and sfp.fid=sfs.fid
+ left join
+ (SELECT ID as cid,CourseID as ccid,FeesType as ftype,Sem_Year as syear FROM T_Course_Fees_Details) as cfd
+ on cfd.cid=sms.cid
+ left join
+ (SELECT CourseID as cid,UniversityID as uid,CourseName as course FROM T_CourseMaster) as cm
+ on cm.cid=sfs.cid
+ left join
+ (SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster) as u
+ on u.uid=cm.uid
+ left join
+ (SELECT ListCode as lcode,ListName as status FROM T_PickListDetails) as list
+ on list.lcode=sms.lcode
+ left join
+ (SELECT StudentID as sid,MobileNumber as phone,FirstName as name,Fathername as father FROM T_StudentDetails) as std on std.sid=sms.sid
+ left join
+ (SELECT BatchCode as bcode,BatchName as batch FROM T_BatchMaster) as b on b.bcode=sfs.batch
+ left join
+ (SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster) as br on br.brcode=sms.branch
+ where std.name != 'null'
+ ";
+ if ($br!= ''){
+
+ $sql.=" and sms.branch = '".$br."'";
+
+ }
+ if ($bat!= ''){
+
+ $sql.=" and b.bcode = '".$bat."'";
+
+ }
+ if ($u!= ''){
+
+ $sql.=" and u.uid = '".$u."'";
+
+ }
+ $sql.=" group by ssid,sem,fbatch";
+ $sql.=" order by sl";
+ $leadDet=$this->db->query($sql);
+ $mstatusDetails = $leadDet->result();
+ if (count($mstatusDetails) > 0) {
+ $results['mstatusList'] = true;
+ $results['mstatusr'] = $mstatusDetails;
+ } else {
+ $results['mstatusList'] = false;
+ $results['mmessage'] = 'No record found';
+ }
+
+ return $results;
+
+ }
+ public function certificate_status($bat=null,$br=null,$u=null){
+
+ $sql = "select @s:=@s+1 sl,sms.sid as ssid,std.name as name,std.father as father,br.bname as bname,ifnull(b.batch,'-') as batch,std.phone as phone,sms.cid as scid,sfp.bdate as bdate,list.status as status,u.uname as uname,cm.course as course,sms.cert_name as cert_name,sms.sem as sem,sms.cdate as cdate,sfs.batch as fbatch,sfs.cid as fcid,cfd.syear as syear,sum(sfs.cf) as crsfee,sum(sfs.stf) as stf,sum(sfs.others) as others,(sum(sfs.cf) + sum(sfs.stf) + sum(sfs.others)) as total,ifnull(sfp.bamount,0) as bamount,(sum(sfs.cf) + (sum(sfs.stf) + sum(sfs.others)) - ifnull(sfp.bamount,0)) as balance
+ from
+ (SELECT StudentID as sid,CourseID as cid,CertificationType as cert_name,BranchCode as branch,CDate as cdate,ListCode as lcode,Comments as cmts,Sem as sem FROM T_CertificationStatus) as sms
+ left join
+ (SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others FROM T_Students_Fees_Status
+ group by sid,batch) as sfs on sfs.sid=sms.sid
+ left join
+ (SELECT StudentID as sid,FeesId as fid,BillDate as bdate,sum(BillAmount) as bamount
+ FROM T_Students_Fees_PaidDetails, (SELECT @s:= 0) AS s
+ group by sid,fid,bdate) as sfp on sfp.sid=sfs.sid and sfp.fid=sfs.fid
+ left join
+ (SELECT ID as cid,CourseID as ccid,FeesType as ftype,Sem_Year as syear FROM T_Course_Fees_Details) as cfd
+ on cfd.cid=sms.cid
+ left join
+ (SELECT CourseID as cid,UniversityID as uid,CourseName as course FROM T_CourseMaster) as cm
+ on cm.cid=sfs.cid
+ left join
+ (SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster) as u
+ on u.uid=cm.uid
+ left join
+ (SELECT ListCode as lcode,ListName as status FROM T_PickListDetails) as list
+ on list.lcode=sms.lcode
+ left join
+ (SELECT StudentID as sid,MobileNumber as phone,FirstName as name,Fathername as father FROM T_StudentDetails) as std on std.sid=sms.sid
+ left join
+ (SELECT BatchCode as bcode,BatchName as batch FROM T_BatchMaster) as b on b.bcode=sfs.batch
+ left join
+ (SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster) as br on br.brcode=sms.branch
+ where std.name != 'null'
+ ";
+ if ($br!= ''){
+
+ $sql.=" and sms.branch = '".$br."'";
+
+ }
+ if ($bat!= ''){
+
+ $sql.=" and b.bcode = '".$bat."'";
+
+ }
+ if ($u!= ''){
+
+ $sql.=" and u.uid = '".$u."'";
+
+ }
+ $sql.=" group by ssid,sem,fbatch";
+ $sql.=" order by sl";
+ $leadDet=$this->db->query($sql);
+ $cert_statusDetails = $leadDet->result();
+ if (count($cert_statusDetails) > 0) {
+ $results['cert_statusList'] = true;
+ $results['cert_status'] = $cert_statusDetails;
+ } else {
+ $results['cert_statusList'] = false;
+ $results['cert_message'] = 'No record found';
+ }
+
+ return $results;
+
+ }
+ public function mark_cert_status($bat=null,$br=null,$u=null,$from=null,$to=null){
+
+ $sql = "select @s:=@s+1 sl,sms.sid as ssid,std.name as name,std.father as father,br.bname as bname,ifnull(b.batch,'-') as batch,std.phone as phone,sms.cmts as cmts,sms.cid as scid,sfp.bdate as bdate,list.status as status,u.uname as uname,cm.course as course,sms.cert_name as cert_name,sms.sem as sem,sms.cdate as cdate,sfs.batch as fbatch,sfs.cid as fcid,cfd.syear as syear,sum(sfs.cf) as crsfee,sum(sfs.stf) as stf,sum(sfs.others) as others,(sum(sfs.cf) + sum(sfs.stf) + sum(sfs.others)) as total,ifnull(sfp.bamount,0) as bamount,(sum(sfs.cf) + (sum(sfs.stf) + sum(sfs.others)) - ifnull(sfp.bamount,0)) as balance
+ from
+ (SELECT StudentID as sid,CourseID as cid,CertificationType as cert_name,BranchCode as branch,CDate as cdate,ListCode as lcode,Comments as cmts,Sem as sem FROM T_CertificationStatus) as sms
+ left join
+ (SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others FROM T_Students_Fees_Status
+ group by sid,batch) as sfs on sfs.sid=sms.sid
+ left join
+ (SELECT StudentID as sid,FeesId as fid,BillDate as bdate,sum(BillAmount) as bamount
+ FROM T_Students_Fees_PaidDetails, (SELECT @s:= 0) AS s
+ group by sid,fid,bdate) as sfp on sfp.sid=sfs.sid and sfp.fid=sfs.fid
+ left join
+ (SELECT ID as cid,CourseID as ccid,FeesType as ftype,Sem_Year as syear FROM T_Course_Fees_Details) as cfd
+ on cfd.cid=sms.cid
+ left join
+ (SELECT CourseID as cid,UniversityID as uid,CourseName as course FROM T_CourseMaster) as cm
+ on cm.cid=sfs.cid
+ left join
+ (SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster) as u
+ on u.uid=cm.uid
+ left join
+ (SELECT ListCode as lcode,ListName as status FROM T_PickListDetails) as list
+ on list.lcode=sms.lcode
+ left join
+ (SELECT StudentID as sid,MobileNumber as phone,FirstName as name,Fathername as father FROM T_StudentDetails) as std on std.sid=sms.sid
+ left join
+ (SELECT BatchCode as bcode,BatchName as batch FROM T_BatchMaster) as b on b.bcode=sfs.batch
+ left join
+ (SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster) as br on br.brcode=sms.branch
+ where std.name != 'null'
+ ";
+ if ($br!= ''){
+
+ $sql.=" and sms.branch = '".$br."'";
+
+ }
+ if ($bat!= ''){
+
+ $sql.=" and b.bcode = '".$bat."'";
+
+ }
+ if ($u!= ''){
+
+ $sql.=" and u.uid = '".$u."'";
+
+ }
+ if ($from and $to != ''){
+ $fromd= date("Y-m-d",strtotime($from));
+ $tod=date("Y-m-d",strtotime($to));
+
+ $sql.="and sms.cdate >= '".$fromd."'
+ and sms.cdate <= '".$tod."'";
+
+ }
+ $sql.=" group by ssid,sem,fbatch";
+ $sql.=" order by sl";
+
+ $leadDet=$this->db->query($sql);
+ $mcert_statusDetails = $leadDet->result();
+ if (count($mcert_statusDetails) > 0) {
+ $results['markcert_statusList'] = true;
+ $results['markcert_status'] = $mcert_statusDetails;
+ } else {
+ $results['markcert_statusList'] = false;
+ $results['markcert_message'] = 'No record found';
+ }
+
+ return $results;
+
+ }
+ public function expense($from=null,$to=null){
+
+ $sql = "SELECT exp.TypeName as exp_name,sum(dbm.Amount) as amount FROM T_Income_Outcome_Master exp
+ join T_DayBookMaster dbm on dbm.Type=exp.ID
+ where dbm.Name = 'I001'
+ ";
+
+ if ($from and $to != ''){
+ $fromd= date("d-m-Y",strtotime($from));
+ $tod=date("d-m-Y",strtotime($to));
+
+ $sql.="and dbm.Date >= '".$fromd."'
+ and dbm.Date <= '".$tod."'";
+
+ }
+ $sql.=" group by exp_name";
+
+
+ $leadDet=$this->db->query($sql);
+ $expense = $leadDet->result();
+ if (count($expense) > 0) {
+ $results['expense_list'] = true;
+ $results['expense'] = $expense;
+ } else {
+ $results['expense_list'] = false;
+ $results['expense_message'] = 'No record found';
+ }
+
+ return $results;
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/SeesionMaster_model.php b/api/application/models/SeesionMaster_model.php
new file mode 100644
index 0000000..5b83bc6
--- /dev/null
+++ b/api/application/models/SeesionMaster_model.php
@@ -0,0 +1,189 @@
+db->select('SessionName');
+ $this->db->where('SessionName', $arrayDetails['SessionName']);
+ if($this->db->get(SESSIONMASTER)->first_row()){
+ $result['sessionStatus'] = false;
+ $result['message'] ="This sessions is already exist.";
+ }
+ else{
+ $insertMaster['SessionName']=$arrayDetails['SessionName'];
+ $insertMaster['SessionDate']=$arrayDetails['SessionDate'];
+ $insertMaster['CreatedBy']=$arrayDetails['CreatedBy'];
+ $insertMaster['IsActive']=$arrayDetails['IsActive'];
+ $insertMaster['CreatedOn']=$arrayDetails['CreatedOn'];
+
+ $this->db->insert(SESSIONMASTER, $insertMaster);
+
+ if ($this->db->affected_rows() == '1') {
+ $insertDetails['SessionID']=$this->db->insert_id();
+ foreach ($university['UniversityID'] as $row1){
+ $insertDetails['UniversityID']=$row1['UniversityID'];
+ $insertDetails['CreatedBy']=$arrayDetails['CreatedBy'];
+ $insertDetails['IsActive']=$arrayDetails['IsActive'];
+ $insertDetails['CreatedOn']=$arrayDetails['CreatedOn'];
+ $this->db->insert(SESSIONDETAILS, $insertDetails);
+
+ }
+
+ $result['sessionStatus'] = true;
+ $result['message'] = "Sessions added successfully";
+ } else {
+ $result['sessionStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+
+
+
+ return $result;
+
+ }
+
+
+ /*
+ * Get session master details
+ * created by kms
+ * */
+
+ public function getSession()
+ {
+ $this->db->select('SM.SessionID,SM.SessionDate,SM.SessionName,GROUP_CONCAT(SD.UniversityID) as UniversityID,GROUP_CONCAT(SM.SessionID) as GrpID,SM.IsActive,GROUP_CONCAT(US.UniversityName) as UniversityName');
+ $this->db->from(SESSIONMASTER.' as SM');
+ $this->db->join(SESSIONDETAILS.' as SD', 'SM.SessionID = SD.SessionID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = SD.UniversityID');
+ $this->db->where('SD.IsActive','1');
+ $this->db->order_by('SM.SessionID','DESC');
+ $this->db->group_by('SM.SessionID','DESC');
+ $sessionDetails = $this->db->get();
+ if($sessionDetails->result()){
+
+ $result['sessionStatus'] = true;
+ $result['details'] = $sessionDetails->result();
+ }
+ else {
+ $result['sessionStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+ // load batch model for get university details
+ $this->load->model('Batch_model', 'batch');
+ $result['universityDetails'] = $this->batch->getUniversityDetails();
+
+
+ return $result;
+
+ }
+
+ /*
+ * update session master details
+ * created by kms
+ * */
+ public function updateSession($arrayDetails=null,$universityDetails=null)
+ {
+ $this->db->select('SessionName');
+ $this->db->where('SessionName', $arrayDetails['SessionName']);
+ $this->db->where('SessionID !=', $arrayDetails['SessionID']);
+ if($this->db->get(SESSIONMASTER)->first_row()){
+ $result['sessionStatus'] = false;
+ $result['message'] ="This sessions is already exist.";
+ }
+ else{
+ $this->db->where('SessionID', $arrayDetails['SessionID']);
+ $upateStatus=$this->db->update(SESSIONMASTER, $arrayDetails);
+
+ if($upateStatus){
+ $deactiveStatus['IsActive']=false;
+ $deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('SessionID ',$arrayDetails['SessionID']);
+ $updateActivityStatusDeactive = $this->db->update(SESSIONDETAILS, $deactiveStatus);
+
+ if($updateActivityStatusDeactive){
+
+ if($universityDetails['University']){
+
+ foreach ($universityDetails['University'] as $urow){
+ $this->db->select('ID');
+ $this->db->where('SessionID',$arrayDetails['SessionID']);
+ $this->db->where('UniversityID',$urow);
+ if($this->db->get(SESSIONDETAILS)->first_row()){
+ $existStatusUpdate['IsActive']=true;
+ $existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('SessionID',$arrayDetails['SessionID']);
+ $this->db->where('UniversityID',$urow);
+ $this->db->update(SESSIONDETAILS, $existStatusUpdate);
+ }
+ else{
+ $update_array["UniversityID"]=$urow;
+ $update_array["SessionID"]=$arrayDetails['SessionID'];
+ $update_array["IsActive"]=true;
+ $update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
+ $update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
+ $this->db->insert(SESSIONDETAILS, $update_array);
+
+ }
+
+ }
+ }
+ else{
+ $activateStatus['IsActive']=true;
+ $this->db->where('SessionID ',$arrayDetails['SessionID']);
+ $this->db->update(SESSIONMASTER, $activateStatus);
+
+ }
+
+
+
+ $result['sessionStatus'] = true;
+ $result['message'] = "Sessions updated successfully";
+ }
+
+
+ } else {
+ $result['sessionStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+ return $result;
+
+ }
+ /*
+ * Get university details
+ * created by kms
+ * */
+ public function getUniversityDetails()//doubt
+ {
+ $this->db->select('UniversityID,UniversityName');
+ $this->db->order_by('UniversityID','ASC');
+ $this->db->where('IsActive','1');
+ // $this->db->where_not_in('ID', $id);
+ $universityDetails = $this->db->get(UNIVERSITY);
+ return $universityDetails->result();
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/SeesionSchedule_model.php b/api/application/models/SeesionSchedule_model.php
new file mode 100644
index 0000000..f374aee
--- /dev/null
+++ b/api/application/models/SeesionSchedule_model.php
@@ -0,0 +1,206 @@
+db->select('SCDate');
+ $this->db->where('SCDate', $arrayDetails['SCDate']);
+ $this->db->where('SessionID', $arrayDetails['SessionID']);
+ if($this->db->get(SESSIONSCHEDULE)->first_row()){
+ $result['sessionStatus'] = false;
+ $result['message'] ="This same session/date is already exist.";
+ }
+ else{
+ $insertMaster['SCDate']=$arrayDetails['SCDate'];
+ $insertMaster['SessionID']=$arrayDetails['SessionID'];
+ $insertMaster['CreatedBy']=$arrayDetails['CreatedBy'];
+ $insertMaster['IsActive']=$arrayDetails['IsActive'];
+ $insertMaster['CreatedOn']=$arrayDetails['CreatedOn'];
+
+ $this->db->insert(SESSIONSCHEDULE, $insertMaster);
+
+ if ($this->db->affected_rows() == '1') {
+ $insertDetails['SessionID']=$this->db->insert_id();
+ foreach ($Timings['Timings'] as $row1){
+ $insertDetails['StartTime']=$row1['startTime'];
+ $insertDetails['EndTime']=$row1['endTime'];
+ $insertDetails['CreatedBy']=$arrayDetails['CreatedBy'];
+ $insertDetails['IsActive']=$arrayDetails['IsActive'];
+ $insertDetails['CreatedOn']=$arrayDetails['CreatedOn'];
+ $this->db->insert(SESSIONSCHEDULEDETAILS, $insertDetails);
+
+ }
+
+ $result['sessionStatus'] = true;
+ $result['message'] = "Schedules added successfully";
+ } else {
+ $result['sessionStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+
+
+
+ return $result;
+
+ }
+
+
+ /*
+ * Get session schedule master details
+ * created by kms
+ * */
+
+ public function getSessionSchedule()
+ {
+ $this->db->select('SS.SCID,SM.SessionName,SM.SessionID,SS.IsActive,SS.SCDate');
+ $this->db->from(SESSIONSCHEDULE.' as SS');
+ $this->db->join(SESSIONMASTER.' as SM', 'SS.SessionID = SM.SessionID');
+ // $this->db->where('SM.IsActive','1');
+ $this->db->order_by('SS.SCID','DESC');
+ $sessionDetails = $this->db->get();
+ $result_array = array();
+ if($sessionDetails->result()){
+
+ foreach ($sessionDetails->result() as $row)
+ {
+ $scheduleDetails['SCID'] = $row->SCID;
+ $scheduleDetails['SessionName'] = $row->SessionName;
+ $scheduleDetails['SessionID'] = $row->SessionID;
+ $scheduleDetails['SCDate'] = $row->SCDate;
+ // $scheduleDetails['ScheduleDate'] = $row->SCDate;
+ $scheduleDetails['IsActive'] = $row->IsActive;
+ $scheduleDetails['ScheduleDetails'] = $this->getSessionScheduleDetails($row->SCID);
+ $result[]=$scheduleDetails;
+
+ }
+
+ $result_array['sessionStatus'] = true;
+ $result_array['details'] = $result;
+ }
+ else {
+ $result_array['sessionStatus'] = false;
+ $result_array['message'] = "No records found!";
+ }
+
+ $result_array['sessionMaster'] = $this->getSessionMasterDetails();
+
+
+ return $result_array;
+
+ }
+
+ /*
+ * get schedule details
+ * created by kms
+ * */
+
+ public function getSessionScheduleDetails($scheduleID=null)
+ {
+ $this->db->select('SD.StartTime,SD.EndTime,SD.SSD as ScheduleID');
+ $this->db->from(SESSIONSCHEDULEDETAILS.' as SD');
+ $this->db->join(SESSIONSCHEDULE.' as SS', 'SS.SCID = SD.SessionID');
+ $this->db->where('SD.SessionID',$scheduleID);
+ $this->db->group_by('SD.SSD','ASC');
+ $sessionDetails = $this->db->get();
+ return $sessionDetails->result();
+
+ }
+
+
+
+ /*
+ * update session schedule details
+ * created by kms
+ * */
+ public function updateSessionSchedule($arrayDetails=null,$Timings=null)
+ {
+
+ $this->db->select('SessionID');
+ $this->db->where('SessionID', $arrayDetails['SessionID']);
+ $this->db->where('SCDate', $arrayDetails['SCDate']);
+ $this->db->where('SCID !=', $arrayDetails['SCID']);
+ if($this->db->get(SESSIONSCHEDULE)->first_row()){
+ $result['sessionStatus'] = false;
+ $result['message'] ="This same session/date is already exist.";
+ }
+ else{
+ $this->db->where('SCID', $arrayDetails['SCID']);
+ $upateStatus=$this->db->update(SESSIONSCHEDULE, $arrayDetails);
+
+ if($upateStatus){
+
+ if($Timings['Timings']){
+
+ foreach ($Timings['Timings'] as $urow){
+ if($urow['scheduleID']==''){
+ $insertDetails['SessionID']=$arrayDetails['SCID'];
+ $insertDetails['StartTime']=$urow['startTime'];
+ $insertDetails['EndTime']=$urow['endTime'];
+ $insertDetails['IsActive']=$arrayDetails['IsActive'];
+ $insertDetails['CreatedBy']=$arrayDetails['UpdatedBy'];
+ $insertDetails['CreatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->insert(SESSIONSCHEDULEDETAILS, $insertDetails);
+
+ }
+ else{
+ $updateDetails['SessionID']=$arrayDetails['SCID'];
+ $updateDetails['StartTime']=$urow['startTime'];
+ $updateDetails['EndTime']=$urow['endTime'];
+ $updateDetails['IsActive']=$arrayDetails['IsActive'];
+ $updateDetails['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $updateDetails['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('SSD',$urow['scheduleID']);
+ $this->db->where('SessionID',$arrayDetails['SCID']);
+ $this->db->update(SESSIONSCHEDULEDETAILS, $updateDetails);
+
+ }
+
+
+ }
+ }
+ $result['sessionStatus'] = true;
+ $result['message'] = "Schedules updated successfully";
+
+ } else {
+ $result['sessionStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+ return $result;
+
+ }
+ /*
+ * Get session master details
+ * created by kms
+ * */
+ public function getSessionMasterDetails()//doubt
+ {
+ $this->db->select('SessionID,SessionName');
+ $this->db->order_by('SessionID','DESC');
+ $this->db->where('IsActive','1');
+ $sessionDetails = $this->db->get(SESSIONMASTER);
+ return $sessionDetails->result();
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/StatusUpdation_model.php b/api/application/models/StatusUpdation_model.php
new file mode 100644
index 0000000..6076a7d
--- /dev/null
+++ b/api/application/models/StatusUpdation_model.php
@@ -0,0 +1,1068 @@
+get_status_list_code($reqDetails);
+ $subQuery = "SELECT P.ListCode , P.ListName
+ FROM ".PICK_LIST_DETAILS." as P LEFT JOIN ".DEFAULTACTIVITY." as SM ON SM.StatusCode = P.ListCode
+ WHERE
+ SM.StudentActivityCode = '$statusCode'
+ AND SM.IsActive = '1'";
+
+ $queryDetails = $this->db->query($subQuery);
+ // $this->db->select('ListCode, ListName');
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->from('T_PickListDetails');
+ // $this->db->where('ListCode', 'S034');
+ // $staDetails = $this->db->get();
+ $statusDetails = $queryDetails->result();
+ if (count($statusDetails) > 0) {
+ $results['statusList'] = true;
+ $results['statusList_details'] = $statusDetails;
+ } else {
+ $results['statusList'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+ }
+
+ public function get_couser_name($cours) {
+ $this->db->select('t2.CourseName');
+ // $this->db->from('' . COURSE_FEES . ' as t1');
+ $this->db->from('' . COURSE . ' as t2');
+ $this->db->where('t2.CourseID', $cours);
+ $roleDetails = $this->db->get()->first_row();
+ return "$roleDetails->CourseName";
+ }
+
+ // update Application status
+ public function update_applicationStatus($arr,$reqDetails) {
+ $this->db->insert_batch(APPLICATION_STATUS, $arr);
+ if ($this->db->affected_rows() >= 1) {
+ if($this->get_ListCode_status($arr[0]['ListCode'])){
+ $dateToMsg = $arr[0]['AppDate'];
+ $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']);
+ $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
+ $getCourseName = $this->get_couser_name($arr[0]['CourseID']);
+ $mesg = "Status Update : $cerNamtToMsg $getCourseName - $statuToMsg $dateToMsg.";
+ $this->smssend($arr, $mesg);
+ }
+ // $result['addStatus'] = true;
+ // $result['message'] = "Successfully Certification Status Updated";
+ $this->updateDocumentStatusInCallTrack($arr,$reqDetails);
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Documents Status Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ // update certificate stauts
+ public function update_certificateStatus($arr) {
+ // $this->get_status_name_ListCode($arr[0]['ListCode']);
+ // $dateToMsg = $arr[0]['CDate'];
+ // print_r($arr);exit();
+ // echo $this->get_status_name_ListCode($arr[0]['ListCode']);exit();
+ $this->db->insert_batch(CERTIFICATION_STATUS, $arr);
+ if ($this->db->affected_rows() >= 1) {
+ // if( ($this->get_status_name_ListCode($arr[0]['ListCode']) == 'Received' || 'received' || 'RECEIVED') || ($this->get_status_name_ListCode($arr[0]['ListCode']) == 'Issued' || 'issued' || 'ISSUED')) {
+ if($this->get_ListCode_status($arr[0]['ListCode'])){
+ $dateToMsg = $arr[0]['CDate'];
+ $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']);
+ // $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
+ $cerNamtToMsg = 'MARK CARD';
+ $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']);
+ $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg.";
+
+ // $mesg = "Status Update : $cerNamtToMsg - $statuToMsg $dateToMsg.";
+ $this->smssend($arr, $mesg);
+ }
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Mark Card Status Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ // get certificate list
+ public function get_certificate_list() {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(CERTIFICATION);
+ $this->db->where('IsActive', 1);
+ $cerfDetails = $this->db->get();
+ $certificateDetails = $cerfDetails->result();
+ if (count($certificateDetails) > 0) {
+ $results['certificateStatus'] = true;
+ $results['certificate_details'] = $certificateDetails;
+ } else {
+ $results['certificateStatus'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+ }
+
+
+ // self function for getting registered mobile for sms
+ public function get_registered_mobile($num) {
+ $this->db->select('MobileNumber');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $num);
+ $roleDetails = $this->db->get()->first_row();
+ return $roleDetails->MobileNumber;
+ }
+
+ // self function for getting the status for the LISTCODE
+ public function get_ListCode_status($listCode) {
+ // print_r ($listCode);exit();
+ $this->db->select('ListName');
+ $this->db->from(PICK_LIST_DETAILS);
+ $this->db->where('ListCode', $listCode);
+ // $this->db->or_like('ListName', 'RECEIVED');
+ // $this->db->or_like('ListName', 'ISSUED');
+ $statusDetails = $this->db->get()->first_row();
+ // echo $statusDetails->ListName;exit();
+ if ( $statusDetails->ListName == 'RECEIVED' || $statusDetails->ListName == 'ISSUED') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public function get_prev_status_list($reqDetailsFor, $reqDetails){
+ if( $reqDetailsFor == 'STUDY_MATERIAL') {
+ $searchFor = 'M001';
+ $searchTableFor = STUDY_MATERIAL_STATUS;
+ $this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
+ $this->db->from(''. $searchTableFor . ' as t1');
+ $this->db->where('t1.StudentID', $reqDetails['student']);
+ $this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
+ $this->db->where('t2.CourseID', $reqDetails['CourseID']);
+ $this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
+ $this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $statusDetails = $this->db->get();
+ $prevStatusDetails = $statusDetails->result();
+ if (count($prevStatusDetails) > 0) {
+ $results['preStatusDetails'] = true;
+ $results['preStatus_details_list'] = $prevStatusDetails;
+ } else {
+ $results['preStatusDetails'] = false;
+ $results['message'] = 'No record found';
+ }
+ } else if ( $reqDetailsFor == 'APPICATION_STATUS' ) {
+ $searchFor = 'A001';
+ $searchTableFor = APPLICATION_STATUS;
+ $this->db->select('t1.*, t4.Firstname, t5.ListName, t6.CertificateName');
+ $this->db->from(''. $searchTableFor . ' as t1');
+ $this->db->where('t1.StudentID', $reqDetails['student']);
+ // $this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
+ // $this->db->where('t2.CourseID', $reqDetails['CourseID']);
+ $this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
+ $this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
+ $this->db->join('' . CERTIFICATION . ' as t6', 't6.CertificationID = t1.CertificationType', 'LEFT');
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $statusDetails = $this->db->get();
+ $prevStatusDetails = $statusDetails->result();
+ if (count($prevStatusDetails) > 0) {
+ $results['preStatusDetails'] = true;
+ $results['preStatus_details_list'] = $prevStatusDetails;
+ } else {
+ $results['preStatusDetails'] = false;
+ $results['message'] = 'No record found';
+ }
+ } else if ( $reqDetailsFor == 'CERTIFICATION_STATUS' ) {
+ $searchFor = 'C001';
+ $searchTableFor = CERTIFICATION_STATUS;
+ $this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
+ $this->db->from(''. $searchTableFor . ' as t1');
+ $this->db->where('t1.StudentID', $reqDetails['student']);
+ $this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
+ $this->db->where('t2.CourseID', $reqDetails['CourseID']);
+ $this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
+ $this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
+ // $this->db->join('' . CERTIFICATION . ' as t6', 't6.CertificationID = t1.CertificationType', 'LEFT');
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $statusDetails = $this->db->get();
+ $prevStatusDetails = $statusDetails->result();
+ if (count($prevStatusDetails) > 0) {
+ $results['preStatusDetails'] = true;
+ $results['preStatus_details_list'] = $prevStatusDetails;
+ } else {
+ $results['preStatusDetails'] = false;
+ $results['message'] = 'No record found';
+ }
+ } else if ( $reqDetailsFor == 'ANSWERBOOKLET_STATUS' ) {
+ $searchFor = 'B001';
+ $searchTableFor = ANSWER_BOOKLET;
+ $this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
+ $this->db->from(''. $searchTableFor . ' as t1');
+ $this->db->where('t1.StudentID', $reqDetails['student']);
+ $this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
+ $this->db->where('t2.CourseID', $reqDetails['CourseID']);
+ $this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
+ $this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
+ $this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
+ $this->db->order_by('t1.CreatedOn', 'DESC');
+ $statusDetails = $this->db->get();
+ $prevStatusDetails = $statusDetails->result();
+ if (count($prevStatusDetails) > 0) {
+ $results['preStatusDetails'] = true;
+ $results['preStatus_details_list'] = $prevStatusDetails;
+ } else {
+ $results['preStatusDetails'] = false;
+ $results['message'] = 'No record found';
+ }
+ }
+ return $results;
+ }
+
+ public function get_status_name_ListCode($listCode) {
+ $this->db->select('ListName');
+ $this->db->from(PICK_LIST_DETAILS);
+ $this->db->where('ListCode', $listCode);
+ $statusDetails = $this->db->get()->first_row();
+ return $statusDetails->ListName;
+ }
+
+ // self function for getting certificate name for the CERTIFICATECODE
+ public function get_certificate_name($listCode) {
+ $this->db->select('CertificateName');
+ $this->db->from(CERTIFICATION);
+ $this->db->where('CertificationID', $listCode);
+ $cerfDetails = $this->db->get()->first_row();
+ return $cerfDetails->CertificateName;
+ }
+
+ // update answer booklet status
+ public function update_answerbooklet($arr,$reqDetails) {
+ // print_r($arr);exit();
+ $this->db->insert_batch(ANSWER_BOOKLET, $arr);
+ if ($this->db->affected_rows() >= 1) {
+ $this->updateBookletStatusInCallTrack($arr,$reqDetails);
+ // $this->smssend($arr);
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Answer Booklet Status Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ public function get_couser_sem_yr_msg($cours) {
+ $this->db->select('t1.Sem_Year, t2.CourseName');
+ $this->db->from('' . COURSE_FEES . ' as t1');
+ $this->db->join('' . COURSE . ' as t2', 't2.CourseID = t1.CourseID', 'LEFT');
+ $this->db->where('ID', $cours);
+ $roleDetails = $this->db->get()->first_row();
+ return "$roleDetails->Sem_Year $roleDetails->CourseName";
+
+ }
+
+ // update study material status
+ public function update_semyear($arr) {
+ // echo $cours;exit();
+ // $this->get_status_name_ListCode($arr[0]['ListCode']);
+ $this->db->insert_batch(STUDY_MATERIAL_STATUS, $arr);
+ if ($this->db->affected_rows() >= 1) {
+ // if(($this->get_status_name_ListCode($arr[0]['ListCode']) == 'Received' || 'received' || 'Active') || ($this->get_status_name_ListCode($arr[0]['ListCode']) == 'Issued' || 'issued')) {
+ if($this->get_ListCode_status($arr[0]['ListCode']) == true) {
+ $dateToMsg = $arr[0]['SDate'];
+ $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']);
+ $cerNamtToMsg = 'Study Material';
+ $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']);
+ $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg.";
+ $this->smssend($arr, $mesg);
+ }
+ // $this->smssend($arr);
+ $result['addStatus'] = true;
+ $result['message'] = "Successfully Study Material Status Updated";
+ } else {
+ $result['addStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ // get sem/Year for the course
+ public function get_semyear_result($reqData, $stuFor) {
+ // echo $stuFor;exit();
+ $subQuery = "SELECT CF.Sem_Year, CF.ID , IF(CF.ProgramType = 'Y001', '0', '1') as SEM_YEAR_TYPE
+ FROM ".COURSE_FEES." as CF LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.FeesType = CF.ID
+ WHERE
+ SFS.CourseID = '$reqData'
+ AND SFS.StudentID = '$stuFor'";
+ // AND CF.ProgramType ='Y001'";
+ $queryDetails = $this->db->query($subQuery);
+ $results['semYearResult'] = true;
+ $results['semYear_result_details'] = $queryDetails->result();
+ return $results;
+ }
+
+ // get serach result
+ public function get_search_result($reqData, $req) {
+ // print_r($reqData['University']);
+ // print_r($req);
+ // exit();
+ $University = $reqData['University'];
+ $Course = $reqData['Course'];
+ $Batch = $reqData['Batch'];
+ $branch = $req['localBranchID'];
+ if( $branch == 'All' ) {
+
+ // echo $University;
+ // echo $branch
+
+ if($University != '' && $Course == '' && $Batch == '') {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ($University != '' && $Course != '' && $Batch == '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ( $University != '' && $Course == '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ }else if ( $University != '' && $Course != '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ }
+ } else {
+ // echo $University;
+ // echo $branch;
+
+ if($University != '' && $Course == '' && $Batch == '') {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.BranchID = '$branch'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ($University != '' && $Course != '' && $Batch == '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.BranchID = '$branch'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ( $University != '' && $Course == '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID
+ LEFT JOIN ".COURSE." as C ON C.CourseID = SC.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.BranchID = '$branch'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ } else if ( $University != '' && $Course != '' && $Batch != '' ) {
+ $subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
+ FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON
+ SC.CourseID = C.CourseID
+ LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID
+ WHERE SFS.CourseID = SC.CourseID AND
+ SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND S.IsActive = '1'
+ AND SC.BranchID = '$branch'
+ AND SC.IsActive = '1'";
+ // AND S.BranchCode = '$branch'
+ // SC.UniversityID LIKE '%$University%'
+ // AND SC.CourseID LIKE '%$Course%'
+ // AND SC.BatchCode LIKE '%$Batch%'
+ $queryDetails = $this->db->query($subQuery);
+ $results['searchResult'] = true;
+ $results['search_result_details'] = $queryDetails->result();
+ }
+ }
+ return $results;
+ }
+
+ // get list of universities, course, batch
+ public function get_university_course_batch() {
+ $this->db->select('t1.UniversityID, t1.UniversityName');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(''.UNIVERSITY. ' as t1');
+ $this->db->where('IsActive', 1);
+ // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $univDetails = $this->db->get();
+ $universityDetails = $univDetails->result();
+ $endResult = [];
+ foreach($universityDetails as $clip){
+ // University Details
+ $resultArr['UniversityID'] = $clip->UniversityID;
+ $resultArr['UniversityName'] = $clip->UniversityName;
+ // Course Details
+ $this->db->select('t2.CourseID, t2.CourseName, t2.CourseCode');
+ $this->db->from(''.COURSE. ' as t2');
+ $this->db->where('t2.UniversityID', $clip->UniversityID);
+ $this->db->where('t2.IsActive', 1);
+ $courDetails = $this->db->get();
+ $courseDetails = $courDetails->result();
+ $resultArr['Course'] =$courseDetails;
+ // Batch Details
+ $this->db->select('t3.BatchName, t3.BatchCode');
+ $this->db->from(''.BATCH. ' as t3');
+ $this->db->where('t3.UniversityID', $clip->UniversityID);
+ $this->db->where('t3.IsActive', 1);
+
+ //Session Details
+ // $this->db->select('B.SessionID, B.SessionName');
+ // $this->db->from(SESSIONMASTER . ' as B');
+ // $this->db->join(SESSIONDETAILS . ' SD', 'SD.SessionID = B.SessionID');
+ // $this->db->where('SD.UniversityID', $clip->UniversityID);
+ // $this->db->where('B.IsActive', 1);
+ // $this->db->where('SD.IsActive', 1);
+
+ $batDetails = $this->db->get();
+ $batchDetails = $batDetails->result();
+ $resultArr['Batch'] =$batchDetails;
+ array_push($endResult, $resultArr);
+ }
+ $results['univList'] = true;
+ $results['university_details'] = $endResult;
+ return $results;
+ }
+
+
+ // http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf
+ // API Key : xegCdYUIMf3
+ // Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login.
+ // This is the template to be used.
+ public function smssend($arr, $msg)
+ {
+ $number =array();
+ foreach($arr as $ar){
+ $mobi = $this->get_registered_mobile($ar['StudentID']);
+ array_push($number, "91$mobi");
+ }
+ $mobile = implode(',', $number);
+ // $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
+ // $mobile = "91$mobile";
+
+ $message = urlencode($msg);
+ // echo $mobile , $message;
+ $ch=curl_init();
+ curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED");
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ $output =curl_exec($ch);
+
+ // print_r($output);exit();
+ curl_close($ch);
+ return $output;
+ }
+
+ // public function mailsend() {
+ // //Load email library
+ // $this->load->library('email');
+
+ // //SMTP & mail configuration
+ // $config = array(
+ // 'protocol' => 'smtp',
+ // 'smtp_host' => 'ssl://smtp.example.com',
+ // 'smtp_port' => 465,
+ // 'smtp_user' => 'email@example.com',
+ // 'smtp_pass' => 'email_password',
+ // 'mailtype' => 'html',
+ // 'charset' => 'utf-8'
+ // );
+ // $this->email->initialize($config);
+ // $this->email->set_mailtype("html");
+ // $this->email->set_newline("\r\n");
+
+ // //Email content
+ // $htmlContent = 'Sending email via SMTP server
';
+ // $htmlContent .= 'This email has sent via SMTP server from CodeIgniter application.
';
+
+ // // Email body load the html template
+ // // $body = $this->load->view('emails/anillabs.php',$data,TRUE);
+
+
+ // $this->email->to('recipient@example.com');
+ // $this->email->from('sender@example.com','MyWebsite');
+ // $this->email->subject('How to send email via SMTP server in CodeIgniter');
+ // $this->email->message($htmlContent);
+
+ // //Send email
+ // $this->email->send();
+ // }
+
+ /*
+ * update followup details for booklet details in call tracking
+ * created by kms
+ * */
+ public function updateBookletStatusInCallTrack($fromDetails=null,$reqDetails=null){
+ // get student details
+ $this->db->select('PLD.ListCode');
+ $this->db->from(PICK_LIST_DETAILS.' as PLD');
+ $this->db->where('PLD.ListName','ISSUED TO STUDENTS');
+ $this->db->where('PLD.ListCode',$fromDetails[0]['ListCode']);
+ $this->db->where('PLD.IsActive','1');
+ $checkStatus=$this->db->get()->last_row();
+ if($checkStatus){
+
+
+ $studentDetails = $this->studentInfo($fromDetails);
+ if($studentDetails){
+ $arrayDetails['MobileNumber']=$studentDetails->MobileNumber;
+ $arrayDetails['LeadName']=$studentDetails->Firstname;
+ $arrayDetails['University']=$studentDetails->UniversityName;
+ $arrayDetails['Course']=$studentDetails->CourseName;
+ $arrayDetails['StatusCode']=$fromDetails[0]['ListCode'];
+ $arrayDetails['CreatedBranch']=$fromDetails[0]['BranchCode'];
+ $arrayDetails['CreatedOn']=$fromDetails[0]['CreatedOn'];
+ $arrayDetails['FollowupOn']=$fromDetails[0]['AnsDate'];
+ $arrayDetails['FollowupComments']=$fromDetails[0]['Comments'];
+ if($reqDetails['localType']==SUPER_ADMIN){
+ $this->db->select('LO.ID');
+ $this->db->from(STAFF_BRANCH.' as STB');
+ $this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID');
+ $this->db->where('STB.BranchCode',$fromDetails[0]['BranchCode']);
+ $this->db->where('LO.ListCode',ADMIN);
+ $this->db->where('STB.IsActive','1');
+ $this->db->where('LO.IsActive','1');
+ $assignDet=$this->db->get()->last_row();
+ if($assignDet){
+ $arrayDetails['CreatedBy']=$assignDet->ID;
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails[0]['CreatedBy'];
+ }
+
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails[0]['CreatedBy'];
+ }
+
+ // create activity in call tracking
+ $this->db->select('ActivityID,ActivityName');
+ $this->db->like('ActivityName', 'Answer Booklet', 'after');
+ $this->db->where('IsActive', '1');
+ $activityDetails=$this->db->get(ACTIVITY)->last_row();
+ if($activityDetails){
+
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ // hide tracking updated code
+
+ /*$this->db->select('LD.LeadID,LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']);
+ $this->db->where('LT.ActivityStatus',$activityDetails->ActivityID);
+ $this->db->like('LT.University',$arrayDetails['University'],'after');
+ $this->db->like('LT.Course',$arrayDetails['Course'],'after');
+ $leadDet=$this->db->get()->last_row();
+
+ if($leadDet){
+ $this->db->select('FollowupOn');
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ // $this->db->order_by('InteractionId','DESC');
+ $existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row();
+ // upate tracking status
+ $changeStatusCode['StatusCode'] = $arrayDetails['StatusCode'];
+ $changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy'];
+ $changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn'];
+ $changeStatusCode['CreatedBranch']=$arrayDetails['CreatedBranch'];
+
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $this->db->update(LEAD_TRACKING, $changeStatusCode);
+ // end update status
+ $updateTrackDetails['TrackingID'] = $leadDet->TrackingID;
+ $updateTrackDetails['FollowupOn'] = $existFollowupOn->FollowupOn;
+ $updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments'];
+ $updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails);
+
+ }
+
+ else{
+ $this->db->select('LeadID');
+ $this->db->where('MobileNumber',$arrayDetails['MobileNumber']);
+ $checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row();
+ if($checkLeadDet){
+ $updateLeadDetails['LeadID'] = $checkLeadDet->LeadID;
+ $updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID;
+ $updateLeadDetails['University'] = $arrayDetails['University'];
+ $updateLeadDetails['Course'] = $arrayDetails['Course'];
+ $updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode'];
+ $updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $updateLeadDetails['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $updateLeadDetails);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $followup_Details['TrackingID']=$this->db->insert_id();
+ $followup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $followup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $followup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $followup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
+ // this if for insert follow up details
+
+ }
+
+ }
+ else{
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ }
+
+
+ }*/
+
+
+ }
+ }
+
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ /*
+ * update followup details for application status in call tracking
+ * created by kms
+ * */
+ public function updateDocumentStatusInCallTrack($fromDetails=null,$reqDetails=null){
+
+
+ // check certificate type
+ $this->db->select('CFM.CertificationID');
+ $this->db->from(CERTIFICATION_MASTER.' as CFM');
+ $this->db->where('CFM.CertificateName','APPLICATION');
+ $this->db->where('CFM.CertificationID',$fromDetails[0]['CertificationType']);
+ $this->db->where('CFM.IsActive','1');
+ $checkApplicationStatus=$this->db->get()->last_row();
+ if($checkApplicationStatus){
+ // get student details
+ $this->db->select('PLD.ListCode');
+ $this->db->from(PICK_LIST_DETAILS.' as PLD');
+ $this->db->where('PLD.ListName','PENDING');
+ $this->db->where('PLD.ListCode',$fromDetails[0]['ListCode']);
+ $this->db->where('PLD.IsActive','1');
+ $checkStatus=$this->db->get()->last_row();
+ if($checkStatus){
+
+ $studentDetails = $this->studentInfoForDocumentStatus($fromDetails);
+ if($studentDetails){
+ $arrayDetails['MobileNumber']=$studentDetails->MobileNumber;
+ $arrayDetails['LeadName']=$studentDetails->Firstname;
+ $arrayDetails['University']=$studentDetails->UniversityName;
+ $arrayDetails['Course']=$studentDetails->CourseName;
+ $arrayDetails['StatusCode']=$fromDetails[0]['ListCode'];
+ $arrayDetails['CreatedBranch']=$fromDetails[0]['BranchCode'];
+ $arrayDetails['CreatedOn']=$fromDetails[0]['CreatedOn'];
+ $arrayDetails['FollowupOn']=$fromDetails[0]['AppDate'];
+ $arrayDetails['FollowupComments']=$fromDetails[0]['Comments'];
+ if($reqDetails['localType']==SUPER_ADMIN){
+ $this->db->select('LO.ID');
+ $this->db->from(STAFF_BRANCH.' as STB');
+ $this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID');
+ $this->db->where('STB.BranchCode',$fromDetails[0]['BranchCode']);
+ $this->db->where('LO.ListCode',ADMIN);
+ $this->db->where('STB.IsActive','1');
+ $this->db->where('LO.IsActive','1');
+ $assignDet=$this->db->get()->last_row();
+ if($assignDet){
+ $arrayDetails['CreatedBy']=$assignDet->ID;
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails[0]['CreatedBy'];
+ }
+
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails[0]['CreatedBy'];
+ }
+
+ // create activity in call tracking
+ $this->db->select('ActivityID,ActivityName');
+ $this->db->like('ActivityName', 'Application', 'after');
+ $this->db->where('IsActive', '1');
+ $activityDetails=$this->db->get(ACTIVITY)->last_row();
+ if($activityDetails){
+
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ /// hide seperate track id
+
+ /* $this->db->select('LD.LeadID,LT.TrackingID');
+ $this->db->from(LEAD_DETAILS.' as LD');
+ $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
+ $this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']);
+ $this->db->where('LT.ActivityStatus',$activityDetails->ActivityID);
+ $this->db->like('LT.University',$arrayDetails['University'],'after');
+ $this->db->like('LT.Course',$arrayDetails['Course'],'after');
+ $leadDet=$this->db->get()->last_row();
+
+ if($leadDet){
+ $this->db->select('FollowupOn');
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ // $this->db->order_by('InteractionId','DESC');
+ $existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row();
+ // upate tracking status
+ $changeStatusCode['StatusCode'] = $arrayDetails['StatusCode'];
+ $changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy'];
+ $changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn'];
+ $changeStatusCode['CreatedBranch']=$arrayDetails['CreatedBranch'];
+
+ $this->db->where('TrackingID',$leadDet->TrackingID);
+ $this->db->update(LEAD_TRACKING, $changeStatusCode);
+ // end update status
+ $updateTrackDetails['TrackingID'] = $leadDet->TrackingID;
+ $updateTrackDetails['FollowupOn'] = $arrayDetails['FollowupOn'];
+ $updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments'];
+ $updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails);
+
+ }
+
+ else{
+ $this->db->select('LeadID');
+ $this->db->where('MobileNumber',$arrayDetails['MobileNumber']);
+ $checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row();
+ if($checkLeadDet){
+ $updateLeadDetails['LeadID'] = $checkLeadDet->LeadID;
+ $updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID;
+ $updateLeadDetails['University'] = $arrayDetails['University'];
+ $updateLeadDetails['Course'] = $arrayDetails['Course'];
+ $updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode'];
+ $updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $updateLeadDetails['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $updateLeadDetails);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $followup_Details['TrackingID']=$this->db->insert_id();
+ $followup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $followup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $followup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $followup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
+ // this if for insert follow up details
+
+ }
+
+ }
+ else{
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $activityDetails->ActivityID;
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+ }
+
+
+ }*/
+
+
+ }
+ }
+
+
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ else{
+ return false;
+ }
+
+ }
+
+ /*
+ * get student info
+ * created by kms
+ * */
+ public function studentInfo($details=null){
+
+ $this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName');
+ $this->db->from(COURSE_FEES.' as CF');
+ $this->db->join(STUDENTCOURSE.' as STC', 'STC.CourseID = CF.CourseID');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('ST.StudentID',$details[0]['StudentID']);
+ $this->db->where('CF.ID',$details[0]['CourseID']);
+ $leadDet=$this->db->get()->last_row();
+ if($leadDet){
+ return $leadDet;
+ }
+ else{
+ return false;
+ }
+
+ }
+ /*
+ * get student info for documet updates
+ * created by kms
+ * */
+ public function studentInfoForDocumentStatus($details=null){
+
+ $this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName');
+ $this->db->from(STUDENTCOURSE.' as STC');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('ST.StudentID',$details[0]['StudentID']);
+ $this->db->where('STC.CourseID',$details[0]['CourseID']);
+ $leadDet=$this->db->get()->last_row();
+ if($leadDet){
+ return $leadDet;
+ }
+ else{
+ return false;
+ }
+
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/api/application/models/Status_model.php b/api/application/models/Status_model.php
new file mode 100644
index 0000000..66272ba
--- /dev/null
+++ b/api/application/models/Status_model.php
@@ -0,0 +1,121 @@
+db->select('ListCode');
+ $this->db->where('ListGroup', '1');
+ $this->db->where('ListName', $arrayDetails['ListName']);
+ if($this->db->get(PICK_LIST_DETAILS)->first_row()){
+ $result['Status'] = false;
+ $result['message'] = "Status name is already exist!";
+ } else {
+ $this->db->insert(PICK_LIST_DETAILS, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['Status'] = true;
+ $result['message'] = "Successfully status details added";
+ }
+ else {
+ $result['Status'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+ // $checkExistActivity = $this->db->get(PICK_LIST_DETAILS);
+
+
+
+
+ return $result;
+
+ }
+
+
+
+ /*
+ * get status details
+ * parama id
+ * created by Surendiran
+ * */
+
+ public function getStatus()
+ {
+ $this->db->select('ListCode,ListName,IsActive');
+ $this->db->where('ListGroup','1');
+ $this->db->order_by('ListCode','DESC');
+ $statusDetails = $this->db->get(PICK_LIST_DETAILS);
+ if($statusDetails->result()){
+
+ $result['Status'] = true;
+ $result['details'] = $statusDetails->result();
+ }
+ else {
+ $result['Status'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+ /*
+ * update status details
+ * created by Surendiran
+ * */
+
+ public function update($arrayDetails=null,$ListCode=null)
+ {
+ $this->db->select('ListName');
+ $this->db->where('ListName', $arrayDetails['ListName']);
+ $this->db->where_not_in('ListCode', $ListCode);
+ if($this->db->get(PICK_LIST_DETAILS)->first_row()){
+ $result['Status'] = false;
+ $result['message'] = "Status name is already exist!";
+ } else {
+ $this->db->where('ListCode',$ListCode);
+ $this->db->update(PICK_LIST_DETAILS, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $result['Status'] = true;
+ $result['message'] = "Successfully status details updated";
+ }
+ else {
+ $result['Status'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+ }
+
+ public function getStatusBranchList( $id ) {
+ $this->db->select('BranchCode, BranchName');
+ $this->db->from(BRANCH);
+ $getBranchDetails = $this->db->get();
+ $branchDetails = $getBranchDetails->result();
+ if (count($branchDetails) > 0) {
+ $results['branchListStatus'] = true;
+ $results['branch_list_details'] = $branchDetails;
+ } else {
+ $results['branchListStatus'] = false;
+ $results['message'] = "Branch Is Not Avail.";
+ }
+ return $results;
+ }
+
+ public function getBranchStatusList($branchCode) {
+echo $branchCode;exit();
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/Student_model.php b/api/application/models/Student_model.php
new file mode 100644
index 0000000..d484991
--- /dev/null
+++ b/api/application/models/Student_model.php
@@ -0,0 +1,1347 @@
+db->select('t1.BranchCode,t1.BranchName');
+ $this->db->from('' . BRANCH . ' as t1');
+
+ // $this->db->where('t1.IsActive', 1);
+
+ $branchDetails = $this->db->get();
+ $checkArr = $branchDetails->result();
+ if (count($checkArr) > 0) {
+ $result['branDetailstatus'] = true;
+ $result['branch_details'] = $branchDetails->result();
+ }
+ else {
+ $result['branDetailstatus'] = false;
+ }
+
+ return $result;
+ }
+
+ // check the branch active status for student add
+
+ public function getBranchActiveStatusforStuAdd($branchId)
+ {
+ $this->db->select('t1.IsActive');
+ $this->db->from('' . BRANCH . ' as t1');
+ $this->db->where('BranchCode', $branchId);
+ $statusDetails = $this->db->get()->first_row();
+
+ // echo $statusDetails->IsActive;exit();
+
+ $result['branch_active_status'] = $statusDetails->IsActive;
+ return $result;
+
+ // if (count($checkArr) > 0) {
+ // $result['branDetailstatus'] = true;
+ // $result['branch_details'] = $branchDetails->result();
+ // } else {
+ // $result['branDetailstatus'] = false;
+ // }
+ // return $result;
+
+ }
+
+ // get student list based on login user
+
+ public function get_student_list($loginUserId, $loginUserBranchId, $loginUserType, $getSearchData)
+ {
+
+ // print_r($getSearchData);exit();
+ // echo $loginUserId, $loginUserBranchId, $loginUserType; exit();
+
+ if ($loginUserType == SUPER_ADMIN) {
+
+ // list for super admin based on branch
+
+ if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') {
+ $this->db->select('t1.*');
+ $this->db->from('' . STUDENTS . ' as t1');
+
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->where('BranchCode', $loginUserBranchId);
+
+ $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT');
+ $this->db->where('t2.BranchID', $loginUserBranchId);
+ $this->db->group_by('t2.StudentID');
+ $this->db->order_by('t2.CreatedOn', 'DESC');
+ $stuDetails = $this->db->get();
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+ else {
+
+ // print_r($getSearchData);exit();
+ // $this->db->select('t1.*');
+ // // $this->db->from(STUDENTS);
+ // $this->db->from('' . STUDENTS . ' as t1');
+ // $this->db->order_by('t1.CreatedOn', 'DESC');
+ // $this->db->where('t1.BranchCode', $loginUserBranchId);
+ // $this->db->from('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT');
+ // $this->db->where('t2.UniversityID', $getSearchData["University"]);
+ // $this->db->where('t2.CourseID', $getSearchData["Course"]);
+
+ $University = $getSearchData['University'];
+ $Course = $getSearchData['Course'];
+
+ // $Batch = $getSearchData['Batch'];
+
+ $Batch = '';
+ $StuStatus = $getSearchData['Status'];
+ if ($StuStatus == '') {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else
+ if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ }
+ else {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else
+ if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ }
+
+ $stuDetails = $this->db->query($subQuery);
+
+ // $stuDetails = $this->db->get();
+
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+
+ // if ($loginUserBranchId == 'All') {
+ // // for getting all branch details
+ // $staffId = $this->selfGetEmpId($loginUserId);
+ // $this->db->select('*');
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->from(STAFF);
+ // // not for SuperAdmin and Student Role code
+ // $this->db->where_not_in('StaffID', $staffId);
+ // // $this->db->where('BranchCode', $loginUserBranchId);
+ // $empDetails = $this->db->get();
+ // $checkArr = $empDetails->result();
+ // if (count($checkArr) > 0) {
+ // $results['employeeList'] = true;
+ // $results['employees_details'] = $empDetails->result();
+ // } else {
+ // $results['employeeList'] = false;
+ // $results['message'] = 'No record found';
+ // }
+ // } else {
+ // $staffId = $this->selfGetEmpId($loginUserId);
+ // $this->db->select('*');
+ // $this->db->order_by('CreatedOn', 'DESC');
+ // $this->db->from(STAFF);
+ // // not for SuperAdmin and Student Role code
+ // $this->db->where_not_in('StaffID', $staffId);
+ // $this->db->where('BranchCode', $loginUserBranchId);
+ // $empDetails = $this->db->get();
+ // $checkArr = $empDetails->result();
+ // if (count($checkArr) > 0) {
+ // $results['employeeList'] = true;
+ // $results['employees_details'] = $empDetails->result();
+ // } else {
+ // $results['employeeList'] = false;
+ // $results['message'] = 'No record found';
+ // }
+ // }
+
+ }
+ else if ($loginUserType == ADMIN) {
+
+ // list for admin
+
+ if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') {
+
+ // print_r($getSearchData);exit();
+
+ $this->db->select('t1.*');
+ $this->db->from('' . STUDENTS . ' as t1');
+
+ // $this->db->where('BranchCode', $loginUserBranchId);
+ // $this->db->group_by('user_id');
+
+ $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT');
+ $this->db->where('t2.BranchID', $loginUserBranchId);
+ $this->db->group_by('t2.StudentID');
+ $this->db->order_by('t2.CreatedOn', 'DESC');
+ $stuDetails = $this->db->get();
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+ else {
+ $University = $getSearchData['University'];
+ $Course = $getSearchData['Course'];
+
+ // $Batch = $getSearchData['Batch'];
+
+ $Batch = '';
+ $StuStatus = $getSearchData['Status'];
+ if ($StuStatus == '') {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ }
+ else {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ }
+
+ $stuDetails = $this->db->query($subQuery);
+
+ // $stuDetails = $this->db->get();
+
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+ }
+ else if ($loginUserType == EMPLOYEE) {
+
+ // list for staff
+ // list for admin
+
+ if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') {
+
+ // print_r($getSearchData);exit();
+
+ $this->db->select("t1.*, IF(t3.ID > 0, '1' , '0') as Fee_paid_exist");
+ $this->db->from('' . STUDENTS . ' as t1');
+ $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT');
+ $this->db->join('' . STUDENTS_FEES_PAID . ' as t3', 't3.StudentID = t1.StudentID', 'LEFT');
+ $this->db->where('t2.BranchID', $loginUserBranchId);
+ $this->db->group_by('t2.StudentID');
+ // $this->db->from(STUDENTS);
+ $this->db->order_by('t2.CreatedOn', 'DESC');
+ $stuDetails = $this->db->get();
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+ else {
+
+ // print_r($getSearchData);exit();
+ // $this->db->select('t1.*');
+ // // $this->db->from(STUDENTS);
+ // $this->db->from('' . STUDENTS . ' as t1');
+ // $this->db->order_by('t1.CreatedOn', 'DESC');
+ // $this->db->where('t1.BranchCode', $loginUserBranchId);
+ // $this->db->from('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT');
+ // $this->db->where('t2.UniversityID', $getSearchData["University"]);
+ // $this->db->where('t2.CourseID', $getSearchData["Course"]);
+
+ $University = $getSearchData['University'];
+ $Course = $getSearchData['Course'];
+
+ // $Batch = $getSearchData['Batch'];
+
+ $Batch = '';
+ $StuStatus = $getSearchData['Status'];
+ if ($StuStatus == '') {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*, IF(SFP.ID > 0, '1' , '0') as Fee_paid_exist
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID LEFT JOIN ". STUDENTS_FEES_PAID ." as SFP ON SFP.StudentID = S.StudentID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*, IF(SFP.ID > 0, '1' , '0') as Fee_paid_exist
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID LEFT JOIN ". STUDENTS_FEES_PAID ." as SFP ON SFP.StudentID = S.StudentID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ } // ### query branch code changed from student branch code to student course branch code
+
+ // AND S.BranchCode = '$loginUserBranchId' -> SC.BranchCode = '$loginUserBranchId'
+ // (SC.UniversityID = '$University'
+ // OR (SC.CourseID = '$Course' AND SC.UniversityID = '$University'))
+
+ }
+ else {
+ if ($University != '' && $Course == '') {
+ $subQuery = "SELECT S.*, IF(SFP.ID > 0, '1' , '0') as Fee_paid_exist
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID LEFT JOIN ". STUDENTS_FEES_PAID ." as SFP ON SFP.StudentID = S.StudentID
+ WHERE
+ SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+ else if ($University != '' && $Course != '') {
+ $subQuery = "SELECT S.*, IF(SFP.ID > 0, '1' , '0') as Fee_paid_exist
+ FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
+ LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
+ SC.CourseID = C.CourseID LEFT JOIN ". STUDENTS_FEES_PAID ." as SFP ON SFP.StudentID = S.StudentID
+ WHERE
+ SC.CourseID = '$Course' AND SC.UniversityID = '$University'
+ AND SC.BranchID = '$loginUserBranchId'
+ AND S.IsActive = '$StuStatus'
+ GROUP BY SC.StudentID
+ ORDER BY S.CreatedOn";
+ }
+
+ // ### query branch code changed from student branch code to student course branch code
+ // AND S.BranchCode = '$loginUserBranchId' -> SC.BranchCode = '$loginUserBranchId'
+
+ }
+
+ $stuDetails = $this->db->query($subQuery);
+
+ // $stuDetails = $this->db->get();
+
+ $checkArr = $stuDetails->result();
+ if (count($checkArr) > 0) {
+ $results['studentList'] = true;
+ $results['student_details'] = $stuDetails->result();
+ }
+ else {
+ $results['studentList'] = false;
+ }
+ }
+ }
+ else {
+ $results['studentList'] = false;
+ }
+
+ return $results;
+ }
+
+ // get a student cource list
+
+ public function get_student_course_list($studentId, $req)
+ {
+
+ // echo $req['localBranchID'];exit();
+
+ $this->db->select("t1.*,t2.UniversityName,t3.CourseName,t3.CourseCode,t4.SessionName, IF(t6.ID > 0, '1' , '0') as Fee_paid_exist");
+ $this->db->from('' . STUDENTCOURSE . ' as t1');
+ $this->db->join('' . UNIVERSITY . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $this->db->join('' . COURSE . ' as t3', 't3.CourseID = t1.CourseID', 'LEFT');
+ $this->db->join('' . SESSIONMASTER . ' as t4', 't4.SessionID = t1.SessionID', 'LEFT');
+ $this->db->join(''.STUDENTS_FEES_STATUS.' as t5', 't5.StudentID = '.$studentId.' AND t5.CourseID = t1.CourseID', 'LEFT');
+ $this->db->join(''.STUDENTS_FEES_PAID.' as t6', 't6.FeesId = t5.FeesID', 'LEFT');
+ $this->db->where('t1.BranchID', $req['localBranchID']);
+ $this->db->where('t1.StudentID', $studentId);
+ $this->db->group_by('t1.CourseID');
+ $courseDetails = $this->db->get();
+ $checkArr = $courseDetails->result();
+ if (count($checkArr) > 0) {
+ $result['stuCourseDetails'] = true;
+ $result['course_details'] = $courseDetails->result();
+ }
+ else {
+ $result['stuCourseDetails'] = false;
+ }
+
+ return $result;
+ }
+
+ // get student course details
+
+ public function get_student_course($studentcourseId)
+ {
+ $this->db->select('*');
+ $this->db->from(STUDENTCOURSE);
+ $this->db->where('ID', $studentcourseId);
+ $courseDetails = $this->db->get();
+ $checkArr = $courseDetails->result();
+ if (count($checkArr) > 0) {
+ $result['stuCourseDetails'] = true;
+ $result['course_details'] = $courseDetails->result();
+ }
+ else {
+ $result['stuCourseDetails'] = false;
+ }
+
+ return $result;
+ }
+
+ // get university list
+
+ public function get_university_list()
+ {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(UNIVERSITY);
+ $this->db->where('IsActive', 1);
+ $univDetails = $this->db->get();
+ $universityDetails = $univDetails->result();
+ if (count($universityDetails) > 0) {
+ $results['univList'] = true;
+ $results['university_details'] = $universityDetails;
+ }
+ else {
+ $results['univList'] = false;
+ $results['message'] = 'No record found';
+ }
+
+ return $results;
+ }
+
+ // get course, batch for university
+
+ public function get_courseBatch_list($univId)
+ {
+ $this->db->select('C.CourseID, C.CourseName,C.Specilization1,C.Specilization2, C.CourseCode');
+ $this->db->from(COURSE . ' as C');
+ $this->db->where('UniversityID', $univId);
+ $this->db->where('IsActive', 1);
+ $courseDetails = $this->db->get();
+ if ($courseDetails->result()) {
+ $this->db->select('B.SessionID, B.SessionName');
+ $this->db->from(SESSIONMASTER . ' as B');
+ $this->db->join(SESSIONDETAILS . ' SD', 'SD.SessionID = B.SessionID');
+ $this->db->where('SD.UniversityID', $univId);
+ $this->db->where('B.IsActive', 1);
+ $this->db->where('SD.IsActive', 1);
+ $batchDetails = $this->db->get();
+ if ($batchDetails->result()) {
+ $result['courseStatus'] = true;
+ $result['course_details'] = $courseDetails->result();
+ $result['batch_details'] = $batchDetails->result();
+ }
+ else {
+ $result['courseStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+ }
+ else {
+ $result['courseStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+ }
+
+ // Get exist student details
+
+ public function get_exist_stu_details($data, $reqArr)
+ {
+
+ // echo $data;exit();
+
+ $this->db->select('t0.*');
+ $this->db->from('' . STUDENTS . ' as t0');
+ $this->db->where('t0.StudentID', $data);
+ $personalDetails = $this->db->get()->result();
+ $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t3.Specilization1,t3.Specilization2,t4.SessionName, t5.BranchName');
+
+ // $this->db->from('' . STUDENTS . ' as t0');
+
+ $this->db->from('' . STUDENTCOURSE . ' as t1');
+ $this->db->join('' . UNIVERSITY . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
+ $this->db->join('' . COURSE . ' as t3', 't3.CourseID = t1.CourseID', 'LEFT');
+ $this->db->join('' . SESSIONMASTER . ' as t4', 't4.SessionID = t1.SessionID', 'LEFT');
+ $this->db->join('' . BRANCH . ' as t5', 't5.BranchCode = t1.BranchID', 'LEFT');
+ $this->db->where('t1.StudentID', $data);
+
+ // $this->db->group_by('t1.StudentID');
+
+ $courseDetails = $this->db->get()->result();
+ $result['personalDetails'] = $personalDetails;
+ $result['courseDetails'] = $courseDetails;
+ $result['existingStudentDetailsStatus'] = true;
+ return $result;
+ }
+
+ // check exist
+
+ public function check_exist($data, $checkData)
+ {
+ if ($checkData == 'studentId') {
+
+ // check for student id
+ // $this->db->select('*');
+ // $this->db->from(STAFF);
+ // $this->db->where('StaffID', $data);
+ // if ($this->db->get()->first_row()) {
+ // $result['existEmpId'] = true;
+ // $result['message'] = "This Employee ID is already exist!";
+ // } else {
+ // $result['existEmpId'] = false;
+ // }
+
+ }
+ else if ($checkData == 'mobileNumber') {
+
+ // check for mobile number
+
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $data);
+ $details = $this->db->get()->result();
+
+ // echo count($details);exit();
+
+ if (count($details) > 0) {
+
+ // print_r($details);exit();
+ // echo $details[0]->StudentID;exit();
+
+ $datas['studentId'] = $details[0]->StudentID;
+ $datas['type'] = 'R001';
+ $result['details'] = $datas;
+ $result['existMobile'] = true;
+ $result['message'] = "This Mobile Number is already exist!";
+ }
+ else {
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $data);
+ $details1 = $this->db->get()->result();
+ if ($details1 > 0) {
+ $datas['studentId'] = $details1[0]->StaffID;
+ $datas['type'] = $details1[0]->ListCode;
+ $result['details'] = $datas;
+ $result['existMobile'] = true;
+ $result['message'] = "This Mobile Number is already exist!";
+ }
+ else {
+ $result['existMobile'] = false;
+ }
+ }
+ }
+ else if ($checkData == 'emailId') {
+
+ // check for email id
+
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('EmailID', $data);
+ if ($this->db->get()->first_row()) {
+ $result['existEmailId'] = true;
+ $result['message'] = "This EmailId is already exist!";
+ }
+ else {
+ $result['existEmailId'] = false;
+ }
+ }
+ else {
+ }
+
+ return $result;
+ }
+
+ // add student course
+
+ public function add_student_course($studID, $Arr)
+ {
+ if ($this->getBranchActiveStatusforStuAdd($Arr['BranchID']) ['branch_active_status'] === '1') {
+ $this->db->select('*');
+ $this->db->from(STUDENTCOURSE);
+ $this->db->where('StudentID', $studID);
+ $this->db->where('CourseID', $Arr['CourseID']);
+ if ($this->db->get()->first_row()) {
+ $result['addStuCourseStatus'] = false;
+ $result['message'] = "This Student Already exist for this course";
+ }
+ else {
+ $this->db->insert(STUDENTCOURSE, $Arr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addStuCourseStatus'] = true;
+ $result['message'] = "Successfully Student Course Details Updated";
+ }
+ else {
+ $result['addStuCourseStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ }
+ else {
+ $result['addStuCourseStatus'] = false;
+ $result['message'] = "New Cource Cannot able to create for In-Active Branch";
+ }
+
+ return $result;
+ }
+
+ // add student
+
+ public function add_student($Arr, $courseArr, $imagename, $imageSource, $size)
+ {
+
+ // echo $this->getBranchActiveStatusforStuAdd($courseArr['BranchID'])['branch_active_status'];exit();
+
+ if ($this->getBranchActiveStatusforStuAdd($courseArr['BranchID']) ['branch_active_status'] === '1') {
+
+ // echo 'in';exit();
+
+ if ($imageSource == '') { // add employee without image
+ $imageNameDb = 'default.jpeg';
+ $Arr['ProfilePicPath'] = "student/" . $imageNameDb;
+
+ // print_r($Arr);
+ // print_r($courseArr);exit();
+
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $Arr['MobileNumber']);
+ if ($this->db->get()->first_row()) {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "This Student Already exist";
+ }
+ else {
+ $this->db->insert(STUDENTS, $Arr);
+ $insert_id = $this->db->insert_id('StudentID');
+ $courseArr['StudentID'] = $insert_id;
+ if ($this->db->affected_rows() == '1') {
+ $this->db->insert(STUDENTCOURSE, $courseArr);
+ if ($this->db->affected_rows() == '1') {
+ $loginArr['StaffID'] = $courseArr['StudentID'];
+ $loginArr['ListCode'] = STUDENT;
+ $loginArr['MobileNumber'] = $Arr['MobileNumber'];
+ $loginArr['EmailId'] = $Arr['EmailID'];
+ $loginArr['IsActive'] = $Arr['IsActive'];
+ $loginArr['CreatedBy'] = $Arr['CreatedBy'];
+ $loginArr['CreatedOn'] = $Arr['CreatedOn'];
+ $loginArr['Password'] = ENCR_PASSWORD;
+ $this->db->insert(LOGIN, $loginArr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addStudentStatus'] = true;
+ $result['message'] = "Successfully student details added";
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ }
+ else {
+ $target = "../images/student/";
+ $getUploadStatus = $this->upload_image($imageSource, $size, $target);
+ $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
+ $Arr['ProfilePicPath'] = "student/" . $imageNameDb;
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $Arr['MobileNumber']);
+ if ($this->db->get()->first_row()) {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "This Student Already exist";
+ }
+ else {
+ $this->db->insert(STUDENTS, $Arr);
+ $insert_id = $this->db->insert_id('StudentID');
+ $courseArr['StudentID'] = $insert_id;
+ if ($this->db->affected_rows() == '1') {
+ $this->db->insert(STUDENTCOURSE, $courseArr);
+ if ($this->db->affected_rows() == '1') {
+ $loginArr['StaffID'] = $courseArr['StudentID'];
+ $loginArr['ListCode'] = STUDENT;
+ $loginArr['MobileNumber'] = $Arr['MobileNumber'];
+ $loginArr['EmailId'] = $Arr['EmailID'];
+ $loginArr['IsActive'] = $Arr['IsActive'];
+ $loginArr['CreatedBy'] = $Arr['CreatedBy'];
+ $loginArr['CreatedOn'] = $Arr['CreatedOn'];
+ $loginArr['Password'] = ENCR_PASSWORD;
+ $this->db->insert(LOGIN, $loginArr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addStudentStatus'] = true;
+ $result['message'] = "Successfully student details added";
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ }
+ }
+ else {
+ $result['addStudentStatus'] = false;
+ $result['message'] = "New Student cannot able to create for In-Active Branch";
+ }
+
+ return $result;
+ }
+
+ // check existing data while update
+
+ public function check_update_exist($exceptId, $datas, $checkFor)
+ {
+ if ($checkFor == 'mobileNumber') {
+
+ // check update for mobile number
+
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $datas);
+ $this->db->where_not_in('StudentID', $exceptId);
+ if ($this->db->get()->first_row()) {
+ $result['existMobile'] = true;
+ $this->db->select('MobileNumber');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $exceptId);
+ $result['resetValue'] = $this->db->get()->first_row();
+ $result['message'] = "This Mobile Number is already exist!";
+ }
+ else {
+
+ // check login
+
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $datas);
+ $this->db->where_not_in('StaffID', $exceptId);
+ if ($this->db->get()->first_row()) {
+ $result['existMobile'] = true;
+ $this->db->select('MobileNumber');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $exceptId);
+ $result['resetValue'] = $this->db->get()->first_row();
+ $result['message'] = "This Mobile Number is already exist!";
+ }
+ else {
+ $result['existMobile'] = false;
+ }
+ }
+ }
+ else if ($checkFor == 'emailId') {
+
+ // check update for email
+
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('EmailID', $datas);
+ $this->db->where_not_in('StudentID', $exceptId);
+ if ($this->db->get()->first_row()) {
+ $result['existEmailId'] = true;
+ $this->db->select('EmailID');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $exceptId);
+ $result['resetValue'] = $this->db->get()->first_row();
+ $result['message'] = "This EmailId is already exist!";
+ }
+ else {
+ $result['existEmailId'] = false;
+ }
+ }
+ else {
+ }
+
+ return $result;
+ }
+
+ // get the student entrollment doc details
+
+ public function getStudent_doc_details($stuId)
+ {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(STUDENTDOCUMENTDETAILS);
+ $this->db->where('StudentID', $stuId);
+ $getDocDetails = $this->db->get();
+ $documentDetails = $getDocDetails->result();
+ if (count($documentDetails) > 0) {
+ $results['docListStatus'] = true;
+ $results['student_doc_details'] = $documentDetails;
+ }
+ else {
+ $results['docListStatus'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+ }
+
+ public function deleteStu_doc_details($stuId, $docId)
+ {
+ $sql1 = "SELECT * FROM ".STUDENTDOCUMENTDETAILS." WHERE StudentID = '" . $stuId . "' AND ID = '" . $docId . "'";
+ $resultSql1 = $this->db->query($sql1)->result();
+ if(count($resultSql1) > 0){
+ // print_r($resultSql1);
+ // echo $resultSql1[0]->DocumentStorePath;exit();
+ $sql = "DELETE FROM ".STUDENTDOCUMENTDETAILS." WHERE StudentID = '" . $stuId . "' AND ID = '" . $docId . "'";
+ if ($this->db->query($sql)) {
+ try{
+ if(!file_exists('../images/' . $resultSql1[0]->DocumentStorePath)) {
+ throw new Exception("File Not Found.");
+ }else {
+ unlink('../images/' . $resultSql1[0]->DocumentStorePath);
+ }
+ } catch(Exception $e){
+ // echo "Error :";
+ } finally {
+ $results['message'] = 'Deleted Successfully.';
+ $results['deleteStatus'] = true;
+ }
+ }
+ else {
+ $results['deleteStatus'] = false;
+ $results['message'] = 'Something went wrong.please try again';
+ }
+ }else{
+ $results['deleteStatus'] = false;
+ $results['message'] = 'Something went wrong.please try again';
+ }
+ return $results;
+ }
+
+ // add student entroll doc details
+
+ public function student_entroll_doc_add($req, $doc_status)
+ {
+
+ // if( $doc_status == "true") {
+
+ $target = "../images/documents/";
+ $getUploadStatus = $this->upload_doc_student($req['doc_source'], $req['doc_name'], $req['doc_size'], $target, $req['student_id']);
+ if ($imageNameDb = $getUploadStatus['status'] == true) {
+ $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
+
+ // echo $imageNameDb;exit();
+
+ $strPath = "documents/" . $imageNameDb;
+ $stuId = $req['student_id'];
+ $docTypeName = $req['document_type_name'];
+ $docStatus = $req['document_status'];
+ $docComments = $req['document_comments'];
+ $docCreatedBy = $req['CreatedBy'];
+ $docCreatadOn = $req['CreatedOn'];
+
+ // echo $docCreatadOn;exit();
+ // ".STAFF_BRANCH."
+
+ $sql1 = "INSERT INTO ".STUDENTDOCUMENTDETAILS." (StudentID, DocumentName, Status, DocumentStorePath, Comments, CreatedBy, CreatedOn)
+ VALUES ('$stuId', '$docTypeName', '$docStatus', '$strPath', '$docComments', '$docCreatedBy', '$docCreatadOn')";
+
+ // update branch to staff_branch table
+
+ if ($this->db->query($sql1) == '1') {
+ $result['stuDocUpdateStatus'] = true;
+ $result['message'] = "Successfully Student document details updated";
+ }
+ else {
+ $result['stuDocUpdateStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['stuDocUpdateStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ return $result;
+ }
+
+ // student document upload target path
+
+ public function upload_doc_student($imageSource, $doc_name, $size, $target, $stu_id)
+ {
+ $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') , 0, 12);
+ $new_regNo = "Dri_" . $key2 . "_" . $stu_id . "_" . $doc_name;
+ $targetPlace = $target . $new_regNo;
+
+ // echo $targetPlace;exit();
+
+ if (!move_uploaded_file($imageSource, $targetPlace)) {
+ return $result['status'] = false;
+ }
+ else {
+ $result['status'] = true;
+ $result['imageName'] = $new_regNo;
+ return $result;
+ }
+ }
+
+ public function getStudent_PendingDoc_Details($stuID) {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(STUDENTDOCUMENTTRACKDETAILS);
+ $this->db->where('StudentID', $stuID);
+ $getPendDocDetails = $this->db->get();
+ $documentPendingDetails = $getPendDocDetails->result();
+ if (count($documentPendingDetails) > 0) {
+ $results['PendingDocListStatus'] = true;
+ $results['student_pending_doc_details'] = $documentPendingDetails;
+ }
+ else {
+ $results['PendingDocListStatus'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+ }
+
+ // add student enrollment pending document details
+ public function addStu_PendingDoc_Details($reqData,$localdata) {
+ // echo "model";
+ // print_r($reqData);exit();
+ $this->db->insert(STUDENTDOCUMENTTRACKDETAILS, $reqData);
+ if ($this->db->affected_rows() > 0) {
+ // Entry for call track
+ if($reqData['Status']=='1'){
+ $this->updatePendingDocumentInCallTrack($reqData,$localdata);
+ }
+
+ // end call track entry
+ $results['AddStuPendingDocStatus'] = true;
+ $results['message'] = "Added Successfully.";
+ } else {
+ $results['AddStuPendingDocStatus'] = false;
+ $results['message'] = "Something went wrong.please try again.";
+ }
+ return $results;
+ }
+
+ public function deleteStu_entrollPending_doc_details($id) {
+ // echo $id;exit();
+ $sql = "DELETE FROM ".STUDENTDOCUMENTTRACKDETAILS." WHERE ID = '" . $id . "'";
+ if ($this->db->query($sql)) {
+ $results['deleteStatus'] = true;
+ $results['message'] = 'Document pending track details deleted.';
+ } else {
+ $results['deleteStatus'] = false;
+ $results['message'] = 'Something went wrong.please try again';
+ }
+ return $results;
+ }
+
+
+ // update student personal details
+
+ public function update_student($empArr, $updateFor, $imagename, $imageSource, $size)
+ {
+ // print_r($empArr);exit();
+ if ($imageSource == '') {
+ // print_r($empArr);
+ // print_r($updateFor);
+ // exit();
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ $this->db->where_not_in('StudentID', $updateFor);
+ if ($this->db->get()->first_row()) {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ }
+ else {
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ $this->db->where_not_in('StaffID', $updateFor);
+ if ($this->db->get()->first_row()) {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ }
+ else {
+ $this->db->where('StudentID', $updateFor);
+ $this->db->update(STUDENTS, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $mobile = $empArr['MobileNumber'];
+ $email = $empArr['EmailID'];
+ $active = $empArr['IsActive'];
+ $updatedBy = $empArr['UpdatedBy'];
+ $updatedOn = $empArr['UpdatedOn'];
+ $sql = "UPDATE " . LOGIN . " SET MobileNumber='$mobile', EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'";
+ if ($this->db->query($sql) == '1') {
+ $result['updateStuStatus'] = true;
+ $result['message'] = "Successfully student details Updated";
+ }
+ else {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ }
+ }
+ else {
+ $this->db->select('*');
+ $this->db->from(STUDENTS);
+ $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ $this->db->where_not_in('StudentID', $updateFor);
+ if ($this->db->get()->first_row()) {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ }
+ else {
+ $this->db->select('*');
+ $this->db->from(LOGIN);
+ $this->db->where('MobileNumber', $empArr['MobileNumber']);
+ $this->db->where_not_in('StaffID', $updateFor);
+ if ($this->db->get()->first_row()) {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "This Mobile Number Already Exist";
+ }
+ else {
+ $target = "../images/student/";
+ $getUploadStatus = $this->upload_image($imageSource, $size, $target);
+ $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
+ $empArr['ProfilePicPath'] = "student/" . $imageNameDb;
+ $this->db->select('ProfilePicPath');
+ $this->db->from(STUDENTS);
+ $this->db->where('StudentID', $updateFor);
+ $roleDetails = $this->db->get()->first_row();
+
+ // echo $roleDetails->ProfilePicPath;
+ // exit();
+
+ if ($roleDetails->ProfilePicPath != '' && $roleDetails->ProfilePicPath != 'student/default.jpeg') {
+ unlink('../images/' . $roleDetails->ProfilePicPath);
+ }
+ else {
+ }
+ $this->db->where('StudentID', $updateFor);
+ $this->db->update(STUDENTS, $empArr);
+ if ($this->db->affected_rows() == '1') {
+ $mobile = $empArr['MobileNumber'];
+ $email = $empArr['EmailID'];
+ $active = $empArr['IsActive'];
+ $updatedBy = $empArr['UpdatedBy'];
+ $updatedOn = $empArr['UpdatedOn'];
+ $sql = "UPDATE " . LOGIN . " SET MobileNumber='$mobile', EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'";
+ if ($this->db->query($sql) == '1') {
+ $result['updateStuStatus'] = true;
+ $result['message'] = "Successfully student details Updated";
+ }
+ else {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ else {
+ $result['updateStuStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ }
+ }
+ return $result;
+ }
+
+ // Update Student Course Details
+
+ public function update_student_course($reqArr, $id)
+ {
+
+ // print_r($id);
+ // print_r($reqArr);
+ // exit();
+
+ $this->db->select('*');
+ $this->db->from(STUDENTCOURSE);
+ $this->db->where('StudentID', $reqArr['StudentID']);
+ $this->db->where('CourseID', $reqArr['CourseID']);
+ $this->db->where_not_in('ID', $id);
+ if ($this->db->get()->first_row()) {
+ $result['updateStuCourseStatus'] = false;
+ $result['message'] = "This Student Already exist for this course";
+ }
+ else {
+ $this->db->where('ID', $id);
+ $this->db->update(STUDENTCOURSE, $reqArr);
+ if ($this->db->affected_rows() == '1') {
+ $result['updateStuCourseStatus'] = true;
+ $result['message'] = "Successfully Student Course Details Updated";
+ }
+ else {
+ $result['updateStuCourseStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+ }
+
+ // image upload in taget path
+
+ public function upload_image($imageSource, $size, $target)
+ {
+ $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') , 0, 12);
+ $new_regNo = "Dri_" . $key2 . "." . 'jpeg';
+ $targetPlace = $target . $new_regNo;
+
+ // echo $targetPlace;exit();
+
+ if (!move_uploaded_file($imageSource, $targetPlace)) {
+ return $result['status'] = false;
+ }
+ else {
+ $result['status'] = true;
+ $result['imageName'] = $new_regNo;
+ return $result;
+ }
+ }
+
+
+ /*
+ * update followup details for application status in call tracking
+ * created by kms
+ * */
+ public function updatePendingDocumentInCallTrack($fromDetails=null,$localdata=null){
+
+ // check document type
+ $this->db->select('AC.ActivityID,PLD.ListCode');
+ $this->db->from(ACTIVITY_STATUS.' as AS');
+ $this->db->join(ACTIVITY.' as AC', 'AC.ActivityID = AS.ActivityID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AS.StatusName');
+ $this->db->where('AC.ActivityName','DOCUMENT FOLLOWUP');
+ $this->db->where('PLD.ListName','PENDING');
+ $this->db->where('AC.IsActive','1');
+ $this->db->where('AS.IsActive','1');
+ $checkApplicationStatus=$this->db->get()->last_row();
+ if($checkApplicationStatus){
+
+ $studentDetails = $this->studentInfoForDocumentStatus($fromDetails);
+ if($studentDetails){
+ $arrayDetails['MobileNumber']=$studentDetails->MobileNumber;
+ $arrayDetails['LeadName']=$studentDetails->Firstname;
+ $arrayDetails['University']="";
+ $arrayDetails['Course']="";
+ $arrayDetails['ActivityStatus'] = $checkApplicationStatus->ActivityID;;
+ $arrayDetails['StatusCode']=$checkApplicationStatus->ListCode;
+ $arrayDetails['CreatedBranch']=$localdata['localBranchID'];
+ $arrayDetails['CreatedOn']=$fromDetails['CreatedOn'];
+ $arrayDetails['FollowupOn']=$date = date('d-m-Y');
+ $arrayDetails['FollowupComments']=$fromDetails['Details'];
+ if($localdata['localType']==SUPER_ADMIN){
+ $this->db->select('LO.ID');
+ $this->db->from(STAFF_BRANCH.' as STB');
+ $this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID');
+ $this->db->where('STB.BranchCode',$localdata['localBranchID']);
+ $this->db->where('LO.ListCode',ADMIN);
+ $this->db->where('STB.IsActive','1');
+ $this->db->where('LO.IsActive','1');
+ $assignDet=$this->db->get()->last_row();
+ if($assignDet){
+ $arrayDetails['CreatedBy']=$assignDet->ID;
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails['CreatedBy'];
+ }
+
+ }
+ else{
+ $arrayDetails['CreatedBy']=$fromDetails['CreatedBy'];
+ }
+
+ // new lead details
+ $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
+ $newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
+ $newLeadDetails['CreatedBy'] = $fromDetails['CreatedBy'];
+ $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_DETAILS, $newLeadDetails);
+ // this if for insert lead details
+ if($this->db->affected_rows() == '1'){
+ // get and store insert id from db
+ $track_Details['LeadID']=$this->db->insert_id();
+ $track_Details['ActivityStatus'] = $arrayDetails['ActivityStatus'];
+ $track_Details['University'] = $arrayDetails['University'];
+ $track_Details['Course'] = $arrayDetails['Course'];
+ $track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
+ $track_Details['StatusCode'] = $arrayDetails['StatusCode'];
+ $track_Details['CreatedBy'] = $fromDetails['CreatedBy'];
+ $track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
+ $this->db->insert(LEAD_TRACKING, $track_Details);
+ // this if for insert tracking details
+ if($this->db->affected_rows() == '1'){
+ $insertfollowup_Details['TrackingID']=$this->db->insert_id();
+ $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
+ $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
+ $insertfollowup_Details['CreatedBy'] = $fromDetails['CreatedBy'];
+ $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
+ $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
+ // this if for insert follow up details
+
+ }
+
+
+ }
+
+
+
+ }
+
+
+ else{
+ return false;
+ }
+ }
+ else{
+ return false;
+ }
+
+ }
+
+ /*
+ * get student info for documet updates
+ * created by kms
+ * */
+ public function studentInfoForDocumentStatus($details=null){
+
+ $this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName');
+ $this->db->from(STUDENTCOURSE.' as STC');
+ $this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
+ $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
+ $this->db->where('ST.StudentID',$details['StudentID']);
+ // $this->db->where('STC.CourseID',$details[0]['CourseID']);
+ $leadDet=$this->db->get()->last_row();
+ if($leadDet){
+ return $leadDet;
+ }
+ else{
+ return false;
+ }
+
+ }
+}
diff --git a/api/application/models/Studentview_model.php b/api/application/models/Studentview_model.php
new file mode 100644
index 0000000..4dfa717
--- /dev/null
+++ b/api/application/models/Studentview_model.php
@@ -0,0 +1,390 @@
+db->select('ST.*');
+ $this->db->from( LOGIN . ' as LO');
+ $this->db->join( STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID');
+ $this->db->where('LO.ID', $requestedBy);
+ $studentDetails = $this->db->get()->first_row();
+ if($studentDetails){
+ $result['studentStatus'] = true;
+ $result['studentDetails'] = $studentDetails;
+ // get student course details
+ $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID);
+ }
+ else{
+ $result['studentStatus'] = false;
+ $result['studentInfo'] = "";
+ }
+ }
+ else if($requestFrom =='1'){
+ $this->db->select('ST.*');
+ $this->db->from( LOGIN . ' as LO');
+ $this->db->join( STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID');
+ $this->db->where('ST.StudentID', $requestedBy);
+ $studentDetails = $this->db->get()->first_row();
+ if($studentDetails){
+ $result['studentStatus'] = true;
+ $result['studentDetails'] = $studentDetails;
+ // get student course details
+ $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID);
+ }
+ else{
+ $result['studentStatus'] = false;
+ $result['studentInfo'] = "";
+ }
+ }
+ else if ($requestFrom =='3'){
+ $this->db->select('ST.*');
+ $this->db->from( LOGIN . ' as LO');
+ $this->db->join( STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID');
+ $this->db->where('ST.MobileNumber', $requestedBy);
+ $studentDetails = $this->db->get()->first_row();
+ if($studentDetails){
+ $result['studentStatus'] = true;
+ $result['studentDetails'] = $studentDetails;
+ // get student course details
+ $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID);
+ }
+ else{
+ $result['studentStatus'] = false;
+ $result['studentInfo'] = "";
+ }
+ }
+
+ return $result;
+
+ }
+ /*
+ * get student course details
+ * created by kms
+ * */
+ public function getStudentCourse($studentId=null){
+
+ $this->db->select('SCU.EnrollmentID,CU.CourseID,CU.CourseName,US.UniversityID,US.UniversityName,US.UniversityShortName');
+ $this->db->from( STUDENTCOURSE . ' as SCU');
+ $this->db->join( COURSE . ' as CU', 'CU.CourseID = SCU.CourseID');
+ $this->db->join( UNIVERSITY . ' as US', 'US.UniversityID = SCU.UniversityID');
+ // $this->db->join( SESSIONMASTER . ' as SM', 'SM.SessionID = SCU.SessionID');
+ $this->db->where('SCU.StudentID', $studentId);
+ $courseDetails = $this->db->get();
+ if($courseDetails->result()){
+ $studentCourseStatus['status'] = true;
+ foreach ($courseDetails->result() as $row){
+ $fetchData['CourseID']=$row->CourseID;
+ $fetchData['CourseName']=$row->CourseName;
+ $fetchData['UniversityID']=$row->UniversityID;
+ $fetchData['UniversityName']=$row->UniversityName;
+ $fetchData['UniveShortName'] = $row->UniversityShortName;
+ // $fetchData['SessionName']=$row->SessionName;
+ $fetchData['EnrollmentID']=$row->EnrollmentID;
+ // get student fees details
+ $fetchData['feesDetails']=$this->getStudentFeesDetails($studentId,$row->CourseID);
+ // get student boollet details
+ $fetchData['studyMaterialDetails']=$this->getStudentMaterialDetails($studentId,$row->CourseID);
+ // get application details
+ $fetchData['applicationDetails']=$this->getStudentCertificateDetails($studentId,$row->CourseID);
+ // get student Mark crad details
+ $fetchData['markCardDetails']=$this->getMarkcardDetails($studentId,$row->CourseID);
+
+ $CourseArray[]=$fetchData;
+
+
+ }
+ $studentCourseStatus['courseStatus'] = $CourseArray;
+ }
+ else{
+ $studentCourseStatus['status'] = false;
+ }
+
+ return $studentCourseStatus;
+ }
+
+ /*
+ * get student fees details
+ * created by kms
+ * */
+ public function getStudentFeesDetails($studentID=null,$courseID=null){
+ $serachArray=[WAIVER,REFERRAL];
+
+ $this->db->distinct();
+ $this->db->select('SFS.FeesID,SFS.FeesType,SFS.RollNo,ifnull(SFS.CourseFees,0) as CourseFees,ifnull(SFS.STFOrWR,0) as STFOrWR,ifnull(SFS.Waiver,0) as Waiver,ifnull(SFS.Others,0) as Others,CF.Sem_Year,CF.FeesType as CourseFeesType,SM.SessionName,SM1.SessionName as ToSessionName,CF.ProgramType,BA.BatchName,BA.BatchDate');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
+ $this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
+ $this->db->join(STUDENTS_FEES_PAID.' as SFP','SFP.FeesId = SFS.FeesID','left');
+ $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode');
+ $this->db->where('SFS.CourseID', $courseID);
+ $this->db->where('SFS.StudentID', $studentID);
+ $this->db->order_by('SFS.FeesID', 'ASC');
+ $getFeeDetails = $this->db->get();
+ if($getFeeDetails->result()){
+ foreach ($getFeeDetails->result() as $feeRow){
+ $storePaidDetails['FeesID'] = $feeRow->FeesID;
+ $storePaidDetails['FeesName'] = $feeRow->Sem_Year;
+ $storePaidDetails['CourseFees'] = $feeRow->CourseFees;
+ $storePaidDetails['ProgramType'] = $feeRow->ProgramType;
+ $storePaidDetails['SessionName'] = $feeRow->SessionName;
+ if($feeRow->ToSessionName=='' || $feeRow->ToSessionName==null){
+ $storePaidDetails['ToSessionName'] = "Not Applicable";
+ }
+ else{
+ $storePaidDetails['ToSessionName'] = $feeRow->ToSessionName;
+ }
+
+ $storePaidDetails['RollNo'] = $feeRow->RollNo;
+ $storePaidDetails['STFOrWR'] = $feeRow->STFOrWR;
+ $storePaidDetails['Waiver'] = $feeRow->Waiver;
+ $storePaidDetails['Others'] = $feeRow->Others;
+ $storePaidDetails['CourseFeesType'] = $feeRow->CourseFeesType;
+ $storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+ $storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
+ if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
+ $storePaidDetails['BalanceAmount']=0;
+
+ }
+ else{
+ $storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+
+ // sepearte for student waiver and referral bill list
+ $this->db->select('ifnull(SUM((BillAmount)),0) as StudentWaiverRefAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $this->db->where_in('ModeOfPayment',$serachArray);
+ $studentWaiverRefAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+
+ $storePaidDetails['StudentWaiverRefAmount']=$studentWaiverRefAmount[0]->StudentWaiverRefAmount;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as StudentPaidAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $this->db->where('ModeOfPayment !=',WAIVER);
+ $this->db->where('ModeOfPayment !=',REFERRAL);
+ $studentPaidAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+
+ $storePaidDetails['StudentPaidAmount']=$studentPaidAmount[0]->StudentPaidAmount;
+ $storePaidDetails['BatchName'] = $feeRow->BatchName;
+ $storePaidDetails['BatchDate'] = $feeRow->BatchDate;
+
+ // for get paid bill details
+ // for get paid bill details
+ $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO,BillDate,ModeOfPayment,ReceiptNo,BR.BranchName,BR.Address,BR.LogoPath,STF.Firstname as ReceivedBy');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
+ $this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
+ $this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
+ $this->db->where('SFP.FeesId',$feeRow->FeesID);
+ $this->db->order_by('SFP.ID',"ASC");
+ $this->db->group_by('SFP.BillNO');
+ $storePaidDetails['paidDetails']=$this->db->get()->result();
+ // for installment details
+ $this->load->model('Fees_status_model');
+
+ $InstallemtResult = $this->Fees_status_model->getInstallmentDetails($feeRow->FeesID);
+
+ if($InstallemtResult != false){
+ $storePaidDetails['InstallmentDetails']=$InstallemtResult;
+ }
+ else{
+
+ $storePaidDetails['InstallmentDetails']="";
+
+
+ }
+ $mergeResult[]=$storePaidDetails;
+
+ }
+
+ $getStudentDefaultFees = $this->getDefaultCourseFees($studentID,$courseID);
+ if($getStudentDefaultFees != false){
+ return array_merge($mergeResult,$getStudentDefaultFees);
+ }
+ else{
+ return$mergeResult;
+ }
+
+ }
+ else {
+ return false;
+ }
+
+ }
+ /*
+ * get default course details
+ * created by kms
+ * */
+ public function getDefaultCourseFees($studentID=null,$courseID=null){
+ $serachArray = ["PC","TC","DC","MC","OTHER"];
+ $this->db->distinct();
+ $this->db->select('SFS.FeesID,SFS.FeesType,SFS.SessionName,SFS.RollNo,ifnull(SFS.CourseFees,0) as CourseFees,ifnull(SFS.STFOrWR,0) as STFOrWR,ifnull(SFS.Waiver,0) as Waiver,ifnull(SFS.Others,0) as Others');
+ $this->db->from(STUDENTS_FEES_STATUS.' as SFS');
+ $this->db->join(STUDENTS_FEES_PAID.' as SFP','SFP.FeesId = SFS.FeesID','left');
+ //$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
+ $this->db->where('SFS.CourseID', $courseID);
+ $this->db->where('SFS.StudentID', $studentID);
+ $this->db->where_in('SFS.FeesType', $serachArray);
+ $this->db->order_by('SFS.FeesID', 'ASC');
+ $getFeeDetails = $this->db->get();
+ if($getFeeDetails->result()){
+ foreach ($getFeeDetails->result() as $feeRow){
+ $storePaidDetails['FeesID'] = $feeRow->FeesID;
+ $storePaidDetails['FeesName'] = $feeRow->FeesType;
+ $storePaidDetails['ProgramType'] = $feeRow->FeesType;
+ $storePaidDetails['CourseFees'] = $feeRow->CourseFees;
+ $storePaidDetails['SessionName'] = "Not Applicable";
+ $storePaidDetails['ToSessionName'] = "Not Applicable";
+ $storePaidDetails['RollNo'] = $feeRow->RollNo;
+ $storePaidDetails['STFOrWR'] = $feeRow->STFOrWR;
+ $storePaidDetails['Waiver'] = $feeRow->Waiver;
+ $storePaidDetails['Others'] = $feeRow->Others;
+ $storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver;
+
+ $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
+ $this->db->where('FeesId',$feeRow->FeesID);
+ $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
+ $storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
+ if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
+ $storePaidDetails['BalanceAmount']=0;
+
+ }
+ else{
+ $storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
+ }
+ $storePaidDetails['BatchName'] = "Not Applicable";
+ $storePaidDetails['BatchDate'] = "";
+
+ // for get paid bill details
+ $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO,BillDate,ModeOfPayment,ReceiptNo,BR.BranchName,BR.Address,BR.LogoPath,STF.Firstname as ReceivedBy');
+ $this->db->from(STUDENTS_FEES_PAID.' as SFP');
+ $this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
+ $this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
+ $this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
+ $this->db->where('SFP.FeesId',$feeRow->FeesID);
+ $this->db->order_by('SFP.ID',"ASC");
+ $this->db->group_by('SFP.BillNO');
+ $storePaidDetails['paidDetails']=$this->db->get()->result();
+ $storePaidDetails['InstallmentDetails']="";
+ $mergeResult[]=$storePaidDetails;
+
+ }
+
+ return $mergeResult;
+ }
+ else {
+ return false;
+ }
+
+ }
+
+ /*
+ * get student study material details
+ * created by kms
+ * */
+ public function getStudentMaterialDetails($studentID=null,$courseID=null){
+ $this->db->select('SMS.CourseID,SMS.SDate,SMS.Comments,SMS.Sem,CF.Sem_Year,CF.FeesType,PLD.ListName');
+ $this->db->from(STUDY_MATERIAL_STATUS.' as SMS');
+ $this->db->join(COURSE_FEES.' as CF','CF.ID = SMS.CourseID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = CF.CourseID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = SMS.ListCode');
+ $this->db->where('CU.CourseID', $courseID);
+ $this->db->where('SMS.StudentID', $studentID);
+ $this->db->order_by('SMS.ID', 'DESC');
+ $getMaterialDetails = $this->db->get();
+ if ($getMaterialDetails->result()){
+ return $getMaterialDetails->result();
+ }
+ else{
+ return false;
+ }
+ }
+ /*
+ * get student certificate details
+ * created by kms
+ * */
+ public function getStudentCertificateDetails($studentID=null,$courseID=null){
+ $this->db->select('AS.CertificationNo,AS.AppDate,AS.Comments,CM.CertificateName,PLD.ListName');
+ $this->db->from(APPLICATION_STATUS.' as AS');
+ $this->db->join(CERTIFICATION_MASTER.' as CM','CM.CertificationID = AS.CertificationType');
+ //$this->db->join(COURSE_FEES.' as CF','CF.ID = AS.CourseID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = AS.CourseID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AS.ListCode');
+ $this->db->where('CU.CourseID', $courseID);
+ $this->db->where('AS.StudentID', $studentID);
+ $this->db->order_by('AS.ID', 'DESC');
+ $getCertDetails = $this->db->get();
+
+ if($getCertDetails->result()){
+ return $getCertDetails->result();
+ }
+
+ else {
+ return false;
+ }
+
+ }
+ /*
+ * get mark card details
+ * created by kms
+ * */
+ public function getMarkcardDetails($studentID=null,$courseID=null){
+
+ $this->db->select('CS.CourseID,CS.CertificationNo,CS.CDate,CS.Comments,CS.CertificationType as CertificateName,CF.Sem_Year,CF.FeesType,CS.Sem,PLD.ListName');
+ $this->db->from(CERTIFICATION_STATUS.' as CS');
+ $this->db->join(COURSE_FEES.' as CF','CF.ID = CS.CourseID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = CF.CourseID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = CS.ListCode');
+ $this->db->where('CU.CourseID', $courseID);
+ $this->db->where('CS.StudentID', $studentID);
+ $this->db->where_in('CS.CertificationType', 'MARK CARD');
+ $this->db->order_by('CS.ID', 'DESC');
+ $getMarkDetails = $this->db->get();
+ if ($getMarkDetails->result()){
+ return $getMarkDetails->result();
+ }
+ else{
+ return false;
+ }
+ }
+ /*
+ * get student application details
+ * created by kms*/
+ public function getStudentApplicationDetails($studentID=null,$courseID=null){
+ $this->db->select('AS.CourseID,AS.AppDate,AS.Comments,CF.Sem_Year,PLD.ListName');
+ $this->db->from(APPLICATION_STATUS.' as AS');
+ $this->db->join(COURSE_FEES.' as CF','CF.ID = AS.CourseID');
+ $this->db->join(COURSE.' as CU', 'CU.CourseID = CF.CourseID');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AS.ListCode');
+ $this->db->where('CU.CourseID', $courseID);
+ $this->db->where('AS.StudentID', $studentID);
+ $this->db->order_by('AS.ID', 'DESC');
+ $getAppDetails = $this->db->get();
+ if ($getAppDetails->result()){
+ return $getAppDetails->result();
+ }
+ else{
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/api/application/models/Subject_model.php b/api/application/models/Subject_model.php
new file mode 100644
index 0000000..d4e185a
--- /dev/null
+++ b/api/application/models/Subject_model.php
@@ -0,0 +1,102 @@
+db->select('SubjectCode');
+ $this->db->where('SubjectCode',$arrayDetails['SubjectCode']);
+ if($this->db->get(SUBJECTMASTER)->first_row()){
+ $result['SubjectStatus']=false;
+ $result['message']="This subject code already exists";
+ }else{
+
+ $this->db->insert(SUBJECTMASTER,$arrayDetails);
+ if ($this->db->affected_rows() == '1') {
+
+ $result['SubjectStatus']=true;
+ $result['message']="Successfully Subject Code is added";
+
+ }else{
+ $result['SubjectStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+ return $result;
+}
+
+
+ /*
+ * Update Subject details
+ * created by srk
+ */
+
+public function updateSubject($arrayDetails=null,$SubjectID=null)
+{
+ $this->db->select('SubjectCode');
+ $this->db->where('SubjectCode',$arrayDetails['SubjectCode']);
+ $this->db->where('SubjectCode !=', $arrayDetails['SubjectCode']);
+ if($this->db->get(SUBJECTMASTER)->first_row()){
+ $result['SubjectStatus']=false;
+ $result['message']="This subject code is already exists";
+ }else{
+ $this->db->where('SubjectID',$SubjectID);
+ $upateStatus=$this->db->update(SUBJECTMASTER, $arrayDetails);
+
+
+
+ if($upateStatus){
+
+ $result['SubjectStatus'] = true;
+ $result['message'] = "Successfully Subject details updated";
+ }
+
+ else {
+
+ $result['SubjectStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+
+ }
+ }
+
+ return $result;
+
+ }
+ /*
+ * Get subject details
+ * created by srk
+ */
+
+
+
+ public function getSubject()
+ {
+ $this->db->select('*');
+ $this->db->order_by('CreatedOn','DESC');
+ $subjectDetails = $this->db->get(SUBJECTMASTER);
+
+
+ if($subjectDetails->result()){
+
+ $result['SubjectStatus'] = true;
+ $result['details'] = $subjectDetails->result();
+ }
+ else {
+ $result['SubjectStatus'] = false;
+ $result['message'] = "No records found!";
+ }
+
+ return $result;
+
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/University_model.php b/api/application/models/University_model.php
new file mode 100644
index 0000000..a9a1018
--- /dev/null
+++ b/api/application/models/University_model.php
@@ -0,0 +1,368 @@
+db->select('*');
+ $this->db->order_by('CreatedOn', 'DESC');
+ $this->db->from(UNIVERSITY);
+ $univDetails = $this->db->get();
+ $universityDetails = $univDetails->result();
+ if (count($universityDetails) > 0) {
+ $results['univList'] = true;
+ $results['university_details'] = $universityDetails;
+ } else {
+ $results['univList'] = false;
+ $results['message'] = 'No record found';
+ }
+ return $results;
+ }
+
+ // update univesity details
+ public function update_university_details($updateFor, $Arr) {
+ $this->db->where('UniversityID', $updateFor);
+ $this->db->update(UNIVERSITY, $Arr);
+ if ($this->db->affected_rows() == '1') {
+ $result['updateUniversityStatus'] = true;
+ $result['message'] = "Successfully University details Updated";
+ } else {
+ $result['updateUniversityStatus'] = false;
+ $result['message'] = "Successfully University details Updated";
+ }
+ return $result;
+ }
+
+ // check exist details
+ public function check_Univ_Exist($data, $check) {
+ // check update for mobile number
+ $this->db->select('*');
+ $this->db->from(UNIVERSITY);
+ $this->db->where('UniversityID', $data);
+ if ($this->db->get()->first_row()) {
+ $result['existUniv'] = true;
+ $result['message'] = "This University Id is already exist!";
+ } else {
+ $result['existUniv'] = false;
+ }
+ return $result;
+ }
+
+ // add university details
+ public function insert_Univ($arr) {
+ $this->db->insert(UNIVERSITY, $arr);
+ if ($this->db->affected_rows() == '1') {
+ $result['addUniv'] = true;
+ $result['message'] = "Successfully University details added";
+ } else {
+ $result['addUniv'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ return $result;
+ }
+
+ public function addActivity($arrayDetails=null,$jsonData=null)
+ {
+ $this->db->select('ActivityID,ActivityName');
+
+ $this->db->where('ActivityName', $arrayDetails['ActivityName']);
+
+ if($this->db->get(ACTIVITY)->first_row()){
+ $result['activityStatus'] = false;
+ $result['message'] = "Activity name is already exist!";
+ }
+ else{
+
+ $this->db->insert(ACTIVITY, $arrayDetails);
+ if($this->db->affected_rows() == '1'){
+ $last = $this->db->order_by('ActivityID',"desc")->limit(1)->get(ACTIVITY)->row();
+ $lastActivityID=$last->ActivityID;
+
+ if($jsonData){
+
+ foreach ($jsonData as $srow){
+ $status_array["StatusName"]=$srow['id'];
+ $status_array["ActivityID"]=$lastActivityID;
+ $status_array["IsActive"]=$arrayDetails['IsActive'];
+ $status_array["CreatedBy"]=$arrayDetails['CreatedBy'];
+ $status_array["CreatedOn"]=$arrayDetails['CreatedOn'];
+ $this->db->insert(ACTIVITY_STATUS, $status_array);
+ }
+ }
+ $result['activityStatus'] = true;
+ $result['message'] = "Successfully activity details added";
+
+ }
+ else {
+ $result['activityStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+ }
+
+
+
+ return $result;
+
+ }
+
+ /*
+ * get Activity details
+ * parama id
+ * created by Surendiran
+ * */
+
+ public function getActivity()
+ {
+ $this->db->distinct();
+ $this->db->select('ActivityID,ActivityName,Description,IsActive');
+ $this->db->order_by('ActivityID','DESC');
+ $activityDetails=$this->db->get(ACTIVITY);
+ if($activityDetails->result()){
+
+ $activity_result['activityStatus'] = true;
+ foreach ($activityDetails->result() as $row){
+ $result_array['ActivityID'] = $row->ActivityID;
+ $result_array['ActivityName'] = $row->ActivityName;
+ $result_array['IsActive'] = $row->IsActive;
+ $result_array['Description'] = $row->Description;
+ $this->db->select('AVS.StatusID,PLD.ListCode,PLD.ListName');
+ $this->db->from(ACTIVITY_STATUS .' as AVS');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AVS.StatusName');
+ $this->db->where('AVS.ActivityID',$row->ActivityID);
+ $this->db->where('AVS.IsActive','1');
+ $result_array['statusDetails']=$this->db->get()->result();
+ $result[]=$result_array;
+ }
+
+ $activity_result['details'] = $result;
+
+
+ }
+ else {
+ $activity_result['activityStatus'] = false;
+ $activity_result['details'] = "No records found!";
+ }
+ $activity_result['masterStatusList']=$this->getAllStatusList('1');
+ return $activity_result;
+
+ }
+ /*
+ * get status details
+ * created by kms
+ * */
+
+ public function getAllStatusList($groupName=null)
+ {
+ $this->db->select('ListCode,ListName');
+ $this->db->where('ListGroup',$groupName);
+ $this->db->where('IsActive','1');
+ $this->db->order_by('ListCode','ASC');
+ $status = $this->db->get(PICK_LIST_DETAILS);
+ return $status->result();
+ }
+
+
+ /*
+ * update activity details details
+ * created by Surendiran
+ * */
+ public function updateActivity($arrayDetails=null,$jsonData=null) {
+
+ $this->db->select('ActivityName');
+ $this->db->where('ActivityName',$arrayDetails['ActivityName']);
+ $this->db->where('ActivityID !=',$arrayDetails['ActivityID']);
+ if($this->db->get(ACTIVITY)->first_row()){
+ $result['activityStatus'] = false;
+ $result['message'] = "Activity name is already exist!";
+ }
+ else{
+
+ $this->db->where('ActivityID ',$arrayDetails['ActivityID']);
+ $updateStatus=$this->db->update(ACTIVITY, $arrayDetails);
+ if($updateStatus){
+ $deactiveStatus['IsActive']=false;
+ $deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('ActivityID ',$arrayDetails['ActivityID']);
+ $updateActivityStatusDeactive = $this->db->update(ACTIVITY_STATUS, $deactiveStatus);
+ if($updateActivityStatusDeactive){
+
+ if($jsonData){
+
+ foreach ($jsonData as $urow){
+
+ $this->db->select('StatusName');
+ $this->db->where('StatusName',$urow);
+ $this->db->where('ActivityID',$arrayDetails['ActivityID']);
+ if($this->db->get(ACTIVITY_STATUS)->first_row()){
+ $existStatusUpdate['IsActive']=true;
+ $existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('StatusName',$urow);
+ $this->db->where('ActivityID',$arrayDetails['ActivityID']);
+ $this->db->update(ACTIVITY_STATUS, $existStatusUpdate);
+ }
+ else{
+ $update_array["StatusName"]=$urow;
+ $update_array["ActivityID"]=$arrayDetails['ActivityID'];
+ $update_array["IsActive"]=true;
+ $update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
+ $update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
+ $this->db->insert(ACTIVITY_STATUS, $update_array);
+
+ }
+
+ }
+ }
+ else{
+ $activateStatus['IsActive']=true;
+ $this->db->where('ActivityID ',$arrayDetails['ActivityID']);
+ $this->db->update(ACTIVITY_STATUS, $activateStatus);
+
+ }
+
+
+
+ $result['activityStatus'] = true;
+ $result['message'] = "Successfully activity details updated";
+ }
+
+
+ }
+ else {
+ $result['activityStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+ }
+
+ return $result;
+ }
+
+ /*
+ * get default activity details
+ * created by kms
+ * */
+ public function getDefaultActivity()
+ {
+ $arr = array('ListGroup'=>2,'ListGroup'=>6);
+ $this->db->distinct();
+ $this->db->select('ListName,ListCode,IsActive');
+ $this->db->order_by('ListName','ASC');
+ $this->db->or_where('ListGroup','2');
+ $this->db->or_where('ListGroup','6');
+ $this->db->or_where('ListGroup','7');
+ $this->db->or_where('ListGroup','8');
+ $this->db->or_where('ListGroup','9');
+ $defaultActivityDetails=$this->db->get(PICK_LIST_DETAILS);
+ if($defaultActivityDetails->result()){
+ $activity_result['activityStatus'] = true;
+ foreach ($defaultActivityDetails->result() as $row){
+ $result_array['ActivityID'] = $row->ListCode;
+ $result_array['ActivityName'] = $row->ListName;
+ $result_array['IsActive'] = $row->IsActive;
+ $this->db->select('DA.StudentActivityCode,PLD.ListCode,PLD.ListName');
+ $this->db->from(DEFAULTACTIVITY .' as DA');
+ $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = DA.StatusCode');
+ // $this->db->where('PLD.IsActive','1');
+ $this->db->where('DA.IsActive','1');
+ $this->db->where('DA.StudentActivityCode',$row->ListCode);
+ $result_array['statusDetails']=$this->db->get()->result();
+ $result[]=$result_array;
+ }
+
+ $activity_result['details'] = $result;
+
+
+ }
+ else {
+ $activity_result['activityStatus'] = false;
+ $activity_result['details'] = "No records found!";
+ }
+ $activity_result['masterStatusList']=$this->getAllStatusList('1');
+ return $activity_result;
+
+ }
+ /*
+ * update default activity status
+ * created by kms
+ * */
+ public function updateDefaultActivity($arrayDetails=null,$jsonData=null) {
+
+
+ $deactiveStatus['IsActive']=false;
+ $deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('StudentActivityCode ',$arrayDetails['StudentActivityCode']);
+ $updateActivityStatusDeactive = $this->db->update(DEFAULTACTIVITY, $deactiveStatus);
+ if($updateActivityStatusDeactive){
+
+ if($jsonData){
+
+ foreach ($jsonData as $urow){
+
+ $this->db->select('StatusCode');
+ $this->db->where('StatusCode',$urow);
+ $this->db->where('StudentActivityCode',$arrayDetails['StudentActivityCode']);
+ if($this->db->get(DEFAULTACTIVITY)->first_row()){
+ $existStatusUpdate['IsActive']=true;
+ $existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
+ $existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
+ $this->db->where('StatusCode',$urow);
+ $this->db->where('StudentActivityCode',$arrayDetails['StudentActivityCode']);
+ $this->db->update(DEFAULTACTIVITY, $existStatusUpdate);
+ }
+ else{
+ $update_array["StatusCode"]=$urow;
+ $update_array["StudentActivityCode"]=$arrayDetails['StudentActivityCode'];
+ $update_array["IsActive"]=true;
+ $update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
+ $update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
+ $this->db->insert(DEFAULTACTIVITY, $update_array);
+
+ }
+
+ }
+ }
+ /*else{
+ $activateStatus['IsActive']=true;
+ $this->db->where('StudentActivityCode ',$arrayDetails['StudentActivityCode']);
+ $this->db->update(DEFAULTACTIVITY, $activateStatus);
+
+ }*/
+
+
+
+ $result['activityStatus'] = true;
+ $result['message'] = "Successfully status updated";
+ }
+
+
+
+ else {
+ $result['activityStatus'] = false;
+ $result['message'] = "Something went wrong.please try again";
+ }
+
+
+
+ return $result;
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/models/index.html b/api/application/models/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/models/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/third_party/index.html b/api/application/third_party/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/third_party/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/views/errors/cli/error_404.php b/api/application/views/errors/cli/error_404.php
new file mode 100644
index 0000000..6984b61
--- /dev/null
+++ b/api/application/views/errors/cli/error_404.php
@@ -0,0 +1,8 @@
+
+
+An uncaught Exception was encountered
+
+Type:
+Message:
+Filename: getFile(), "\n"; ?>
+Line Number: getLine(); ?>
+
+
+
+Backtrace:
+getTrace() as $error): ?>
+
+ File:
+ Line:
+ Function:
+
+
+
+
diff --git a/api/application/views/errors/cli/error_general.php b/api/application/views/errors/cli/error_general.php
new file mode 100644
index 0000000..6984b61
--- /dev/null
+++ b/api/application/views/errors/cli/error_general.php
@@ -0,0 +1,8 @@
+
+
+A PHP Error was encountered
+
+Severity:
+Message:
+Filename:
+Line Number:
+
+
+
+Backtrace:
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
diff --git a/api/application/views/errors/cli/index.html b/api/application/views/errors/cli/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/views/errors/cli/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/views/errors/html/error_404.php b/api/application/views/errors/html/error_404.php
new file mode 100644
index 0000000..756ea9d
--- /dev/null
+++ b/api/application/views/errors/html/error_404.php
@@ -0,0 +1,64 @@
+
+
+
+
+404 Page Not Found
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/application/views/errors/html/error_db.php b/api/application/views/errors/html/error_db.php
new file mode 100644
index 0000000..f5a43f6
--- /dev/null
+++ b/api/application/views/errors/html/error_db.php
@@ -0,0 +1,64 @@
+
+
+
+
+Database Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/application/views/errors/html/error_exception.php b/api/application/views/errors/html/error_exception.php
new file mode 100644
index 0000000..8784886
--- /dev/null
+++ b/api/application/views/errors/html/error_exception.php
@@ -0,0 +1,32 @@
+
+
+
+
+
An uncaught Exception was encountered
+
+
Type:
+
Message:
+
Filename: getFile(); ?>
+
Line Number: getLine(); ?>
+
+
+
+
Backtrace:
+ getTrace() as $error): ?>
+
+
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/application/views/errors/html/error_general.php b/api/application/views/errors/html/error_general.php
new file mode 100644
index 0000000..fc3b2eb
--- /dev/null
+++ b/api/application/views/errors/html/error_general.php
@@ -0,0 +1,64 @@
+
+
+
+
+Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/application/views/errors/html/error_php.php b/api/application/views/errors/html/error_php.php
new file mode 100644
index 0000000..b146f9c
--- /dev/null
+++ b/api/application/views/errors/html/error_php.php
@@ -0,0 +1,33 @@
+
+
+
+
+
A PHP Error was encountered
+
+
Severity:
+
Message:
+
Filename:
+
Line Number:
+
+
+
+
Backtrace:
+
+
+
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/application/views/errors/html/index.html b/api/application/views/errors/html/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/views/errors/html/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/views/errors/index.html b/api/application/views/errors/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/views/errors/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/views/index.html b/api/application/views/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/api/application/views/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/api/application/views/rest_server.php b/api/application/views/rest_server.php
new file mode 100644
index 0000000..5212e6d
--- /dev/null
+++ b/api/application/views/rest_server.php
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+ REST Server Tests
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/application/views/welcome_message.php b/api/application/views/welcome_message.php
new file mode 100644
index 0000000..9ba456f
--- /dev/null
+++ b/api/application/views/welcome_message.php
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+ Welcome to CodeIgniter
+
+
+
+
+
+
+
Welcome to CodeIgniter!
+
+
+
+
+
+
+
+
+
+
The page you are looking at is being generated dynamically by CodeIgniter.
+
+
If you would like to edit this page you'll find it located at:
+
application/views/welcome_message.php
+
+
The corresponding controller for this page is found at:
+
application/controllers/Welcome.php
+
+
+
If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.
+
+
+
+
+
+
+
+
diff --git a/api/composer.json b/api/composer.json
new file mode 100644
index 0000000..64d1be1
--- /dev/null
+++ b/api/composer.json
@@ -0,0 +1,22 @@
+{
+ "description": "The CodeIgniter framework",
+ "name": "codeigniter/framework",
+ "type": "project",
+ "homepage": "https://codeigniter.com",
+ "license": "MIT",
+ "support": {
+ "forum": "http://forum.codeigniter.com/",
+ "wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
+ "irc": "irc://irc.freenode.net/codeigniter",
+ "source": "https://github.com/bcit-ci/CodeIgniter"
+ },
+ "require": {
+ "php": ">=5.2.4"
+ },
+ "suggest": {
+ "paragonie/random_compat": "Provides better randomness in PHP 5.x"
+ },
+ "require-dev": {
+ "mikey179/vfsStream": "1.1.*"
+ }
+}
\ No newline at end of file
diff --git a/api/composer.lock b/api/composer.lock
new file mode 100644
index 0000000..3e8e07b
--- /dev/null
+++ b/api/composer.lock
@@ -0,0 +1,51 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "hash": "425582499c09ce5b5eebb2abb6dc2111",
+ "content-hash": "163eb4764cfceda4201e2d993dd1e79d",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "mikey179/vfsStream",
+ "version": "v1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mikey179/vfsStream.git",
+ "reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/fc0fe8f4d0b527254a2dc45f0c265567c881d07e",
+ "reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "org\\bovigo\\vfs": "src/main/php"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD"
+ ],
+ "homepage": "http://vfs.bovigo.org/",
+ "time": "2012-08-25 12:49:29"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=5.2.4"
+ },
+ "platform-dev": []
+}
diff --git a/api/index.php b/api/index.php
new file mode 100644
index 0000000..0e240df
--- /dev/null
+++ b/api/index.php
@@ -0,0 +1,327 @@
+='))
+ {
+ error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
+ }
+ else
+ {
+ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
+ }
+ break;
+
+ default:
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
+ echo 'The application environment is not set correctly.';
+ exit(1); // EXIT_ERROR
+}
+
+/*
+ *---------------------------------------------------------------
+ * SYSTEM DIRECTORY NAME
+ *---------------------------------------------------------------
+ *
+ * This variable must contain the name of your "system" directory.
+ * Set the path if it is not in the same directory as this file.
+ */
+ $system_path = 'system';
+
+/*
+ *---------------------------------------------------------------
+ * APPLICATION DIRECTORY NAME
+ *---------------------------------------------------------------
+ *
+ * If you want this front controller to use a different "application"
+ * directory than the default one you can set its name here. The directory
+ * can also be renamed or relocated anywhere on your server. If you do,
+ * use an absolute (full) server path.
+ * For more info please see the user guide:
+ *
+ * https://codeigniter.com/user_guide/general/managing_apps.html
+ *
+ * NO TRAILING SLASH!
+ */
+ $application_folder = 'application';
+
+/*
+ *---------------------------------------------------------------
+ * VIEW DIRECTORY NAME
+ *---------------------------------------------------------------
+ *
+ * If you want to move the view directory out of the application
+ * directory, set the path to it here. The directory can be renamed
+ * and relocated anywhere on your server. If blank, it will default
+ * to the standard location inside your application directory.
+ * If you do move this, use an absolute (full) server path.
+ *
+ * NO TRAILING SLASH!
+ */
+ $view_folder = '';
+
+
+/*
+ * --------------------------------------------------------------------
+ * DEFAULT CONTROLLER
+ * --------------------------------------------------------------------
+ *
+ * Normally you will set your default controller in the routes.php file.
+ * You can, however, force a custom routing by hard-coding a
+ * specific controller class/function here. For most applications, you
+ * WILL NOT set your routing here, but it's an option for those
+ * special instances where you might want to override the standard
+ * routing in a specific front controller that shares a common CI installation.
+ *
+ * IMPORTANT: If you set the routing here, NO OTHER controller will be
+ * callable. In essence, this preference limits your application to ONE
+ * specific controller. Leave the function name blank if you need
+ * to call functions dynamically via the URI.
+ *
+ * Un-comment the $routing array below to use this feature
+ */
+ // The directory name, relative to the "controllers" directory. Leave blank
+ // if your controller is not in a sub-directory within the "controllers" one
+ // $routing['directory'] = '';
+
+ // The controller class file name. Example: mycontroller
+ // $routing['controller'] = '';
+
+ // The controller function you wish to be called.
+ // $routing['function'] = '';
+
+
+/*
+ * -------------------------------------------------------------------
+ * CUSTOM CONFIG VALUES
+ * -------------------------------------------------------------------
+ *
+ * The $assign_to_config array below will be passed dynamically to the
+ * config class when initialized. This allows you to set custom config
+ * items or override any default config values found in the config.php file.
+ * This can be handy as it permits you to share one application between
+ * multiple front controller files, with each file containing different
+ * config values.
+ *
+ * Un-comment the $assign_to_config array below to use this feature
+ */
+ // $assign_to_config['name_of_config_item'] = 'value of config item';
+
+
+
+// --------------------------------------------------------------------
+// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
+// --------------------------------------------------------------------
+
+/*
+ * ---------------------------------------------------------------
+ * Resolve the system path for increased reliability
+ * ---------------------------------------------------------------
+ */
+
+ // Set the current directory correctly for CLI requests
+ if (defined('STDIN'))
+ {
+ chdir(dirname(__FILE__));
+ }
+
+ if (($_temp = realpath($system_path)) !== FALSE)
+ {
+ $system_path = $_temp.DIRECTORY_SEPARATOR;
+ }
+ else
+ {
+ // Ensure there's a trailing slash
+ $system_path = strtr(
+ rtrim($system_path, '/\\'),
+ '/\\',
+ DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
+ ).DIRECTORY_SEPARATOR;
+ }
+
+ // Is the system path correct?
+ if ( ! is_dir($system_path))
+ {
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
+ echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
+ exit(3); // EXIT_CONFIG
+ }
+
+/*
+ * -------------------------------------------------------------------
+ * Now that we know the path, set the main path constants
+ * -------------------------------------------------------------------
+ */
+ // The name of THIS file
+ define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
+
+ // Path to the system directory
+ define('BASEPATH', $system_path);
+
+ // Path to the front controller (this file) directory
+ define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
+
+ // Name of the "system" directory
+ define('SYSDIR', basename(BASEPATH));
+
+ // The path to the "application" directory
+ if (is_dir($application_folder))
+ {
+ if (($_temp = realpath($application_folder)) !== FALSE)
+ {
+ $application_folder = $_temp;
+ }
+ else
+ {
+ $application_folder = strtr(
+ rtrim($application_folder, '/\\'),
+ '/\\',
+ DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
+ );
+ }
+ }
+ elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
+ {
+ $application_folder = BASEPATH.strtr(
+ trim($application_folder, '/\\'),
+ '/\\',
+ DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
+ );
+ }
+ else
+ {
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
+ echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
+ exit(3); // EXIT_CONFIG
+ }
+
+ define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
+
+ // The path to the "views" directory
+ if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
+ {
+ $view_folder = APPPATH.'views';
+ }
+ elseif (is_dir($view_folder))
+ {
+ if (($_temp = realpath($view_folder)) !== FALSE)
+ {
+ $view_folder = $_temp;
+ }
+ else
+ {
+ $view_folder = strtr(
+ rtrim($view_folder, '/\\'),
+ '/\\',
+ DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
+ );
+ }
+ }
+ elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
+ {
+ $view_folder = APPPATH.strtr(
+ trim($view_folder, '/\\'),
+ '/\\',
+ DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
+ );
+ }
+ else
+ {
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
+ echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
+ exit(3); // EXIT_CONFIG
+ }
+
+ define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
+
+/*
+ * --------------------------------------------------------------------
+ * LOAD THE BOOTSTRAP FILE
+ * --------------------------------------------------------------------
+ *
+ * And away we go...
+ */
+require_once BASEPATH.'core/CodeIgniter.php';
diff --git a/api/system/.htaccess b/api/system/.htaccess
new file mode 100644
index 0000000..97c65d2
--- /dev/null
+++ b/api/system/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
\ No newline at end of file
diff --git a/api/system/core/Benchmark.php b/api/system/core/Benchmark.php
new file mode 100644
index 0000000..b1d74f7
--- /dev/null
+++ b/api/system/core/Benchmark.php
@@ -0,0 +1,133 @@
+marker[$name] = microtime(TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Elapsed time
+ *
+ * Calculates the time difference between two marked points.
+ *
+ * If the first parameter is empty this function instead returns the
+ * {elapsed_time} pseudo-variable. This permits the full system
+ * execution time to be shown in a template. The output class will
+ * swap the real value for this variable.
+ *
+ * @param string $point1 A particular marked point
+ * @param string $point2 A particular marked point
+ * @param int $decimals Number of decimal places
+ *
+ * @return string Calculated elapsed time on success,
+ * an '{elapsed_string}' if $point1 is empty
+ * or an empty string if $point1 is not found.
+ */
+ public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
+ {
+ if ($point1 === '')
+ {
+ return '{elapsed_time}';
+ }
+
+ if ( ! isset($this->marker[$point1]))
+ {
+ return '';
+ }
+
+ if ( ! isset($this->marker[$point2]))
+ {
+ $this->marker[$point2] = microtime(TRUE);
+ }
+
+ return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Memory Usage
+ *
+ * Simply returns the {memory_usage} marker.
+ *
+ * This permits it to be put it anywhere in a template
+ * without the memory being calculated until the end.
+ * The output class will swap the real value for this variable.
+ *
+ * @return string '{memory_usage}'
+ */
+ public function memory_usage()
+ {
+ return '{memory_usage}';
+ }
+
+}
diff --git a/api/system/core/CodeIgniter.php b/api/system/core/CodeIgniter.php
new file mode 100644
index 0000000..a2067fb
--- /dev/null
+++ b/api/system/core/CodeIgniter.php
@@ -0,0 +1,556 @@
+ '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal)
+ {
+ if (strpos($_registered, $key) === FALSE)
+ {
+ continue;
+ }
+
+ foreach (array_keys($$superglobal) as $var)
+ {
+ if (isset($GLOBALS[$var]) && ! in_array($var, $_protected, TRUE))
+ {
+ $GLOBALS[$var] = NULL;
+ }
+ }
+ }
+ }
+}
+
+
+/*
+ * ------------------------------------------------------
+ * Define a custom error handler so we can log PHP errors
+ * ------------------------------------------------------
+ */
+ set_error_handler('_error_handler');
+ set_exception_handler('_exception_handler');
+ register_shutdown_function('_shutdown_handler');
+
+/*
+ * ------------------------------------------------------
+ * Set the subclass_prefix
+ * ------------------------------------------------------
+ *
+ * Normally the "subclass_prefix" is set in the config file.
+ * The subclass prefix allows CI to know if a core class is
+ * being extended via a library in the local application
+ * "libraries" folder. Since CI allows config items to be
+ * overridden via data set in the main index.php file,
+ * before proceeding we need to know if a subclass_prefix
+ * override exists. If so, we will set this value now,
+ * before any classes are loaded
+ * Note: Since the config file data is cached it doesn't
+ * hurt to load it here.
+ */
+ if ( ! empty($assign_to_config['subclass_prefix']))
+ {
+ get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
+ }
+
+/*
+ * ------------------------------------------------------
+ * Should we use a Composer autoloader?
+ * ------------------------------------------------------
+ */
+ if ($composer_autoload = config_item('composer_autoload'))
+ {
+ if ($composer_autoload === TRUE)
+ {
+ file_exists(APPPATH.'vendor/autoload.php')
+ ? require_once(APPPATH.'vendor/autoload.php')
+ : log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
+ }
+ elseif (file_exists($composer_autoload))
+ {
+ require_once($composer_autoload);
+ }
+ else
+ {
+ log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload);
+ }
+ }
+
+/*
+ * ------------------------------------------------------
+ * Start the timer... tick tock tick tock...
+ * ------------------------------------------------------
+ */
+ $BM =& load_class('Benchmark', 'core');
+ $BM->mark('total_execution_time_start');
+ $BM->mark('loading_time:_base_classes_start');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the hooks class
+ * ------------------------------------------------------
+ */
+ $EXT =& load_class('Hooks', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Is there a "pre_system" hook?
+ * ------------------------------------------------------
+ */
+ $EXT->call_hook('pre_system');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the config class
+ * ------------------------------------------------------
+ *
+ * Note: It is important that Config is loaded first as
+ * most other classes depend on it either directly or by
+ * depending on another class that uses it.
+ *
+ */
+ $CFG =& load_class('Config', 'core');
+
+ // Do we have any manually set config items in the index.php file?
+ if (isset($assign_to_config) && is_array($assign_to_config))
+ {
+ foreach ($assign_to_config as $key => $value)
+ {
+ $CFG->set_item($key, $value);
+ }
+ }
+
+/*
+ * ------------------------------------------------------
+ * Important charset-related stuff
+ * ------------------------------------------------------
+ *
+ * Configure mbstring and/or iconv if they are enabled
+ * and set MB_ENABLED and ICONV_ENABLED constants, so
+ * that we don't repeatedly do extension_loaded() or
+ * function_exists() calls.
+ *
+ * Note: UTF-8 class depends on this. It used to be done
+ * in it's constructor, but it's _not_ class-specific.
+ *
+ */
+ $charset = strtoupper(config_item('charset'));
+ ini_set('default_charset', $charset);
+
+ if (extension_loaded('mbstring'))
+ {
+ define('MB_ENABLED', TRUE);
+ // mbstring.internal_encoding is deprecated starting with PHP 5.6
+ // and it's usage triggers E_DEPRECATED messages.
+ @ini_set('mbstring.internal_encoding', $charset);
+ // This is required for mb_convert_encoding() to strip invalid characters.
+ // That's utilized by CI_Utf8, but it's also done for consistency with iconv.
+ mb_substitute_character('none');
+ }
+ else
+ {
+ define('MB_ENABLED', FALSE);
+ }
+
+ // There's an ICONV_IMPL constant, but the PHP manual says that using
+ // iconv's predefined constants is "strongly discouraged".
+ if (extension_loaded('iconv'))
+ {
+ define('ICONV_ENABLED', TRUE);
+ // iconv.internal_encoding is deprecated starting with PHP 5.6
+ // and it's usage triggers E_DEPRECATED messages.
+ @ini_set('iconv.internal_encoding', $charset);
+ }
+ else
+ {
+ define('ICONV_ENABLED', FALSE);
+ }
+
+ if (is_php('5.6'))
+ {
+ ini_set('php.internal_encoding', $charset);
+ }
+
+/*
+ * ------------------------------------------------------
+ * Load compatibility features
+ * ------------------------------------------------------
+ */
+
+ require_once(BASEPATH.'core/compat/mbstring.php');
+ require_once(BASEPATH.'core/compat/hash.php');
+ require_once(BASEPATH.'core/compat/password.php');
+ require_once(BASEPATH.'core/compat/standard.php');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the UTF-8 class
+ * ------------------------------------------------------
+ */
+ $UNI =& load_class('Utf8', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the URI class
+ * ------------------------------------------------------
+ */
+ $URI =& load_class('URI', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the routing class and set the routing
+ * ------------------------------------------------------
+ */
+ $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the output class
+ * ------------------------------------------------------
+ */
+ $OUT =& load_class('Output', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Is there a valid cache file? If so, we're done...
+ * ------------------------------------------------------
+ */
+ if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
+ {
+ exit;
+ }
+
+/*
+ * -----------------------------------------------------
+ * Load the security class for xss and csrf support
+ * -----------------------------------------------------
+ */
+ $SEC =& load_class('Security', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Load the Input class and sanitize globals
+ * ------------------------------------------------------
+ */
+ $IN =& load_class('Input', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Load the Language class
+ * ------------------------------------------------------
+ */
+ $LANG =& load_class('Lang', 'core');
+
+/*
+ * ------------------------------------------------------
+ * Load the app controller and local controller
+ * ------------------------------------------------------
+ *
+ */
+ // Load the base controller class
+ require_once BASEPATH.'core/Controller.php';
+
+ /**
+ * Reference to the CI_Controller method.
+ *
+ * Returns current CI instance object
+ *
+ * @return CI_Controller
+ */
+ function &get_instance()
+ {
+ return CI_Controller::get_instance();
+ }
+
+ if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
+ {
+ require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
+ }
+
+ // Set a mark point for benchmarking
+ $BM->mark('loading_time:_base_classes_end');
+
+/*
+ * ------------------------------------------------------
+ * Sanity checks
+ * ------------------------------------------------------
+ *
+ * The Router class has already validated the request,
+ * leaving us with 3 options here:
+ *
+ * 1) an empty class name, if we reached the default
+ * controller, but it didn't exist;
+ * 2) a query string which doesn't go through a
+ * file_exists() check
+ * 3) a regular request for a non-existing page
+ *
+ * We handle all of these as a 404 error.
+ *
+ * Furthermore, none of the methods in the app controller
+ * or the loader class can be called via the URI, nor can
+ * controller methods that begin with an underscore.
+ */
+
+ $e404 = FALSE;
+ $class = ucfirst($RTR->class);
+ $method = $RTR->method;
+
+ if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
+ {
+ $e404 = TRUE;
+ }
+ else
+ {
+ require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
+
+ if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
+ {
+ $e404 = TRUE;
+ }
+ elseif (method_exists($class, '_remap'))
+ {
+ $params = array($method, array_slice($URI->rsegments, 2));
+ $method = '_remap';
+ }
+ elseif ( ! method_exists($class, $method))
+ {
+ $e404 = TRUE;
+ }
+ /**
+ * DO NOT CHANGE THIS, NOTHING ELSE WORKS!
+ *
+ * - method_exists() returns true for non-public methods, which passes the previous elseif
+ * - is_callable() returns false for PHP 4-style constructors, even if there's a __construct()
+ * - method_exists($class, '__construct') won't work because CI_Controller::__construct() is inherited
+ * - People will only complain if this doesn't work, even though it is documented that it shouldn't.
+ *
+ * ReflectionMethod::isConstructor() is the ONLY reliable check,
+ * knowing which method will be executed as a constructor.
+ */
+ elseif ( ! is_callable(array($class, $method)) && strcasecmp($class, $method) === 0)
+ {
+ $reflection = new ReflectionMethod($class, $method);
+ if ( ! $reflection->isPublic() OR $reflection->isConstructor())
+ {
+ $e404 = TRUE;
+ }
+ }
+ }
+
+ if ($e404)
+ {
+ if ( ! empty($RTR->routes['404_override']))
+ {
+ if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
+ {
+ $error_method = 'index';
+ }
+
+ $error_class = ucfirst($error_class);
+
+ if ( ! class_exists($error_class, FALSE))
+ {
+ if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'))
+ {
+ require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php');
+ $e404 = ! class_exists($error_class, FALSE);
+ }
+ // Were we in a directory? If so, check for a global override
+ elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php'))
+ {
+ require_once(APPPATH.'controllers/'.$error_class.'.php');
+ if (($e404 = ! class_exists($error_class, FALSE)) === FALSE)
+ {
+ $RTR->directory = '';
+ }
+ }
+ }
+ else
+ {
+ $e404 = FALSE;
+ }
+ }
+
+ // Did we reset the $e404 flag? If so, set the rsegments, starting from index 1
+ if ( ! $e404)
+ {
+ $class = $error_class;
+ $method = $error_method;
+
+ $URI->rsegments = array(
+ 1 => $class,
+ 2 => $method
+ );
+ }
+ else
+ {
+ show_404($RTR->directory.$class.'/'.$method);
+ }
+ }
+
+ if ($method !== '_remap')
+ {
+ $params = array_slice($URI->rsegments, 2);
+ }
+
+/*
+ * ------------------------------------------------------
+ * Is there a "pre_controller" hook?
+ * ------------------------------------------------------
+ */
+ $EXT->call_hook('pre_controller');
+
+/*
+ * ------------------------------------------------------
+ * Instantiate the requested controller
+ * ------------------------------------------------------
+ */
+ // Mark a start point so we can benchmark the controller
+ $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
+
+ $CI = new $class();
+
+/*
+ * ------------------------------------------------------
+ * Is there a "post_controller_constructor" hook?
+ * ------------------------------------------------------
+ */
+ $EXT->call_hook('post_controller_constructor');
+
+/*
+ * ------------------------------------------------------
+ * Call the requested method
+ * ------------------------------------------------------
+ */
+ call_user_func_array(array(&$CI, $method), $params);
+
+ // Mark a benchmark end point
+ $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
+
+/*
+ * ------------------------------------------------------
+ * Is there a "post_controller" hook?
+ * ------------------------------------------------------
+ */
+ $EXT->call_hook('post_controller');
+
+/*
+ * ------------------------------------------------------
+ * Send the final rendered output to the browser
+ * ------------------------------------------------------
+ */
+ if ($EXT->call_hook('display_override') === FALSE)
+ {
+ $OUT->_display();
+ }
+
+/*
+ * ------------------------------------------------------
+ * Is there a "post_system" hook?
+ * ------------------------------------------------------
+ */
+ $EXT->call_hook('post_system');
diff --git a/api/system/core/Common.php b/api/system/core/Common.php
new file mode 100644
index 0000000..91c585f
--- /dev/null
+++ b/api/system/core/Common.php
@@ -0,0 +1,857 @@
+=');
+ }
+
+ return $_is_php[$version];
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('is_really_writable'))
+{
+ /**
+ * Tests for file writability
+ *
+ * is_writable() returns TRUE on Windows servers when you really can't write to
+ * the file, based on the read-only attribute. is_writable() is also unreliable
+ * on Unix servers if safe_mode is on.
+ *
+ * @link https://bugs.php.net/bug.php?id=54709
+ * @param string
+ * @return bool
+ */
+ function is_really_writable($file)
+ {
+ // If we're on a Unix server with safe_mode off we call is_writable
+ if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR ! ini_get('safe_mode')))
+ {
+ return is_writable($file);
+ }
+
+ /* For Windows servers and safe_mode "on" installations we'll actually
+ * write a file then read it. Bah...
+ */
+ if (is_dir($file))
+ {
+ $file = rtrim($file, '/').'/'.md5(mt_rand());
+ if (($fp = @fopen($file, 'ab')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ fclose($fp);
+ @chmod($file, 0777);
+ @unlink($file);
+ return TRUE;
+ }
+ elseif ( ! is_file($file) OR ($fp = @fopen($file, 'ab')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ fclose($fp);
+ return TRUE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('load_class'))
+{
+ /**
+ * Class registry
+ *
+ * This function acts as a singleton. If the requested class does not
+ * exist it is instantiated and set to a static variable. If it has
+ * previously been instantiated the variable is returned.
+ *
+ * @param string the class name being requested
+ * @param string the directory where the class should be found
+ * @param string an optional argument to pass to the class constructor
+ * @return object
+ */
+ function &load_class($class, $directory = 'libraries', $param = NULL)
+ {
+ static $_classes = array();
+
+ // Does the class exist? If so, we're done...
+ if (isset($_classes[$class]))
+ {
+ return $_classes[$class];
+ }
+
+ $name = FALSE;
+
+ // Look for the class first in the local application/libraries folder
+ // then in the native system/libraries folder
+ foreach (array(APPPATH, BASEPATH) as $path)
+ {
+ if (file_exists($path.$directory.'/'.$class.'.php'))
+ {
+ $name = 'CI_'.$class;
+
+ if (class_exists($name, FALSE) === FALSE)
+ {
+ require_once($path.$directory.'/'.$class.'.php');
+ }
+
+ break;
+ }
+ }
+
+ // Is the request a class extension? If so we load it too
+ if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
+ {
+ $name = config_item('subclass_prefix').$class;
+
+ if (class_exists($name, FALSE) === FALSE)
+ {
+ require_once(APPPATH.$directory.'/'.$name.'.php');
+ }
+ }
+
+ // Did we find the class?
+ if ($name === FALSE)
+ {
+ // Note: We use exit() rather than show_error() in order to avoid a
+ // self-referencing loop with the Exceptions class
+ set_status_header(503);
+ echo 'Unable to locate the specified class: '.$class.'.php';
+ exit(5); // EXIT_UNK_CLASS
+ }
+
+ // Keep track of what we just loaded
+ is_loaded($class);
+
+ $_classes[$class] = isset($param)
+ ? new $name($param)
+ : new $name();
+ return $_classes[$class];
+ }
+}
+
+// --------------------------------------------------------------------
+
+if ( ! function_exists('is_loaded'))
+{
+ /**
+ * Keeps track of which libraries have been loaded. This function is
+ * called by the load_class() function above
+ *
+ * @param string
+ * @return array
+ */
+ function &is_loaded($class = '')
+ {
+ static $_is_loaded = array();
+
+ if ($class !== '')
+ {
+ $_is_loaded[strtolower($class)] = $class;
+ }
+
+ return $_is_loaded;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('get_config'))
+{
+ /**
+ * Loads the main config.php file
+ *
+ * This function lets us grab the config file even if the Config class
+ * hasn't been instantiated yet
+ *
+ * @param array
+ * @return array
+ */
+ function &get_config(Array $replace = array())
+ {
+ static $config;
+
+ if (empty($config))
+ {
+ $file_path = APPPATH.'config/config.php';
+ $found = FALSE;
+ if (file_exists($file_path))
+ {
+ $found = TRUE;
+ require($file_path);
+ }
+
+ // Is the config file in the environment folder?
+ if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
+ {
+ require($file_path);
+ }
+ elseif ( ! $found)
+ {
+ set_status_header(503);
+ echo 'The configuration file does not exist.';
+ exit(3); // EXIT_CONFIG
+ }
+
+ // Does the $config array exist in the file?
+ if ( ! isset($config) OR ! is_array($config))
+ {
+ set_status_header(503);
+ echo 'Your config file does not appear to be formatted correctly.';
+ exit(3); // EXIT_CONFIG
+ }
+ }
+
+ // Are any values being dynamically added or replaced?
+ foreach ($replace as $key => $val)
+ {
+ $config[$key] = $val;
+ }
+
+ return $config;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('config_item'))
+{
+ /**
+ * Returns the specified config item
+ *
+ * @param string
+ * @return mixed
+ */
+ function config_item($item)
+ {
+ static $_config;
+
+ if (empty($_config))
+ {
+ // references cannot be directly assigned to static variables, so we use an array
+ $_config[0] =& get_config();
+ }
+
+ return isset($_config[0][$item]) ? $_config[0][$item] : NULL;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('get_mimes'))
+{
+ /**
+ * Returns the MIME types array from config/mimes.php
+ *
+ * @return array
+ */
+ function &get_mimes()
+ {
+ static $_mimes;
+
+ if (empty($_mimes))
+ {
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ {
+ $_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
+ }
+ elseif (file_exists(APPPATH.'config/mimes.php'))
+ {
+ $_mimes = include(APPPATH.'config/mimes.php');
+ }
+ else
+ {
+ $_mimes = array();
+ }
+ }
+
+ return $_mimes;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('is_https'))
+{
+ /**
+ * Is HTTPS?
+ *
+ * Determines if the application is accessed via an encrypted
+ * (HTTPS) connection.
+ *
+ * @return bool
+ */
+ function is_https()
+ {
+ if ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')
+ {
+ return TRUE;
+ }
+ elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https')
+ {
+ return TRUE;
+ }
+ elseif ( ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off')
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('is_cli'))
+{
+
+ /**
+ * Is CLI?
+ *
+ * Test to see if a request was made from the command line.
+ *
+ * @return bool
+ */
+ function is_cli()
+ {
+ return (PHP_SAPI === 'cli' OR defined('STDIN'));
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('show_error'))
+{
+ /**
+ * Error Handler
+ *
+ * This function lets us invoke the exception class and
+ * display errors using the standard error template located
+ * in application/views/errors/error_general.php
+ * This function will send the error page directly to the
+ * browser and exit.
+ *
+ * @param string
+ * @param int
+ * @param string
+ * @return void
+ */
+ function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
+ {
+ $status_code = abs($status_code);
+ if ($status_code < 100)
+ {
+ $exit_status = $status_code + 9; // 9 is EXIT__AUTO_MIN
+ if ($exit_status > 125) // 125 is EXIT__AUTO_MAX
+ {
+ $exit_status = 1; // EXIT_ERROR
+ }
+
+ $status_code = 500;
+ }
+ else
+ {
+ $exit_status = 1; // EXIT_ERROR
+ }
+
+ $_error =& load_class('Exceptions', 'core');
+ echo $_error->show_error($heading, $message, 'error_general', $status_code);
+ exit($exit_status);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('show_404'))
+{
+ /**
+ * 404 Page Handler
+ *
+ * This function is similar to the show_error() function above
+ * However, instead of the standard error template it displays
+ * 404 errors.
+ *
+ * @param string
+ * @param bool
+ * @return void
+ */
+ function show_404($page = '', $log_error = TRUE)
+ {
+ $_error =& load_class('Exceptions', 'core');
+ $_error->show_404($page, $log_error);
+ exit(4); // EXIT_UNKNOWN_FILE
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('log_message'))
+{
+ /**
+ * Error Logging Interface
+ *
+ * We use this as a simple mechanism to access the logging
+ * class and send messages to be logged.
+ *
+ * @param string the error level: 'error', 'debug' or 'info'
+ * @param string the error message
+ * @return void
+ */
+ function log_message($level, $message)
+ {
+ static $_log;
+
+ if ($_log === NULL)
+ {
+ // references cannot be directly assigned to static variables, so we use an array
+ $_log[0] =& load_class('Log', 'core');
+ }
+
+ $_log[0]->write_log($level, $message);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('set_status_header'))
+{
+ /**
+ * Set HTTP Status Header
+ *
+ * @param int the status code
+ * @param string
+ * @return void
+ */
+ function set_status_header($code = 200, $text = '')
+ {
+ if (is_cli())
+ {
+ return;
+ }
+
+ if (empty($code) OR ! is_numeric($code))
+ {
+ show_error('Status codes must be numeric', 500);
+ }
+
+ if (empty($text))
+ {
+ is_int($code) OR $code = (int) $code;
+ $stati = array(
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 307 => 'Temporary Redirect',
+
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Timeout',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Long',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested Range Not Satisfiable',
+ 417 => 'Expectation Failed',
+ 422 => 'Unprocessable Entity',
+ 426 => 'Upgrade Required',
+ 428 => 'Precondition Required',
+ 429 => 'Too Many Requests',
+ 431 => 'Request Header Fields Too Large',
+
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Timeout',
+ 505 => 'HTTP Version Not Supported',
+ 511 => 'Network Authentication Required',
+ );
+
+ if (isset($stati[$code]))
+ {
+ $text = $stati[$code];
+ }
+ else
+ {
+ show_error('No status text available. Please check your status code number or supply your own message text.', 500);
+ }
+ }
+
+ if (strpos(PHP_SAPI, 'cgi') === 0)
+ {
+ header('Status: '.$code.' '.$text, TRUE);
+ }
+ else
+ {
+ $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
+ header($server_protocol.' '.$code.' '.$text, TRUE, $code);
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+if ( ! function_exists('_error_handler'))
+{
+ /**
+ * Error Handler
+ *
+ * This is the custom error handler that is declared at the (relative)
+ * top of CodeIgniter.php. The main reason we use this is to permit
+ * PHP errors to be logged in our own log files since the user may
+ * not have access to server logs. Since this function effectively
+ * intercepts PHP errors, however, we also need to display errors
+ * based on the current error_reporting level.
+ * We do that with the use of a PHP error template.
+ *
+ * @param int $severity
+ * @param string $message
+ * @param string $filepath
+ * @param int $line
+ * @return void
+ */
+ function _error_handler($severity, $message, $filepath, $line)
+ {
+ $is_error = (((E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);
+
+ // When an error occurred, set the status header to '500 Internal Server Error'
+ // to indicate to the client something went wrong.
+ // This can't be done within the $_error->show_php_error method because
+ // it is only called when the display_errors flag is set (which isn't usually
+ // the case in a production environment) or when errors are ignored because
+ // they are above the error_reporting threshold.
+ if ($is_error)
+ {
+ set_status_header(500);
+ }
+
+ // Should we ignore the error? We'll get the current error_reporting
+ // level and add its bits with the severity bits to find out.
+ if (($severity & error_reporting()) !== $severity)
+ {
+ return;
+ }
+
+ $_error =& load_class('Exceptions', 'core');
+ $_error->log_exception($severity, $message, $filepath, $line);
+
+ // Should we display the error?
+ if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
+ {
+ $_error->show_php_error($severity, $message, $filepath, $line);
+ }
+
+ // If the error is fatal, the execution of the script should be stopped because
+ // errors can't be recovered from. Halting the script conforms with PHP's
+ // default error handling. See http://www.php.net/manual/en/errorfunc.constants.php
+ if ($is_error)
+ {
+ exit(1); // EXIT_ERROR
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_exception_handler'))
+{
+ /**
+ * Exception Handler
+ *
+ * Sends uncaught exceptions to the logger and displays them
+ * only if display_errors is On so that they don't show up in
+ * production environments.
+ *
+ * @param Exception $exception
+ * @return void
+ */
+ function _exception_handler($exception)
+ {
+ $_error =& load_class('Exceptions', 'core');
+ $_error->log_exception('error', 'Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine());
+
+ is_cli() OR set_status_header(500);
+ // Should we display the error?
+ if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
+ {
+ $_error->show_exception($exception);
+ }
+
+ exit(1); // EXIT_ERROR
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_shutdown_handler'))
+{
+ /**
+ * Shutdown Handler
+ *
+ * This is the shutdown handler that is declared at the top
+ * of CodeIgniter.php. The main reason we use this is to simulate
+ * a complete custom exception handler.
+ *
+ * E_STRICT is purposively neglected because such events may have
+ * been caught. Duplication or none? None is preferred for now.
+ *
+ * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
+ * @return void
+ */
+ function _shutdown_handler()
+ {
+ $last_error = error_get_last();
+ if (isset($last_error) &&
+ ($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)))
+ {
+ _error_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+if ( ! function_exists('remove_invisible_characters'))
+{
+ /**
+ * Remove Invisible Characters
+ *
+ * This prevents sandwiching null characters
+ * between ascii characters, like Java\0script.
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function remove_invisible_characters($str, $url_encoded = TRUE)
+ {
+ $non_displayables = array();
+
+ // every control character except newline (dec 10),
+ // carriage return (dec 13) and horizontal tab (dec 09)
+ if ($url_encoded)
+ {
+ $non_displayables[] = '/%0[0-8bcef]/i'; // url encoded 00-08, 11, 12, 14, 15
+ $non_displayables[] = '/%1[0-9a-f]/i'; // url encoded 16-31
+ }
+
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
+
+ do
+ {
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
+ }
+ while ($count);
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('html_escape'))
+{
+ /**
+ * Returns HTML escaped variable.
+ *
+ * @param mixed $var The input string or array of strings to be escaped.
+ * @param bool $double_encode $double_encode set to FALSE prevents escaping twice.
+ * @return mixed The escaped string or array of strings as a result.
+ */
+ function html_escape($var, $double_encode = TRUE)
+ {
+ if (empty($var))
+ {
+ return $var;
+ }
+
+ if (is_array($var))
+ {
+ foreach (array_keys($var) as $key)
+ {
+ $var[$key] = html_escape($var[$key], $double_encode);
+ }
+
+ return $var;
+ }
+
+ return htmlspecialchars($var, ENT_QUOTES, config_item('charset'), $double_encode);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_stringify_attributes'))
+{
+ /**
+ * Stringify attributes for use in HTML tags.
+ *
+ * Helper function used to convert a string, array, or object
+ * of attributes to a string.
+ *
+ * @param mixed string, array, object
+ * @param bool
+ * @return string
+ */
+ function _stringify_attributes($attributes, $js = FALSE)
+ {
+ $atts = NULL;
+
+ if (empty($attributes))
+ {
+ return $atts;
+ }
+
+ if (is_string($attributes))
+ {
+ return ' '.$attributes;
+ }
+
+ $attributes = (array) $attributes;
+
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"';
+ }
+
+ return rtrim($atts, ',');
+ }
+}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('function_usable'))
+{
+ /**
+ * Function usable
+ *
+ * Executes a function_exists() check, and if the Suhosin PHP
+ * extension is loaded - checks whether the function that is
+ * checked might be disabled in there as well.
+ *
+ * This is useful as function_exists() will return FALSE for
+ * functions disabled via the *disable_functions* php.ini
+ * setting, but not for *suhosin.executor.func.blacklist* and
+ * *suhosin.executor.disable_eval*. These settings will just
+ * terminate script execution if a disabled function is executed.
+ *
+ * The above described behavior turned out to be a bug in Suhosin,
+ * but even though a fix was commited for 0.9.34 on 2012-02-12,
+ * that version is yet to be released. This function will therefore
+ * be just temporary, but would probably be kept for a few years.
+ *
+ * @link http://www.hardened-php.net/suhosin/
+ * @param string $function_name Function to check for
+ * @return bool TRUE if the function exists and is safe to call,
+ * FALSE otherwise.
+ */
+ function function_usable($function_name)
+ {
+ static $_suhosin_func_blacklist;
+
+ if (function_exists($function_name))
+ {
+ if ( ! isset($_suhosin_func_blacklist))
+ {
+ $_suhosin_func_blacklist = extension_loaded('suhosin')
+ ? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
+ : array();
+ }
+
+ return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);
+ }
+
+ return FALSE;
+ }
+}
diff --git a/api/system/core/Config.php b/api/system/core/Config.php
new file mode 100644
index 0000000..9fd3e4a
--- /dev/null
+++ b/api/system/core/Config.php
@@ -0,0 +1,379 @@
+config =& get_config();
+
+ // Set the base_url automatically if none was provided
+ if (empty($this->config['base_url']))
+ {
+ if (isset($_SERVER['SERVER_ADDR']))
+ {
+ if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
+ {
+ $server_addr = '['.$_SERVER['SERVER_ADDR'].']';
+ }
+ else
+ {
+ $server_addr = $_SERVER['SERVER_ADDR'];
+ }
+
+ $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
+ .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
+ }
+ else
+ {
+ $base_url = 'http://localhost/';
+ }
+
+ $this->set_item('base_url', $base_url);
+ }
+
+ log_message('info', 'Config Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load Config File
+ *
+ * @param string $file Configuration file name
+ * @param bool $use_sections Whether configuration values should be loaded into their own section
+ * @param bool $fail_gracefully Whether to just return FALSE or display an error message
+ * @return bool TRUE if the file was loaded correctly or FALSE on failure
+ */
+ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
+ {
+ $file = ($file === '') ? 'config' : str_replace('.php', '', $file);
+ $loaded = FALSE;
+
+ foreach ($this->_config_paths as $path)
+ {
+ foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
+ {
+ $file_path = $path.'config/'.$location.'.php';
+ if (in_array($file_path, $this->is_loaded, TRUE))
+ {
+ return TRUE;
+ }
+
+ if ( ! file_exists($file_path))
+ {
+ continue;
+ }
+
+ include($file_path);
+
+ if ( ! isset($config) OR ! is_array($config))
+ {
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+
+ show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
+ }
+
+ if ($use_sections === TRUE)
+ {
+ $this->config[$file] = isset($this->config[$file])
+ ? array_merge($this->config[$file], $config)
+ : $config;
+ }
+ else
+ {
+ $this->config = array_merge($this->config, $config);
+ }
+
+ $this->is_loaded[] = $file_path;
+ $config = NULL;
+ $loaded = TRUE;
+ log_message('debug', 'Config file loaded: '.$file_path);
+ }
+ }
+
+ if ($loaded === TRUE)
+ {
+ return TRUE;
+ }
+ elseif ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+
+ show_error('The configuration file '.$file.'.php does not exist.');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a config file item
+ *
+ * @param string $item Config item name
+ * @param string $index Index name
+ * @return string|null The configuration item or NULL if the item doesn't exist
+ */
+ public function item($item, $index = '')
+ {
+ if ($index == '')
+ {
+ return isset($this->config[$item]) ? $this->config[$item] : NULL;
+ }
+
+ return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a config file item with slash appended (if not empty)
+ *
+ * @param string $item Config item name
+ * @return string|null The configuration item or NULL if the item doesn't exist
+ */
+ public function slash_item($item)
+ {
+ if ( ! isset($this->config[$item]))
+ {
+ return NULL;
+ }
+ elseif (trim($this->config[$item]) === '')
+ {
+ return '';
+ }
+
+ return rtrim($this->config[$item], '/').'/';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Site URL
+ *
+ * Returns base_url . index_page [. uri_string]
+ *
+ * @uses CI_Config::_uri_string()
+ *
+ * @param string|string[] $uri URI string or an array of segments
+ * @param string $protocol
+ * @return string
+ */
+ public function site_url($uri = '', $protocol = NULL)
+ {
+ $base_url = $this->slash_item('base_url');
+
+ if (isset($protocol))
+ {
+ // For protocol-relative links
+ if ($protocol === '')
+ {
+ $base_url = substr($base_url, strpos($base_url, '//'));
+ }
+ else
+ {
+ $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
+ }
+ }
+
+ if (empty($uri))
+ {
+ return $base_url.$this->item('index_page');
+ }
+
+ $uri = $this->_uri_string($uri);
+
+ if ($this->item('enable_query_strings') === FALSE)
+ {
+ $suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
+
+ if ($suffix !== '')
+ {
+ if (($offset = strpos($uri, '?')) !== FALSE)
+ {
+ $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
+ }
+ else
+ {
+ $uri .= $suffix;
+ }
+ }
+
+ return $base_url.$this->slash_item('index_page').$uri;
+ }
+ elseif (strpos($uri, '?') === FALSE)
+ {
+ $uri = '?'.$uri;
+ }
+
+ return $base_url.$this->item('index_page').$uri;
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Base URL
+ *
+ * Returns base_url [. uri_string]
+ *
+ * @uses CI_Config::_uri_string()
+ *
+ * @param string|string[] $uri URI string or an array of segments
+ * @param string $protocol
+ * @return string
+ */
+ public function base_url($uri = '', $protocol = NULL)
+ {
+ $base_url = $this->slash_item('base_url');
+
+ if (isset($protocol))
+ {
+ // For protocol-relative links
+ if ($protocol === '')
+ {
+ $base_url = substr($base_url, strpos($base_url, '//'));
+ }
+ else
+ {
+ $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
+ }
+ }
+
+ return $base_url.$this->_uri_string($uri);
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Build URI string
+ *
+ * @used-by CI_Config::site_url()
+ * @used-by CI_Config::base_url()
+ *
+ * @param string|string[] $uri URI string or an array of segments
+ * @return string
+ */
+ protected function _uri_string($uri)
+ {
+ if ($this->item('enable_query_strings') === FALSE)
+ {
+ is_array($uri) && $uri = implode('/', $uri);
+ return ltrim($uri, '/');
+ }
+ elseif (is_array($uri))
+ {
+ return http_build_query($uri);
+ }
+
+ return $uri;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * System URL
+ *
+ * @deprecated 3.0.0 Encourages insecure practices
+ * @return string
+ */
+ public function system_url()
+ {
+ $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
+ return $this->slash_item('base_url').end($x).'/';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set a config file item
+ *
+ * @param string $item Config item key
+ * @param string $value Config item value
+ * @return void
+ */
+ public function set_item($item, $value)
+ {
+ $this->config[$item] = $value;
+ }
+
+}
diff --git a/api/system/core/Controller.php b/api/system/core/Controller.php
new file mode 100644
index 0000000..83b3df2
--- /dev/null
+++ b/api/system/core/Controller.php
@@ -0,0 +1,96 @@
+ $class)
+ {
+ $this->$var =& load_class($class);
+ }
+
+ $this->load =& load_class('Loader', 'core');
+ $this->load->initialize();
+ log_message('info', 'Controller Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the CI singleton
+ *
+ * @static
+ * @return object
+ */
+ public static function &get_instance()
+ {
+ return self::$instance;
+ }
+
+}
diff --git a/api/system/core/Exceptions.php b/api/system/core/Exceptions.php
new file mode 100644
index 0000000..4e10f28
--- /dev/null
+++ b/api/system/core/Exceptions.php
@@ -0,0 +1,274 @@
+ 'Error',
+ E_WARNING => 'Warning',
+ E_PARSE => 'Parsing Error',
+ E_NOTICE => 'Notice',
+ E_CORE_ERROR => 'Core Error',
+ E_CORE_WARNING => 'Core Warning',
+ E_COMPILE_ERROR => 'Compile Error',
+ E_COMPILE_WARNING => 'Compile Warning',
+ E_USER_ERROR => 'User Error',
+ E_USER_WARNING => 'User Warning',
+ E_USER_NOTICE => 'User Notice',
+ E_STRICT => 'Runtime Notice'
+ );
+
+ /**
+ * Class constructor
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->ob_level = ob_get_level();
+ // Note: Do not log messages from this constructor.
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Exception Logger
+ *
+ * Logs PHP generated error messages
+ *
+ * @param int $severity Log level
+ * @param string $message Error message
+ * @param string $filepath File path
+ * @param int $line Line number
+ * @return void
+ */
+ public function log_exception($severity, $message, $filepath, $line)
+ {
+ $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
+ log_message('error', 'Severity: '.$severity.' --> '.$message.' '.$filepath.' '.$line);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 404 Error Handler
+ *
+ * @uses CI_Exceptions::show_error()
+ *
+ * @param string $page Page URI
+ * @param bool $log_error Whether to log the error
+ * @return void
+ */
+ public function show_404($page = '', $log_error = TRUE)
+ {
+ if (is_cli())
+ {
+ $heading = 'Not Found';
+ $message = 'The controller/method pair you requested was not found.';
+ }
+ else
+ {
+ $heading = '404 Page Not Found';
+ $message = 'The page you requested was not found.';
+ }
+
+ // By default we log this, but allow a dev to skip it
+ if ($log_error)
+ {
+ log_message('error', $heading.': '.$page);
+ }
+
+ echo $this->show_error($heading, $message, 'error_404', 404);
+ exit(4); // EXIT_UNKNOWN_FILE
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * General Error Page
+ *
+ * Takes an error message as input (either as a string or an array)
+ * and displays it using the specified template.
+ *
+ * @param string $heading Page heading
+ * @param string|string[] $message Error message
+ * @param string $template Template name
+ * @param int $status_code (default: 500)
+ *
+ * @return string Error page output
+ */
+ public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
+ {
+ $templates_path = config_item('error_views_path');
+ if (empty($templates_path))
+ {
+ $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ }
+
+ if (is_cli())
+ {
+ $message = "\t".(is_array($message) ? implode("\n\t", $message) : $message);
+ $template = 'cli'.DIRECTORY_SEPARATOR.$template;
+ }
+ else
+ {
+ set_status_header($status_code);
+ $message = ''.(is_array($message) ? implode('
', $message) : $message).'
';
+ $template = 'html'.DIRECTORY_SEPARATOR.$template;
+ }
+
+ if (ob_get_level() > $this->ob_level + 1)
+ {
+ ob_end_flush();
+ }
+ ob_start();
+ include($templates_path.$template.'.php');
+ $buffer = ob_get_contents();
+ ob_end_clean();
+ return $buffer;
+ }
+
+ // --------------------------------------------------------------------
+
+ public function show_exception($exception)
+ {
+ $templates_path = config_item('error_views_path');
+ if (empty($templates_path))
+ {
+ $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ }
+
+ $message = $exception->getMessage();
+ if (empty($message))
+ {
+ $message = '(null)';
+ }
+
+ if (is_cli())
+ {
+ $templates_path .= 'cli'.DIRECTORY_SEPARATOR;
+ }
+ else
+ {
+ $templates_path .= 'html'.DIRECTORY_SEPARATOR;
+ }
+
+ if (ob_get_level() > $this->ob_level + 1)
+ {
+ ob_end_flush();
+ }
+
+ ob_start();
+ include($templates_path.'error_exception.php');
+ $buffer = ob_get_contents();
+ ob_end_clean();
+ echo $buffer;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Native PHP error handler
+ *
+ * @param int $severity Error level
+ * @param string $message Error message
+ * @param string $filepath File path
+ * @param int $line Line number
+ * @return string Error page output
+ */
+ public function show_php_error($severity, $message, $filepath, $line)
+ {
+ $templates_path = config_item('error_views_path');
+ if (empty($templates_path))
+ {
+ $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ }
+
+ $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
+
+ // For safety reasons we don't show the full file path in non-CLI requests
+ if ( ! is_cli())
+ {
+ $filepath = str_replace('\\', '/', $filepath);
+ if (FALSE !== strpos($filepath, '/'))
+ {
+ $x = explode('/', $filepath);
+ $filepath = $x[count($x)-2].'/'.end($x);
+ }
+
+ $template = 'html'.DIRECTORY_SEPARATOR.'error_php';
+ }
+ else
+ {
+ $template = 'cli'.DIRECTORY_SEPARATOR.'error_php';
+ }
+
+ if (ob_get_level() > $this->ob_level + 1)
+ {
+ ob_end_flush();
+ }
+ ob_start();
+ include($templates_path.$template.'.php');
+ $buffer = ob_get_contents();
+ ob_end_clean();
+ echo $buffer;
+ }
+
+}
diff --git a/api/system/core/Hooks.php b/api/system/core/Hooks.php
new file mode 100644
index 0000000..856795c
--- /dev/null
+++ b/api/system/core/Hooks.php
@@ -0,0 +1,266 @@
+item('enable_hooks') === FALSE)
+ {
+ return;
+ }
+
+ // Grab the "hooks" definition file.
+ if (file_exists(APPPATH.'config/hooks.php'))
+ {
+ include(APPPATH.'config/hooks.php');
+ }
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
+ }
+
+ // If there are no hooks, we're done.
+ if ( ! isset($hook) OR ! is_array($hook))
+ {
+ return;
+ }
+
+ $this->hooks =& $hook;
+ $this->enabled = TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Call Hook
+ *
+ * Calls a particular hook. Called by CodeIgniter.php.
+ *
+ * @uses CI_Hooks::_run_hook()
+ *
+ * @param string $which Hook name
+ * @return bool TRUE on success or FALSE on failure
+ */
+ public function call_hook($which = '')
+ {
+ if ( ! $this->enabled OR ! isset($this->hooks[$which]))
+ {
+ return FALSE;
+ }
+
+ if (is_array($this->hooks[$which]) && ! isset($this->hooks[$which]['function']))
+ {
+ foreach ($this->hooks[$which] as $val)
+ {
+ $this->_run_hook($val);
+ }
+ }
+ else
+ {
+ $this->_run_hook($this->hooks[$which]);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run Hook
+ *
+ * Runs a particular hook
+ *
+ * @param array $data Hook details
+ * @return bool TRUE on success or FALSE on failure
+ */
+ protected function _run_hook($data)
+ {
+ // Closures/lambda functions and array($object, 'method') callables
+ if (is_callable($data))
+ {
+ is_array($data)
+ ? $data[0]->{$data[1]}()
+ : $data();
+
+ return TRUE;
+ }
+ elseif ( ! is_array($data))
+ {
+ return FALSE;
+ }
+
+ // -----------------------------------
+ // Safety - Prevents run-away loops
+ // -----------------------------------
+
+ // If the script being called happens to have the same
+ // hook call within it a loop can happen
+ if ($this->_in_progress === TRUE)
+ {
+ return;
+ }
+
+ // -----------------------------------
+ // Set file path
+ // -----------------------------------
+
+ if ( ! isset($data['filepath'], $data['filename']))
+ {
+ return FALSE;
+ }
+
+ $filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
+
+ if ( ! file_exists($filepath))
+ {
+ return FALSE;
+ }
+
+ // Determine and class and/or function names
+ $class = empty($data['class']) ? FALSE : $data['class'];
+ $function = empty($data['function']) ? FALSE : $data['function'];
+ $params = isset($data['params']) ? $data['params'] : '';
+
+ if (empty($function))
+ {
+ return FALSE;
+ }
+
+ // Set the _in_progress flag
+ $this->_in_progress = TRUE;
+
+ // Call the requested class and/or function
+ if ($class !== FALSE)
+ {
+ // The object is stored?
+ if (isset($this->_objects[$class]))
+ {
+ if (method_exists($this->_objects[$class], $function))
+ {
+ $this->_objects[$class]->$function($params);
+ }
+ else
+ {
+ return $this->_in_progress = FALSE;
+ }
+ }
+ else
+ {
+ class_exists($class, FALSE) OR require_once($filepath);
+
+ if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
+ {
+ return $this->_in_progress = FALSE;
+ }
+
+ // Store the object and execute the method
+ $this->_objects[$class] = new $class();
+ $this->_objects[$class]->$function($params);
+ }
+ }
+ else
+ {
+ function_exists($function) OR require_once($filepath);
+
+ if ( ! function_exists($function))
+ {
+ return $this->_in_progress = FALSE;
+ }
+
+ $function($params);
+ }
+
+ $this->_in_progress = FALSE;
+ return TRUE;
+ }
+
+}
diff --git a/api/system/core/Input.php b/api/system/core/Input.php
new file mode 100644
index 0000000..b81d51e
--- /dev/null
+++ b/api/system/core/Input.php
@@ -0,0 +1,897 @@
+_allow_get_array = (config_item('allow_get_array') === TRUE);
+ $this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
+ $this->_enable_csrf = (config_item('csrf_protection') === TRUE);
+ $this->_standardize_newlines = (bool) config_item('standardize_newlines');
+
+ $this->security =& load_class('Security', 'core');
+
+ // Do we need the UTF-8 class?
+ if (UTF8_ENABLED === TRUE)
+ {
+ $this->uni =& load_class('Utf8', 'core');
+ }
+
+ // Sanitize global arrays
+ $this->_sanitize_globals();
+
+ // CSRF Protection check
+ if ($this->_enable_csrf === TRUE && ! is_cli())
+ {
+ $this->security->csrf_verify();
+ }
+
+ log_message('info', 'Input Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch from array
+ *
+ * Internal method used to retrieve values from global arrays.
+ *
+ * @param array &$array $_GET, $_POST, $_COOKIE, $_SERVER, etc.
+ * @param mixed $index Index for item to be fetched from $array
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL)
+ {
+ is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
+
+ // If $index is NULL, it means that the whole $array is requested
+ isset($index) OR $index = array_keys($array);
+
+ // allow fetching multiple keys at once
+ if (is_array($index))
+ {
+ $output = array();
+ foreach ($index as $key)
+ {
+ $output[$key] = $this->_fetch_from_array($array, $key, $xss_clean);
+ }
+
+ return $output;
+ }
+
+ if (isset($array[$index]))
+ {
+ $value = $array[$index];
+ }
+ elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
+ {
+ $value = $array;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $key = trim($matches[0][$i], '[]');
+ if ($key === '') // Empty notation will return the value as array
+ {
+ break;
+ }
+
+ if (isset($value[$key]))
+ {
+ $value = $value[$key];
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ return NULL;
+ }
+
+ return ($xss_clean === TRUE)
+ ? $this->security->xss_clean($value)
+ : $value;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the GET array
+ *
+ * @param mixed $index Index for item to be fetched from $_GET
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function get($index = NULL, $xss_clean = NULL)
+ {
+ return $this->_fetch_from_array($_GET, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the POST array
+ *
+ * @param mixed $index Index for item to be fetched from $_POST
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function post($index = NULL, $xss_clean = NULL)
+ {
+ return $this->_fetch_from_array($_POST, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from POST data with fallback to GET
+ *
+ * @param string $index Index for item to be fetched from $_POST or $_GET
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function post_get($index, $xss_clean = NULL)
+ {
+ return isset($_POST[$index])
+ ? $this->post($index, $xss_clean)
+ : $this->get($index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from GET data with fallback to POST
+ *
+ * @param string $index Index for item to be fetched from $_GET or $_POST
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function get_post($index, $xss_clean = NULL)
+ {
+ return isset($_GET[$index])
+ ? $this->get($index, $xss_clean)
+ : $this->post($index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the COOKIE array
+ *
+ * @param mixed $index Index for item to be fetched from $_COOKIE
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function cookie($index = NULL, $xss_clean = NULL)
+ {
+ return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the SERVER array
+ *
+ * @param mixed $index Index for item to be fetched from $_SERVER
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function server($index, $xss_clean = NULL)
+ {
+ return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the php://input stream
+ *
+ * Useful when you need to access PUT, DELETE or PATCH request data.
+ *
+ * @param string $index Index for item to be fetched
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return mixed
+ */
+ public function input_stream($index = NULL, $xss_clean = NULL)
+ {
+ // Prior to PHP 5.6, the input stream can only be read once,
+ // so we'll need to check if we have already done that first.
+ if ( ! is_array($this->_input_stream))
+ {
+ // $this->raw_input_stream will trigger __get().
+ parse_str($this->raw_input_stream, $this->_input_stream);
+ is_array($this->_input_stream) OR $this->_input_stream = array();
+ }
+
+ return $this->_fetch_from_array($this->_input_stream, $index, $xss_clean);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Set cookie
+ *
+ * Accepts an arbitrary number of parameters (up to 7) or an associative
+ * array in the first parameter containing all the values.
+ *
+ * @param string|mixed[] $name Cookie name or an array containing parameters
+ * @param string $value Cookie value
+ * @param int $expire Cookie expiration time in seconds
+ * @param string $domain Cookie domain (e.g.: '.yourdomain.com')
+ * @param string $path Cookie path (default: '/')
+ * @param string $prefix Cookie name prefix
+ * @param bool $secure Whether to only transfer cookies via SSL
+ * @param bool $httponly Whether to only makes the cookie accessible via HTTP (no javascript)
+ * @return void
+ */
+ public function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
+ {
+ if (is_array($name))
+ {
+ // always leave 'name' in last place, as the loop will break otherwise, due to $$item
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item)
+ {
+ if (isset($name[$item]))
+ {
+ $$item = $name[$item];
+ }
+ }
+ }
+
+ if ($prefix === '' && config_item('cookie_prefix') !== '')
+ {
+ $prefix = config_item('cookie_prefix');
+ }
+
+ if ($domain == '' && config_item('cookie_domain') != '')
+ {
+ $domain = config_item('cookie_domain');
+ }
+
+ if ($path === '/' && config_item('cookie_path') !== '/')
+ {
+ $path = config_item('cookie_path');
+ }
+
+ if ($secure === FALSE && config_item('cookie_secure') === TRUE)
+ {
+ $secure = config_item('cookie_secure');
+ }
+
+ if ($httponly === FALSE && config_item('cookie_httponly') !== FALSE)
+ {
+ $httponly = config_item('cookie_httponly');
+ }
+
+ if ( ! is_numeric($expire))
+ {
+ $expire = time() - 86500;
+ }
+ else
+ {
+ $expire = ($expire > 0) ? time() + $expire : 0;
+ }
+
+ setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the IP Address
+ *
+ * Determines and validates the visitor's IP address.
+ *
+ * @return string IP address
+ */
+ public function ip_address()
+ {
+ if ($this->ip_address !== FALSE)
+ {
+ return $this->ip_address;
+ }
+
+ $proxy_ips = config_item('proxy_ips');
+ if ( ! empty($proxy_ips) && ! is_array($proxy_ips))
+ {
+ $proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
+ }
+
+ $this->ip_address = $this->server('REMOTE_ADDR');
+
+ if ($proxy_ips)
+ {
+ foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
+ {
+ if (($spoof = $this->server($header)) !== NULL)
+ {
+ // Some proxies typically list the whole chain of IP
+ // addresses through which the client has reached us.
+ // e.g. client_ip, proxy_ip1, proxy_ip2, etc.
+ sscanf($spoof, '%[^,]', $spoof);
+
+ if ( ! $this->valid_ip($spoof))
+ {
+ $spoof = NULL;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ if ($spoof)
+ {
+ for ($i = 0, $c = count($proxy_ips); $i < $c; $i++)
+ {
+ // Check if we have an IP address or a subnet
+ if (strpos($proxy_ips[$i], '/') === FALSE)
+ {
+ // An IP address (and not a subnet) is specified.
+ // We can compare right away.
+ if ($proxy_ips[$i] === $this->ip_address)
+ {
+ $this->ip_address = $spoof;
+ break;
+ }
+
+ continue;
+ }
+
+ // We have a subnet ... now the heavy lifting begins
+ isset($separator) OR $separator = $this->valid_ip($this->ip_address, 'ipv6') ? ':' : '.';
+
+ // If the proxy entry doesn't match the IP protocol - skip it
+ if (strpos($proxy_ips[$i], $separator) === FALSE)
+ {
+ continue;
+ }
+
+ // Convert the REMOTE_ADDR IP address to binary, if needed
+ if ( ! isset($ip, $sprintf))
+ {
+ if ($separator === ':')
+ {
+ // Make sure we're have the "full" IPv6 format
+ $ip = explode(':',
+ str_replace('::',
+ str_repeat(':', 9 - substr_count($this->ip_address, ':')),
+ $this->ip_address
+ )
+ );
+
+ for ($j = 0; $j < 8; $j++)
+ {
+ $ip[$j] = intval($ip[$j], 16);
+ }
+
+ $sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b';
+ }
+ else
+ {
+ $ip = explode('.', $this->ip_address);
+ $sprintf = '%08b%08b%08b%08b';
+ }
+
+ $ip = vsprintf($sprintf, $ip);
+ }
+
+ // Split the netmask length off the network address
+ sscanf($proxy_ips[$i], '%[^/]/%d', $netaddr, $masklen);
+
+ // Again, an IPv6 address is most likely in a compressed form
+ if ($separator === ':')
+ {
+ $netaddr = explode(':', str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':')), $netaddr));
+ for ($j = 0; $j < 8; $j++)
+ {
+ $netaddr[$i] = intval($netaddr[$j], 16);
+ }
+ }
+ else
+ {
+ $netaddr = explode('.', $netaddr);
+ }
+
+ // Convert to binary and finally compare
+ if (strncmp($ip, vsprintf($sprintf, $netaddr), $masklen) === 0)
+ {
+ $this->ip_address = $spoof;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( ! $this->valid_ip($this->ip_address))
+ {
+ return $this->ip_address = '0.0.0.0';
+ }
+
+ return $this->ip_address;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate IP Address
+ *
+ * @param string $ip IP address
+ * @param string $which IP protocol: 'ipv4' or 'ipv6'
+ * @return bool
+ */
+ public function valid_ip($ip, $which = '')
+ {
+ switch (strtolower($which))
+ {
+ case 'ipv4':
+ $which = FILTER_FLAG_IPV4;
+ break;
+ case 'ipv6':
+ $which = FILTER_FLAG_IPV6;
+ break;
+ default:
+ $which = NULL;
+ break;
+ }
+
+ return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch User Agent string
+ *
+ * @return string|null User Agent string or NULL if it doesn't exist
+ */
+ public function user_agent($xss_clean = NULL)
+ {
+ return $this->_fetch_from_array($_SERVER, 'HTTP_USER_AGENT', $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Sanitize Globals
+ *
+ * Internal method serving for the following purposes:
+ *
+ * - Unsets $_GET data, if query strings are not enabled
+ * - Cleans POST, COOKIE and SERVER data
+ * - Standardizes newline characters to PHP_EOL
+ *
+ * @return void
+ */
+ protected function _sanitize_globals()
+ {
+ // Is $_GET data allowed? If not we'll set the $_GET to an empty array
+ if ($this->_allow_get_array === FALSE)
+ {
+ $_GET = array();
+ }
+ elseif (is_array($_GET))
+ {
+ foreach ($_GET as $key => $val)
+ {
+ $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+ }
+ }
+
+ // Clean $_POST Data
+ if (is_array($_POST))
+ {
+ foreach ($_POST as $key => $val)
+ {
+ $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+ }
+ }
+
+ // Clean $_COOKIE Data
+ if (is_array($_COOKIE))
+ {
+ // Also get rid of specially treated cookies that might be set by a server
+ // or silly application, that are of no use to a CI application anyway
+ // but that when present will trip our 'Disallowed Key Characters' alarm
+ // http://www.ietf.org/rfc/rfc2109.txt
+ // note that the key names below are single quoted strings, and are not PHP variables
+ unset(
+ $_COOKIE['$Version'],
+ $_COOKIE['$Path'],
+ $_COOKIE['$Domain']
+ );
+
+ foreach ($_COOKIE as $key => $val)
+ {
+ if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE)
+ {
+ $_COOKIE[$cookie_key] = $this->_clean_input_data($val);
+ }
+ else
+ {
+ unset($_COOKIE[$key]);
+ }
+ }
+ }
+
+ // Sanitize PHP_SELF
+ $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
+
+ log_message('debug', 'Global POST, GET and COOKIE data sanitized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Input Data
+ *
+ * Internal method that aids in escaping data and
+ * standardizing newline characters to PHP_EOL.
+ *
+ * @param string|string[] $str Input string(s)
+ * @return string
+ */
+ protected function _clean_input_data($str)
+ {
+ if (is_array($str))
+ {
+ $new_array = array();
+ foreach (array_keys($str) as $key)
+ {
+ $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
+ }
+ return $new_array;
+ }
+
+ /* We strip slashes if magic quotes is on to keep things consistent
+
+ NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
+ it will probably not exist in future versions at all.
+ */
+ if ( ! is_php('5.4') && get_magic_quotes_gpc())
+ {
+ $str = stripslashes($str);
+ }
+
+ // Clean UTF-8 if supported
+ if (UTF8_ENABLED === TRUE)
+ {
+ $str = $this->uni->clean_string($str);
+ }
+
+ // Remove control characters
+ $str = remove_invisible_characters($str, FALSE);
+
+ // Standardize newlines if needed
+ if ($this->_standardize_newlines === TRUE)
+ {
+ return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Keys
+ *
+ * Internal method that helps to prevent malicious users
+ * from trying to exploit keys we make sure that keys are
+ * only named with alpha-numeric text and a few other items.
+ *
+ * @param string $str Input string
+ * @param bool $fatal Whether to terminate script exection
+ * or to return FALSE if an invalid
+ * key is encountered
+ * @return string|bool
+ */
+ protected function _clean_input_keys($str, $fatal = TRUE)
+ {
+ if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str))
+ {
+ if ($fatal === TRUE)
+ {
+ return FALSE;
+ }
+ else
+ {
+ set_status_header(503);
+ echo 'Disallowed Key Characters.';
+ exit(7); // EXIT_USER_INPUT
+ }
+ }
+
+ // Clean UTF-8 if supported
+ if (UTF8_ENABLED === TRUE)
+ {
+ return $this->uni->clean_string($str);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Request Headers
+ *
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return array
+ */
+ public function request_headers($xss_clean = FALSE)
+ {
+ // If header is already defined, return it immediately
+ if ( ! empty($this->headers))
+ {
+ return $this->_fetch_from_array($this->headers, NULL, $xss_clean);
+ }
+
+ // In Apache, you can simply call apache_request_headers()
+ if (function_exists('apache_request_headers'))
+ {
+ $this->headers = apache_request_headers();
+ }
+ else
+ {
+ isset($_SERVER['CONTENT_TYPE']) && $this->headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
+
+ foreach ($_SERVER as $key => $val)
+ {
+ if (sscanf($key, 'HTTP_%s', $header) === 1)
+ {
+ // take SOME_HEADER and turn it into Some-Header
+ $header = str_replace('_', ' ', strtolower($header));
+ $header = str_replace(' ', '-', ucwords($header));
+
+ $this->headers[$header] = $_SERVER[$key];
+ }
+ }
+ }
+
+ return $this->_fetch_from_array($this->headers, NULL, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Request Header
+ *
+ * Returns the value of a single member of the headers class member
+ *
+ * @param string $index Header name
+ * @param bool $xss_clean Whether to apply XSS filtering
+ * @return string|null The requested header on success or NULL on failure
+ */
+ public function get_request_header($index, $xss_clean = FALSE)
+ {
+ static $headers;
+
+ if ( ! isset($headers))
+ {
+ empty($this->headers) && $this->request_headers();
+ foreach ($this->headers as $key => $value)
+ {
+ $headers[strtolower($key)] = $value;
+ }
+ }
+
+ $index = strtolower($index);
+
+ if ( ! isset($headers[$index]))
+ {
+ return NULL;
+ }
+
+ return ($xss_clean === TRUE)
+ ? $this->security->xss_clean($headers[$index])
+ : $headers[$index];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is AJAX request?
+ *
+ * Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
+ *
+ * @return bool
+ */
+ public function is_ajax_request()
+ {
+ return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is CLI request?
+ *
+ * Test to see if a request was made from the command line.
+ *
+ * @deprecated 3.0.0 Use is_cli() instead
+ * @return bool
+ */
+ public function is_cli_request()
+ {
+ return is_cli();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Request Method
+ *
+ * Return the request method
+ *
+ * @param bool $upper Whether to return in upper or lower case
+ * (default: FALSE)
+ * @return string
+ */
+ public function method($upper = FALSE)
+ {
+ return ($upper)
+ ? strtoupper($this->server('REQUEST_METHOD'))
+ : strtolower($this->server('REQUEST_METHOD'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Magic __get()
+ *
+ * Allows read access to protected properties
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ if ($name === 'raw_input_stream')
+ {
+ isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input');
+ return $this->_raw_input_stream;
+ }
+ elseif ($name === 'ip_address')
+ {
+ return $this->ip_address;
+ }
+ }
+
+}
diff --git a/api/system/core/Lang.php b/api/system/core/Lang.php
new file mode 100644
index 0000000..1fcff07
--- /dev/null
+++ b/api/system/core/Lang.php
@@ -0,0 +1,203 @@
+load($value, $idiom, $return, $add_suffix, $alt_path);
+ }
+
+ return;
+ }
+
+ $langfile = str_replace('.php', '', $langfile);
+
+ if ($add_suffix === TRUE)
+ {
+ $langfile = preg_replace('/_lang$/', '', $langfile).'_lang';
+ }
+
+ $langfile .= '.php';
+
+ if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom))
+ {
+ $config =& get_config();
+ $idiom = empty($config['language']) ? 'english' : $config['language'];
+ }
+
+ if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom)
+ {
+ return;
+ }
+
+ // Load the base file, so any others found can override it
+ $basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
+ if (($found = file_exists($basepath)) === TRUE)
+ {
+ include($basepath);
+ }
+
+ // Do we have an alternative path to look in?
+ if ($alt_path !== '')
+ {
+ $alt_path .= 'language/'.$idiom.'/'.$langfile;
+ if (file_exists($alt_path))
+ {
+ include($alt_path);
+ $found = TRUE;
+ }
+ }
+ else
+ {
+ foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
+ {
+ $package_path .= 'language/'.$idiom.'/'.$langfile;
+ if ($basepath !== $package_path && file_exists($package_path))
+ {
+ include($package_path);
+ $found = TRUE;
+ break;
+ }
+ }
+ }
+
+ if ($found !== TRUE)
+ {
+ show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
+ }
+
+ if ( ! isset($lang) OR ! is_array($lang))
+ {
+ log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
+
+ if ($return === TRUE)
+ {
+ return array();
+ }
+ return;
+ }
+
+ if ($return === TRUE)
+ {
+ return $lang;
+ }
+
+ $this->is_loaded[$langfile] = $idiom;
+ $this->language = array_merge($this->language, $lang);
+
+ log_message('info', 'Language file loaded: language/'.$idiom.'/'.$langfile);
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Language line
+ *
+ * Fetches a single line of text from the language array
+ *
+ * @param string $line Language line key
+ * @param bool $log_errors Whether to log an error message if the line is not found
+ * @return string Translation
+ */
+ public function line($line, $log_errors = TRUE)
+ {
+ $value = isset($this->language[$line]) ? $this->language[$line] : FALSE;
+
+ // Because killer robots like unicorns!
+ if ($value === FALSE && $log_errors === TRUE)
+ {
+ log_message('error', 'Could not find the language line "'.$line.'"');
+ }
+
+ return $value;
+ }
+
+}
diff --git a/api/system/core/Loader.php b/api/system/core/Loader.php
new file mode 100644
index 0000000..d2c3508
--- /dev/null
+++ b/api/system/core/Loader.php
@@ -0,0 +1,1437 @@
+ TRUE);
+
+ /**
+ * List of paths to load libraries from
+ *
+ * @var array
+ */
+ protected $_ci_library_paths = array(APPPATH, BASEPATH);
+
+ /**
+ * List of paths to load models from
+ *
+ * @var array
+ */
+ protected $_ci_model_paths = array(APPPATH);
+
+ /**
+ * List of paths to load helpers from
+ *
+ * @var array
+ */
+ protected $_ci_helper_paths = array(APPPATH, BASEPATH);
+
+ /**
+ * List of cached variables
+ *
+ * @var array
+ */
+ protected $_ci_cached_vars = array();
+
+ /**
+ * List of loaded classes
+ *
+ * @var array
+ */
+ protected $_ci_classes = array();
+
+ /**
+ * List of loaded models
+ *
+ * @var array
+ */
+ protected $_ci_models = array();
+
+ /**
+ * List of loaded helpers
+ *
+ * @var array
+ */
+ protected $_ci_helpers = array();
+
+ /**
+ * List of class name mappings
+ *
+ * @var array
+ */
+ protected $_ci_varmap = array(
+ 'unit_test' => 'unit',
+ 'user_agent' => 'agent'
+ );
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Class constructor
+ *
+ * Sets component load paths, gets the initial output buffering level.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->_ci_ob_level = ob_get_level();
+ $this->_ci_classes =& is_loaded();
+
+ log_message('info', 'Loader Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initializer
+ *
+ * @todo Figure out a way to move this to the constructor
+ * without breaking *package_path*() methods.
+ * @uses CI_Loader::_ci_autoloader()
+ * @used-by CI_Controller::__construct()
+ * @return void
+ */
+ public function initialize()
+ {
+ $this->_ci_autoloader();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Loaded
+ *
+ * A utility method to test if a class is in the self::$_ci_classes array.
+ *
+ * @used-by Mainly used by Form Helper function _get_validation_object().
+ *
+ * @param string $class Class name to check for
+ * @return string|bool Class object name if loaded or FALSE
+ */
+ public function is_loaded($class)
+ {
+ return array_search(ucfirst($class), $this->_ci_classes, TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Library Loader
+ *
+ * Loads and instantiates libraries.
+ * Designed to be called from application controllers.
+ *
+ * @param string $library Library name
+ * @param array $params Optional parameters to pass to the library class constructor
+ * @param string $object_name An optional object name to assign to
+ * @return object
+ */
+ public function library($library, $params = NULL, $object_name = NULL)
+ {
+ if (empty($library))
+ {
+ return $this;
+ }
+ elseif (is_array($library))
+ {
+ foreach ($library as $key => $value)
+ {
+ if (is_int($key))
+ {
+ $this->library($value, $params);
+ }
+ else
+ {
+ $this->library($key, $params, $value);
+ }
+ }
+
+ return $this;
+ }
+
+ if ($params !== NULL && ! is_array($params))
+ {
+ $params = NULL;
+ }
+
+ $this->_ci_load_library($library, $params, $object_name);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Model Loader
+ *
+ * Loads and instantiates models.
+ *
+ * @param string $model Model name
+ * @param string $name An optional object name to assign to
+ * @param bool $db_conn An optional database connection configuration to initialize
+ * @return object
+ */
+ public function model($model, $name = '', $db_conn = FALSE)
+ {
+ if (empty($model))
+ {
+ return $this;
+ }
+ elseif (is_array($model))
+ {
+ foreach ($model as $key => $value)
+ {
+ is_int($key) ? $this->model($value, '', $db_conn) : $this->model($key, $value, $db_conn);
+ }
+
+ return $this;
+ }
+
+ $path = '';
+
+ // Is the model in a sub-folder? If so, parse out the filename and path.
+ if (($last_slash = strrpos($model, '/')) !== FALSE)
+ {
+ // The path is in front of the last slash
+ $path = substr($model, 0, ++$last_slash);
+
+ // And the model name behind it
+ $model = substr($model, $last_slash);
+ }
+
+ if (empty($name))
+ {
+ $name = $model;
+ }
+
+ if (in_array($name, $this->_ci_models, TRUE))
+ {
+ return $this;
+ }
+
+ $CI =& get_instance();
+ if (isset($CI->$name))
+ {
+ throw new RuntimeException('The model name you are loading is the name of a resource that is already being used: '.$name);
+ }
+
+ if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE))
+ {
+ if ($db_conn === TRUE)
+ {
+ $db_conn = '';
+ }
+
+ $this->database($db_conn, FALSE, TRUE);
+ }
+
+ // Note: All of the code under this condition used to be just:
+ //
+ // load_class('Model', 'core');
+ //
+ // However, load_class() instantiates classes
+ // to cache them for later use and that prevents
+ // MY_Model from being an abstract class and is
+ // sub-optimal otherwise anyway.
+ if ( ! class_exists('CI_Model', FALSE))
+ {
+ $app_path = APPPATH.'core'.DIRECTORY_SEPARATOR;
+ if (file_exists($app_path.'Model.php'))
+ {
+ require_once($app_path.'Model.php');
+ if ( ! class_exists('CI_Model', FALSE))
+ {
+ throw new RuntimeException($app_path."Model.php exists, but doesn't declare class CI_Model");
+ }
+ }
+ elseif ( ! class_exists('CI_Model', FALSE))
+ {
+ require_once(BASEPATH.'core'.DIRECTORY_SEPARATOR.'Model.php');
+ }
+
+ $class = config_item('subclass_prefix').'Model';
+ if (file_exists($app_path.$class.'.php'))
+ {
+ require_once($app_path.$class.'.php');
+ if ( ! class_exists($class, FALSE))
+ {
+ throw new RuntimeException($app_path.$class.".php exists, but doesn't declare class ".$class);
+ }
+ }
+ }
+
+ $model = ucfirst($model);
+ if ( ! class_exists($model, FALSE))
+ {
+ foreach ($this->_ci_model_paths as $mod_path)
+ {
+ if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
+ {
+ continue;
+ }
+
+ require_once($mod_path.'models/'.$path.$model.'.php');
+ if ( ! class_exists($model, FALSE))
+ {
+ throw new RuntimeException($mod_path."models/".$path.$model.".php exists, but doesn't declare class ".$model);
+ }
+
+ break;
+ }
+
+ if ( ! class_exists($model, FALSE))
+ {
+ throw new RuntimeException('Unable to locate the model you have specified: '.$model);
+ }
+ }
+ elseif ( ! is_subclass_of($model, 'CI_Model'))
+ {
+ throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
+ }
+
+ $this->_ci_models[] = $name;
+ $CI->$name = new $model();
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Loader
+ *
+ * @param mixed $params Database configuration options
+ * @param bool $return Whether to return the database object
+ * @param bool $query_builder Whether to enable Query Builder
+ * (overrides the configuration setting)
+ *
+ * @return object|bool Database object if $return is set to TRUE,
+ * FALSE on failure, CI_Loader instance in any other case
+ */
+ public function database($params = '', $return = FALSE, $query_builder = NULL)
+ {
+ // Grab the super object
+ $CI =& get_instance();
+
+ // Do we even need to load the database class?
+ if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
+ {
+ return FALSE;
+ }
+
+ require_once(BASEPATH.'database/DB.php');
+
+ if ($return === TRUE)
+ {
+ return DB($params, $query_builder);
+ }
+
+ // Initialize the db variable. Needed to prevent
+ // reference errors with some configurations
+ $CI->db = '';
+
+ // Load the DB class
+ $CI->db =& DB($params, $query_builder);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load the Database Utilities Class
+ *
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Utilities class object or not
+ * @return object
+ */
+ public function dbutil($db = NULL, $return = FALSE)
+ {
+ $CI =& get_instance();
+
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
+ {
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
+ }
+
+ require_once(BASEPATH.'database/DB_utility.php');
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_utility.php');
+ $class = 'CI_DB_'.$db->dbdriver.'_utility';
+
+ if ($return === TRUE)
+ {
+ return new $class($db);
+ }
+
+ $CI->dbutil = new $class($db);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load the Database Forge Class
+ *
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Forge class object or not
+ * @return object
+ */
+ public function dbforge($db = NULL, $return = FALSE)
+ {
+ $CI =& get_instance();
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
+ {
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
+ }
+
+ require_once(BASEPATH.'database/DB_forge.php');
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_forge.php');
+
+ if ( ! empty($db->subdriver))
+ {
+ $driver_path = BASEPATH.'database/drivers/'.$db->dbdriver.'/subdrivers/'.$db->dbdriver.'_'.$db->subdriver.'_forge.php';
+ if (file_exists($driver_path))
+ {
+ require_once($driver_path);
+ $class = 'CI_DB_'.$db->dbdriver.'_'.$db->subdriver.'_forge';
+ }
+ }
+ else
+ {
+ $class = 'CI_DB_'.$db->dbdriver.'_forge';
+ }
+
+ if ($return === TRUE)
+ {
+ return new $class($db);
+ }
+
+ $CI->dbforge = new $class($db);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * View Loader
+ *
+ * Loads "view" files.
+ *
+ * @param string $view View name
+ * @param array $vars An associative array of data
+ * to be extracted for use in the view
+ * @param bool $return Whether to return the view output
+ * or leave it to the Output class
+ * @return object|string
+ */
+ public function view($view, $vars = array(), $return = FALSE)
+ {
+ return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generic File Loader
+ *
+ * @param string $path File path
+ * @param bool $return Whether to return the file output
+ * @return object|string
+ */
+ public function file($path, $return = FALSE)
+ {
+ return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Variables
+ *
+ * Once variables are set they become available within
+ * the controller class and its "view" files.
+ *
+ * @param array|object|string $vars
+ * An associative array or object containing values
+ * to be set, or a value's name if string
+ * @param string $val Value to set, only used if $vars is a string
+ * @return object
+ */
+ public function vars($vars, $val = '')
+ {
+ if (is_string($vars))
+ {
+ $vars = array($vars => $val);
+ }
+
+ $vars = $this->_ci_object_to_array($vars);
+
+ if (is_array($vars) && count($vars) > 0)
+ {
+ foreach ($vars as $key => $val)
+ {
+ $this->_ci_cached_vars[$key] = $val;
+ }
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clear Cached Variables
+ *
+ * Clears the cached variables.
+ *
+ * @return CI_Loader
+ */
+ public function clear_vars()
+ {
+ $this->_ci_cached_vars = array();
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Variable
+ *
+ * Check if a variable is set and retrieve it.
+ *
+ * @param string $key Variable name
+ * @return mixed The variable or NULL if not found
+ */
+ public function get_var($key)
+ {
+ return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Variables
+ *
+ * Retrieves all loaded variables.
+ *
+ * @return array
+ */
+ public function get_vars()
+ {
+ return $this->_ci_cached_vars;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Helper Loader
+ *
+ * @param string|string[] $helpers Helper name(s)
+ * @return object
+ */
+ public function helper($helpers = array())
+ {
+ foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
+ {
+ if (isset($this->_ci_helpers[$helper]))
+ {
+ continue;
+ }
+
+ // Is this a helper extension request?
+ $ext_helper = config_item('subclass_prefix').$helper;
+ $ext_loaded = FALSE;
+ foreach ($this->_ci_helper_paths as $path)
+ {
+ if (file_exists($path.'helpers/'.$ext_helper.'.php'))
+ {
+ include_once($path.'helpers/'.$ext_helper.'.php');
+ $ext_loaded = TRUE;
+ }
+ }
+
+ // If we have loaded extensions - check if the base one is here
+ if ($ext_loaded === TRUE)
+ {
+ $base_helper = BASEPATH.'helpers/'.$helper.'.php';
+ if ( ! file_exists($base_helper))
+ {
+ show_error('Unable to load the requested file: helpers/'.$helper.'.php');
+ }
+
+ include_once($base_helper);
+ $this->_ci_helpers[$helper] = TRUE;
+ log_message('info', 'Helper loaded: '.$helper);
+ continue;
+ }
+
+ // No extensions found ... try loading regular helpers and/or overrides
+ foreach ($this->_ci_helper_paths as $path)
+ {
+ if (file_exists($path.'helpers/'.$helper.'.php'))
+ {
+ include_once($path.'helpers/'.$helper.'.php');
+
+ $this->_ci_helpers[$helper] = TRUE;
+ log_message('info', 'Helper loaded: '.$helper);
+ break;
+ }
+ }
+
+ // unable to load the helper
+ if ( ! isset($this->_ci_helpers[$helper]))
+ {
+ show_error('Unable to load the requested file: helpers/'.$helper.'.php');
+ }
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load Helpers
+ *
+ * An alias for the helper() method in case the developer has
+ * written the plural form of it.
+ *
+ * @uses CI_Loader::helper()
+ * @param string|string[] $helpers Helper name(s)
+ * @return object
+ */
+ public function helpers($helpers = array())
+ {
+ return $this->helper($helpers);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Language Loader
+ *
+ * Loads language files.
+ *
+ * @param string|string[] $files List of language file names to load
+ * @param string Language name
+ * @return object
+ */
+ public function language($files, $lang = '')
+ {
+ get_instance()->lang->load($files, $lang);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Config Loader
+ *
+ * Loads a config file (an alias for CI_Config::load()).
+ *
+ * @uses CI_Config::load()
+ * @param string $file Configuration file name
+ * @param bool $use_sections Whether configuration values should be loaded into their own section
+ * @param bool $fail_gracefully Whether to just return FALSE or display an error message
+ * @return bool TRUE if the file was loaded correctly or FALSE on failure
+ */
+ public function config($file, $use_sections = FALSE, $fail_gracefully = FALSE)
+ {
+ return get_instance()->config->load($file, $use_sections, $fail_gracefully);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Driver Loader
+ *
+ * Loads a driver library.
+ *
+ * @param string|string[] $library Driver name(s)
+ * @param array $params Optional parameters to pass to the driver
+ * @param string $object_name An optional object name to assign to
+ *
+ * @return object|bool Object or FALSE on failure if $library is a string
+ * and $object_name is set. CI_Loader instance otherwise.
+ */
+ public function driver($library, $params = NULL, $object_name = NULL)
+ {
+ if (is_array($library))
+ {
+ foreach ($library as $key => $value)
+ {
+ if (is_int($key))
+ {
+ $this->driver($value, $params);
+ }
+ else
+ {
+ $this->driver($key, $params, $value);
+ }
+ }
+
+ return $this;
+ }
+ elseif (empty($library))
+ {
+ return FALSE;
+ }
+
+ if ( ! class_exists('CI_Driver_Library', FALSE))
+ {
+ // We aren't instantiating an object here, just making the base class available
+ require BASEPATH.'libraries/Driver.php';
+ }
+
+ // We can save the loader some time since Drivers will *always* be in a subfolder,
+ // and typically identically named to the library
+ if ( ! strpos($library, '/'))
+ {
+ $library = ucfirst($library).'/'.$library;
+ }
+
+ return $this->library($library, $params, $object_name);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Package Path
+ *
+ * Prepends a parent path to the library, model, helper and config
+ * path arrays.
+ *
+ * @see CI_Loader::$_ci_library_paths
+ * @see CI_Loader::$_ci_model_paths
+ * @see CI_Loader::$_ci_helper_paths
+ * @see CI_Config::$_config_paths
+ *
+ * @param string $path Path to add
+ * @param bool $view_cascade (default: TRUE)
+ * @return object
+ */
+ public function add_package_path($path, $view_cascade = TRUE)
+ {
+ $path = rtrim($path, '/').'/';
+
+ array_unshift($this->_ci_library_paths, $path);
+ array_unshift($this->_ci_model_paths, $path);
+ array_unshift($this->_ci_helper_paths, $path);
+
+ $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths;
+
+ // Add config file path
+ $config =& $this->_ci_get_component('config');
+ $config->_config_paths[] = $path;
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Package Paths
+ *
+ * Return a list of all package paths.
+ *
+ * @param bool $include_base Whether to include BASEPATH (default: FALSE)
+ * @return array
+ */
+ public function get_package_paths($include_base = FALSE)
+ {
+ return ($include_base === TRUE) ? $this->_ci_library_paths : $this->_ci_model_paths;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Remove Package Path
+ *
+ * Remove a path from the library, model, helper and/or config
+ * path arrays if it exists. If no path is provided, the most recently
+ * added path will be removed removed.
+ *
+ * @param string $path Path to remove
+ * @return object
+ */
+ public function remove_package_path($path = '')
+ {
+ $config =& $this->_ci_get_component('config');
+
+ if ($path === '')
+ {
+ array_shift($this->_ci_library_paths);
+ array_shift($this->_ci_model_paths);
+ array_shift($this->_ci_helper_paths);
+ array_shift($this->_ci_view_paths);
+ array_pop($config->_config_paths);
+ }
+ else
+ {
+ $path = rtrim($path, '/').'/';
+ foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
+ {
+ if (($key = array_search($path, $this->{$var})) !== FALSE)
+ {
+ unset($this->{$var}[$key]);
+ }
+ }
+
+ if (isset($this->_ci_view_paths[$path.'views/']))
+ {
+ unset($this->_ci_view_paths[$path.'views/']);
+ }
+
+ if (($key = array_search($path, $config->_config_paths)) !== FALSE)
+ {
+ unset($config->_config_paths[$key]);
+ }
+ }
+
+ // make sure the application default paths are still in the array
+ $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH)));
+ $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH)));
+ $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH)));
+ $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE));
+ $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH)));
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Internal CI Data Loader
+ *
+ * Used to load views and files.
+ *
+ * Variables are prefixed with _ci_ to avoid symbol collision with
+ * variables made available to view files.
+ *
+ * @used-by CI_Loader::view()
+ * @used-by CI_Loader::file()
+ * @param array $_ci_data Data to load
+ * @return object
+ */
+ protected function _ci_load($_ci_data)
+ {
+ // Set the default data variables
+ foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
+ {
+ $$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE;
+ }
+
+ $file_exists = FALSE;
+
+ // Set the path to the requested file
+ if (is_string($_ci_path) && $_ci_path !== '')
+ {
+ $_ci_x = explode('/', $_ci_path);
+ $_ci_file = end($_ci_x);
+ }
+ else
+ {
+ $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
+ $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view;
+
+ foreach ($this->_ci_view_paths as $_ci_view_file => $cascade)
+ {
+ if (file_exists($_ci_view_file.$_ci_file))
+ {
+ $_ci_path = $_ci_view_file.$_ci_file;
+ $file_exists = TRUE;
+ break;
+ }
+
+ if ( ! $cascade)
+ {
+ break;
+ }
+ }
+ }
+
+ if ( ! $file_exists && ! file_exists($_ci_path))
+ {
+ show_error('Unable to load the requested file: '.$_ci_file);
+ }
+
+ // This allows anything loaded using $this->load (views, files, etc.)
+ // to become accessible from within the Controller and Model functions.
+ $_ci_CI =& get_instance();
+ foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
+ {
+ if ( ! isset($this->$_ci_key))
+ {
+ $this->$_ci_key =& $_ci_CI->$_ci_key;
+ }
+ }
+
+ /*
+ * Extract and cache variables
+ *
+ * You can either set variables using the dedicated $this->load->vars()
+ * function or via the second parameter of this function. We'll merge
+ * the two types and cache them so that views that are embedded within
+ * other views can have access to these variables.
+ */
+ if (is_array($_ci_vars))
+ {
+ foreach (array_keys($_ci_vars) as $key)
+ {
+ if (strncmp($key, '_ci_', 4) === 0)
+ {
+ unset($_ci_vars[$key]);
+ }
+ }
+
+ $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
+ }
+ extract($this->_ci_cached_vars);
+
+ /*
+ * Buffer the output
+ *
+ * We buffer the output for two reasons:
+ * 1. Speed. You get a significant speed boost.
+ * 2. So that the final rendered template can be post-processed by
+ * the output class. Why do we need post processing? For one thing,
+ * in order to show the elapsed page load time. Unless we can
+ * intercept the content right before it's sent to the browser and
+ * then stop the timer it won't be accurate.
+ */
+ ob_start();
+
+ // If the PHP installation does not support short tags we'll
+ // do a little string replacement, changing the short tags
+ // to standard PHP echo statements.
+ if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE)
+ {
+ echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('=', ' $this->_ci_ob_level + 1)
+ {
+ ob_end_flush();
+ }
+ else
+ {
+ $_ci_CI->output->append_output(ob_get_contents());
+ @ob_end_clean();
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Internal CI Library Loader
+ *
+ * @used-by CI_Loader::library()
+ * @uses CI_Loader::_ci_init_library()
+ *
+ * @param string $class Class name to load
+ * @param mixed $params Optional parameters to pass to the class constructor
+ * @param string $object_name Optional object name to assign to
+ * @return void
+ */
+ protected function _ci_load_library($class, $params = NULL, $object_name = NULL)
+ {
+ // Get the class name, and while we're at it trim any slashes.
+ // The directory path can be included as part of the class name,
+ // but we don't want a leading slash
+ $class = str_replace('.php', '', trim($class, '/'));
+
+ // Was the path included with the class name?
+ // We look for a slash to determine this
+ if (($last_slash = strrpos($class, '/')) !== FALSE)
+ {
+ // Extract the path
+ $subdir = substr($class, 0, ++$last_slash);
+
+ // Get the filename from the path
+ $class = substr($class, $last_slash);
+ }
+ else
+ {
+ $subdir = '';
+ }
+
+ $class = ucfirst($class);
+
+ // Is this a stock library? There are a few special conditions if so ...
+ if (file_exists(BASEPATH.'libraries/'.$subdir.$class.'.php'))
+ {
+ return $this->_ci_load_stock_library($class, $subdir, $params, $object_name);
+ }
+
+ // Let's search for the requested library file and load it.
+ foreach ($this->_ci_library_paths as $path)
+ {
+ // BASEPATH has already been checked for
+ if ($path === BASEPATH)
+ {
+ continue;
+ }
+
+ $filepath = $path.'libraries/'.$subdir.$class.'.php';
+
+ // Safety: Was the class already loaded by a previous call?
+ if (class_exists($class, FALSE))
+ {
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
+ {
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
+ {
+ return $this->_ci_init_library($class, '', $params, $object_name);
+ }
+ }
+
+ log_message('debug', $class.' class already loaded. Second attempt ignored.');
+ return;
+ }
+ // Does the file exist? No? Bummer...
+ elseif ( ! file_exists($filepath))
+ {
+ continue;
+ }
+
+ include_once($filepath);
+ return $this->_ci_init_library($class, '', $params, $object_name);
+ }
+
+ // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
+ if ($subdir === '')
+ {
+ return $this->_ci_load_library($class.'/'.$class, $params, $object_name);
+ }
+
+ // If we got this far we were unable to find the requested class.
+ log_message('error', 'Unable to load the requested class: '.$class);
+ show_error('Unable to load the requested class: '.$class);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Internal CI Stock Library Loader
+ *
+ * @used-by CI_Loader::_ci_load_library()
+ * @uses CI_Loader::_ci_init_library()
+ *
+ * @param string $library_name Library name to load
+ * @param string $file_path Path to the library filename, relative to libraries/
+ * @param mixed $params Optional parameters to pass to the class constructor
+ * @param string $object_name Optional object name to assign to
+ * @return void
+ */
+ protected function _ci_load_stock_library($library_name, $file_path, $params, $object_name)
+ {
+ $prefix = 'CI_';
+
+ if (class_exists($prefix.$library_name, FALSE))
+ {
+ if (class_exists(config_item('subclass_prefix').$library_name, FALSE))
+ {
+ $prefix = config_item('subclass_prefix');
+ }
+
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
+ {
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
+ {
+ return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
+ }
+ }
+
+ log_message('debug', $library_name.' class already loaded. Second attempt ignored.');
+ return;
+ }
+
+ $paths = $this->_ci_library_paths;
+ array_pop($paths); // BASEPATH
+ array_pop($paths); // APPPATH (needs to be the first path checked)
+ array_unshift($paths, APPPATH);
+
+ foreach ($paths as $path)
+ {
+ if (file_exists($path = $path.'libraries/'.$file_path.$library_name.'.php'))
+ {
+ // Override
+ include_once($path);
+ if (class_exists($prefix.$library_name, FALSE))
+ {
+ return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
+ }
+ else
+ {
+ log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name);
+ }
+ }
+ }
+
+ include_once(BASEPATH.'libraries/'.$file_path.$library_name.'.php');
+
+ // Check for extensions
+ $subclass = config_item('subclass_prefix').$library_name;
+ foreach ($paths as $path)
+ {
+ if (file_exists($path = $path.'libraries/'.$file_path.$subclass.'.php'))
+ {
+ include_once($path);
+ if (class_exists($subclass, FALSE))
+ {
+ $prefix = config_item('subclass_prefix');
+ break;
+ }
+ else
+ {
+ log_message('debug', $path.' exists, but does not declare '.$subclass);
+ }
+ }
+ }
+
+ return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Internal CI Library Instantiator
+ *
+ * @used-by CI_Loader::_ci_load_stock_library()
+ * @used-by CI_Loader::_ci_load_library()
+ *
+ * @param string $class Class name
+ * @param string $prefix Class name prefix
+ * @param array|null|bool $config Optional configuration to pass to the class constructor:
+ * FALSE to skip;
+ * NULL to search in config paths;
+ * array containing configuration data
+ * @param string $object_name Optional object name to assign to
+ * @return void
+ */
+ protected function _ci_init_library($class, $prefix, $config = FALSE, $object_name = NULL)
+ {
+ // Is there an associated config file for this class? Note: these should always be lowercase
+ if ($config === NULL)
+ {
+ // Fetch the config paths containing any package paths
+ $config_component = $this->_ci_get_component('config');
+
+ if (is_array($config_component->_config_paths))
+ {
+ $found = FALSE;
+ foreach ($config_component->_config_paths as $path)
+ {
+ // We test for both uppercase and lowercase, for servers that
+ // are case-sensitive with regard to file names. Load global first,
+ // override with environment next
+ if (file_exists($path.'config/'.strtolower($class).'.php'))
+ {
+ include($path.'config/'.strtolower($class).'.php');
+ $found = TRUE;
+ }
+ elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php'))
+ {
+ include($path.'config/'.ucfirst(strtolower($class)).'.php');
+ $found = TRUE;
+ }
+
+ if (file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
+ {
+ include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
+ $found = TRUE;
+ }
+ elseif (file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
+ {
+ include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
+ $found = TRUE;
+ }
+
+ // Break on the first found configuration, thus package
+ // files are not overridden by default paths
+ if ($found === TRUE)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ $class_name = $prefix.$class;
+
+ // Is the class name valid?
+ if ( ! class_exists($class_name, FALSE))
+ {
+ log_message('error', 'Non-existent class: '.$class_name);
+ show_error('Non-existent class: '.$class_name);
+ }
+
+ // Set the variable name we will assign the class to
+ // Was a custom class name supplied? If so we'll use it
+ if (empty($object_name))
+ {
+ $object_name = strtolower($class);
+ if (isset($this->_ci_varmap[$object_name]))
+ {
+ $object_name = $this->_ci_varmap[$object_name];
+ }
+ }
+
+ // Don't overwrite existing properties
+ $CI =& get_instance();
+ if (isset($CI->$object_name))
+ {
+ if ($CI->$object_name instanceof $class_name)
+ {
+ log_message('debug', $class_name." has already been instantiated as '".$object_name."'. Second attempt aborted.");
+ return;
+ }
+
+ show_error("Resource '".$object_name."' already exists and is not a ".$class_name." instance.");
+ }
+
+ // Save the class name and object name
+ $this->_ci_classes[$object_name] = $class;
+
+ // Instantiate the class
+ $CI->$object_name = isset($config)
+ ? new $class_name($config)
+ : new $class_name();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * CI Autoloader
+ *
+ * Loads component listed in the config/autoload.php file.
+ *
+ * @used-by CI_Loader::initialize()
+ * @return void
+ */
+ protected function _ci_autoloader()
+ {
+ if (file_exists(APPPATH.'config/autoload.php'))
+ {
+ include(APPPATH.'config/autoload.php');
+ }
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
+ }
+
+ if ( ! isset($autoload))
+ {
+ return;
+ }
+
+ // Autoload packages
+ if (isset($autoload['packages']))
+ {
+ foreach ($autoload['packages'] as $package_path)
+ {
+ $this->add_package_path($package_path);
+ }
+ }
+
+ // Load any custom config file
+ if (count($autoload['config']) > 0)
+ {
+ foreach ($autoload['config'] as $val)
+ {
+ $this->config($val);
+ }
+ }
+
+ // Autoload helpers and languages
+ foreach (array('helper', 'language') as $type)
+ {
+ if (isset($autoload[$type]) && count($autoload[$type]) > 0)
+ {
+ $this->$type($autoload[$type]);
+ }
+ }
+
+ // Autoload drivers
+ if (isset($autoload['drivers']))
+ {
+ $this->driver($autoload['drivers']);
+ }
+
+ // Load libraries
+ if (isset($autoload['libraries']) && count($autoload['libraries']) > 0)
+ {
+ // Load the database driver.
+ if (in_array('database', $autoload['libraries']))
+ {
+ $this->database();
+ $autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
+ }
+
+ // Load all other libraries
+ $this->library($autoload['libraries']);
+ }
+
+ // Autoload models
+ if (isset($autoload['model']))
+ {
+ $this->model($autoload['model']);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * CI Object to Array translator
+ *
+ * Takes an object as input and converts the class variables to
+ * an associative array with key/value pairs.
+ *
+ * @param object $object Object data to translate
+ * @return array
+ */
+ protected function _ci_object_to_array($object)
+ {
+ return is_object($object) ? get_object_vars($object) : $object;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * CI Component getter
+ *
+ * Get a reference to a specific library or model.
+ *
+ * @param string $component Component name
+ * @return bool
+ */
+ protected function &_ci_get_component($component)
+ {
+ $CI =& get_instance();
+ return $CI->$component;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep filename
+ *
+ * This function prepares filenames of various items to
+ * make their loading more reliable.
+ *
+ * @param string|string[] $filename Filename(s)
+ * @param string $extension Filename extension
+ * @return array
+ */
+ protected function _ci_prep_filename($filename, $extension)
+ {
+ if ( ! is_array($filename))
+ {
+ return array(strtolower(str_replace(array($extension, '.php'), '', $filename).$extension));
+ }
+ else
+ {
+ foreach ($filename as $key => $val)
+ {
+ $filename[$key] = strtolower(str_replace(array($extension, '.php'), '', $val).$extension);
+ }
+
+ return $filename;
+ }
+ }
+
+}
diff --git a/api/system/core/Log.php b/api/system/core/Log.php
new file mode 100644
index 0000000..cf6c75a
--- /dev/null
+++ b/api/system/core/Log.php
@@ -0,0 +1,296 @@
+ 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
+
+ /**
+ * mbstring.func_override flag
+ *
+ * @var bool
+ */
+ protected static $func_override;
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Class constructor
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $config =& get_config();
+
+ isset(self::$func_override) OR self::$func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
+
+ $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
+ $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
+ ? ltrim($config['log_file_extension'], '.') : 'php';
+
+ file_exists($this->_log_path) OR mkdir($this->_log_path, 0755, TRUE);
+
+ if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
+ {
+ $this->_enabled = FALSE;
+ }
+
+ if (is_numeric($config['log_threshold']))
+ {
+ $this->_threshold = (int) $config['log_threshold'];
+ }
+ elseif (is_array($config['log_threshold']))
+ {
+ $this->_threshold = 0;
+ $this->_threshold_array = array_flip($config['log_threshold']);
+ }
+
+ if ( ! empty($config['log_date_format']))
+ {
+ $this->_date_fmt = $config['log_date_format'];
+ }
+
+ if ( ! empty($config['log_file_permissions']) && is_int($config['log_file_permissions']))
+ {
+ $this->_file_permissions = $config['log_file_permissions'];
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write Log File
+ *
+ * Generally this function will be called using the global log_message() function
+ *
+ * @param string $level The error level: 'error', 'debug' or 'info'
+ * @param string $msg The error message
+ * @return bool
+ */
+ public function write_log($level, $msg)
+ {
+ if ($this->_enabled === FALSE)
+ {
+ return FALSE;
+ }
+
+ $level = strtoupper($level);
+
+ if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+ && ! isset($this->_threshold_array[$this->_levels[$level]]))
+ {
+ return FALSE;
+ }
+
+ $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
+ $message = '';
+
+ if ( ! file_exists($filepath))
+ {
+ $newfile = TRUE;
+ // Only add protection to php files
+ if ($this->_file_ext === 'php')
+ {
+ $message .= "\n\n";
+ }
+ }
+
+ if ( ! $fp = @fopen($filepath, 'ab'))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+
+ // Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
+ if (strpos($this->_date_fmt, 'u') !== FALSE)
+ {
+ $microtime_full = microtime(TRUE);
+ $microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
+ $date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
+ $date = $date->format($this->_date_fmt);
+ }
+ else
+ {
+ $date = date($this->_date_fmt);
+ }
+
+ $message .= $this->_format_line($level, $date, $msg);
+
+ for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
+ {
+ if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
+ {
+ break;
+ }
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ if (isset($newfile) && $newfile === TRUE)
+ {
+ chmod($filepath, $this->_file_permissions);
+ }
+
+ return is_int($result);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format the log line.
+ *
+ * This is for extensibility of log formatting
+ * If you want to change the log format, extend the CI_Log class and override this method
+ *
+ * @param string $level The error level
+ * @param string $date Formatted date string
+ * @param string $message The log message
+ * @return string Formatted log line with a new line character '\n' at the end
+ */
+ protected function _format_line($level, $date, $message)
+ {
+ return $level.' - '.$date.' --> '.$message."\n";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Byte-safe strlen()
+ *
+ * @param string $str
+ * @return int
+ */
+ protected static function strlen($str)
+ {
+ return (self::$func_override)
+ ? mb_strlen($str, '8bit')
+ : strlen($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Byte-safe substr()
+ *
+ * @param string $str
+ * @param int $start
+ * @param int $length
+ * @return string
+ */
+ protected static function substr($str, $start, $length = NULL)
+ {
+ if (self::$func_override)
+ {
+ // mb_substr($str, $start, null, '8bit') returns an empty
+ // string on PHP 5.3
+ isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
+ return mb_substr($str, $start, $length, '8bit');
+ }
+
+ return isset($length)
+ ? substr($str, $start, $length)
+ : substr($str, $start);
+ }
+}
diff --git a/api/system/core/Model.php b/api/system/core/Model.php
new file mode 100644
index 0000000..941881a
--- /dev/null
+++ b/api/system/core/Model.php
@@ -0,0 +1,80 @@
+$key;
+ }
+
+}
diff --git a/api/system/core/Output.php b/api/system/core/Output.php
new file mode 100644
index 0000000..cf6510f
--- /dev/null
+++ b/api/system/core/Output.php
@@ -0,0 +1,848 @@
+_zlib_oc = (bool) ini_get('zlib.output_compression');
+ $this->_compress_output = (
+ $this->_zlib_oc === FALSE
+ && config_item('compress_output') === TRUE
+ && extension_loaded('zlib')
+ );
+
+ isset(self::$func_override) OR self::$func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
+
+ // Get mime types for later
+ $this->mimes =& get_mimes();
+
+ log_message('info', 'Output Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Output
+ *
+ * Returns the current output string.
+ *
+ * @return string
+ */
+ public function get_output()
+ {
+ return $this->final_output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Output
+ *
+ * Sets the output string.
+ *
+ * @param string $output Output data
+ * @return CI_Output
+ */
+ public function set_output($output)
+ {
+ $this->final_output = $output;
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Append Output
+ *
+ * Appends data onto the output string.
+ *
+ * @param string $output Data to append
+ * @return CI_Output
+ */
+ public function append_output($output)
+ {
+ $this->final_output .= $output;
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Header
+ *
+ * Lets you set a server header which will be sent with the final output.
+ *
+ * Note: If a file is cached, headers will not be sent.
+ * @todo We need to figure out how to permit headers to be cached.
+ *
+ * @param string $header Header
+ * @param bool $replace Whether to replace the old header value, if already set
+ * @return CI_Output
+ */
+ public function set_header($header, $replace = TRUE)
+ {
+ // If zlib.output_compression is enabled it will compress the output,
+ // but it will not modify the content-length header to compensate for
+ // the reduction, causing the browser to hang waiting for more data.
+ // We'll just skip content-length in those cases.
+ if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0)
+ {
+ return $this;
+ }
+
+ $this->headers[] = array($header, $replace);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Content-Type Header
+ *
+ * @param string $mime_type Extension of the file we're outputting
+ * @param string $charset Character set (default: NULL)
+ * @return CI_Output
+ */
+ public function set_content_type($mime_type, $charset = NULL)
+ {
+ if (strpos($mime_type, '/') === FALSE)
+ {
+ $extension = ltrim($mime_type, '.');
+
+ // Is this extension supported?
+ if (isset($this->mimes[$extension]))
+ {
+ $mime_type =& $this->mimes[$extension];
+
+ if (is_array($mime_type))
+ {
+ $mime_type = current($mime_type);
+ }
+ }
+ }
+
+ $this->mime_type = $mime_type;
+
+ if (empty($charset))
+ {
+ $charset = config_item('charset');
+ }
+
+ $header = 'Content-Type: '.$mime_type
+ .(empty($charset) ? '' : '; charset='.$charset);
+
+ $this->headers[] = array($header, TRUE);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Current Content-Type Header
+ *
+ * @return string 'text/html', if not already set
+ */
+ public function get_content_type()
+ {
+ for ($i = 0, $c = count($this->headers); $i < $c; $i++)
+ {
+ if (sscanf($this->headers[$i][0], 'Content-Type: %[^;]', $content_type) === 1)
+ {
+ return $content_type;
+ }
+ }
+
+ return 'text/html';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Header
+ *
+ * @param string $header
+ * @return string
+ */
+ public function get_header($header)
+ {
+ // Combine headers already sent with our batched headers
+ $headers = array_merge(
+ // We only need [x][0] from our multi-dimensional array
+ array_map('array_shift', $this->headers),
+ headers_list()
+ );
+
+ if (empty($headers) OR empty($header))
+ {
+ return NULL;
+ }
+
+ for ($i = 0, $c = count($headers); $i < $c; $i++)
+ {
+ if (strncasecmp($header, $headers[$i], $l = self::strlen($header)) === 0)
+ {
+ return trim(self::substr($headers[$i], $l+1));
+ }
+ }
+
+ return NULL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set HTTP Status Header
+ *
+ * As of version 1.7.2, this is an alias for common function
+ * set_status_header().
+ *
+ * @param int $code Status code (default: 200)
+ * @param string $text Optional message
+ * @return CI_Output
+ */
+ public function set_status_header($code = 200, $text = '')
+ {
+ set_status_header($code, $text);
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Enable/disable Profiler
+ *
+ * @param bool $val TRUE to enable or FALSE to disable
+ * @return CI_Output
+ */
+ public function enable_profiler($val = TRUE)
+ {
+ $this->enable_profiler = is_bool($val) ? $val : TRUE;
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Profiler Sections
+ *
+ * Allows override of default/config settings for
+ * Profiler section display.
+ *
+ * @param array $sections Profiler sections
+ * @return CI_Output
+ */
+ public function set_profiler_sections($sections)
+ {
+ if (isset($sections['query_toggle_count']))
+ {
+ $this->_profiler_sections['query_toggle_count'] = (int) $sections['query_toggle_count'];
+ unset($sections['query_toggle_count']);
+ }
+
+ foreach ($sections as $section => $enable)
+ {
+ $this->_profiler_sections[$section] = ($enable !== FALSE);
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Cache
+ *
+ * @param int $time Cache expiration time in minutes
+ * @return CI_Output
+ */
+ public function cache($time)
+ {
+ $this->cache_expiration = is_numeric($time) ? $time : 0;
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Display Output
+ *
+ * Processes and sends finalized output data to the browser along
+ * with any server headers and profile data. It also stops benchmark
+ * timers so the page rendering speed and memory usage can be shown.
+ *
+ * Note: All "view" data is automatically put into $this->final_output
+ * by controller class.
+ *
+ * @uses CI_Output::$final_output
+ * @param string $output Output data override
+ * @return void
+ */
+ public function _display($output = '')
+ {
+ // Note: We use load_class() because we can't use $CI =& get_instance()
+ // since this function is sometimes called by the caching mechanism,
+ // which happens before the CI super object is available.
+ $BM =& load_class('Benchmark', 'core');
+ $CFG =& load_class('Config', 'core');
+
+ // Grab the super object if we can.
+ if (class_exists('CI_Controller', FALSE))
+ {
+ $CI =& get_instance();
+ }
+
+ // --------------------------------------------------------------------
+
+ // Set the output data
+ if ($output === '')
+ {
+ $output =& $this->final_output;
+ }
+
+ // --------------------------------------------------------------------
+
+ // Do we need to write a cache file? Only if the controller does not have its
+ // own _output() method and we are not dealing with a cache file, which we
+ // can determine by the existence of the $CI object above
+ if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
+ {
+ $this->_write_cache($output);
+ }
+
+ // --------------------------------------------------------------------
+
+ // Parse out the elapsed time and memory usage,
+ // then swap the pseudo-variables with the data
+
+ $elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
+
+ if ($this->parse_exec_vars === TRUE)
+ {
+ $memory = round(memory_get_usage() / 1024 / 1024, 2).'MB';
+ $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);
+ }
+
+ // --------------------------------------------------------------------
+
+ // Is compression requested?
+ if (isset($CI) // This means that we're not serving a cache file, if we were, it would already be compressed
+ && $this->_compress_output === TRUE
+ && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
+ {
+ ob_start('ob_gzhandler');
+ }
+
+ // --------------------------------------------------------------------
+
+ // Are there any server headers to send?
+ if (count($this->headers) > 0)
+ {
+ foreach ($this->headers as $header)
+ {
+ @header($header[0], $header[1]);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ // Does the $CI object exist?
+ // If not we know we are dealing with a cache file so we'll
+ // simply echo out the data and exit.
+ if ( ! isset($CI))
+ {
+ if ($this->_compress_output === TRUE)
+ {
+ if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
+ {
+ header('Content-Encoding: gzip');
+ header('Content-Length: '.self::strlen($output));
+ }
+ else
+ {
+ // User agent doesn't support gzip compression,
+ // so we'll have to decompress our cache
+ $output = gzinflate(self::substr($output, 10, -8));
+ }
+ }
+
+ echo $output;
+ log_message('info', 'Final output sent to browser');
+ log_message('debug', 'Total execution time: '.$elapsed);
+ return;
+ }
+
+ // --------------------------------------------------------------------
+
+ // Do we need to generate profile data?
+ // If so, load the Profile class and run it.
+ if ($this->enable_profiler === TRUE)
+ {
+ $CI->load->library('profiler');
+ if ( ! empty($this->_profiler_sections))
+ {
+ $CI->profiler->set_sections($this->_profiler_sections);
+ }
+
+ // If the output data contains closing