Initial import

This commit is contained in:
sas.fajri
2026-04-27 10:26:26 +07:00
commit bf9b9097ee
2388 changed files with 3002242 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
vendor/
.vscode/
.DS_Store
composer.phar

4
.htaccess Normal file
View File

@@ -0,0 +1,4 @@
RewriteEngine on
RewriteBase /one-api/
RewriteCond $1 !^(index\.php|assets|user_guide|robots\.txt)
RewriteRule ^(.*)$ /one-api/index.php/$1 [L]

3987
Patient.php Normal file

File diff suppressed because it is too large Load Diff

6
application/.htaccess Normal file
View File

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

11
application/cache/index.html vendored Normal file
View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -0,0 +1,135 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Drivers
| 4. Helper files
| 5. Custom config files
| 6. Language files
| 7. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in system/libraries/ or your
| application/libraries/ directory, with the addition of the
| 'database' library, which is somewhat of a special case.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'email', 'session');
|
| You can also supply an alternative library name to be assigned
| in the controller:
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array();
/*
| -------------------------------------------------------------------
| 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();
/*
| -------------------------------------------------------------------
| 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();

View File

@@ -0,0 +1,523 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = '';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
$config['uri_protocol'] = 'REQUEST_URI';
/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| https://codeigniter.com/user_guide/general/urls.html
*/
$config['url_suffix'] = '';
/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = 'english';
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
| See http://php.net/htmlspecialchars for a list of supported charsets.
|
*/
$config['charset'] = 'UTF-8';
/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the 'hooks' feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| https://codeigniter.com/user_guide/general/core_classes.html
| https://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';
/*
|--------------------------------------------------------------------------
| Composer auto-loading
|--------------------------------------------------------------------------
|
| Enabling this setting will tell CodeIgniter to look for a Composer
| package auto-loader script in application/vendor/autoload.php.
|
| $config['composer_autoload'] = TRUE;
|
| Or if you have your vendor/ directory located somewhere else, you
| can opt to set a specific path as well:
|
| $config['composer_autoload'] = '/path/to/vendor/autoload.php';
|
| For more information about Composer, please visit http://getcomposer.org/
|
| Note: This will NOT disable or override the CodeIgniter-specific
| autoloading (application/config/autoload.php)
*/
$config['composer_autoload'] = false;
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify which characters are permitted within your URLs.
| When someone tries to submit a URL with disallowed characters they will
| get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| The configured value is actually a regular expression character group
| and it will be executed as: ! preg_match('/^[<permitted_uri_chars>]+$/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/
|
| 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['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
/*
|--------------------------------------------------------------------------
| Allow $_GET array
|--------------------------------------------------------------------------
|
| 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.
|
| WARNING: This feature is DEPRECATED and currently available only
| for backwards compatibility purposes!
|
*/
$config['allow_get_array'] = TRUE;
/*
|--------------------------------------------------------------------------
| 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'] = '';
/*
|--------------------------------------------------------------------------
| 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'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$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.
|
| WARNING: This feature is DEPRECATED and currently available only
| for backwards compatibility purposes!
|
*/
$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';
/*
|--------------------------------------------------------------------------
| 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'] = '';

View File

@@ -0,0 +1,85 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Display Debug backtrace
|--------------------------------------------------------------------------
|
| If set to TRUE, a backtrace will be displayed along with php errors. If
| error_reporting is disabled, the backtrace will not display, regardless
| of this setting
|
*/
defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
defined('FILE_READ_MODE') OR define('FILE_READ_MODE', 0644);
defined('FILE_WRITE_MODE') OR define('FILE_WRITE_MODE', 0666);
defined('DIR_READ_MODE') OR define('DIR_READ_MODE', 0755);
defined('DIR_WRITE_MODE') OR define('DIR_WRITE_MODE', 0755);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
defined('FOPEN_READ') OR define('FOPEN_READ', 'rb');
defined('FOPEN_READ_WRITE') OR define('FOPEN_READ_WRITE', 'r+b');
defined('FOPEN_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
defined('FOPEN_WRITE_CREATE') OR define('FOPEN_WRITE_CREATE', 'ab');
defined('FOPEN_READ_WRITE_CREATE') OR define('FOPEN_READ_WRITE_CREATE', 'a+b');
defined('FOPEN_WRITE_CREATE_STRICT') OR define('FOPEN_WRITE_CREATE_STRICT', 'xb');
defined('FOPEN_READ_WRITE_CREATE_STRICT') OR define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/*
|--------------------------------------------------------------------------
| Exit Status Codes
|--------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') OR define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') OR define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') OR define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') OR define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') OR define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') OR define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') OR define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') OR define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

View File

@@ -0,0 +1,185 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->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' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onedev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['clinicdev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one_clinic',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['antrione'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'antrione',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onelog'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

View File

@@ -0,0 +1,185 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->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' => 'localhost',
'username' => 'root',
'password' => 'mcupramita123321',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onedev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'mcupramita123321',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['clinicdev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'mcupramita123321',
'database' => 'one_clinic',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['antrione'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'mcupramita123321',
'database' => 'antrione',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onelog'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'mcupramita123321',
'database' => 'one_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

View File

@@ -0,0 +1,319 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->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' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'cpone',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['screener'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'screener',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onedev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'cpone',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['cpone_corporate'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'cpone_corporate',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['cpone_log'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'cpone_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['log'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'cpone_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['clinicdev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'one_clinic',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['local_ai'] = array(
'dsn' => '',
'hostname' => '192.168.0.116',
'username' => 'root',
'password' => 'Sasone!102938',
'database' => 'cpone',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['one'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['antrione'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'antrione',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onelog'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'admin',
'password' => 'Sasone!102938',
'database' => 'one_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

View File

@@ -0,0 +1,185 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->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' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onedev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['clinicdev'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one_clinic',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['antrione'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'antrione',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['onelog'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'pramita102938',
'database' => 'one_log',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

View File

@@ -0,0 +1,24 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$_doctypes = array(
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
);

View File

@@ -0,0 +1,103 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| Foreign Characters
| -------------------------------------------------------------------
| This file contains an array of foreign characters for transliteration
| conversion used by the Text helper
|
*/
$foreign_characters = array(
'/ä|æ|ǽ/' => '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'
);

View File

@@ -0,0 +1,13 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| https://codeigniter.com/user_guide/general/hooks.html
|
*/

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Memcached settings
| -------------------------------------------------------------------------
| Your Memcached servers can be specified below.
|
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
*/
$config = array(
'default' => array(
'hostname' => '127.0.0.1',
'port' => '11211',
'weight' => '1',
),
);

View File

@@ -0,0 +1,84 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
$config['migration_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
| Migration Type
|--------------------------------------------------------------------------
|
| Migration file names may be based on a sequential identifier or on
| a timestamp. Options are:
|
| 'sequential' = Sequential migration naming (001_add_blog.php)
| 'timestamp' = Timestamp migration naming (20121031104401_add_blog.php)
| Use timestamp format YYYYMMDDHHIISS.
|
| Note: If this configuration value is missing the Migration library
| defaults to 'sequential' for backward compatibility with CI2.
|
*/
$config['migration_type'] = 'timestamp';
/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
$config['migration_table'] = 'migrations';
/*
|--------------------------------------------------------------------------
| Auto Migrate To Latest
|--------------------------------------------------------------------------
|
| If this is set to TRUE when you load the migrations class and have
| $config['migration_enabled'] set to TRUE the system will auto migrate
| to your latest migration (whatever $config['migration_version'] is
| set to). This way you do not have to call migrations anywhere else
| in your code to have the latest migration.
|
*/
$config['migration_auto_latest'] = FALSE;
/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->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/';

View File

@@ -0,0 +1,184 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
return array(
'hqx' => 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',
'7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'7zip' => array('application/x-7z-compressed', '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'
);

View File

@@ -0,0 +1,14 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Profiler Sections
| -------------------------------------------------------------------------
| This file lets you determine whether or not various sections of Profiler
| data are displayed when the Profiler is enabled.
| Please see the user guide for info:
|
| https://codeigniter.com/user_guide/general/profiling.html
|
*/

View File

@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| https://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
| $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

View File

@@ -0,0 +1,64 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| SMILEYS
| -------------------------------------------------------------------
| This file contains an array of smileys for use with the emoticon helper.
| Individual images can be used to replace multiple smileys. For example:
| :-) and :) use the same image replacement.
|
| Please see user guide for more info:
| https://codeigniter.com/user_guide/helpers/smiley_helper.html
|
*/
$smileys = array(
// smiley image name width height alt
':-)' => 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')
);

View File

@@ -0,0 +1,214 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
*/
$platforms = array(
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS'
);
// 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' => 'Edge',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser'
);
$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'
);

View File

@@ -0,0 +1,27 @@
@host = http://10.9.10.38:8080
@token = MYmIZGwkLQUjmFHiL2kgrOjhUyZnk507oBD2BDwM
### API Untuk List Paket Dispenser HIS
GET {{host}}/api/cpone/paket
?search=TESTING BUGS
&code=250600004
&start_date=2025-01-01
&end_date=2027-12-30
&per_page=10
Authorization: Bearer {{token}}
### API Untuk Detail Paket Dispenser HIS
GET {{host}}/api/cpone/paket/DISP-260200004
Authorization: Bearer {{token}}
### API Untuk List Layanan dan Harga HIS
GET {{host}}/api/cpone/layanan
Authorization: Bearer {{token}}
###
GET https://devcpone.aplikasi.web.id/one-api/api_his/GetMapingLayanan
### API Untuk pendaftaran Pasien MCU
SE

View File

@@ -0,0 +1,5 @@
POST https://devcpone.aplikasi.web.id/one-api/api_itf/getOrderDetail
{
"orderNumber": "I2410180003"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
<?php
class Info extends MY_Controller {
function __construct() {
parent::__construct();
}
function index() {
echo json_encode(["status"=>"OK", "message" => Date()]);
}
}

View File

@@ -0,0 +1,180 @@
<?php
class Qontak_api extends MY_Controller
{
var $token = "WWEfmnLJXPBGBQodjshDQMQgeyhVDbNDC-VR0apf2lc";
var $wa_integration_id = "db560b73-53d1-422f-9482-b3d895191ece";
var $template_id = "54770b4e-8603-4dc2-a148-f17447cb2aa6";
function __construct()
{
parent::__construct();
}
function send_wa()
{
$url = "https://service-chat.qontak.com/api/open/v1/broadcasts/whatsapp/direct";
$hp = $this->sys_input["hp"];
$hp_name = $this->sys_input["hp_name"];
$patient_name = $this->sys_input["patient_name"];
$filename = $this->sys_input["filename"];
$result_date = $this->sys_input["result_date"];
$uploaded_url_doc = "https://cdn.qontak.com/uploads/direct/files/2bdb1add-fb1f-4d5e-aa66-5cee1cb4864e/example-report.pdf";
$param = [
"to_name" => $hp_name,
"to_number" => $hp,
"message_template_id" => $this->template_id,
"channel_integration_id" => $this->wa_integration_id,
"language" => [
"code" => "id"
],
"parameters" => [
"header" => [
"format" => "DOCUMENT",
"params" => [
[
"key" => "url",
"value" => $uploaded_url_doc
],
[
"key" => "filename",
"value" => $filename
]
]
],
"body" => [
[
"key" => 1,
"value" => "nama",
"value_text" => $hp_name
],
[
"key" => 2,
"value" => "tipe",
"value_text" => $patient_name
],
[
"key" => 3,
"value" => "berlaku",
"value_text" => $result_date
],
]
]
];
$json_param = json_encode($param);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $json_param,
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer {$this->token}",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if ($error != "") {
echo json_encode(["status" => "ERR", "message" => $error]);
exit;
}
echo $response;
}
function get_integration()
{
$url = "https://service-chat.qontak.com/api/open/v1/integrations?target_channel=wa&limit=10";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => false,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$this->token}",
],
]);
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if ($error != "") {
echo json_encode(["status" => "ERR", "message" => $error]);
exit;
}
echo $response;
}
function upload_file()
{
$url = "https://service-chat.qontak.com/api/open/v1/file_uploader";
$fileName = $this->sys_input["file_name"];
$rpt_url = $this->sys_input["rpt_url"];
$mimeType = $this->sys_input["mime"];
$fileContents = file_get_contents($rpt_url);
$boundary = uniqid();
$body = "--$boundary\r\n" .
"Content-Disposition: form-data; name=\"file\"; filename=\"$fileName\"\r\n" .
"Content-Type: $mimeType\r\n\r\n" .
$fileContents . "\r\n" .
"--$boundary--\r\n";
// Set cURL options
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$this->token}",
"Content-Type: multipart/form-data; boundary=$boundary"
],
CURLOPT_POSTFIELDS => $body
]);
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if ($error) {
echo json_encode(["status" => "ERR", "message" => $error]);
exit;
}
echo $response;
}
function list_template()
{
$url = "https://service-chat.qontak.com/api/open/v1/templates/whatsapp";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => false,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$this->token}",
],
]);
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if ($error != "") {
echo json_encode(["status" => "ERR", "message" => $error]);
exit;
}
echo $response;
}
}

View File

@@ -0,0 +1,47 @@
<?php
class Rpt_img_background extends MY_Controller
{
function __construct()
{
parent::__construct();
}
function index() {}
function project_from_t_orderheader($id)
{
$sql = "";
$qry = $this->db->query($sql, [$id]);
if (!$qry) {
}
return 0;
}
function project($id, $code)
{
$img = APPPATH . "../../one-ui/BackgroundWesterindoPrimaya.png";
$referer = $this->input->server('HTTP_REFERER');
//di gunakan untuk mencari project berdasarkan code
//code ini di hardcode dari rpt untuk menentukan id itu jenis apa
switch ($code) {
default:
//T_OrderHeaderID
$project_id = $this->project_from_t_orderheader($id);
break;
}
// echo "img : $img";
// if (file_exists($img)) {
// echo " file exists";
// } else {
// echo " file not exists";
// }
if ($project_id == 0) {
$img = APPPATH . "../../one-ui/BackgroundWesterindoPrimaya.png";
}
file_put_contents("/xtmp/referer-rpt.log", "referer : $referer | code : $code |\n");
file_put_contents("/xtmp/referer-rpt.log", print_r($_SERVER, true), FILE_APPEND);
Header("Content-Type: image/png");
echo file_get_contents($img);
exit;
}
}

View File

@@ -0,0 +1,479 @@
<?php
class Station extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "STATION API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookupbahan(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$sql = "select T_BahanID as id,
T_BahanT_SampleStationID as usergroupid,
T_BahanCode as code,
T_BahanName As name,
'xxx' as action
from t_bahan
join t_samplestation oN T_BahanT_SampleStationID = T_SampleStationID
where
T_BahanT_SampleStationID = {$id} AND T_BahanIsActive = 'Y'";
//echo $sql;
$rows = $this->db_onedev->query($sql)->result();
$result = array ("total" => count($rows), "records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function lookup()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$search = $prm['search'];
$all = $prm['all'];
$limit = '';
if($all == 'N'){
$limit = ' LIMIT 10';
}
$sql = "select COUNT(*) as total
from t_samplestation
where
T_SampleStationIsActive = 'Y'";
$sql_param = array($search);
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$sql = "select T_SampleStationID as id,
T_SampleStationCode as code,
T_SampleStationName as name,
T_SampleStationIsNonLab as isnonlab, T_SampleStationName as description , 'xxx' as usergrouptype
from t_samplestation
where
T_SampleStationName LIKE CONCAT('%','{$search}','%') AND
T_SampleStationIsActive = 'Y' $limit";
$sql_param = array($search);
$query = $this->db_onedev->query($sql);
//echo $this->db_onedev->last_query();
if ($query) {
$rows = $query->result_array();
} else {
$this->sys_error_db("t_samplestation select",$this->db_onedev);
exit;
}
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewstation()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name_station = $prm['name'];
$code_station = $prm['code'];
$isnonlab_station = $prm['isnonlab'];
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'";
$exist_name = $this->db_onedev->query($query)->row()->exist;
//echo $exist_name;
if($exist_name == 0 ){
$sql = "insert into t_samplestation(
T_SampleStationCode,
T_SampleStationName,
T_SampleStationIsNonLab,
T_SampleStationCreated,
T_SampleStationLastUpdated
)
values( ?, ?, ?,now(), now())";
$query = $this->db_onedev->query($sql,
array(
$name_station,
$code_station,
$isnonlab_station
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("t_samplestation insert");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada '));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editstation()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$id_station = $prm['id'];
$code_station = $prm['code'];
$name_station = $prm['name'];
$isnonlab_station = $prm['isnonlab'];
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'
AND T_SampleStationID <> {$id_station} ";
$exist_name = $this->db_onedev->query($query)->row()->exist;
if($exist_name == 0){
$sql = "update t_samplestation SET
T_SampleStationCode = ?,
T_SampleStationName = ?,
T_SampleStationIsNonLab = ?,
T_SampleStationLastUpdated = now()
where
T_SampleStationID = ?
";
$query = $this->db_onedev->query($sql,
array(
$code_station,
$name_station,
$isnonlab_station,
$id_station
)
);
//file_put_contents("/tmp/adi-update-user.sql",$this->db_onedev->last_query());
//echo $query;
if (!$query) {
$this->sys_error_db("t_samplestation update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id_station));
$this->sys_ok($result);
}else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editbahan()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$bahanid = $prm['xid'];
$code = $prm['code'];
$name = $prm['name'];
$xstationname = $prm['xstationname'];
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'
and T_BahanID <> $bahanid ";
$exist_name = $this->db_onedev->query($query)->row()->exist;
if($exist_name == 0){
$sql = "update m_user SET
T_BahanCode = ?,
T_BahanName = ?,
T_BahanT_SampleStationID = ?,
T_BahanLastUpdated = now()
where T_BahanID = ? ";
$query = $this->db_onedev->query($sql,
array(
$code,
$name,
$xstationname["T_SampleStationID"],
$bahanid
));
if (!$query) {
$this->sys_error_db("t_bahan update",$this->db_onedev);
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $bahanid));
$this->sys_ok($result);
} else {
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewbahan()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$stationid = $prm['stationid'];
$code = $prm['code'];
$name = $prm['name'];
if($prm['xid'] == 0){
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'";
$exist_name = $this->db_onedev->query($query)->row()->exist;
if($exist_name == 0){
$sql = "insert into t_bahan(
T_BahanT_SampleStationID,
T_BahanCode,
T_BahanName,
T_BahanCreated,
T_BahanLastUpdated
)
values( ?,?,?,now(),now())";
$query = $this->db_onedev->query($sql,
array(
$stationid,
$code,
$name
)
);
if (!$query) {
$this->sys_error_db("t_bahan insert",$this->db_onedev);
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
}else{
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}' AND T_BahanID <> {$prm['xid']}";
$exist_name = $this->db_onedev->query($query)->row()->exist;
//echo $query;
//echo $query;
if($exist_name == 0 ){
$sql = "UPDATE t_bahan SET T_BahanName = '{$name}', T_BahanCode = '{$code}' WHERE T_BahanID = '{$prm['xid']}'";
//echo $sql;
$query = $this->db_onedev->query($sql);
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function deletebahan()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$sql = "update t_bahan SET
T_BahanIsActive = 'N',
T_BahanLastUpdated = now()
WHERE
T_BahanID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("t_bahan delete");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function deleteselect()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$sql = "update t_samplestation SET
T_SampleStationIsActive = 'N',
T_SampleStationLastUpdated = now()
WHERE
T_SampleStationID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("t_samplestation delete");
exit;
}
$sql = "UPDATE m_user SET
M_UserIsActive = 'N',
M_UserLastUpdated = now()
WHERE
M_UserM_UserGroupID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("m_user delete");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
echo(".:: -- ::.");
}
}

View File

@@ -0,0 +1,181 @@
<?php
class Bridging extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data,$userid=999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
$result['success'] = true;
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
echo json_encode($errors);
exit;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
$success = array('status' => 'success','message' => 'Berhasil Login');
echo json_encode($success);
exit;
}
}
}

View File

@@ -0,0 +1,421 @@
<?php
class Corporate extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
}
else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
}
else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
}
else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_corporate()
{
// Ambil parameter
$corporate_name = $this->input->get('corporate_name');
$corporate_status = $this->input->get('corporate_status');
$corporate_code = $this->input->get('corporate_code');
$where_query = "WHERE c.CorporateIsActive = 'Y'";
if ($corporate_name) {
$where_query .= "AND ( c.CorporateName LIKE '%{$corporate_name}%' OR c.CorporateCode LIKE '%{$corporate_name}%' ) ";
}
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$sql_base = "SELECT
DISTINCT c.CorporateID AS corporate_id,
0 as T_OrderHeaderID,
c.CorporateName AS corporate_name,
c.CorporateCode AS corporate_code,
c.CorporateAddress AS corporate_address,
c.CorporateEmail AS corporate_email,
c.CorporatePhone AS corporate_phone,
ais_pillar_name,
'' as Ais_CorporateStatus ,
'' AS corporate_status,
'' AS Ais_CorporateID
FROM corporate c
LEFT JOIN corporate_type ON CorporateCorporateTypeID = CorporateTypeID
LEFT JOIN ais_pillar ON CorporateTypeais_pillar_code = ais_pillar_code
$where_query
GROUP BY c.CorporateID
ORDER BY c.CorporateID ASC
LIMIT $limit OFFSET $offset";
//echo $sql_base;
$params = [];
// Count total records for pagination
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT
DISTINCT c.CorporateID AS corporate_id
FROM corporate c
$where_query
) AS x
";
$qry_count = $this->db_onedev->query($count_sql);
// echo $this->db_onedev->last_query();
$total = $qry_count->row()->total ?? 0;
$qry = $this->db_onedev->query($sql_base);
// echo $this->db_onedev->last_query();
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
if ($data) {
foreach ($data as $k => $d) {
$data[$k]['corporate_status'] = 'N';
$data[$k]['Ais_CorporateStatus'] = null;
$data[$k]['Ais_CorporateID'] = null;
$sql = "SELECT *
FROM " . $this->db_log->database . ".ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC
LIMIT 1";
$qry_corporate = $this->db_log->query($sql, [$d['corporate_code']]);
if ($qry_corporate) {
$data[$k]['corporate_status'] = 'N';
$status = $qry_corporate->row()->Ais_CorporateStatus;
if ($status && $status == 'SUCCESS') {
$data[$k]['corporate_status'] = 'Y';
}
$data[$k]['Ais_CorporateStatus'] = $qry_corporate->row()->Ais_CorporateStatus;
$data[$k]['Ais_CorporateID'] = $qry_corporate->row()->Ais_CorporateID;
}
}
}
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
// Ambil corporate_code dari query parameter
$corporate_code = $this->input->get('corporate_code');
if (empty($corporate_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'corporate_code parameter is required'
]));
}
$sql = "SELECT
Ais_CorporateID AS id,
Ais_CorporateCorporateCode AS corporate_code,
Ais_CorporateJSON AS json,
Ais_CorporateStatus AS status,
Ais_CorporateResponse AS response,
Ais_CorporateLastUpdate AS last_update,
Ais_CorporateUserID AS user_id
FROM ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$corporate_code]);
$results = $qry->result_array();
if ($results) {
foreach ($results as &$r) {
$r['json'] = json_decode($r['json']);
$r['response'] = json_decode($r['response']);
}
unset($r);
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'success',
'data' => $results
]));
}
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => "No data found for corporate_code: $corporate_code"
]));
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,421 @@
<?php
class Packet extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_packet()
{
$sql_base = "SELECT
p.T_PacketID,
p.T_PacketName AS packet_name,
p.T_PacketType,
p.T_PacketPrice,
p.T_PacketSasCode AS packet_code,
p.T_PacketStartDate,
p.T_PacketEndDate,
ph.T_PriceHeaderID,
ph.T_PriceHeaderName AS priceheader_name,
ph.T_PriceHeaderCode AS priceheader_code,
ph.T_PriceHeaderStartDate,
ph.T_PriceHeaderEndDate,
ap.Ais_PacketStatus AS Ais_PacketStatus,
IF(MAX(ap.Ais_PacketID) IS NULL, 'N', 'Y') AS packet_status
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
";
// Ambil parameter
$packet_name = $this->input->get('packet_name');
$packet_code = $this->input->get('packet_code');
$priceheader_name = $this->input->get('priceheader_name');
$priceheader_code = $this->input->get('priceheader_code');
$packet_status = $this->input->get('packet_status'); // Y / N
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [];
// Status packet Y/N dari ais_packet
if ($packet_status === 'Y') {
$where_clauses[] = "ap.Ais_PacketID IS NOT NULL";
} elseif ($packet_status === 'N') {
$where_clauses[] = "ap.Ais_PacketID IS NULL";
}
// Filter by packet name
if ($packet_name) {
$where_clauses[] = "p.T_PacketName LIKE ?";
$params[] = "%$packet_name%";
}
// Filter by packet code
if ($packet_code) {
$where_clauses[] = "p.T_PacketSasCode LIKE ?";
$params[] = "%$packet_code%";
}
// Filter by priceheader name
if ($priceheader_name) {
$where_clauses[] = "ph.T_PriceHeaderName LIKE ?";
$params[] = "%$priceheader_name%";
}
// Filter by priceheader code
if ($priceheader_code) {
$where_clauses[] = "ph.T_PriceHeaderCode LIKE ?";
$params[] = "%$priceheader_code%";
}
// Build WHERE
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// Count total records for pagination
// Count distinct packet ID
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT p.T_PacketID
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
$where_sql
GROUP BY p.T_PacketID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// Main SQL
$sql = $sql_base . $where_sql . "
GROUP BY p.T_PacketID
ORDER BY p.T_PacketID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring packet.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring packet.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$packet_code = $this->input->get('packet_code');
if (empty($packet_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error', 'message' => 'packet_code parameter is required']));
}
$sql = "SELECT
Ais_PacketT_PacketSasCode AS packet_code,
Ais_PacketLastUpdated AS packet_update,
Ais_PacketJson AS packet_json,
Ais_PacketStatus AS status,
Ais_PacketResponse AS packet_response
FROM ais_packet
WHERE Ais_PacketT_PacketSasCode = ?
ORDER BY Ais_PacketLastUpdated DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, array($packet_code));
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

View File

@@ -0,0 +1,433 @@
<?php
class Packet extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
}
else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
}
else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
}
else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_packet()
{
// Ambil parameter
$packet_name = $this->input->get('packet_name');
$packet_code = $this->input->get('packet_code');
$priceheader_name = $this->input->get('priceheader_name');
$priceheader_code = $this->input->get('priceheader_code');
$packet_status = $this->input->get('packet_status'); // Y / N
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [];
$sql = "SELECT
p.T_PacketID,
p.T_PacketName AS packet_name,
p.T_PacketType,
p.T_PacketPrice,
p.T_PacketSasCode AS packet_code,
p.T_PacketStartDate,
p.T_PacketEndDate,
ph.T_PriceHeaderID,
ph.T_PriceHeaderName AS priceheader_name,
ph.T_PriceHeaderCode AS priceheader_code,
ph.T_PriceHeaderStartDate,
ph.T_PriceHeaderEndDate,
ap.Ais_PacketStatus AS Ais_PacketStatus,
'' AS packet_status
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID AND t_packetIsActive = 'Y'
LEFT JOIN " . $this->db_log->database . ".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
";
// Status packet Y/N dari ais_packet
if ($packet_status === 'Y') {
$where_clauses[] = "ap.Ais_PacketID IS NOT NULL";
}
elseif ($packet_status === 'N') {
$where_clauses[] = "ap.Ais_PacketID IS NULL";
}
// Filter by packet name
if ($packet_name) {
$where_clauses[] = "p.T_PacketName LIKE ?";
$params[] = "%$packet_name%";
}
// Filter by packet code
if ($packet_code) {
$where_clauses[] = "p.T_PacketSasCode LIKE ?";
$params[] = "%$packet_code%";
}
// Filter by priceheader name
if ($priceheader_name) {
$where_clauses[] = "ph.T_PriceHeaderName LIKE ?";
$params[] = "%$priceheader_name%";
}
// Filter by priceheader code
if ($priceheader_code) {
$where_clauses[] = "ph.T_PriceHeaderCode LIKE ?";
$params[] = "%$priceheader_code%";
}
// Tambahkan WHERE jika ada klausa
if (!empty($where_clauses)) {
$sql .= " WHERE " . implode(" AND ", $where_clauses);
}
// Hitung total data
$sql_count = "SELECT COUNT(*) as total FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID AND t_packetIsActive = 'Y'
LEFT JOIN " . $this->db_log->database . ".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
";
if (!empty($where_clauses)) {
$sql_count .= " WHERE " . implode(" AND ", $where_clauses);
}
$qry_count = $this->db_onedev->query($sql_count, $params);
$total = $qry_count->row()->total;
// Tambahkan pagination
$sql .= " LIMIT ? OFFSET ?";
$params[] = $limit;
$params[] = $offset;
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
$this->error_log(array('fn_name' => 'monitoring_packet', 'message' => 't_packet select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal mengambil data monitoring packet.');
echo json_encode($errors);
exit;
}
$data = $qry->result_array();
// Format data
foreach ($data as &$row) {
$row['T_PacketStartDate'] = $row['T_PacketStartDate'] ? date('Y-m-d', strtotime($row['T_PacketStartDate'])) : null;
$row['T_PacketEndDate'] = $row['T_PacketEndDate'] ? date('Y-m-d', strtotime($row['T_PacketEndDate'])) : null;
$row['T_PriceHeaderStartDate'] = $row['T_PriceHeaderStartDate'] ? date('Y-m-d', strtotime($row['T_PriceHeaderStartDate'])) : null;
$row['T_PriceHeaderEndDate'] = $row['T_PriceHeaderEndDate'] ? date('Y-m-d', strtotime($row['T_PriceHeaderEndDate'])) : null;
}
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring packet.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$packet_code = $this->input->get('packet_code');
if (empty($packet_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error', 'message' => 'packet_code parameter is required']));
}
$sql = "SELECT
Ais_PacketT_PacketSasCode AS packet_code,
Ais_PacketLastUpdated AS packet_update,
Ais_PacketJson AS packet_json,
Ais_PacketStatus AS status,
Ais_PacketResponse AS packet_response
FROM ais_packet
WHERE Ais_PacketT_PacketSasCode = ?
ORDER BY Ais_PacketLastUpdated DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, array($packet_code));
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
}
else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

View File

@@ -0,0 +1,269 @@
<?php
class Test extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Transaction API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* Generic PUT request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
return $errors;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
return $errors;
}
return $result;
}
}
function monitoring_test()
{
// SQL base
$sql_base = "SELECT
t.T_TestID,
t.T_TestCode AS test_code,
t.T_TestSasCode AS sas_code,
t.T_TestName AS test_name,
t.T_TestIsPrice AS is_price,
t.T_TestIsResult AS is_result,
t.T_TestIsActive AS test_active,
at.Ais_TestStatus AS Ais_TestStatus,
at.Ais_TestLastUpdate AS test_last_update,
IF (at.Ais_TestID IS NULL, 'N', 'Y') AS test_status
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestStatus, Ais_TestLastUpdate, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
";
// Ambil parameter
$test_name = $this->input->get('test_name'); // TRUE for XSS filtering
$sas_code = $this->input->get('sas_code');
$test_code = $this->input->get('test_code');
$test_status = $this->input->get('test_status');
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [
"t.T_TestIsActive = 'Y'"
];
// Status filter
if ($test_status === 'Y') {
$where_clauses[] = "at.Ais_TestID IS NOT NULL";
} elseif ($test_status === 'N') {
$where_clauses[] = "at.Ais_TestID IS NULL";
}
if ($test_name) {
$where_clauses[] = "t.T_TestName LIKE ?";
$params[] = "%$test_name%";
}
if ($test_code) {
$where_clauses[] = "t.T_TestCode LIKE ?";
$params[] = "%$test_code%";
}
if ($sas_code) {
$where_clauses[] = "t.T_TestSasCode LIKE ?";
$params[] = "%$sas_code%";
}
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// COUNT
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT t.T_TestID
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
$where_sql
GROUP BY t.T_TestID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// MAIN QUERY
$sql = $sql_base . $where_sql . "
GROUP BY t.T_TestID
ORDER BY t.T_TestID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
// if (!$qry) {
// $this->output
// ->set_content_type('application/json')
// ->set_output(json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']));
// return;
// }
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$sas_code = $this->input->get('sas_code');
if (empty($sas_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'sas_code parameter is required'
]));
}
$sql = "SELECT
Ais_TestID AS id,
Ais_TestTestSasCode AS sas_code,
Ais_TestJSON AS test_json,
Ais_TestStatus AS test_status,
Ais_TestResponse AS test_response,
Ais_TestLastUpdate AS test_last_update
FROM ais_test
WHERE Ais_TestTestSasCode = ?
ORDER BY Ais_TestLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$sas_code]);
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

View File

@@ -0,0 +1,761 @@
<?php
class Transaction extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Transaction API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data,$userid=999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
$result['success'] = true;
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
return $errors;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
return $errors;
}
return $result;
}
}
function post_transaction($labnum='',$xdate=null)
{
// Auth Login
$login = $this->post_auth();
if (!$login['success']) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 555);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
// Get config
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/transaction_full/transaksi.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken'],
'Authorization: Bearer ' . $dt_config['AisConfigAuthToken']
);
if($labnum == ''){
$xdate = $xdate == null ? date('Y-m-d') : $xdate;
}
// Get data
$sql = "SELECT T_OrderHeaderID,
T_OrderHeaderTotal as Total,
T_OrderHeaderLabNumber as RegID,
Mgm_McuM_BranchID as mgm_mcu_m_branch_id,
M_PatientNoReg as MEDRECID,
T_OrderHeaderDate as Tanggal,
T_OrderHeaderDate as PulangTanggal,
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as PerusahaanID,
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as AsuransiID,
T_PriceHeaderCode as GroupTarifID,
M_PatientName as Nama,
M_PatientIdentifierValue as NIK,
DATE_FORMAT(M_PatientDOB, '%Y-%m-%d %H:%i:%s') as TglLahir,
IF(M_PatientGender = 'male','L','P') as JnsKelamin,
'' as NomorPolis,
'' as NomerJaminan,
'2' as JenisRegID,
IF(Mgm_McuM_BranchID = 100,0,1) as JenisPasienID,
'LAB-WESTERINDO-01' as DepartemenID,
'Y' as Pulang,
'Y' as BolehPulang,
'' as Catatan,
'Y' as Verified,
'LABKLINIK' as KelasID,
M_UserEmail as LoginBuat,
T_OrderHeaderCreated as TanggalBuat,
branch_order.M_BranchAis_branch_code as BranchCode,
CorporateTypeais_pillar_code as PillarCode,
'4569' as SiteCenterCode,
M_UserEmail as VerifiedBy,
T_OrderHeaderCreated as VerifiedDate,
'' as TrxLayanan,
'' as TrxItem,
'' as TrxItemReturn,
'' as RegpasNominal,
'' as Trxtt,
'' as TrxBayar,
'' as TrxLain,
'' as PaketDispenser
FROM t_orderheader
JOIN m_branch branch_order ON branch_order.M_BranchID = T_OrderHeaderM_BranchID
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID
JOIN corporate_type ON CorporateTypeID = CorporateTypeID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID -- AND Mgm_McuID = 1566
JOIN t_priceheader ON Mgm_McuT_PriceHeaderID = T_PriceHeaderID
JOIN m_user ON T_OrderHeaderCreatedUserID = M_UserID
LEFT JOIN cpone_log.ais_transaction ON Ais_TransactionOrderHeaderLabNumber = T_OrderHeaderLabNumber AND
Ais_TransactionStatus = 'success'
WHERE T_OrderHeaderIsActive = 'Y' AND
T_OrderHeaderLabNumber = ? AND
Ais_TransactionID IS NULL
GROUP BY T_OrderHeaderID
LIMIT 100";
$qry = $this->db_onedev->query($sql, array($labnum));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$raw_data = $qry->result_array();
$data = array();
foreach ($raw_data as $key => $row) {
$row['TrxLayanan'] = [];
$row['TrxItem'] = [];
$row['TrxItemReturn'] = [];
$row['RegpasNominal'] = [];
$row['Trxtt'] = null;
$row['TrxBayar'] = [];
$row['TrxLain'] = null;
$row['PaketDispenser'] = null;
$layanan = [];
$sql = "SELECT * FROM (
SELECT T_OrderDetailID as TrxLayananID,
case
when Nat_GroupID = 1 then '1100'
when Nat_GroupID = 2 then '1200'
when Nat_GroupID = 3 then '1200'
when Nat_GroupID = 4 then '1303'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,
T_OrderDetailT_TestName as LayananName,
doctorlab.M_DoctorCode as DokterID,
0 as ShareRS,
0 as ShareDokter,
0 as ShareExternal,
0 as ShareLain2,
'' as PihakExternal,
'' as PihakLain2,
'Percentage' as ShareTipe,
T_OrderDetailPrice as Harga,
1 as Jumlah,
1 as Rate,
'N' as FOC,
T_OrderDetailDiscTotal as Diskon,
'Absolute' as TipeDiskon,
'' as DepartemenID,
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
0 as MarkUpCito,
'N' as Cito,
T_PacketSasCode as PaketID,
'LABKLINIK' as KelasID,
'' as TrxLayananDetail,
'Y' as Tagihkan
FROM t_orderdetail
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
JOIN t_orderdetailorder ON T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID AND
T_OrderDetailOrderIsPacket = 'Y' AND T_OrderDetailOrderIsActive = 'Y'
JOIN t_packet ON T_OrderDetailOrderT_PacketID = T_PacketID
JOIN t_packetdetail ON T_PacketDetailT_PacketID = T_PacketID AND T_PacketDetailT_TestID = T_OrderDetailT_TestID AND
T_PacketDetailIsActive = 'Y'
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
WHERE
T_OrderDetailT_OrderHeaderID = ? AND
T_OrderDetailIsActive = 'Y'
UNION
SELECT T_OrderDetailID as TrxLayananID,
Nat_GroupID as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,
T_OrderDetailT_TestName as LayananName,
doctorlab.M_DoctorCode as DokterID,
0 as ShareRS,
0 as ShareDokter,
0 as ShareExternal,
0 as ShareLain2,
'' as PihakExternal,
'' as PihakLain2,
'Percentage' as ShareTipe,
T_OrderDetailPrice as Harga,
1 as Jumlah,
1 as Rate,
'N' as FOC,
T_OrderDetailDiscTotal as Diskon,
'Absolute' as TipeDiskon,
'' as DepartemenID,
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
0 as MarkUpCito,
'N' as Cito,
'' as PaketID,
'LABKLINIK' as KelasID,
NULL as TrxLayananDetail,
'Y' as Tagihkan
FROM `t_orderdetailorder`
JOIN t_orderdetail ON T_OrderdetailT_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID AND
T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
WHERE `T_OrderDetailOrderT_OrderHeaderID` = ? AND `T_OrderDetailOrderIsPacket` = 'N' AND
T_OrderDetailOrderIsActive = 'Y'
) AS t_orderdetailorder";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID'],$row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$total_layanan_debug = 0;
$layanan = $qry->result_array();
$raw_data[$key]['TrxLayanan'] = [];
if(count($layanan) > 0){
foreach($layanan as $key_layanan => $row_layanan){
$total_layanan_debug += $row_layanan['Harga'];
$layanan[$key_layanan]['TrxLayananDetail'] = [];
$sql = "SELECT M_DoctorCode, M_DoctorID
FROM `so_resultentry`
JOIN t_orderdetail ON ? = So_ResultEntryT_OrderDetailID AND T_OrderDetailIsActive = 'Y'
JOIN m_doctor ON M_DoctorID = So_ResultEntryM_DoctorID AND M_DoctorIsActive = 'Y'
WHERE `So_ResultEntryT_OrderHeaderID` = ? AND
`So_ResultEntryIsActive` = 'Y' AND `So_ResultEntryM_DoctorID` > '0'
LIMIT 1
";
$qry = $this->db_onedev->query($sql, array($row_layanan['TrxLayananID'],$row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'so_resultentry select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_resultentry = $qry->result_array();
if (count($get_resultentry) > 0) {
$row_layanan['DokterID'] = $get_resultentry[0]['M_DoctorCode'];
}
$raw_data[$key]['TrxLayanan'][] = $row_layanan;
}
}
$regpasnominal = [];
$jumlah_layanan_lab = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lab
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID = 1
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lab select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_lab = $qry->row_array();
$jumlah_layanan_lab = $get_layanan_lab['total_layanan_lab'];
$jumlah_layanan_radiologi = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_radiologi
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID = 3
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail radiologi select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_radiologi = $qry->row_array();
$jumlah_layanan_radiologi = $get_layanan_radiologi['total_layanan_radiologi'];
$jumlah_layanan_lain = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lain
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID IN (2,4)
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lain select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_lain = $qry->row_array();
$jumlah_layanan_lain = $get_layanan_lain['total_layanan_lain'];
$total_layanan = 0;
$sql = "SELECT SUM(T_OrderDetailTotal) as total_layanan, Mgm_McuM_BranchID as BranchID
FROM t_orderdetail
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail total layanan select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$total_layanan = $qry->row_array();
$total_layanan = $total_layanan['total_layanan'];
$total_bayar = 0;
$sql = "SELECT F_PaymentTotal as total
FROM f_payment
WHERE F_PaymentT_OrderHeaderID = ? AND F_PaymentIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_total_bayar = $qry->result_array();
if (count($get_total_bayar) > 0) {
foreach($get_total_bayar as $key_total_bayar => $row_total_bayar){
$total_bayar += $row_total_bayar['total'];
}
}
$mgm_mcu_m_branch_id = $row['mgm_mcu_m_branch_id'];
$total_ditanggung_pasien = $mgm_mcu_m_branch_id == 100 ? $total_layanan : 0;
$total_ditanggung_penjamin = $mgm_mcu_m_branch_id == 100 ? 0 : $total_layanan;
$regpasnominal = array(
"BiayaParamedik" => "0.00",
"ParamedikDitanggungPasien" => "0.00",
"ParamedikDitanggungPenjamin" => "0.00",
"BiayaAdministrasi" => "0",
"AdmDitanggungPasien" => "0.00",
"AdmDitanggungPenjamin" => "0.00",
"BiayaMaterai" => "0.00",
"BiayaMateraiDitanggungPasien" => "0.00",
"BiayaMateraiDitanggungPenjamin" => "0.00",
"JumlahLayanan" => $jumlah_layanan_lain,
"JumlahLayananRadiologi" => $jumlah_layanan_radiologi,
"JumlahLayananLaboratorium" => $jumlah_layanan_lab,
"JumlahItem" => 0,
"JumlahItemRetur" => 0,
"JumlahTT" => "0.00",
"JumlahBiayaLain" => "0.00",
"JumlahBayar" => $total_bayar,
"TipeDiskonGlobal" => "Absolute",
"DiskonGlobal" => "0.00",
"TotalDitanggungPasien" => $total_ditanggung_pasien,
"TotalDitanggungPenjamin" => $total_ditanggung_penjamin
);
$raw_data[$key]['RegpasNominal'] = array(
$regpasnominal
);
//echo $total_bayar;
$raw_data[$key]['TrxBayar'] = null;
if($total_bayar > 0){
$sql = "SELECT M_PatientNoReg as MEDRECID,
F_PaymentDetailID as BayarID,
IFNULL(F_PaymentDetailAmount,0) as Jumlah,
F_PaymentDetailCreated as Tanggal,
'Pelunasan' as JenisBayarID,
CONCAT(F_PaymentNumber,'.',F_PaymentDetailID) as KwitansiID,
CONCAT(F_PaymentDetailM_PaymentTypeID,F_PaymentDetailM_BankAccountID) as TipeBayarID,
'N' as Dibatalkan
FROM f_paymentdetail
JOIN f_payment ON F_PaymentDetailF_PaymentID = F_PaymentID AND F_PaymentIsActive = 'Y'
JOIN t_orderheader ON F_PaymentT_OrderHeaderID = T_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
WHERE
F_PaymentT_OrderHeaderID = ? AND F_PaymentDetailIsActive = 'Y'
GROUP BY F_PaymentDetailID";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
//echo $this->db_onedev->last_query();
//exit;
$bayar = $qry->result_array();
$raw_data[$key]['TrxBayar'] = $bayar;
}
$raw_data[$key]['Trxtt'] = null;
$raw_data[$key]['TrxLain'] = null;
$raw_data[$key]['PaketDispenser'] = null;
$errors = [];
//echo json_encode($raw_data[$key]);
//exit;
$result = $this->post_request($url, $raw_data[$key], $headers);
if ($result['status'] == '400') {
$sql = "INSERT INTO ais_transaction(
Ais_TransactionOrderHeaderLabNumber,
Ais_TransactionJson,
Ais_TransactionStatus,
Ais_TransactionResponse,
Ais_TransactionUrl,
Ais_TransactionUserID,
Ais_TransactionCreated
)
VALUES(
?,
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array(
$row['RegID'],
json_encode($raw_data[$key]),
'error',
json_encode($result),
$url,
555
));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'transaction insert', 'query' => $this->db_onedev->last_query(), 'json' => json_encode($result)), 999);
$errors[] = array('RegID' => $row['RegID'], 'error' => $result['message']);
}else{
//echo 'insert ais_transaction';
$sql = "INSERT INTO ais_transaction(
Ais_TransactionOrderHeaderLabNumber,
Ais_TransactionJson,
Ais_TransactionStatus,
Ais_TransactionResponse,
Ais_TransactionUrl,
Ais_TransactionUserID,
Ais_TransactionCreated
)
VALUES(
?,
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array(
$row['RegID'],
json_encode($raw_data[$key]),
'success',
json_encode($result),
$url,
555
));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
}
}
if(count($errors) > 0){
$success = array('status' => 'error', 'message' => 'Gagal Post Transaction', 'errors' => $errors);
echo json_encode($success);
exit;
}else{
$success = array('status' => 'success', 'message' => 'Berhasil Post Transaction');
echo json_encode($success);
exit;
}
}
function get_transaction()
{
// Get id from query parameter
$id = $this->input->get('id');
if (empty($id)) {
$errors = array('status' => 'error', 'message' => 'ID parameter is required');
echo json_encode($errors);
exit;
}
$login = $this->post_auth();
if (!$login['success']) {
$this->error_log(array('fn_name' => 'get_transaction_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/transaksi?id=' . $id;
$result = $this->get_request($url);
if (!$result['success']) {
$this->error_log(array('fn_name' => 'get_transaction', 'message' => 'failed get transaction', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Get Transaction');
echo json_encode($errors);
exit;
}
$data = $result['response']['data'] ?? null;
// $data = json_encode($data);
$success = array('status' => 'success', 'message' => 'Berhasil Get Transaction', 'data' => $data);
echo json_encode($success);
exit;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
@baseUrl = https://cpone.aplikasi.web.id/one-api/ais
# @baseUrl = http://his.sismedika.online:4081/westerindo_ais
POST {{baseUrl}}/transaction/post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Re Post Transaction by Labnumber
POST {{baseUrl}}/transaction/re_post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Medrec by No Reg
POST {{baseUrl}}/masterdata/post_medrec_by_noreg
Content-Type: application/json
{
"noreg": "CP2406200033"
}
### GET Medrec by No Reg
POST {{baseUrl}}/masterdata/get_medrec_by_noreg
Content-Type: application/json
{
"noreg": "CP2406200033"
}
### GET Perusahaan by Code
POST {{baseUrl}}/masterdata/get_perusahaan_by_code
Content-Type: application/json
{
"corporate_code": "CP0029"
}
### GET Doctor by Code
POST {{baseUrl}}/masterdata/get_doctor_by_code
Content-Type: application/json
{
"doctor_code": "D240700001"
}
### POST Doctor by Code
POST {{baseUrl}}/masterdata/post_doctor_by_code
Content-Type: application/json
{
"doctor_code": "D240700001"
}
### POST Jenis Layanan
POST {{baseUrl}}/post_jenis_layanan
### GET Jenis Perusahaan
GET {{baseUrl}}/get_jenis_perusahaan?id=1
### POST Jenis Perusahaan
POST {{baseUrl}}/post_jenis_perusahaan
### POST Perusahaan
POST {{baseUrl}}/post_perusahaan
### GET Perusahaan
GET {{baseUrl}}/get_perusahaan
### POST Perusahaan Bulk
POST {{baseUrl}}/post_perusahaan_bulk
### GET Jenis Layanan
GET {{baseUrl}}/get_jenislayanan
### Post Jenis Layanan
Post {{baseUrl}}/post_jenislayanan
### GET Layanan
GET {{baseUrl}}/get_layanan
### Post Layanan
POST {{baseUrl}}/post_layanan
### GET Group Layanan
GET {{baseUrl}}/get_grouplayanan
### Post Group Layanan
POST {{baseUrl}}/post_grouplayanan
### GET Departemen
GET {{baseUrl}}/get_departemen
### Post Departement
POST {{baseUrl}}/post_departemen
### GET Departement
GET {{baseUrl}}/get_medrec
### Post Departement
POST {{baseUrl}}/post_medrec
### GET Transaction
GET {{baseUrl}}/get_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction?date=2024-02-08&limit=1&offset=0
### GET Payment
GET {{baseUrl}}/get_payment?id=6

View File

@@ -0,0 +1,181 @@
<?php
class Bridging extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data,$userid=999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
$result['success'] = true;
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
echo json_encode($errors);
exit;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
$success = array('status' => 'success','message' => 'Berhasil Login');
echo json_encode($success);
exit;
}
}
}

View File

@@ -0,0 +1,417 @@
<?php
class Corporate extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_corporate()
{
// Ambil parameter
$corporate_name = $this->input->get('corporate_name');
$corporate_status = $this->input->get('corporate_status');
$corporate_code = $this->input->get('corporate_code');
$where_query = "WHERE c.CorporateIsActive = 'Y'";
if ($corporate_name || $corporate_code) {
$where_query .= "AND ( c.CorporateName LIKE '%{$corporate_code}%' OR c.CorporateCode LIKE '%{$corporate_code}%' ) ";
}
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$sql_base = "SELECT
DISTINCT c.CorporateID AS corporate_id,
0 as T_OrderHeaderID,
c.CorporateName AS corporate_name,
c.CorporateCode AS corporate_code,
c.CorporateAddress AS corporate_address,
c.CorporateEmail AS corporate_email,
c.CorporatePhone AS corporate_phone,
ais_pillar_name,
'' as Ais_CorporateStatus ,
'' AS corporate_status,
'' AS Ais_CorporateID
FROM corporate c
LEFT JOIN corporate_type ON CorporateCorporateTypeID = CorporateTypeID
LEFT JOIN ais_pillar ON CorporateTypeais_pillar_code = ais_pillar_code
$where_query
GROUP BY c.CorporateID
ORDER BY c.CorporateID ASC
LIMIT $limit OFFSET $offset";
//echo $sql_base;
$params = [];
// Count total records for pagination
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT
DISTINCT c.CorporateID AS corporate_id
FROM corporate c
$where_query
) AS x
";
$qry_count = $this->db_onedev->query($count_sql);
// echo $this->db_onedev->last_query();
$total = $qry_count->row()->total ?? 0;
$qry = $this->db_onedev->query($sql_base);
// echo $this->db_onedev->last_query();
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
if($data){
foreach($data as $k => $d){
$data[$k]['corporate_status'] = 'N';
$data[$k]['Ais_CorporateStatus'] = null;
$data[$k]['Ais_CorporateID'] = null;
$sql = "SELECT *
FROM ".$this->db_log->database.".ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC
LIMIT 1";
$qry_corporate = $this->db_log->query($sql, [$d['corporate_code']]);
if($qry_corporate){
$data[$k]['corporate_status'] = 'N';
$status = $qry_corporate->row()->Ais_CorporateStatus;
if($status && $status == 'SUCCESS'){
$data[$k]['corporate_status'] = 'Y';
}
$data[$k]['Ais_CorporateStatus'] = $qry_corporate->row()->Ais_CorporateStatus;
$data[$k]['Ais_CorporateID'] = $qry_corporate->row()->Ais_CorporateID;
}
}
}
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
// Ambil corporate_code dari query parameter
$corporate_code = $this->input->get('corporate_code');
if (empty($corporate_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'corporate_code parameter is required'
]));
}
$sql = "SELECT
Ais_CorporateID AS id,
Ais_CorporateCorporateCode AS corporate_code,
Ais_CorporateJSON AS json,
Ais_CorporateStatus AS status,
Ais_CorporateResponse AS response,
Ais_CorporateLastUpdate AS last_update,
Ais_CorporateUserID AS user_id
FROM ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$corporate_code]);
$results = $qry->result_array();
if ($results) {
foreach ($results as &$r) {
$r['json'] = json_decode($r['json']);
$r['response'] = json_decode($r['response']);
}
unset($r);
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'success',
'data' => $results
]));
}
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => "No data found for corporate_code: $corporate_code"
]));
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,421 @@
<?php
class Packet extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_packet()
{
$sql_base = "SELECT
p.T_PacketID,
p.T_PacketName AS packet_name,
p.T_PacketType,
p.T_PacketPrice,
p.T_PacketSasCode AS packet_code,
p.T_PacketStartDate,
p.T_PacketEndDate,
ph.T_PriceHeaderID,
ph.T_PriceHeaderName AS priceheader_name,
ph.T_PriceHeaderCode AS priceheader_code,
ph.T_PriceHeaderStartDate,
ph.T_PriceHeaderEndDate,
ap.Ais_PacketStatus AS Ais_PacketStatus,
IF(MAX(ap.Ais_PacketID) IS NULL, 'N', 'Y') AS packet_status
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
";
// Ambil parameter
$packet_name = $this->input->get('packet_name');
$packet_code = $this->input->get('packet_code');
$priceheader_name = $this->input->get('priceheader_name');
$priceheader_code = $this->input->get('priceheader_code');
$packet_status = $this->input->get('packet_status'); // Y / N
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [];
// Status packet Y/N dari ais_packet
if ($packet_status === 'Y') {
$where_clauses[] = "ap.Ais_PacketID IS NOT NULL";
} elseif ($packet_status === 'N') {
$where_clauses[] = "ap.Ais_PacketID IS NULL";
}
// Filter by packet name
if ($packet_name) {
$where_clauses[] = "p.T_PacketName LIKE ?";
$params[] = "%$packet_name%";
}
// Filter by packet code
if ($packet_code) {
$where_clauses[] = "p.T_PacketSasCode LIKE ?";
$params[] = "%$packet_code%";
}
// Filter by priceheader name
if ($priceheader_name) {
$where_clauses[] = "ph.T_PriceHeaderName LIKE ?";
$params[] = "%$priceheader_name%";
}
// Filter by priceheader code
if ($priceheader_code) {
$where_clauses[] = "ph.T_PriceHeaderCode LIKE ?";
$params[] = "%$priceheader_code%";
}
// Build WHERE
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// Count total records for pagination
// Count distinct packet ID
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT p.T_PacketID
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
$where_sql
GROUP BY p.T_PacketID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// Main SQL
$sql = $sql_base . $where_sql . "
GROUP BY p.T_PacketID
ORDER BY p.T_PacketID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring packet.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring packet.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$packet_code = $this->input->get('packet_code');
if (empty($packet_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error', 'message' => 'packet_code parameter is required']));
}
$sql = "SELECT
Ais_PacketT_PacketSasCode AS packet_code,
Ais_PacketLastUpdated AS packet_update,
Ais_PacketJson AS packet_json,
Ais_PacketStatus AS status,
Ais_PacketResponse AS packet_response
FROM ais_packet
WHERE Ais_PacketT_PacketSasCode = ?
ORDER BY Ais_PacketLastUpdated DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, array($packet_code));
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

View File

@@ -0,0 +1,406 @@
<?php
class Patient extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_patient()
{
$sql_base = "SELECT
oh.T_OrderHeaderID,
oh.T_OrderHeaderM_PatientID AS patient_id,
p.M_PatientName AS patient_name,
p.M_PatientNoReg AS patient_noreq,
p.M_PatientGender AS patient_gender,
p.M_PatientDOB AS patient_birthdate,
p.M_PatientHp AS patient_hp,
p.M_PatientEmail AS patient_email,
p.M_PatientIdentifierValue AS patient_identifier,
p.M_PatientNIP AS patient_nip,
p.M_PatientJob AS patient_job,
p.M_PatientPosisi AS patient_posisi,
p.M_PatientDivisi AS pasient_divisi,
am.Ais_MedrecStatus AS medrec_status,
-- STATUS AIS
IF(MAX(am.Ais_MedrecID) IS NULL, 'N', 'Y') AS medrec_status
FROM t_orderheader oh
JOIN m_patient p
ON p.M_PatientID = oh.T_OrderHeaderM_PatientID
LEFT JOIN ".$this->db_log->database.".ais_medrec am
ON am.Ais_MedrecPatientNoReg = p.M_PatientNoReg
";
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
// Filter
$patient_name = $this->input->get('patient_name');
$patient_noreq = $this->input->get('patient_noreq');
$medrec_status = $this->input->get('medrec_status');
$params = [];
$where_clauses = [];
if ($medrec_status === 'Y') {
$where_clauses[] = "am.Ais_MedrecID IS NOT NULL";
} elseif ($medrec_status === 'N') {
$where_clauses[] = "am.Ais_MedrecID IS NULL";
}
if ($patient_name) {
$where_clauses[] = "p.M_PatientName LIKE ?";
$params[] = "%$patient_name%";
}
if ($patient_noreq) {
$where_clauses[] = "p.M_PatientNoReg LIKE ?";
$params[] = "%$patient_noreq%";
}
// WHERE builder
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// Count total rows
$count_sql = "SELECT COUNT(DISTINCT oh.T_OrderHeaderM_PatientID) AS total
FROM t_orderheader oh
JOIN m_patient p
ON p.M_PatientID = oh.T_OrderHeaderM_PatientID
LEFT JOIN ".$this->db_log->database.".ais_medrec am
ON am.Ais_MedrecPatientNoReg = p.M_PatientNoReg
$where_sql";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// Main query
$sql = $sql_base . $where_sql . "
GROUP BY oh.T_OrderHeaderM_PatientID
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data pasien.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data pasien.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
// Ambil patient_noreg dari query parameter
$patient_noreg = $this->input->get('patient_noreg');
if (empty($patient_noreg)) {
$this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'patient_noreg parameter is required'
]));
return;
}
$sql = "SELECT
Ais_MedrecPatientNoReg AS patient_noreg,
Ais_MedrecStatus AS status,
Ais_MedrecJSON AS json,
Ais_MedrecResponse AS response,
Ais_MedrecCreated AS created,
Ais_MedrecUserID AS user_id
FROM ais_medrec
WHERE Ais_MedrecPatientNoReg = ?";
// Query menggunakan db_log
$qry = $this->db_log->query($sql, array($patient_noreg));
// Ambil multiple rows
$results = $qry->result_array();
if ($results) {
foreach ($results as &$result) {
$result['json'] = json_decode($result['json']);
$result['response'] = json_decode($result['response']);
}
unset($result);
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode([
'status' => 'error',
'message' => 'No data found for the given patient_noreq.'
]);
}
exit;
}
}

View File

@@ -0,0 +1,269 @@
<?php
class Test extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Transaction API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* Generic PUT request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
return $errors;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
return $errors;
}
return $result;
}
}
function monitoring_test()
{
// SQL base
$sql_base = "SELECT
t.T_TestID,
t.T_TestCode AS test_code,
t.T_TestSasCode AS sas_code,
t.T_TestName AS test_name,
t.T_TestIsPrice AS is_price,
t.T_TestIsResult AS is_result,
t.T_TestIsActive AS test_active,
at.Ais_TestStatus AS Ais_TestStatus,
at.Ais_TestLastUpdate AS test_last_update,
IF (at.Ais_TestID IS NULL, 'N', 'Y') AS test_status
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestStatus, Ais_TestLastUpdate, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
";
// Ambil parameter
$test_name = $this->input->get('test_name'); // TRUE for XSS filtering
$sas_code = $this->input->get('sas_code');
$test_code = $this->input->get('test_code');
$test_status = $this->input->get('test_status');
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [
"t.T_TestIsActive = 'Y'"
];
// Status filter
if ($test_status === 'Y') {
$where_clauses[] = "at.Ais_TestID IS NOT NULL";
} elseif ($test_status === 'N') {
$where_clauses[] = "at.Ais_TestID IS NULL";
}
if ($test_name) {
$where_clauses[] = "t.T_TestName LIKE ?";
$params[] = "%$test_name%";
}
if ($test_code) {
$where_clauses[] = "t.T_TestCode LIKE ?";
$params[] = "%$test_code%";
}
if ($sas_code) {
$where_clauses[] = "t.T_TestSasCode LIKE ?";
$params[] = "%$sas_code%";
}
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// COUNT
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT t.T_TestID
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
$where_sql
GROUP BY t.T_TestID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// MAIN QUERY
$sql = $sql_base . $where_sql . "
GROUP BY t.T_TestID
ORDER BY t.T_TestID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
// if (!$qry) {
// $this->output
// ->set_content_type('application/json')
// ->set_output(json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']));
// return;
// }
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$sas_code = $this->input->get('sas_code');
if (empty($sas_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'sas_code parameter is required'
]));
}
$sql = "SELECT
Ais_TestID AS id,
Ais_TestTestSasCode AS sas_code,
Ais_TestJSON AS test_json,
Ais_TestStatus AS test_status,
Ais_TestResponse AS test_response,
Ais_TestLastUpdate AS test_last_update
FROM ais_test
WHERE Ais_TestTestSasCode = ?
ORDER BY Ais_TestLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$sas_code]);
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,761 @@
<?php
class Transaction extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Transaction API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data,$userid=999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
$result['success'] = true;
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
return $errors;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
return $errors;
}
return $result;
}
}
function post_transaction($labnum='',$xdate=null)
{
// Auth Login
$login = $this->post_auth();
if (!$login['success']) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 555);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
// Get config
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/transaction_full/transaksi.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken'],
'Authorization: Bearer ' . $dt_config['AisConfigAuthToken']
);
if($labnum == ''){
$xdate = $xdate == null ? date('Y-m-d') : $xdate;
}
// Get data
$sql = "SELECT T_OrderHeaderID,
T_OrderHeaderTotal as Total,
T_OrderHeaderLabNumber as RegID,
Mgm_McuM_BranchID as mgm_mcu_m_branch_id,
M_PatientNoReg as MEDRECID,
T_OrderHeaderDate as Tanggal,
T_OrderHeaderDate as PulangTanggal,
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as PerusahaanID,
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as AsuransiID,
T_PriceHeaderCode as GroupTarifID,
M_PatientName as Nama,
M_PatientIdentifierValue as NIK,
DATE_FORMAT(M_PatientDOB, '%Y-%m-%d %H:%i:%s') as TglLahir,
IF(M_PatientGender = 'male','L','P') as JnsKelamin,
'' as NomorPolis,
'' as NomerJaminan,
'2' as JenisRegID,
IF(Mgm_McuM_BranchID = 100,0,1) as JenisPasienID,
'LAB-WESTERINDO-01' as DepartemenID,
'Y' as Pulang,
'Y' as BolehPulang,
'' as Catatan,
'Y' as Verified,
'LABKLINIK' as KelasID,
M_UserEmail as LoginBuat,
T_OrderHeaderCreated as TanggalBuat,
branch_order.M_BranchAis_branch_code as BranchCode,
CorporateTypeais_pillar_code as PillarCode,
'4569' as SiteCenterCode,
M_UserEmail as VerifiedBy,
T_OrderHeaderCreated as VerifiedDate,
'' as TrxLayanan,
'' as TrxItem,
'' as TrxItemReturn,
'' as RegpasNominal,
'' as Trxtt,
'' as TrxBayar,
'' as TrxLain,
'' as PaketDispenser
FROM t_orderheader
JOIN m_branch branch_order ON branch_order.M_BranchID = T_OrderHeaderM_BranchID
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID
JOIN corporate_type ON CorporateTypeID = CorporateTypeID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID -- AND Mgm_McuID = 1566
JOIN t_priceheader ON Mgm_McuT_PriceHeaderID = T_PriceHeaderID
JOIN m_user ON T_OrderHeaderCreatedUserID = M_UserID
LEFT JOIN cpone_log.ais_transaction ON Ais_TransactionOrderHeaderLabNumber = T_OrderHeaderLabNumber AND
Ais_TransactionStatus = 'success'
WHERE T_OrderHeaderIsActive = 'Y' AND
T_OrderHeaderLabNumber = ? AND
Ais_TransactionID IS NULL
GROUP BY T_OrderHeaderID
LIMIT 100";
$qry = $this->db_onedev->query($sql, array($labnum));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$raw_data = $qry->result_array();
$data = array();
foreach ($raw_data as $key => $row) {
$row['TrxLayanan'] = [];
$row['TrxItem'] = [];
$row['TrxItemReturn'] = [];
$row['RegpasNominal'] = [];
$row['Trxtt'] = null;
$row['TrxBayar'] = [];
$row['TrxLain'] = null;
$row['PaketDispenser'] = null;
$layanan = [];
$sql = "SELECT * FROM (
SELECT T_OrderDetailID as TrxLayananID,
case
when Nat_GroupID = 1 then '1100'
when Nat_GroupID = 2 then '1200'
when Nat_GroupID = 3 then '1200'
when Nat_GroupID = 4 then '1303'
end as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,
T_OrderDetailT_TestName as LayananName,
doctorlab.M_DoctorCode as DokterID,
0 as ShareRS,
0 as ShareDokter,
0 as ShareExternal,
0 as ShareLain2,
'' as PihakExternal,
'' as PihakLain2,
'Percentage' as ShareTipe,
T_OrderDetailPrice as Harga,
1 as Jumlah,
1 as Rate,
'N' as FOC,
T_OrderDetailDiscTotal as Diskon,
'Absolute' as TipeDiskon,
'' as DepartemenID,
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
0 as MarkUpCito,
'N' as Cito,
T_PacketSasCode as PaketID,
'LABKLINIK' as KelasID,
'' as TrxLayananDetail,
'Y' as Tagihkan
FROM t_orderdetail
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
JOIN t_orderdetailorder ON T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID AND
T_OrderDetailOrderIsPacket = 'Y' AND T_OrderDetailOrderIsActive = 'Y'
JOIN t_packet ON T_OrderDetailOrderT_PacketID = T_PacketID
JOIN t_packetdetail ON T_PacketDetailT_PacketID = T_PacketID AND T_PacketDetailT_TestID = T_OrderDetailT_TestID AND
T_PacketDetailIsActive = 'Y'
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
WHERE
T_OrderDetailT_OrderHeaderID = ? AND
T_OrderDetailIsActive = 'Y'
UNION
SELECT T_OrderDetailID as TrxLayananID,
Nat_GroupID as ProfitCostCenterCode,
'' as TrxDepartemenID,
T_OrderDetailCreated as TanggalBuat,
T_OrderDetailT_TestSasCode as LayananID,
T_OrderDetailT_TestName as LayananName,
doctorlab.M_DoctorCode as DokterID,
0 as ShareRS,
0 as ShareDokter,
0 as ShareExternal,
0 as ShareLain2,
'' as PihakExternal,
'' as PihakLain2,
'Percentage' as ShareTipe,
T_OrderDetailPrice as Harga,
1 as Jumlah,
1 as Rate,
'N' as FOC,
T_OrderDetailDiscTotal as Diskon,
'Absolute' as TipeDiskon,
'' as DepartemenID,
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
0 as MarkUpCito,
'N' as Cito,
'' as PaketID,
'LABKLINIK' as KelasID,
NULL as TrxLayananDetail,
'Y' as Tagihkan
FROM `t_orderdetailorder`
JOIN t_orderdetail ON T_OrderdetailT_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID AND
T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
WHERE `T_OrderDetailOrderT_OrderHeaderID` = ? AND `T_OrderDetailOrderIsPacket` = 'N' AND
T_OrderDetailOrderIsActive = 'Y'
) AS t_orderdetailorder";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID'],$row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$total_layanan_debug = 0;
$layanan = $qry->result_array();
$raw_data[$key]['TrxLayanan'] = [];
if(count($layanan) > 0){
foreach($layanan as $key_layanan => $row_layanan){
$total_layanan_debug += $row_layanan['Harga'];
$layanan[$key_layanan]['TrxLayananDetail'] = [];
$sql = "SELECT M_DoctorCode, M_DoctorID
FROM `so_resultentry`
JOIN t_orderdetail ON ? = So_ResultEntryT_OrderDetailID AND T_OrderDetailIsActive = 'Y'
JOIN m_doctor ON M_DoctorID = So_ResultEntryM_DoctorID AND M_DoctorIsActive = 'Y'
WHERE `So_ResultEntryT_OrderHeaderID` = ? AND
`So_ResultEntryIsActive` = 'Y' AND `So_ResultEntryM_DoctorID` > '0'
LIMIT 1
";
$qry = $this->db_onedev->query($sql, array($row_layanan['TrxLayananID'],$row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'so_resultentry select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_resultentry = $qry->result_array();
if (count($get_resultentry) > 0) {
$row_layanan['DokterID'] = $get_resultentry[0]['M_DoctorCode'];
}
$raw_data[$key]['TrxLayanan'][] = $row_layanan;
}
}
$regpasnominal = [];
$jumlah_layanan_lab = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lab
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID = 1
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lab select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_lab = $qry->row_array();
$jumlah_layanan_lab = $get_layanan_lab['total_layanan_lab'];
$jumlah_layanan_radiologi = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_radiologi
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID = 3
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail radiologi select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_radiologi = $qry->row_array();
$jumlah_layanan_radiologi = $get_layanan_radiologi['total_layanan_radiologi'];
$jumlah_layanan_lain = 0;
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lain
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
Nat_GroupID IN (2,4)
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lain select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_layanan_lain = $qry->row_array();
$jumlah_layanan_lain = $get_layanan_lain['total_layanan_lain'];
$total_layanan = 0;
$sql = "SELECT SUM(T_OrderDetailTotal) as total_layanan, Mgm_McuM_BranchID as BranchID
FROM t_orderdetail
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail total layanan select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$total_layanan = $qry->row_array();
$total_layanan = $total_layanan['total_layanan'];
$total_bayar = 0;
$sql = "SELECT F_PaymentTotal as total
FROM f_payment
WHERE F_PaymentT_OrderHeaderID = ? AND F_PaymentIsActive = 'Y'
";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$get_total_bayar = $qry->result_array();
if (count($get_total_bayar) > 0) {
foreach($get_total_bayar as $key_total_bayar => $row_total_bayar){
$total_bayar += $row_total_bayar['total'];
}
}
$mgm_mcu_m_branch_id = $row['mgm_mcu_m_branch_id'];
$total_ditanggung_pasien = $mgm_mcu_m_branch_id == 100 ? $total_layanan : 0;
$total_ditanggung_penjamin = $mgm_mcu_m_branch_id == 100 ? 0 : $total_layanan;
$regpasnominal = array(
"BiayaParamedik" => "0.00",
"ParamedikDitanggungPasien" => "0.00",
"ParamedikDitanggungPenjamin" => "0.00",
"BiayaAdministrasi" => "0",
"AdmDitanggungPasien" => "0.00",
"AdmDitanggungPenjamin" => "0.00",
"BiayaMaterai" => "0.00",
"BiayaMateraiDitanggungPasien" => "0.00",
"BiayaMateraiDitanggungPenjamin" => "0.00",
"JumlahLayanan" => $jumlah_layanan_lain,
"JumlahLayananRadiologi" => $jumlah_layanan_radiologi,
"JumlahLayananLaboratorium" => $jumlah_layanan_lab,
"JumlahItem" => 0,
"JumlahItemRetur" => 0,
"JumlahTT" => "0.00",
"JumlahBiayaLain" => "0.00",
"JumlahBayar" => $total_bayar,
"TipeDiskonGlobal" => "Absolute",
"DiskonGlobal" => "0.00",
"TotalDitanggungPasien" => $total_ditanggung_pasien,
"TotalDitanggungPenjamin" => $total_ditanggung_penjamin
);
$raw_data[$key]['RegpasNominal'] = array(
$regpasnominal
);
//echo $total_bayar;
$raw_data[$key]['TrxBayar'] = null;
if($total_bayar > 0){
$sql = "SELECT M_PatientNoReg as MEDRECID,
F_PaymentDetailID as BayarID,
IFNULL(F_PaymentDetailAmount,0) as Jumlah,
F_PaymentDetailCreated as Tanggal,
'Pelunasan' as JenisBayarID,
CONCAT(F_PaymentNumber,'.',F_PaymentDetailID) as KwitansiID,
CONCAT(F_PaymentDetailM_PaymentTypeID,F_PaymentDetailM_BankAccountID) as TipeBayarID,
'N' as Dibatalkan
FROM f_paymentdetail
JOIN f_payment ON F_PaymentDetailF_PaymentID = F_PaymentID AND F_PaymentIsActive = 'Y'
JOIN t_orderheader ON F_PaymentT_OrderHeaderID = T_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
WHERE
F_PaymentT_OrderHeaderID = ? AND F_PaymentDetailIsActive = 'Y'
GROUP BY F_PaymentDetailID";
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
//echo $this->db_onedev->last_query();
//exit;
$bayar = $qry->result_array();
$raw_data[$key]['TrxBayar'] = $bayar;
}
$raw_data[$key]['Trxtt'] = null;
$raw_data[$key]['TrxLain'] = null;
$raw_data[$key]['PaketDispenser'] = null;
$errors = [];
//echo json_encode($raw_data[$key]);
//exit;
$result = $this->post_request($url, $raw_data[$key], $headers);
if ($result['status'] == '400') {
$sql = "INSERT INTO ais_transaction(
Ais_TransactionOrderHeaderLabNumber,
Ais_TransactionJson,
Ais_TransactionStatus,
Ais_TransactionResponse,
Ais_TransactionUrl,
Ais_TransactionUserID,
Ais_TransactionCreated
)
VALUES(
?,
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array(
$row['RegID'],
json_encode($raw_data[$key]),
'error',
json_encode($result),
$url,
555
));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'transaction insert', 'query' => $this->db_onedev->last_query(), 'json' => json_encode($result)), 999);
$errors[] = array('RegID' => $row['RegID'], 'error' => $result['message']);
}else{
//echo 'insert ais_transaction';
$sql = "INSERT INTO ais_transaction(
Ais_TransactionOrderHeaderLabNumber,
Ais_TransactionJson,
Ais_TransactionStatus,
Ais_TransactionResponse,
Ais_TransactionUrl,
Ais_TransactionUserID,
Ais_TransactionCreated
)
VALUES(
?,
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array(
$row['RegID'],
json_encode($raw_data[$key]),
'success',
json_encode($result),
$url,
555
));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
}
}
if(count($errors) > 0){
$success = array('status' => 'error', 'message' => 'Gagal Post Transaction', 'errors' => $errors);
echo json_encode($success);
exit;
}else{
$success = array('status' => 'success', 'message' => 'Berhasil Post Transaction');
echo json_encode($success);
exit;
}
}
function get_transaction()
{
// Get id from query parameter
$id = $this->input->get('id');
if (empty($id)) {
$errors = array('status' => 'error', 'message' => 'ID parameter is required');
echo json_encode($errors);
exit;
}
$login = $this->post_auth();
if (!$login['success']) {
$this->error_log(array('fn_name' => 'get_transaction_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
}
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/transaksi?id=' . $id;
$result = $this->get_request($url);
if (!$result['success']) {
$this->error_log(array('fn_name' => 'get_transaction', 'message' => 'failed get transaction', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Get Transaction');
echo json_encode($errors);
exit;
}
$data = $result['response']['data'] ?? null;
// $data = json_encode($data);
$success = array('status' => 'success', 'message' => 'Berhasil Get Transaction', 'data' => $data);
echo json_encode($success);
exit;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
@baseUrl = https://cpone.aplikasi.web.id/one-api/ais
# @baseUrl = http://his.sismedika.online:4081/westerindo_ais
POST {{baseUrl}}/transaction/post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Re Post Transaction by Labnumber
POST {{baseUrl}}/transaction/re_post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Medrec by No Reg
POST {{baseUrl}}/masterdata/post_medrec_by_noreg
Content-Type: application/json
{
"noreg": "CP2406200033"
}
### GET Medrec by No Reg
POST {{baseUrl}}/masterdata/get_medrec_by_noreg
Content-Type: application/json
{
"noreg": "CP2406200033"
}
### GET Perusahaan by Code
POST {{baseUrl}}/masterdata/get_perusahaan_by_code
Content-Type: application/json
{
"corporate_code": "CP0029"
}
### GET Doctor by Code
POST {{baseUrl}}/masterdata/get_doctor_by_code
Content-Type: application/json
{
"doctor_code": "D240700001"
}
### POST Doctor by Code
POST {{baseUrl}}/masterdata/post_doctor_by_code
Content-Type: application/json
{
"doctor_code": "D240700001"
}
### POST Jenis Layanan
POST {{baseUrl}}/post_jenis_layanan
### GET Jenis Perusahaan
GET {{baseUrl}}/get_jenis_perusahaan?id=1
### POST Jenis Perusahaan
POST {{baseUrl}}/post_jenis_perusahaan
### POST Perusahaan
POST {{baseUrl}}/post_perusahaan
### GET Perusahaan
GET {{baseUrl}}/get_perusahaan
### POST Perusahaan Bulk
POST {{baseUrl}}/post_perusahaan_bulk
### GET Jenis Layanan
GET {{baseUrl}}/get_jenislayanan
### Post Jenis Layanan
Post {{baseUrl}}/post_jenislayanan
### GET Layanan
GET {{baseUrl}}/get_layanan
### Post Layanan
POST {{baseUrl}}/post_layanan
### GET Group Layanan
GET {{baseUrl}}/get_grouplayanan
### Post Group Layanan
POST {{baseUrl}}/post_grouplayanan
### GET Departemen
GET {{baseUrl}}/get_departemen
### Post Departement
POST {{baseUrl}}/post_departemen
### GET Departement
GET {{baseUrl}}/get_medrec
### Post Departement
POST {{baseUrl}}/post_medrec
### GET Transaction
GET {{baseUrl}}/get_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction?date=2024-02-08&limit=1&offset=0
### GET Payment
GET {{baseUrl}}/get_payment?id=6

View File

@@ -0,0 +1,52 @@
@baseUrl = https://devcpone.aplikasi.web.id/one-api/ais
@contentType = application/json
### ============================================================
### LIST TRANSACTION
### ============================================================
### Request tanpa parameter tanggal (menggunakan default)
GET {{baseUrl}}/transaction/monitoring_transaction/monitoring_transaction?page=1&limit=10
### Request dengan parameter tanggal
GET {{baseUrl}}/transaction/monitoring_transaction?start_date=2025-08-01&end_date=2025-08-05
### Request dengan parameter tanggal dan status transaksi
GET {{baseUrl}}/transaction/monitoring_transaction?ais_status=Y
### Request dengan parameter corporate_id
GET {{baseUrl}}/transaction/monitoring_transaction?corporate_id=53
### Request dengan parameter patient_name
GET {{baseUrl}}/transaction/monitoring_transaction?patient_name=Dony Wahyu Andreansyah
### Request dengan parameter lab_number
GET {{baseUrl}}/transaction/monitoring_transaction?lab_number=H2408010111
### Request get_corporate
GET {{baseUrl}}/transaction/get_corporate
### Request get_json_response dengan parameter lab_number
GET {{baseUrl}}/transaction/get_json_response?lab_number=H2408010111
### Request monitoring_patient berdasarkan halaman
GET {{baseUrl}}/patient/monitoring_patient?page=1
### Request monitoring_patient berdasarkan API
GET {{baseUrl}}/patient/monitoring_patient?page=1&patient_name=Pasien 5 Karyawan
### Request monitoring_patient
GET {{baseUrl}}/patient/monitoring_patient?page=1&patient_noreq=CP2509010001
###
GET {{baseUrl}}/patient/monitoring_patient?medrec_status=N
###
GET {{baseUrl}}/patient/get_json_response?patient_noreg=CP2509010001
###
GET {{baseUrl}}/corporate/monitoring_corporate?page=1

View File

@@ -0,0 +1,181 @@
<?php
class Bridging extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data,$userid=999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
$result['success'] = true;
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
echo json_encode($errors);
exit;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
$success = array('status' => 'success','message' => 'Berhasil Login');
echo json_encode($success);
exit;
}
}
}

View File

@@ -0,0 +1,417 @@
<?php
class Corporate extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_corporate()
{
// Ambil parameter
$corporate_name = $this->input->get('corporate_name');
$corporate_status = $this->input->get('corporate_status');
$corporate_code = $this->input->get('corporate_code');
$where_query = "WHERE c.CorporateIsActive = 'Y'";
if ($corporate_name || $corporate_code) {
$where_query .= "AND ( c.CorporateName LIKE '%{$corporate_code}%' OR c.CorporateCode LIKE '%{$corporate_code}%' ) ";
}
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$sql_base = "SELECT
DISTINCT c.CorporateID AS corporate_id,
0 as T_OrderHeaderID,
c.CorporateName AS corporate_name,
c.CorporateCode AS corporate_code,
c.CorporateAddress AS corporate_address,
c.CorporateEmail AS corporate_email,
c.CorporatePhone AS corporate_phone,
ais_pillar_name,
'' as Ais_CorporateStatus ,
'' AS corporate_status,
'' AS Ais_CorporateID
FROM corporate c
LEFT JOIN corporate_type ON CorporateCorporateTypeID = CorporateTypeID
LEFT JOIN ais_pillar ON CorporateTypeais_pillar_code = ais_pillar_code
$where_query
GROUP BY c.CorporateID
ORDER BY c.CorporateID ASC
LIMIT $limit OFFSET $offset";
//echo $sql_base;
$params = [];
// Count total records for pagination
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT
DISTINCT c.CorporateID AS corporate_id
FROM corporate c
$where_query
) AS x
";
$qry_count = $this->db_onedev->query($count_sql);
// echo $this->db_onedev->last_query();
$total = $qry_count->row()->total ?? 0;
$qry = $this->db_onedev->query($sql_base);
// echo $this->db_onedev->last_query();
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
if($data){
foreach($data as $k => $d){
$data[$k]['corporate_status'] = 'N';
$data[$k]['Ais_CorporateStatus'] = null;
$data[$k]['Ais_CorporateID'] = null;
$sql = "SELECT *
FROM ".$this->db_log->database.".ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC
LIMIT 1";
$qry_corporate = $this->db_log->query($sql, [$d['corporate_code']]);
if($qry_corporate){
$data[$k]['corporate_status'] = 'N';
$status = $qry_corporate->row()->Ais_CorporateStatus;
if($status && $status == 'SUCCESS'){
$data[$k]['corporate_status'] = 'Y';
}
$data[$k]['Ais_CorporateStatus'] = $qry_corporate->row()->Ais_CorporateStatus;
$data[$k]['Ais_CorporateID'] = $qry_corporate->row()->Ais_CorporateID;
}
}
}
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
// Ambil corporate_code dari query parameter
$corporate_code = $this->input->get('corporate_code');
if (empty($corporate_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'corporate_code parameter is required'
]));
}
$sql = "SELECT
Ais_CorporateID AS id,
Ais_CorporateCorporateCode AS corporate_code,
Ais_CorporateJSON AS json,
Ais_CorporateStatus AS status,
Ais_CorporateResponse AS response,
Ais_CorporateLastUpdate AS last_update,
Ais_CorporateUserID AS user_id
FROM ais_corporate
WHERE Ais_CorporateCorporateCode = ?
ORDER BY Ais_CorporateLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$corporate_code]);
$results = $qry->result_array();
if ($results) {
foreach ($results as &$r) {
$r['json'] = json_decode($r['json']);
$r['response'] = json_decode($r['response']);
}
unset($r);
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'success',
'data' => $results
]));
}
return $this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => "No data found for corporate_code: $corporate_code"
]));
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,421 @@
<?php
class Packet extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_packet()
{
$sql_base = "SELECT
p.T_PacketID,
p.T_PacketName AS packet_name,
p.T_PacketType,
p.T_PacketPrice,
p.T_PacketSasCode AS packet_code,
p.T_PacketStartDate,
p.T_PacketEndDate,
ph.T_PriceHeaderID,
ph.T_PriceHeaderName AS priceheader_name,
ph.T_PriceHeaderCode AS priceheader_code,
ph.T_PriceHeaderStartDate,
ph.T_PriceHeaderEndDate,
ap.Ais_PacketStatus AS Ais_PacketStatus,
IF(MAX(ap.Ais_PacketID) IS NULL, 'N', 'Y') AS packet_status
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
";
// Ambil parameter
$packet_name = $this->input->get('packet_name');
$packet_code = $this->input->get('packet_code');
$priceheader_name = $this->input->get('priceheader_name');
$priceheader_code = $this->input->get('priceheader_code');
$packet_status = $this->input->get('packet_status'); // Y / N
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [];
// Status packet Y/N dari ais_packet
if ($packet_status === 'Y') {
$where_clauses[] = "ap.Ais_PacketID IS NOT NULL";
} elseif ($packet_status === 'N') {
$where_clauses[] = "ap.Ais_PacketID IS NULL";
}
// Filter by packet name
if ($packet_name) {
$where_clauses[] = "p.T_PacketName LIKE ?";
$params[] = "%$packet_name%";
}
// Filter by packet code
if ($packet_code) {
$where_clauses[] = "p.T_PacketSasCode LIKE ?";
$params[] = "%$packet_code%";
}
// Filter by priceheader name
if ($priceheader_name) {
$where_clauses[] = "ph.T_PriceHeaderName LIKE ?";
$params[] = "%$priceheader_name%";
}
// Filter by priceheader code
if ($priceheader_code) {
$where_clauses[] = "ph.T_PriceHeaderCode LIKE ?";
$params[] = "%$priceheader_code%";
}
// Build WHERE
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// Count total records for pagination
// Count distinct packet ID
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT p.T_PacketID
FROM t_packet p
JOIN t_priceheader ph
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
LEFT JOIN ".$this->db_log->database.".ais_packet ap
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
$where_sql
GROUP BY p.T_PacketID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// Main SQL
$sql = $sql_base . $where_sql . "
GROUP BY p.T_PacketID
ORDER BY p.T_PacketID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring packet.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring packet.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$packet_code = $this->input->get('packet_code');
if (empty($packet_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error', 'message' => 'packet_code parameter is required']));
}
$sql = "SELECT
Ais_PacketT_PacketSasCode AS packet_code,
Ais_PacketLastUpdated AS packet_update,
Ais_PacketJson AS packet_json,
Ais_PacketStatus AS status,
Ais_PacketResponse AS packet_response
FROM ais_packet
WHERE Ais_PacketT_PacketSasCode = ?
ORDER BY Ais_PacketLastUpdated DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, array($packet_code));
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

View File

@@ -0,0 +1,406 @@
<?php
class Patient extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Resultentry API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
public function error_log($data, $userid = 999)
{
$sql = "INSERT INTO ais_error_log (
AisErrorLogFnName,
AisErrorLogMessage,
AisErrorLogQuery,
AisErrorLogJson,
AisErrorLogUserID,
AisErrorLogCreated
)
VALUES(
?,
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
//echo $this->db_log->last_query();
return true;
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
public function post_request($url, $data = array(), $headers = array())
{
// Default headers
$default_headers = array(
'Content-Type: application/json'
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$result = json_decode($response, true);
if ($result['status'] == 200) {
$result['success'] = true;
} else {
$result['success'] = false;
}
}
return $result;
}
public function get_request($url, $headers = array())
{
// Retrieve configuration
$config = $this->get_config();
$token = $config['AisConfigAuthToken'] ?? 'default-token';
$header_token = $config['AisConfigHeaderToken'];
// Default headers based on the curl command
$default_headers = array(
'Header-Token: ' . $header_token,
'Authorization: Bearer ' . $token
);
// Merge custom headers with default headers
$final_headers = array_merge($default_headers, $headers);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
// Close cURL
curl_close($ch);
// Prepare result
$result = array(
'success' => false,
'http_code' => $http_code,
'response' => null,
'error' => null
);
if ($error) {
$result['error'] = $error;
} else {
$decoded = json_decode($response, true);
$result['response'] = $decoded;
// Check if response is successful based on http code
if ($http_code === 200) {
$result['success'] = true;
}
}
return $result;
}
function get_config()
{
$sql = "SELECT * FROM ais_config LIMIT 1";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
exit;
}
$dt_config = $qry->row_array();
return $dt_config;
}
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl . '/api/auth/auth.php';
$headers = array(
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
exit;
}
//print_r($result);
//exit;
// Check if success
if (!$result['success']) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Login');
echo json_encode($errors);
exit;
} else {
// Update token
$token = $result['data']['token'];
;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if (!$qry) {
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
echo json_encode($errors);
exit;
}
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
return $token;
}
}
/**
* POST request to jenis layanan API
* @param array $data Array of jenis layanan data
* @return array Response from API
*/
function monitoring_patient()
{
$sql_base = "SELECT
oh.T_OrderHeaderID,
oh.T_OrderHeaderM_PatientID AS patient_id,
p.M_PatientName AS patient_name,
p.M_PatientNoReg AS patient_noreq,
p.M_PatientGender AS patient_gender,
p.M_PatientDOB AS patient_birthdate,
p.M_PatientHp AS patient_hp,
p.M_PatientEmail AS patient_email,
p.M_PatientIdentifierValue AS patient_identifier,
p.M_PatientNIP AS patient_nip,
p.M_PatientJob AS patient_job,
p.M_PatientPosisi AS patient_posisi,
p.M_PatientDivisi AS pasient_divisi,
am.Ais_MedrecStatus AS medrec_status,
-- STATUS AIS
IF(MAX(am.Ais_MedrecID) IS NULL, 'N', 'Y') AS medrec_status
FROM t_orderheader oh
JOIN m_patient p
ON p.M_PatientID = oh.T_OrderHeaderM_PatientID
LEFT JOIN ".$this->db_log->database.".ais_medrec am
ON am.Ais_MedrecPatientNoReg = p.M_PatientNoReg
";
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
// Filter
$patient_name = $this->input->get('patient_name');
$patient_noreq = $this->input->get('patient_noreq');
$medrec_status = $this->input->get('medrec_status');
$params = [];
$where_clauses = [];
if ($medrec_status === 'Y') {
$where_clauses[] = "am.Ais_MedrecID IS NOT NULL";
} elseif ($medrec_status === 'N') {
$where_clauses[] = "am.Ais_MedrecID IS NULL";
}
if ($patient_name) {
$where_clauses[] = "p.M_PatientName LIKE ?";
$params[] = "%$patient_name%";
}
if ($patient_noreq) {
$where_clauses[] = "p.M_PatientNoReg LIKE ?";
$params[] = "%$patient_noreq%";
}
// WHERE builder
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// Count total rows
$count_sql = "SELECT COUNT(DISTINCT oh.T_OrderHeaderM_PatientID) AS total
FROM t_orderheader oh
JOIN m_patient p
ON p.M_PatientID = oh.T_OrderHeaderM_PatientID
LEFT JOIN ".$this->db_log->database.".ais_medrec am
ON am.Ais_MedrecPatientNoReg = p.M_PatientNoReg
$where_sql";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// Main query
$sql = $sql_base . $where_sql . "
GROUP BY oh.T_OrderHeaderM_PatientID
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data pasien.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data pasien.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
// Ambil patient_noreg dari query parameter
$patient_noreg = $this->input->get('patient_noreg');
if (empty($patient_noreg)) {
$this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'patient_noreg parameter is required'
]));
return;
}
$sql = "SELECT
Ais_MedrecPatientNoReg AS patient_noreg,
Ais_MedrecStatus AS status,
Ais_MedrecJSON AS json,
Ais_MedrecResponse AS response,
Ais_MedrecCreated AS created,
Ais_MedrecUserID AS user_id
FROM ais_medrec
WHERE Ais_MedrecPatientNoReg = ?";
// Query menggunakan db_log
$qry = $this->db_log->query($sql, array($patient_noreg));
// Ambil multiple rows
$results = $qry->result_array();
if ($results) {
foreach ($results as &$result) {
$result['json'] = json_decode($result['json']);
$result['response'] = json_decode($result['response']);
}
unset($result);
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode([
'status' => 'error',
'message' => 'No data found for the given patient_noreq.'
]);
}
exit;
}
}

View File

@@ -0,0 +1,269 @@
<?php
class Test extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Transaction API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->db_log = $this->load->database("log", true);
$this->load->helper(array('form', 'url'));
}
/**
* Generic POST request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* Generic PUT request function
* @param string $url API endpoint URL
* @param array $data Request payload
* @param array $headers Custom headers (optional)
* @return array Response from API
*/
/**
* POST request to auth API
* @param string $username Username for authentication
* @param string $password Password for authentication
* @return array Response from API
*/
public function post_auth()
{
$dt_config = $this->get_config();
$baseUrl = $dt_config['AisConfigBaseUrl'];
$url = $baseUrl.'/api/auth/auth.php';
$headers = array(
'Header-Token: '.$dt_config['AisConfigHeaderToken']
);
$username = $dt_config['AisConfigUsername'];
$password = $dt_config['AisConfigPassword'];
$data = array(
'username' => $username,
'password' => $password
);
$result = $this->post_request($url, $data, $headers);
$sql = "INSERT INTO ais_login_log(
AisLoginLogUsername,
AisLoginLogPassword,
AisLoginLogHeaderToken,
AisLoginLogResult,
AisLoginLogCreated
)
VALUES(
?,
?,
?,
?,
NOW()
)";
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
exit;
}
//print_r($result);
//exit;
// Check if success
if(!$result['success']){
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
$errors = array('status' => 'error','message' => 'Gagal Login');
return $errors;
}else{
// Update token
$token = $result['data']['token'];;
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
$qry = $this->db_onedev->query($sql, array($token));
//echo $this->db_onedev->last_query();
//exit;
if(!$qry){
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
$errors = array('status' => 'error','message' => 'Gagal Update Token');
return $errors;
}
return $result;
}
}
function monitoring_test()
{
// SQL base
$sql_base = "SELECT
t.T_TestID,
t.T_TestCode AS test_code,
t.T_TestSasCode AS sas_code,
t.T_TestName AS test_name,
t.T_TestIsPrice AS is_price,
t.T_TestIsResult AS is_result,
t.T_TestIsActive AS test_active,
at.Ais_TestStatus AS Ais_TestStatus,
at.Ais_TestLastUpdate AS test_last_update,
IF (at.Ais_TestID IS NULL, 'N', 'Y') AS test_status
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestStatus, Ais_TestLastUpdate, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
";
// Ambil parameter
$test_name = $this->input->get('test_name'); // TRUE for XSS filtering
$sas_code = $this->input->get('sas_code');
$test_code = $this->input->get('test_code');
$test_status = $this->input->get('test_status');
// Pagination
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$params = [];
$where_clauses = [
"t.T_TestIsActive = 'Y'"
];
// Status filter
if ($test_status === 'Y') {
$where_clauses[] = "at.Ais_TestID IS NOT NULL";
} elseif ($test_status === 'N') {
$where_clauses[] = "at.Ais_TestID IS NULL";
}
if ($test_name) {
$where_clauses[] = "t.T_TestName LIKE ?";
$params[] = "%$test_name%";
}
if ($test_code) {
$where_clauses[] = "t.T_TestCode LIKE ?";
$params[] = "%$test_code%";
}
if ($sas_code) {
$where_clauses[] = "t.T_TestSasCode LIKE ?";
$params[] = "%$sas_code%";
}
$where_sql = "";
if (!empty($where_clauses)) {
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
}
// COUNT
$count_sql = "
SELECT COUNT(*) AS total
FROM (
SELECT t.T_TestID
FROM t_test t
LEFT JOIN (
SELECT Ais_TestTestSasCode, Ais_TestID
FROM ".$this->db_log->database.".ais_test
WHERE Ais_TestStatus = 'success'
) at
ON at.Ais_TestTestSasCode = t.T_TestSasCode
$where_sql
GROUP BY t.T_TestID
) AS x
";
$qry_count = $this->db_onedev->query($count_sql, $params);
$total = $qry_count->row()->total ?? 0;
// MAIN QUERY
$sql = $sql_base . $where_sql . "
GROUP BY t.T_TestID
ORDER BY t.T_TestID ASC
LIMIT $limit OFFSET $offset";
$qry = $this->db_onedev->query($sql, $params);
// if (!$qry) {
// $this->output
// ->set_content_type('application/json')
// ->set_output(json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']));
// return;
// }
if (!$qry) {
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
exit;
}
$data = $qry->result_array();
echo json_encode([
'status' => 'success',
'message' => 'Berhasil mengambil data monitoring.',
'data' => $data,
'total' => $total,
'page' => $page,
'limit' => $limit,
'total_page' => ceil($total / $limit)
]);
exit;
}
function get_json_response()
{
$sas_code = $this->input->get('sas_code');
if (empty($sas_code)) {
return $this->output
->set_status_header(400)
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'error',
'message' => 'sas_code parameter is required'
]));
}
$sql = "SELECT
Ais_TestID AS id,
Ais_TestTestSasCode AS sas_code,
Ais_TestJSON AS test_json,
Ais_TestStatus AS test_status,
Ais_TestResponse AS test_response,
Ais_TestLastUpdate AS test_last_update
FROM ais_test
WHERE Ais_TestTestSasCode = ?
ORDER BY Ais_TestLastUpdate DESC";
// Query ke database LOG
$qry = $this->db_log->query($sql, [$sas_code]);
$results = $qry->row_array();
$results = $qry->result_array();
if ($results) {
// Loop through each result to decode JSON
foreach ($results as &$result) {
$result['packet_json'] = json_decode($result['packet_json']);
$result['packet_response'] = json_decode($result['packet_response']);
}
unset($result); // Unset reference to avoid side effects
echo json_encode(['status' => 'success', 'data' => $results]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
}
exit;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
@baseUrl = https://devcpone.aplikasi.web.id/one-api/ais
# @baseUrl = http://his.sismedika.online:4081/westerindo_ais
POST {{baseUrl}}/transaction/post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Re Post Transaction by Labnumber
POST {{baseUrl}}/transaction/re_post_transaction_by_labnumber
Content-Type: application/json
{
"labnumber": "H2509010001"
}
### POST Medrec by No Reg
POST {{baseUrl}}/masterdata/post_medrec_by_noreg
Content-Type: application/json
{
"noreg": "CP2406140001"
}
### POST Jenis Layanan
POST {{baseUrl}}/post_jenis_layanan
### GET Jenis Perusahaan
GET {{baseUrl}}/get_jenis_perusahaan?id=1
### POST Jenis Perusahaan
POST {{baseUrl}}/post_jenis_perusahaan
### POST Perusahaan
POST {{baseUrl}}/post_perusahaan
### GET Perusahaan
GET {{baseUrl}}/get_perusahaan
### POST Perusahaan Bulk
POST {{baseUrl}}/post_perusahaan_bulk
### GET Jenis Layanan
GET {{baseUrl}}/get_jenislayanan
### Post Jenis Layanan
Post {{baseUrl}}/post_jenislayanan
### GET Layanan
GET {{baseUrl}}/get_layanan
### Post Layanan
POST {{baseUrl}}/post_layanan
### GET Group Layanan
GET {{baseUrl}}/get_grouplayanan
### Post Group Layanan
POST {{baseUrl}}/post_grouplayanan
### GET Departemen
GET {{baseUrl}}/get_departemen
### Post Departement
POST {{baseUrl}}/post_departemen
### GET Departement
GET {{baseUrl}}/get_medrec
### Post Departement
POST {{baseUrl}}/post_medrec
### GET Transaction
GET {{baseUrl}}/get_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction
### Post Transaction
POST {{baseUrl}}/post_transaction?date=2024-02-08&limit=1&offset=0
### GET Payment
GET {{baseUrl}}/get_payment?id=6

View File

@@ -0,0 +1,52 @@
@baseUrl = https://devcpone.aplikasi.web.id/one-api/ais
@contentType = application/json
### ============================================================
### LIST TRANSACTION
### ============================================================
### Request tanpa parameter tanggal (menggunakan default)
GET {{baseUrl}}/transaction/monitoring_transaction/monitoring_transaction?page=1&limit=10
### Request dengan parameter tanggal
GET {{baseUrl}}/transaction/monitoring_transaction?start_date=2025-08-01&end_date=2025-08-05
### Request dengan parameter tanggal dan status transaksi
GET {{baseUrl}}/transaction/monitoring_transaction?ais_status=Y
### Request dengan parameter corporate_id
GET {{baseUrl}}/transaction/monitoring_transaction?corporate_id=53
### Request dengan parameter patient_name
GET {{baseUrl}}/transaction/monitoring_transaction?patient_name=Dony Wahyu Andreansyah
### Request dengan parameter lab_number
GET {{baseUrl}}/transaction/monitoring_transaction?lab_number=H2408010111
### Request get_corporate
GET {{baseUrl}}/transaction/get_corporate
### Request get_json_response dengan parameter lab_number
GET {{baseUrl}}/transaction/get_json_response?lab_number=H2408010111
### Request monitoring_patient berdasarkan halaman
GET {{baseUrl}}/patient/monitoring_patient?page=1
### Request monitoring_patient berdasarkan API
GET {{baseUrl}}/patient/monitoring_patient?page=1&patient_name=Pasien 5 Karyawan
### Request monitoring_patient
GET {{baseUrl}}/patient/monitoring_patient?page=1&patient_noreq=CP2509010001
###
GET {{baseUrl}}/patient/monitoring_patient?medrec_status=N
###
GET {{baseUrl}}/patient/get_json_response?patient_noreg=CP2509010001
###
GET {{baseUrl}}/corporate/monitoring_corporate?page=1

View File

@@ -0,0 +1,213 @@
<?php
class AntrianCounterDedicated extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo "Api: Training Playground";
}
function list_location()
{
try {
$sql = "SELECT * FROM location WHERE locationIsActive = 'Y'";
$qry = $this->db_antrione->query($sql);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_counter($branchID)
{
try {
// $prm = $this->sys_input;
// $locationID = array();
// if (isset($prm['locationID'])) {
// $locationID = trim($prm["locationID"]);
// }
$sql = "SELECT counter.* , locationID, locationName,
fn_get_serviceID(counterID,counterIsDedicated) as serviceID
FROM counter
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE counterIsActive = 'Y'
AND counterBranchID = ?;
";
// $sql = "SELECT *
// FROM counter
// WHERE counterIsActive = 'Y'
// AND counterLocationID = ?";
$qry = $this->db_antrione->query($sql, [$branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function get_antrian()
{
try {
$prm = $this->sys_input;
$arrCounter = array();
if (isset($prm['arr_counter'])) {
array_push($prm['arr_counter'], 0);
$arrCounter = implode(",", $prm["arr_counter"]);
}
$branchID = $prm["branchID"];
$sqlNotServed = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
IFNULL(queueSkipDate, 'NEW') as skipQueue,
( CASE
WHEN statusID = 1 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (1)
AND queueLocationID IN (SELECT GROUP_CONCAT(counterLocationID) FROM counter WHERE counterID IN ($arrCounter))
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY IFNULL(queueSkipDate, queueCreated)";
$qryNotServed = $this->db_antrione->query($sqlNotServed, []);
$last_qry_not = $this->db_antrione->last_query();
if (!$qryNotServed) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_not
);
$this->sys_error_db($error);
exit;
}
$notServed = $qryNotServed->result_array();
$sqlCall = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
queueCounterID,
counterCode,
counterID,
( CASE
WHEN statusID = 2 THEN 1
WHEN statusID = 5 THEN 2
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
JOIN counter ON queueCounterID = counterID
WHERE queueIsActive = 'Y'
AND statusID IN (2, 5)
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qryCall = $this->db_antrione->query($sqlCall, []);
$last_qry_served = $this->db_antrione->last_query();
if (!$qryCall) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_served
);
$this->sys_error_db($error);
exit;
}
$call = $qryCall->result_array();
$sqlServed = "SELECT queueID,
statusID, IFNULL(queueNumber,'') as queueNumber,
queueCounterID,
counterCode,
counterID,
( CASE
WHEN statusID = 3 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
AND serviceIsConsultDoctor = 'N'
AND queueBranchID = {$branchID}
JOIN status
ON statusID = queueStatusID
JOIN counter ON queueCounterID = counterID
WHERE queueIsActive = 'Y'
AND statusID IN (3)
AND queueCounterID IN ($arrCounter)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qryServed = $this->db_antrione->query($sqlServed, []);
$last_qry_call = $this->db_antrione->last_query();
if (!$qryServed) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry_call
);
$this->sys_error_db($error);
exit;
}
$served = $qryServed->result_array();
$data = [];
$data["served"] = $served;
$data['not_served'] = $notServed;
$data['call'] = $call;
$data['qry_call'] = $last_qry_call;
$data['qry_not_served'] = $last_qry_not;
$data['qry_serve'] = $last_qry_served;
$result = array(
$data
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,243 @@
<?php
class Layanandokter extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo ('API SERVICE');
}
function list_layanan_dokter()
{
try {
// if (!$this->isLogin) {
// $this->sys_error("Invalid Token");
// exit;
// }
$prm = $this->sys_input;
$serviceId = "0";
if (isset($prm['serviceId'])) {
// $serviceId = trim(str_replace("[]","",$prm["serviceId"]));
$serviceId = implode(",", $prm['serviceId']);
}
// $serviceIdfix = "1,15";
// belum dilayani
$sql_belum_dilayani = "SELECT queueID,
statusID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 1 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (1)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY IFNULL(queueSkipDate, queueCreated)";
$qry_belum_dilayani = $this->db_antrione->query($sql_belum_dilayani);
$last_qry_belum_dilayani = $this->db_antrione->last_query();
if (!$qry_belum_dilayani) {
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error);
// exit;
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_belum_dilayani)
);
exit;
}
$belum_dilayani = $qry_belum_dilayani->result_array();
$arr_serviceName = [];
$result = [];
foreach ($belum_dilayani as $key => $val) {
$serviceName = $val['serviceDoctorName'];
if (in_array($serviceName, $arr_serviceName)) {
continue;
}
$result[] = $val;
$arr_serviceName[] = $serviceName;
}
$belum_dilayani = $result;
$sql_call = "SELECT queueID,
statusID,
queueServiceID as serviceID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 2 THEN 1
WHEN statusID = 5 THEN 3
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (2,5)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qry_call = $this->db_antrione->query($sql_call);
$last_qry_call = $this->db_antrione->last_query();
if (!$qry_call) {
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_call)
);
exit;
}
$call = $qry_call->result_array();
$arr_serviceName = [];
$result = [];
foreach ($call as $key => $val) {
$serviceName = $val['serviceDoctorName'];
if (in_array($serviceName, $arr_serviceName)) {
continue;
}
$result[] = $val;
$arr_serviceName[] = $serviceName;
}
$call = $result;
// sedang dilayani
$sql_sedang_dilayani = "SELECT queueID,
queueServiceID as serviceID,
IFNULL(queueNumber,'') as queueNumber,
IFNULL(serviceDoctorName,'') as serviceDoctorName,
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
( CASE
WHEN statusID = 3 THEN 1
END ) as order_status
FROM queue
JOIN service
ON serviceID = queueServiceID
AND serviceIsActive = 'Y'
JOIN status
ON statusID = queueStatusID
WHERE queueIsActive = 'Y'
AND statusID IN (3)
AND serviceIsConsultDoctor = 'Y'
AND serviceId IN ($serviceId)
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
ORDER BY order_status, queueCreated asc";
$qry_sedang_dilayani = $this->db_antrione->query($sql_sedang_dilayani);
$last_qry_sedang_dilayani = $this->db_antrione->last_query();
if (!$qry_sedang_dilayani) {
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error);
// exit;
$this->db_antrione->trans_rollback();
echo json_encode(
array("status" => "ERR", "message" => $last_qry_sedang_dilayani)
);
exit;
}
$sedang_dilayani = $qry_sedang_dilayani->result_array();
$data = [];
$data['call'] = $call;
$data['belumDilayani'] = $belum_dilayani;
$data['sedangDilayani'] = $sedang_dilayani;
$result = array(
$data
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_service()
{
try {
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'
and serviceIsConsultDoctor = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function list_service_not_consult()
{
try {
$sql = "SELECT * FROM service
WHERE serviceIsActive = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,252 @@
<?php
class Location extends MY_Controller
{
var $db_antrione;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
$cek = $this->db_antrione->query("select database() as current_db")->result();
// echo $this->db->last_query();
print_r($cek);
}
function save()
{
try{
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$sql_data = "INSERT INTO location(
locationCode,
locationName,
locationUserID,
locationCreated,
locationLastUpdated)
VALUES (?, ?, ?, NOW(), NOW())";
$qry_data = $this->db_antrione->query($sql_data, [$code, $name, $userid]);
$last_qry = $this->db_antrione->last_query();
echo $last_qry;
// if(!$qry_data) {
// $this->db_antrione->trans_rollback();
// $error = array(
// "message" => $this->db_antrione->error()["message"],
// "sql" => $last_qry
// );
// $this->sys_error_db($error, $this->db_antrione);
// exit;
// }
// $this->db_antrione->trans_commit();
// $result = array(
// "affected_rows" => $this->db_antrione->affected_rows(),
// "inserted_id" => $this->db_antrione->insert_id()
// );
// $this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function search()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$search = "";
if(isset($prm["search"])) {
$search = trim($prm["search"]);
if ($search != ""){
$search = "%" . $prm["search"] . "%";
}else{
$search = "%%";
}
}
$sortBy = $prm["sortBy"];
$sortStatus = $prm["sortStatus"];
if($sortBy){
$q_sort = "ORDER BY ".$sortBy." ".$sortStatus;
}
$number_offset = 0;
$number_limit = 10;
if($prm["current_page"] > 0) {
$number_offset = ($prm["current_page"] - 1) * $number_limit;
}
$sql_filter = "SELECT count(DISTINCT locationID) as total
FROM location
WHERE locationName like ? AND locationIsActive = 'Y'";
$qry_filter = $this->db_antrione->query($sql_filter, [$search]);
// $last_qry = $this->db_antrione->last_query();
// print_r($last_qry);
$tot_count = 0;
$tot_page = 0;
if($qry_filter) {
$tot_count = $qry_filter->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
}else{
$this->sys_error_db("location select count", $this->db_antrione);
exit;
}
$sql_data = "SELECT DISTINCT locationID as id,
locationName, locationIsActive
FROM location
WHERE locationName like ? AND locationIsActive = 'Y'
$q_sort
limit ? offset ?";
$qry_data = $this->db_antrione->query($sql_data, [$search, $number_limit, $number_offset]);
if($qry_data) {
$rows = $qry_data->result_array();
}else{
$this->sys_error_db("location select", $this->db_antrione);
exit;
}
$result = array(
"total" => $tot_page,
"total_filter" => $tot_count,
"records" => $rows
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function edit()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$id = "";
if (isset($prm['id'])) {
if (is_numeric($prm["id"])){
$id = trim($prm["id"]);
}
}
$sql = "UPDATE location
SET locationName = ?,
locationUserID = ?,
locationLastUpdated = NOW()
WHERE locationID = ?";
$qry = $this->db_antrione->query($sql, [$name, $userid, $id]);
$last_qry = $this->db_antrione->last_query();
// print_r($last_qry);
if(!$qry) {
$this->db_antrione->trans_rollback();
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error, $this->db_antrione);
exit;
}
$this->db_antrione->trans_commit();
$result = array(
"total" => 1,
"affected_rows" => $this->db_antrione->affected_rows()
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function delete()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_antrione->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$id = "";
if(isset($prm['id'])) {
if(is_numeric($prm["id"])) {
$id = trim($prm["id"]);
}
}
$sql = "UPDATE location
SET locationIsActive = 'N',
locationUserID = ?,
locationLastUpdated = NOW()
WHERE locationID = ?";
$qry = $this->db_antrione->query($sql, [$userid, $id]);
$last_qry = $this->db_antrione->last_query();
if(!$qry){
$this->db_antrione->trans_rollback();
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error, $this->db_antrione);
exit;
}
// print_r($last_qry);
$this->db_antrione->trans_commit();
$result = array(
"affected_rows" => $this->db_antrione->affected_rows()
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}
?>

View File

@@ -0,0 +1,131 @@
<?php
class Nonlab extends MY_Controller
{
function get_call($station_id=NULL,$trx_date=NULL,$status=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
T_SamplingQueueLastStatusID as trx_id,
T_SampleStationName as sample_station,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext
FROM t_sampling_queue_last_status
JOIN t_orderheader ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN t_samplestation ON T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
T_SampleStationIsActive = 'Y'
WHERE
T_SamplingQueueLastStatusT_SampleStationID = ? AND
T_SamplingQueueLastStatusT_SamplingQueueStatusID = ? AND
DATE(T_SamplingQueueLastStatusLastUpdated) = ? AND
T_SamplingQueueLastStatusIsActive = 'Y'";
$query = $this->db_onedev->query($sql,array($station_id,$status,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_data($station_id=NULL,$trx_date=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = "SELECT T_OrderHeaderID as order_id,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext,
CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
IFNULL(T_SamplingQueueStatusName,'new') as status,
IFNULL(T_SamplingQueueLastStatusT_SamplingQueueStatusID,0) as last_status_id
FROM t_orderheader
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = ?
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
T_SamplingSoT_TestID = T_TestID AND
T_SamplingSoT_SampleStationID = T_SampleStationID AND
T_SamplingSoIsActive = 'Y'
LEFT JOIN t_sampling_queue_last_status ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID AND
T_SamplingCallStatusIsActive = 'Y'
WHERE
T_OrderHeaderIsActive = 'Y' AND
( DATE(T_OrderHeaderAddonIsComingDate) = ? OR DATE(T_OrderHeaderDate) = ? )
GROUP BY T_OrderHeaderID
HAVING fn_fo_get_laststatus(T_OrderHeaderID) IN (3,5) AND last_status_id NOT IN (1,3,5)
ORDER BY T_OrderHeaderIsCito DESC, T_OrderHeaderID ASC";
//echo $sql;
$query = $this->db_onedev->query($sql,array($station_id,$trx_date,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_station(){
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT T_SampleStationID as id,
T_SampleStationCode as code,
T_SampleStationName as name,
T_SampleStationIsNonLab as is_nonlab
FROM t_samplestation
WHERE
T_SampleStationIsActive = 'Y'";
$query = $this->db_onedev->query($sql);
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_images(){
$dir = "/home/one/project/one/one-media/one-antrian/nonlab/";
$files = scandir($dir);
$results = [];
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
} else if ($value != "." && $value != "..") {
getDirContents($path, $results);
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
}
}
$this->sys_ok($results);
exit;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,349 @@
<?php
class Service extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
}
function index()
{
echo ('API SERVICE');
}
function search()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
// print_r($prm);
// exit;
$search = "%%";
if (isset($prm['search'])) {
$search = trim($prm["search"]);
$search = '%' . $prm['search'] . '%';
}
$order_by = "serviceCode";
if (isset($prm['order_by'])) {
$order_by = trim($prm["order_by"]);
}
$order = "asc";
if (isset($prm['order'])) {
$order = trim($prm["order"]);
}
$sort = "order by " . $order_by . " " . $order;
$page = $prm["page"];
$ROW_PER_PAGE = 10;
$start_offset = 0;
if (isset($prm["page"])) {
if (
is_numeric($prm["page"]) && $prm["page"] > 0
) {
$start_offset = ($page - 1) * $ROW_PER_PAGE;
}
}
$total_count = 0;
$total_page = 0;
$sqlCount = "SELECT COUNT(*) AS total FROM service
WHERE serviceIsActive = 'Y'
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
ORDER BY serviceCode";
$qryCount = $this->db_antrione->query($sqlCount, [$search, $search]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCount) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$sql = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
$sort
LIMIT 10 OFFSET ?";
$qry = $this->db_antrione->query($sql, [$search, $search, $start_offset]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$total = $qryCount->row_array();
$total_count = $total['total'];
$total_page = ceil($total_count / $ROW_PER_PAGE);
$data = $qry->result_array();
$result = array(
"total_filter" => $total_count,
"total" => $total_page,
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function add()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$priority = "";
if (isset($prm['priority'])) {
$priority = trim($prm["priority"]);
}
$foOrder = "";
if (isset($prm['foOrder'])) {
$foOrder = trim($prm["foOrder"]);
}
$isConsultDoctor = "";
if (isset($prm['isConsultDoctor'])) {
$isConsultDoctor = trim($prm["isConsultDoctor"]);
}
$nameDoctor = "";
if (isset($prm['nameDoctor'])) {
$nameDoctor = trim($prm["nameDoctor"]);
}
if ($isConsultDoctor == 'Y') {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
exit;
}
} else {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
$this->sys_error("code, name, priority, fo order is mandatory");
exit;
}
}
$this->db_antrione->trans_begin();
$sql = "INSERT INTO service
(serviceCode,
serviceName,
servicePriority,
serviceIsFoOrder,
serviceIsConsultDoctor,
serviceDoctorName
)
VALUES(?, ?, ?, ?, ?, ?)";
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$insertedId = $this->db_antrione->insert_id();
$sqlNumbering = "INSERT INTO numbering
(numberingServiceID,
numberingPrefix,
numberingDigit,
numberingReset)
VALUES(? ,? , 4, 'D')";
$qryNumbering = $this->db_antrione->query($sqlNumbering, [$insertedId, $insertedId]);
if (!$qryNumbering) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$this->db_antrione->trans_complete();
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function update()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$code = "";
if (isset($prm['code'])) {
$code = trim($prm["code"]);
}
$id = "";
if (isset($prm['id'])) {
$id = trim($prm["id"]);
}
$name = "";
if (isset($prm['name'])) {
$name = trim($prm["name"]);
}
$priority = "";
if (isset($prm['priority'])) {
$priority = trim($prm["priority"]);
}
$foOrder = "";
if (isset($prm['foOrder'])) {
$foOrder = trim($prm["foOrder"]);
}
$isConsultDoctor = "";
if (isset($prm['isConsultDoctor'])) {
$isConsultDoctor = trim($prm["isConsultDoctor"]);
}
$nameDoctor = "";
if (isset($prm['nameDoctor'])) {
$nameDoctor = trim($prm["nameDoctor"]);
}
if ($isConsultDoctor == 'Y') {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
exit;
}
} else {
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
$this->sys_error("code, name, priority, fo order is mandatory");
exit;
}
}
$sql = "UPDATE service SET serviceCode = ?,
serviceName = ?,
servicePriority = ?,
serviceIsFoOrder = ?,
serviceIsConsultDoctor = ?,
serviceDoctorName = ?
WHERE serviceID = ?";
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor, $id]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function delete()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = "";
if (isset($prm['id'])) {
$id = trim($prm["id"]);
}
$this->db_antrione->trans_begin();
$sql = "UPDATE service SET
serviceIsActive = 'N'
WHERE serviceID = ?";
$qry = $this->db_antrione->query($sql, [intval($id)]);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$sqlNumbering = "UPDATE numbering SET
numberingIsActive = 'N'
WHERE numberingServiceID = ?";
$qryNumbering = $this->db_antrione->query($sqlNumbering, [intval($id)]);
$last_qry = $this->db_antrione->last_query();
if (!$qryNumbering) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$this->db_antrione->trans_complete();
$result = array(
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function listService()
{
try {
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'";
$qry = $this->db_antrione->query($sql, []);
$last_qry = $this->db_antrione->last_query();
if (!$qry) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error);
exit;
}
$data = $qry->result_array();
$result = array(
"records" => $data,
"qry" => $last_qry
);
$this->sys_ok($result);
exit;
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,319 @@
<?php
class Ticket extends MY_Controller
{
var $db_antrione;
var $load;
var $IP_SOCKET_IO;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
$this->IP_SOCKET_IO = "127.0.0.1";
// $this->IP_SOCKET_IO = "devone.aplikasi.web.id";
}
function index()
{
echo ('API GET ANTRIAN NUMBER');
}
function getAntrian()
{
try {
$prm = $this->sys_input;
$serviceId = '';
if (isset($prm['service_id'])) {
$serviceId = trim($prm["service_id"]);
}
$boothId = '';
if (isset($prm['booth_id'])) {
$boothId = trim($prm["booth_id"]);
}
$branchID = '';
if (isset($prm['branch_id'])) {
$branchID = trim($prm["branch_id"]);
}
if ($serviceId == '' || $boothId == '' || $branchID == '') {
$this->sys_error_db("service id, booth id, branch id are mandatory");
exit;
}
$this->db_antrione->trans_begin();
$sqlCek = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND serviceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$serviceCek = $qryCek->result_array();
// print_r($serviceCek);
// exit;
if (count($serviceCek) == 0) {
$error = array(
"message" => "service tidak ada ",
);
$this->sys_error_db($error);
$this->db_antrione->trans_rollback();
exit;
}
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID, counterBranchID)) as maxQueue FROM counter
LEFT JOIN counter_service ON counterID = counterServiceCounterID
AND counterServiceIsActive = 'Y'
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
AND counterBranchID = ?
AND counterIsActive = 'Y'
GROUP BY locationID
ORDER BY locationID";
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
// counter_service
// JOIN counter ON counterServiceCounterID = counterID
// AND counterIsActive = 'Y'
// JOIN location ON counterLocationID = locationID
// AND locationIsActive = 'Y'
// WHERE counterServiceServiceID = ?
// AND counterServiceIsActive = 'Y'
// GROUP BY locationID
// ORDER BY locationID";
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$location = $qrygetLocation->result_array();
// print_r($location);
// exit;
$ticketMsg = '';
$locationIdFinal = 0;
$countLocation = count($location);
$masukMana = "";
if ($countLocation == 0) {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office";
$masukMana = "TIdak ada counter yang melayani";
}
if ($countLocation == 1) {
$locationId = intval($location[0]['locationID']);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($queueNum < $location[0]["maxQueue"]) {
$locationIdFinal = $location[0]['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$masukMana = "ada 1 counter yang melayani";
} else {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
$masukMana = "ada 1 counter yang melayani";
}
}
if ($countLocation > 1) {
$locationDedicated = array();
foreach ($location as $value) {
$locationId = intval($value["locationID"]);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
$locationDedicated = $value;
break;
}
}
// print_r($locationDedicated);
// exit;
if ($locationDedicated) {
$locationIdFinal = $locationDedicated['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
} else {
for ($i = 0; $i < $countLocation; $i++) {
$val = $location[$i];
$maxQueue = intval($val["maxQueue"]);
$locationId = intval($val["locationID"]);
$locationName = $val['locationName'];
$isDedicated = $val['counterIsDedicated'];
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?
AND queueBranchID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$locationIdFinal = $location[0]['locationID'];
$masukMana = "countLocation == key && queueNum >= maxQueue";
break;
}
if ($queueNum < $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
$masukMana = "queueNum < maxQueue";
$locationIdFinal = $locationId;
break;
}
if ($queueNum >= $maxQueue) {
$masukMana = "queueNum >= maxQueue";
continue;
}
}
}
}
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
// exit;
$sqlGetNumber = "SELECT fn_get_numbering(?, ?) AS number";
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId, $branchID]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$number = $qryGetNumber->row_array();
$numberQueue = $number['number'];
$uniqueCode = bin2hex(random_bytes(13)); // Generate a unique code of 25 characters
$sqlInsert = "INSERT INTO queue
(queueNumber,
queueStatusID,
queueServiceID,
queueLocationID,
queueTicketBoothID,
queueBranchID,
queueCode)
VALUES
(?, 1, ?, ?, ?, ?, ?)";
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId, $branchID, $uniqueCode]);
$last_qry = $this->db_antrione->last_query();
if (!$qryInsert) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queueId = $this->db_antrione->insert_id();
$sqlLog = "INSERT INTO queuelog
(queueLogDate,
queueLogStatusID,
queueLogCounterID)
VALUES(NOW(),1,0)";
$qryLog = $this->db_antrione->query($sqlLog);
$last_qry = $this->db_antrione->last_query();
if (!$qryLog) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$sqlUpdate = "UPDATE queue SET
queueQueueLogID = ?
WHERE queueID = ?";
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryUpdate) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$this->db_antrione->trans_complete();
$result = array(
"number" => $numberQueue,
"location" => $ticketMsg,
"bagian" => $masukMana,
"code" => $uniqueCode,
"maxQueuePerLantai" => $location
);
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9088/broadcast/printed.fo.{$serviceId}.{$branchID}");
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,302 @@
<?php
class Ticketrspad extends MY_Controller
{
var $db_antrione;
var $load;
function __construct()
{
parent::__construct();
$this->db_antrione = $this->load->database("antrione", true);
$this->IP_SOCKET_IO = "devone.aplikasi.web.id";
}
function index()
{
echo ('API GET ANTRIAN NUMBER');
}
function getAntrian()
{
try {
$prm = $this->sys_input;
$serviceId = '';
if (isset($prm['service_id'])) {
$serviceId = trim($prm["service_id"]);
}
$boothId = '';
if (isset($prm['booth_id'])) {
$boothId = trim($prm["booth_id"]);
}
if ($serviceId == '' || $boothId == '') {
$this->sys_error_db("service id & booth id is mandatory");
exit;
}
$this->db_antrione->trans_begin();
$sqlCek = "SELECT * FROM service
WHERE serviceIsActive = 'Y'
AND serviceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$serviceCek = $qryCek->result_array();
if (count($serviceCek) == 0) {
$error = array(
"message" => "service tidak ada ",
);
$this->sys_error_db($error);
$this->db_antrione->trans_rollback();
exit;
}
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID)) as maxQueue FROM counter
LEFT JOIN counter_service ON counterID = counterServiceCounterID
AND counterServiceIsActive = 'Y'
JOIN location ON counterLocationID = locationID
AND locationIsActive = 'Y'
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
AND counterIsActive = 'Y'
GROUP BY locationID
ORDER BY locationID";
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
// counter_service
// JOIN counter ON counterServiceCounterID = counterID
// AND counterIsActive = 'Y'
// JOIN location ON counterLocationID = locationID
// AND locationIsActive = 'Y'
// WHERE counterServiceServiceID = ?
// AND counterServiceIsActive = 'Y'
// GROUP BY locationID
// ORDER BY locationID";
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$location = $qrygetLocation->result_array();
// print_r($location);
// exit;
$ticketMsg = '';
$locationIdFinal = 0;
$countLocation = count($location);
$masukMana = "";
if ($countLocation == 0) {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office";
$masukMana = "TIdak ada counter yang melayani";
}
if ($countLocation == 1) {
$locationId = intval($location[0]['locationID']);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($queueNum < $location[0]["maxQueue"]) {
$locationIdFinal = $location[0]['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$masukMana = "ada 1 counter yang melayani";
} else {
$locationIdFinal = 1;
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
$masukMana = "ada 1 counter yang melayani";
}
}
if ($countLocation > 1) {
$locationDedicated = array();
foreach ($location as $value) {
$locationId = intval($value["locationID"]);
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
$locationDedicated = $value;
break;
}
}
// print_r($locationDedicated);
// exit;
if ($locationDedicated) {
$locationIdFinal = $locationDedicated['locationID'];
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
} else {
for ($i = 0; $i < $countLocation; $i++) {
$val = $location[$i];
$maxQueue = intval($val["maxQueue"]);
$locationId = intval($val["locationID"]);
$locationName = $val['locationName'];
$isDedicated = $val['counterIsDedicated'];
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
WHERE
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND queueIsActive = 'Y'
AND queueStatusID <> 4
AND queueLocationID = ?
AND queueServiceID = ?";
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queue = $qryCek->row_array();
$queueNum = intval($queue['total']);
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
$locationIdFinal = $location[0]['locationID'];
$masukMana = "countLocation == key && queueNum >= maxQueue";
break;
}
if ($queueNum < $maxQueue) {
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
$masukMana = "queueNum < maxQueue";
$locationIdFinal = $locationId;
break;
}
if ($queueNum >= $maxQueue) {
$masukMana = "queueNum >= maxQueue";
continue;
}
}
}
}
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
// exit;
$sqlGetNumber = "SELECT fn_get_numbering(?) AS number";
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryCek) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$number = $qryGetNumber->row_array();
$numberQueue = $number['number'];
$sqlInsert = "INSERT INTO queue
(queueNumber,
queueStatusID,
queueServiceID,
queueLocationID,
queueTicketBoothID)
VALUES
(?, 1, ?, ?, ?)";
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryInsert) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$queueId = $this->db_antrione->insert_id();
$sqlLog = "INSERT INTO queuelog
(queueLogDate,
queueLogStatusID,
queueLogCounterID)
VALUES(NOW(),1,0)";
$qryLog = $this->db_antrione->query($sqlLog);
$last_qry = $this->db_antrione->last_query();
if (!$qryLog) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$sqlUpdate = "UPDATE queue SET
queueQueueLogID = ?
WHERE queueID = ?";
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
$last_qry = $this->db_antrione->last_query();
if (!$qryUpdate) {
$error = array(
"message" => $this->db_antrione->error()["message"],
"sql" => $last_qry
);
$this->db_antrione->trans_rollback();
$this->sys_error_db($error);
exit;
}
$logId = $this->db_antrione->insert_id();
$this->db_antrione->trans_complete();
$result = array(
"number" => $numberQueue,
"location" => $ticketMsg,
"bagian" => $masukMana,
"maxQueuePerLantai" => $location
);
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/printed.fo.{$serviceId}");
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}

View File

@@ -0,0 +1,235 @@
<?php
class Download_aol extends MY_Controller
{
function __construct()
{
parent::__construct();
$this->baseUrl = "https://mobile.pramita.co.id/one_api_coba/antrian_online/downloader/";
}
function index()
{
//branch
$sql =
"select * from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault='Y'";
$qry = $this->db->query($sql);
if (!$qry) {
echo "{$this->now()} ERR : {$this->db->error()["message"]}\n . {$this->db->last_query}";
exit();
}
$rows = $qry->result_array();
if (count($rows) == 0) {
$this->log("ERR : No Default Branch");
exit();
}
$branchID = $rows[0]["M_BranchID"];
$url = $this->baseUrl . "download/$branchID";
$resp = $this->get($url);
if ($resp["status"] != "OK") {
echo json_encode($resp);
exit;
}
$total = 0;
foreach ($resp["data"] as $data) {
$total++;
$this->db->trans_begin();
$queueID = $data["queueID"];
$queue = [];
$subservice = [];
$patient = [];
foreach ($data as $k => $v) {
if (strpos($k, "queue") === 0) {
$queue[$k] = $v;
}
if (strpos($k, "M_Patient") === 0) {
$patient[$k] = $v;
}
if (strpos($k, "subService") === 0) {
$subservice[$k] = $v;
}
}
//insert into antrian_online.queue
$resp = $this->insert_or_update("antrian_online.queue", $queue, ["queueID"]);
if ($resp["status"] != "OK") {
echo json_encode($resp);
exit;
}
//insert or update antrian_online.subservice
$resp = $this->insert_or_update(
"antrian_online.subservice",
$subservice,
["subServiceID"]
);
if ($resp["status"] != "OK") {
echo json_encode($resp);
exit;
}
//insert or update antrian_online.m_patient
$resp = $this->insert_or_update(
"antrian_online.m_patient",
$patient,
["M_PatientID"]
);
if ($resp["status"] != "OK") {
echo json_encode($resp);
exit;
}
// post to update
$prm = ["queueID" => $queueID, "status" => "Y"];
$url = $this->baseUrl . "/update";
$resp = $this->post($url, json_encode($prm));
if ($resp["status"] == "OK") {
$this->db->trans_commit();
} else {
$this->db->trans_rollback();
echo json_encode($resp);
exit;
}
}
echo json_encode(["status" => "OK", "message" => "$total Queue Downloaded"]);
}
function insert_or_update($table, $dt, $keys)
{
$s_where = "";
$param = [];
foreach ($keys as $k) {
if ($s_where != "") {
$s_where .= " and ";
}
$s_where .= " $k = ?";
$param[] = $dt[$k];
}
$sql = "select count(*) as total
from $table
where $s_where ";
$qry = $this->db->query($sql, $param);
if (!$qry) {
return [
"status" => "ERR",
"message" =>
$this->db->error()["message"] .
"|" .
$this->db->last_query(),
];
}
$rows = $qry->result_array();
$status = "Insert";
if (count($rows) > 0) {
if ($rows[0]["total"] > 0) {
foreach ($keys as $k) {
$this->db->where($k, $dt[$k]);
}
$qry = $this->db->update($table, $dt);
if (!$qry) {
return [
"status" => "ERR",
"message" =>
"ERR Update : " .
$this->db->error()["message"] .
"|" .
$this->db->last_query(),
];
}
$status = "Update";
} else {
//insert
$qry = $this->db->insert($table, $dt);
if (!$qry) {
return [
"status" => "ERR",
"message" =>
"ERR Insert : " .
$this->db->error()["message"] .
"|" .
$this->db->last_query(),
];
}
}
} else {
//insert
$qry = $this->db->insert($table, $dt);
if (!$qry) {
return [
"status" => "ERR",
"message" =>
"ERR Insert : " .
$this->db->error()["message"] .
"|" .
$this->db->last_query(),
];
}
}
return ["status" => "OK", "message" => $status];
}
function log($msg)
{
echo "{$this->now()} $msg\n";
}
function get($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec($ch);
if (curl_errno($ch) > 0) {
return [
"status" => "ERR",
"message" => curl_error($ch),
];
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
return [
"status" => "ERR",
"message" => "Http Response : $httpCode",
];
}
$j_result = json_decode($result, true);
if (!$j_result) {
return [
"status" => "ERR",
"message" => "JSON invalid: $result",
];
}
return $j_result;
}
function post($url, $data)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/octet-stream",
"Content-Length: " . strlen($data),
]);
$result = curl_exec($ch);
if (curl_errno($ch) > 0) {
return [
"status" => "ERR",
"message" => curl_error($ch),
];
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
return [
"status" => "ERR",
"message" => "Http Response : $httpCode",
];
}
$j_result = json_decode($result, true);
if (!$j_result) {
return [
"status" => "ERR",
"message" => "JSON invalid: $result",
];
}
return $j_result;
}
}

View File

@@ -0,0 +1,207 @@
<?php
class Upload_aol extends MY_Controller
{
var $base_url;
function __construct()
{
parent::__construct();
$this->debug = false;
$this->base_url = "https://mobile.pramita.co.id/";
}
function now()
{
return Date("Y-m-d H:i:s");
}
function log($msg)
{
echo "{$this->now()} $msg\n";
}
public function index()
{
//antrian_upload
$this->db->trans_begin();
$sql =
"select * from antrian_upload where AntrianUploadIsActive='Y' and AntrianUploadIsSent ='N' limit 0,1";
$qry = $this->db->query($sql);
if (!$qry) {
$this->log("Error antrian_upload : " . $this->db->error()["message"]);
$this->db->trans_rollback();
exit();
}
if (count($qry->result_array()) == 0) {
$this->log("No Pending antrian_upload.");
$this->db->trans_rollback();
exit();
}
//branch
$sql =
"select * from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault='Y'";
$qry = $this->db->query($sql);
if (!$qry) {
echo "{$this->now()} ERR : {$this->db->error()["message"]}\n . {$this->db->last_query}";
exit();
}
$rows = $qry->result_array();
if (count($rows) == 0) {
$this->log("ERR : No Default Branch");
exit();
}
$branchID = $rows[0]["M_BranchID"];
$branchCode = $rows[0]["M_BranchCode"];
//subservice
//subservice_kuota
//subservice_kuota_detail
$sql =
"select ? subServiceM_BranchID, subservice.*
from subservice";
$qry = $this->db->query($sql, [$branchID]);
if (!$qry) {
echo "{$this->now()} ERR subservice: {$this->db->error()["message"]}\n . {$this->db->last_query()}";
exit();
}
$subservice = $qry->result_array();
$sql = "select ? subServiceQuotaM_BranchID, subservice_kuota.*
from subservice_kuota";
$qry = $this->db->query($sql, [$branchID]);
if (!$qry) {
echo "{$this->now()} ERR subservice_kuota: {$this->db->error()["message"]}\n . {$this->db->last_query()}";
exit();
}
$subservice_kuota = $qry->result_array();
$sql = "select ? SubServiceKuotaDetailM_BranchID, subservice_kuota_detail.*
from subservice_kuota_detail";
$qry = $this->db->query($sql, [$branchID]);
if (!$qry) {
echo "{$this->now()} ERR subservice_kuota_detail : {$this->db->error()["message"]}\n . {$this->db->last_query()}";
exit();
}
$subservice_kuota_detail = $qry->result_array();
$data = [
"subservice" => $subservice,
"subservice_kuota" => $subservice_kuota,
"subservice_kuota_detail" => $subservice_kuota_detail,
];
$jdata = json_encode($data);
$md5 = md5($jdata);
$param = ["md5" => $md5, "data" => $data];
$jparam = json_encode($param);
$zparam = gzcompress($jparam);
$size = round(strlen($zparam) / 1024, 2);
$size_org = round(strlen($jparam) / 1024, 2);
$this->log(
"Upload SubService Kuota Masterdata (compressed): " .
$size_org .
" => " .
$size .
" kB"
);
$url = "{$this->base_url}one-api/antrian_online/r_aol";
$resp = $this->post($url, $zparam);
if ($resp["status"] == "ERR") {
$this->log("Error Upload Subservice Masterdata " . $resp["message"]);
$this->db->trans_rollback();
exit();
}
$sql =
"update antrian_upload set AntrianUploadIsSent='Y', AntrianUploadSentDate = now() where AntrianUploadIsSent='N' and AntrianUploadIsActive='Y'";
$qry = $this->db->query($sql);
if (!$qry) {
echo "{$this->now()} ERR update antrian_upload : {$this->db->error()["message"]}\n . {$this->db->last_query()}";
exit();
}
$this->db->trans_commit();
$this->log("Upload Subservice MasterData [OK] " . json_encode($resp["result"]));
}
function post($url, $data)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/octet-stream",
"Content-Length: " . strlen($data),
]);
$result = curl_exec($ch);
if (curl_errno($ch) > 0) {
return [
"status" => "ERR",
"message" => curl_error($ch),
];
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
return [
"status" => "ERR",
"message" => "Http Response : $httpCode",
];
}
$j_result = json_decode($result, true);
if (!$j_result) {
return [
"status" => "ERR",
"message" => "JSON invalid: $result",
];
}
return $j_result;
}
}
/*
CREATE TABLE `hs_schedule` (
`HS_ScheduleID` int(11) NOT NULL AUTO_INCREMENT,
`HS_ScheduleM_BranchID` int(11) NOT NULL,
`HS_ScheduleM_BranchCode` varchar(2),
`HS_ScheduleM_RegDayID` int(11) NOT NULL,
`HS_ScheduleLimit` int(11) NOT NULL DEFAULT 10,
`HS_ScheduleIsActive` char(1) NOT NULL DEFAULT 'Y',
`HS_ScheduleUserID` int(11) NOT NULL DEFAULT 3,
`HS_ScheduleCreated` datetime NOT NULL DEFAULT current_timestamp(),
`HS_ScheduleLastUpdated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`HS_ScheduleID`,HS_ScheduleM_BranchID),
key(HS_ScheduleM_RegDayID),
key(HS_ScheduleM_BranchCode)
);
CREATE TABLE `hs_scheduledetail` (
`HS_ScheduleDetailID` int(11) NOT NULL AUTO_INCREMENT,
`HS_ScheduleDetailM_BranchID` int(11) NOT NULL ,
`HS_ScheduleDetailM_BranchCode` varchar(2) NOT NULL ,
`HS_ScheduleDetailHS_ScheduleID` int(11) NOT NULL,
`HS_ScheduleDetailM_RegTimeID` int(11) NOT NULL,
`HS_ScheduleDetailIsActive` char(1) NOT NULL DEFAULT 'Y',
`HS_ScheduleDetailUserID` int(11) NOT NULL DEFAULT 3,
`HS_ScheduleDetailCreated` datetime NOT NULL DEFAULT current_timestamp(),
`HS_ScheduleDetailLastUpdated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`HS_ScheduleDetailID`,HS_ScheduleDetailM_BranchID),
KEY `HS_ScheduleDetailHS_ScheduleID` (`HS_ScheduleDetailHS_ScheduleID`),
KEY `HS_ScheduleDetailHS_Time` (`HS_ScheduleDetailM_RegTimeID`)
);
drop table hs_sum_tx;
create table hs_sum_tx (
HS_SumTxM_BranchID int,
HS_SumTxM_BranchCode varchar(2),
HS_SumTxT_TransactionID int,
HS_SumTxT_TrancactionCreated datetime,
HS_SumTxT_OrderDateTime datetime,
HS_SumTxT_OrderID int,
HS_SumTxT_OrderNumber varchar(50),
HS_SumTxT_TransactionIsActive varchar(1),
HS_SumTxT_OrderIsActive varchar(1),
primary key (HS_SumTxM_BranchID,HS_SumTxT_TransactionID,HS_SumTxT_OrderID),
key (HS_SumTxM_BranchID),
key (HS_SumTxT_TransactionID),
key (HS_SumTxT_TrancactionCreated),
key (HS_SumTxT_OrderDateTime),
key (HS_SumTxT_OrderIsActive),
key (HS_SumTxT_TransactionIsActive)
);
*/

View File

@@ -0,0 +1,39 @@
<?php
class Qr_polos extends MY_Controller
{
public function __construct()
{
parent::__construct();
}
function pcr($nolab)
{
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $nolab);
header("Content-type: image/png");
echo $img_qrcode;
exit;
}
public function post($url, $data)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type: application/text',
'Content-Length: ' . strlen($data)
)
);
$result = curl_exec($ch);
if (curl_error($ch) != "") {
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
}
curl_close($ch);
return $result;
}
}

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