add rssa-pintar to git
This commit is contained in:
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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. Helper files
|
||||
| 4. Custom config files
|
||||
| 5. Language files
|
||||
| 6. Models
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Packges
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['packages'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Libraries
|
||||
| -------------------------------------------------------------------
|
||||
| These are the classes located in the system/libraries folder
|
||||
| or in your application/libraries folder.
|
||||
|
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
|
||||
*/
|
||||
|
||||
$autoload['libraries'] = array('form_validation','database','table','session');
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Helper Files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['helper'] = array('url', 'file');
|
||||
*/
|
||||
|
||||
$autoload['helper'] = array('url','form','date');
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| 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('model1', 'model2');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['model'] = array();
|
||||
|
||||
|
||||
/* End of file autoload.php */
|
||||
/* Location: ./application/config/autoload.php */
|
||||
@@ -0,0 +1,370 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
date_default_timezone_set("Asia/Jakarta");
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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'] = 'http://rssa-pintar.rssa';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| URI PROTOCOL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This item determines which server global should be used to retrieve the
|
||||
| URI string. The default setting of 'AUTO' works for most servers.
|
||||
| If your links do not seem to work, try one of the other delicious flavors:
|
||||
|
|
||||
| 'AUTO' Default - auto detects
|
||||
| 'PATH_INFO' Uses the PATH_INFO
|
||||
| 'QUERY_STRING' Uses the QUERY_STRING
|
||||
| 'REQUEST_URI' Uses the REQUEST_URI
|
||||
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
||||
|
|
||||
*/
|
||||
$config['uri_protocol'] = 'AUTO';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| URL suffix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
|
||||
| For more information please see the user guide:
|
||||
|
|
||||
| http://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.
|
||||
|
|
||||
*/
|
||||
$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:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/core_classes.html
|
||||
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
||||
|
|
||||
*/
|
||||
$config['subclass_prefix'] = 'MY_';
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allowed URL Characters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This lets you specify with a regular expression 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.
|
||||
|
|
||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
||||
|
|
||||
*/
|
||||
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable Query Strings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default CodeIgniter uses search-engine friendly segment based URLs:
|
||||
| example.com/who/what/where/
|
||||
|
|
||||
| By default CodeIgniter enables access to the $_GET array. If for some
|
||||
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
||||
|
|
||||
| You can optionally enable standard query string based URLs:
|
||||
| example.com?who=me&what=something&where=here
|
||||
|
|
||||
| Options are: TRUE or FALSE (boolean)
|
||||
|
|
||||
| The other items let you set the query string 'words' that will
|
||||
| invoke your controllers and its functions:
|
||||
| example.com/index.php?c=controller&m=function
|
||||
|
|
||||
| Please note that some of the helpers won't work as expected when
|
||||
| this feature is enabled, since CodeIgniter is designed primarily to
|
||||
| use segment based URLs.
|
||||
|
|
||||
*/
|
||||
$config['allow_get_array'] = TRUE;
|
||||
$config['enable_query_strings'] = FALSE;
|
||||
$config['controller_trigger'] = 'c';
|
||||
$config['function_trigger'] = 'm';
|
||||
$config['directory_trigger'] = 'd'; // experimental not currently in use
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Error Logging Threshold
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you have enabled error logging, you can set an error threshold to
|
||||
| determine what gets logged. Threshold options are:
|
||||
| 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
|
||||
|
|
||||
| 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/ folder. Use a full server path with trailing slash.
|
||||
|
|
||||
*/
|
||||
$config['log_path'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Directory Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Leave this BLANK unless you would like to set something other than the default
|
||||
| system/cache/ folder. Use a full server path with trailing slash.
|
||||
|
|
||||
*/
|
||||
$config['cache_path'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you use the Encryption class or the Session class you
|
||||
| MUST set an encryption key. See the user guide for info.
|
||||
|
|
||||
*/
|
||||
$config['encryption_key'] = 'B3b4SSsss555';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Variables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 'sess_cookie_name' = the name you want for the cookie
|
||||
| 'sess_expiration' = the number of SECONDS you want the session to last.
|
||||
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
|
||||
| 'sess_expire_on_close' = Whether to cause the session to expire automatically
|
||||
| when the browser window is closed
|
||||
| 'sess_encrypt_cookie' = Whether to encrypt the cookie
|
||||
| 'sess_use_database' = Whether to save the session data to a database
|
||||
| 'sess_table_name' = The name of the session database table
|
||||
| 'sess_match_ip' = Whether to match the user's IP address when reading the session data
|
||||
| 'sess_match_useragent' = Whether to match the User Agent when reading the session data
|
||||
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
||||
|
|
||||
*/
|
||||
$config['sess_cookie_name'] = 'ci_session';
|
||||
$config['sess_expiration'] = 7200;
|
||||
$config['sess_expire_on_close'] = FALSE;
|
||||
$config['sess_encrypt_cookie'] = FALSE;
|
||||
$config['sess_use_database'] = FALSE;
|
||||
$config['sess_table_name'] = 'ci_sessions';
|
||||
$config['sess_match_ip'] = FALSE;
|
||||
$config['sess_match_useragent'] = TRUE;
|
||||
$config['sess_time_to_update'] = 300;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cookie Related Variables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 'cookie_prefix' = Set a 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' = Cookies will only be set if a secure HTTPS connection exists.
|
||||
|
|
||||
*/
|
||||
$config['cookie_prefix'] = "";
|
||||
$config['cookie_domain'] = "";
|
||||
$config['cookie_path'] = "/";
|
||||
$config['cookie_secure'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global XSS Filtering
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines whether the XSS filter is always active when GET, POST or
|
||||
| COOKIE data is encountered
|
||||
|
|
||||
*/
|
||||
$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.
|
||||
*/
|
||||
$config['csrf_protection'] = FALSE;
|
||||
$config['csrf_token_name'] = 'csrf_test_name';
|
||||
$config['csrf_cookie_name'] = 'csrf_cookie_name';
|
||||
$config['csrf_expire'] = 7200;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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.
|
||||
|
|
||||
| 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 'gmt'. This pref tells the system whether to use
|
||||
| your server's local time as the master 'now' reference, or convert it to
|
||||
| GMT. 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)
|
||||
|
|
||||
*/
|
||||
$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 the HTTP_X_FORWARDED_FOR
|
||||
| header in order to properly identify the visitor's IP address.
|
||||
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
||||
|
|
||||
*/
|
||||
$config['proxy_ips'] = '';
|
||||
|
||||
|
||||
/* End of file config.php */
|
||||
/* Location: ./application/config/config.php */
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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.
|
||||
|
|
||||
*/
|
||||
define('FILE_READ_MODE', 0644);
|
||||
define('FILE_WRITE_MODE', 0666);
|
||||
define('DIR_READ_MODE', 0755);
|
||||
define('DIR_WRITE_MODE', 0777);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| File Stream Modes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These modes are used when working with fopen()/popen()
|
||||
|
|
||||
*/
|
||||
|
||||
define('FOPEN_READ', 'rb');
|
||||
define('FOPEN_READ_WRITE', 'r+b');
|
||||
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
|
||||
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
|
||||
define('FOPEN_WRITE_CREATE', 'ab');
|
||||
define('FOPEN_READ_WRITE_CREATE', 'a+b');
|
||||
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
|
||||
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
|
||||
|
||||
|
||||
/* End of file constants.php */
|
||||
/* Location: ./application/config/constants.php */
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| ['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 type. ie: mysql. Currently supported:
|
||||
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
||||
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||
| to the table name when using the Active Record 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
|
||||
| ['autoinit'] Whether or not to automatically initialize the database.
|
||||
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
|
||||
| - good for ensuring strict SQL while developing
|
||||
|
|
||||
| The $active_group variable lets you choose which connection group to
|
||||
| make active. By default there is only one group (the 'default' group).
|
||||
|
|
||||
| The $active_record variables lets you determine whether or not to load
|
||||
| the active record class
|
||||
*/
|
||||
|
||||
$active_group = 'default';
|
||||
$active_record = TRUE;
|
||||
|
||||
$db['default']['hostname'] = 'localhost';
|
||||
$db['default']['username'] = 'www-data';
|
||||
$db['default']['password'] = 'www-data';
|
||||
$db['default']['database'] = 'rssa_pintar';
|
||||
$db['default']['dbdriver'] = 'mysqli';
|
||||
$db['default']['dbprefix'] = '';
|
||||
$db['default']['pconnect'] = TRUE;
|
||||
$db['default']['db_debug'] = TRUE;
|
||||
$db['default']['cache_on'] = FALSE;
|
||||
$db['default']['cachedir'] = '';
|
||||
$db['default']['char_set'] = 'utf8';
|
||||
$db['default']['dbcollat'] = 'utf8_general_ci';
|
||||
$db['default']['swap_pre'] = '';
|
||||
$db['default']['autoinit'] = TRUE;
|
||||
$db['default']['stricton'] = FALSE;
|
||||
|
||||
|
||||
/* End of file database.php */
|
||||
/* Location: ./application/config/database.php */
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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">',
|
||||
'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">'
|
||||
);
|
||||
|
||||
/* End of file doctypes.php */
|
||||
/* Location: ./application/config/doctypes.php */
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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',
|
||||
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
|
||||
'/ç|ć|ĉ|ċ|č/' => 'c',
|
||||
'/Ð|Ď|Đ/' => 'D',
|
||||
'/ð|ď|đ/' => 'd',
|
||||
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
|
||||
'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
|
||||
'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
|
||||
'/ĝ|ğ|ġ|ģ/' => 'g',
|
||||
'/Ĥ|Ħ/' => 'H',
|
||||
'/ĥ|ħ/' => 'h',
|
||||
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
|
||||
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
|
||||
'/Ĵ/' => 'J',
|
||||
'/ĵ/' => 'j',
|
||||
'/Ķ/' => 'K',
|
||||
'/ķ/' => 'k',
|
||||
'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
|
||||
'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
|
||||
'/Ñ|Ń|Ņ|Ň/' => 'N',
|
||||
'/ñ|ń|ņ|ň|ʼn/' => 'n',
|
||||
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
|
||||
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
|
||||
'/Ŕ|Ŗ|Ř/' => 'R',
|
||||
'/ŕ|ŗ|ř/' => 'r',
|
||||
'/Ś|Ŝ|Ş|Š/' => 'S',
|
||||
'/ś|ŝ|ş|š|ſ/' => 's',
|
||||
'/Ţ|Ť|Ŧ/' => 'T',
|
||||
'/ţ|ť|ŧ/' => 't',
|
||||
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
|
||||
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
|
||||
'/Ý|Ÿ|Ŷ/' => 'Y',
|
||||
'/ý|ÿ|ŷ/' => 'y',
|
||||
'/Ŵ/' => 'W',
|
||||
'/ŵ/' => 'w',
|
||||
'/Ź|Ż|Ž/' => 'Z',
|
||||
'/ź|ż|ž/' => 'z',
|
||||
'/Æ|Ǽ/' => 'AE',
|
||||
'/ß/'=> 'ss',
|
||||
'/IJ/' => 'IJ',
|
||||
'/ij/' => 'ij',
|
||||
'/Œ/' => 'OE',
|
||||
'/ƒ/' => 'f'
|
||||
);
|
||||
|
||||
/* End of file foreign_chars.php */
|
||||
/* Location: ./application/config/foreign_chars.php */
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/hooks.html
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of file hooks.php */
|
||||
/* Location: ./application/config/hooks.php */
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/Disable Migrations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Migrations are disabled by default but should be enabled
|
||||
| whenever you intend to do a schema migration.
|
||||
|
|
||||
*/
|
||||
$config['migration_enabled'] = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migrations version
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is used to set migration version that the file system should be on.
|
||||
| If you run $this->migration->latest() 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/';
|
||||
|
||||
|
||||
/* End of file migration.php */
|
||||
/* Location: ./application/config/migration.php */
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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.
|
||||
|
|
||||
*/
|
||||
|
||||
$mimes = array( 'hqx' => 'application/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'),
|
||||
'bin' => 'application/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' => 'application/x-photoshop',
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => array('application/pdf', 'application/x-download'),
|
||||
'ai' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
|
||||
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
|
||||
'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',
|
||||
'php' => 'application/x-httpd-php',
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => 'application/x-javascript',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-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-windows-bmp'),
|
||||
'gif' => 'image/gif',
|
||||
'jpeg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpe' => array('image/jpeg', 'image/pjpeg'),
|
||||
'png' => array('image/png', 'image/x-png'),
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
'css' => 'text/css',
|
||||
'html' => 'text/html',
|
||||
'htm' => 'text/html',
|
||||
'shtml' => 'text/html',
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => array('text/plain', 'text/x-log'),
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => 'text/xml',
|
||||
'xsl' => 'text/xml',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => 'application/msword',
|
||||
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),
|
||||
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),
|
||||
'word' => array('application/msword', 'application/octet-stream'),
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822',
|
||||
'json' => array('application/json', 'text/json')
|
||||
);
|
||||
|
||||
|
||||
/* End of file mimes.php */
|
||||
/* Location: ./application/config/mimes.php */
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/profiling.html
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of file profiler.php */
|
||||
/* Location: ./application/config/profiler.php */
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/routing.html
|
||||
|
|
||||
| -------------------------------------------------------------------------
|
||||
| RESERVED ROUTES
|
||||
| -------------------------------------------------------------------------
|
||||
|
|
||||
| There area two 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 what URI segments to use if those provided
|
||||
| in the URL cannot be matched to a valid route.
|
||||
|
|
||||
*/
|
||||
|
||||
$route['default_controller'] = "welcome";
|
||||
$route['404_override'] = '';
|
||||
|
||||
|
||||
/* End of file routes.php */
|
||||
/* Location: ./application/config/routes.php */
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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 simileys. For example:
|
||||
| :-) and :) use the same image replacement.
|
||||
|
|
||||
| Please see user guide for more info:
|
||||
| http://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', 'excaim'),
|
||||
':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
|
||||
|
||||
);
|
||||
|
||||
/* End of file smileys.php */
|
||||
/* Location: ./application/config/smileys.php */
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php if ( ! defined('BASEPATH')) 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 6.0' => 'Windows Longhorn',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'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' => 'Unknown Windows OS',
|
||||
'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'
|
||||
);
|
||||
|
||||
|
||||
// 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(
|
||||
'Flock' => 'Flock',
|
||||
'Chrome' => 'Chrome',
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => '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'
|
||||
);
|
||||
|
||||
$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",
|
||||
'hiptop' => "Danger Hiptop",
|
||||
'nec-' => "NEC",
|
||||
'panasonic' => "Panasonic",
|
||||
'philips' => "Philips",
|
||||
'sagem' => "Sagem",
|
||||
'sanyo' => "Sanyo",
|
||||
'spv' => "SPV",
|
||||
'zte' => "ZTE",
|
||||
'sendo' => "Sendo",
|
||||
|
||||
// Operating Systems
|
||||
'symbian' => "Symbian",
|
||||
'SymbianOS' => "SymbianOS",
|
||||
'elaine' => "Palm",
|
||||
'palm' => "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",
|
||||
|
||||
// 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',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'askjeeves' => 'AskJeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos'
|
||||
);
|
||||
|
||||
/* End of file user_agents.php */
|
||||
/* Location: ./application/config/user_agents.php */
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
use chriskacerguis\RestServer\RestController;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Api_rssa extends RestController
|
||||
{
|
||||
var $module = 'api/login'; //ini nama module
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
Modules::run('security/common_security', $this->module);
|
||||
}
|
||||
public function index_get()
|
||||
{
|
||||
|
||||
//$this->api_login("meninjar@simrs", "dibawahmejasaya");
|
||||
$this->api_connect("pasien", "Y1hLd2tUeTdBSGt6c05sOWxoWmVwV1B6SllkYVhZaHBlTXpJZWNxUw==", "10026543");
|
||||
exit;
|
||||
//$data = $this->db->get('master_user')->result();
|
||||
$array_query = [
|
||||
'select' => 'master_user.*',
|
||||
'from' => 'master_user',
|
||||
'order_by' => 'master_user.mu_id, ASC'
|
||||
];
|
||||
$get_all_data = Modules::run('database/get', $array_query)->result();
|
||||
|
||||
$get_data = Modules::run('database/get', ['from' => 'master_user', 'order_by' => 'mu_id'])->result();
|
||||
//$data = 'Data Berhasil Load Data';
|
||||
$this->response($get_data, RestController::HTTP_OK);
|
||||
}
|
||||
|
||||
public function login_post()
|
||||
{
|
||||
$request = $this->post();
|
||||
$response = null;
|
||||
$method = $this->_detect_method();
|
||||
|
||||
try {
|
||||
$username = isset($request['username']) ? $request['username'] : '';
|
||||
$password = isset($request['password']) ? $request['password'] : '';
|
||||
|
||||
if ($username == "" || $password == "") {
|
||||
$response = response_error("Username dan password harus diisi");
|
||||
$this->set_response($response, RestController::HTTP_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
$where = array(
|
||||
"username" => $username
|
||||
);
|
||||
|
||||
$user_data = $this->m_common->get('user', $where)->row();
|
||||
|
||||
$response = response_error("Username atau password salah");
|
||||
|
||||
if (isset($user_data)) {
|
||||
$is_password_valid = verify_password($password, $user_data->password);
|
||||
unset($user_data->password);
|
||||
if ($is_password_valid)
|
||||
$response = response_success();
|
||||
}
|
||||
|
||||
if (!$response['success']) {
|
||||
$this->set_response($response, RestController::HTTP_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
$response = response_success("Login berhasil");
|
||||
$this->set_response($response, RestController::HTTP_OK);
|
||||
} catch (Exception $ex) {
|
||||
|
||||
$response = response_error($ex->getMessage());
|
||||
// $this->set_response($response, RestController::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function api_connect($param, $token, $value)
|
||||
{
|
||||
|
||||
//$url = "http://10.10.123.63:9000/api/pasien/10026543";
|
||||
$url = "http://10.10.123.63:9000/api/" . $param . "/" . $value;
|
||||
|
||||
//print_r($url);
|
||||
$authorization = "x-token:" . $token;
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [$authorization],
|
||||
CURLOPT_URL => $url
|
||||
]);
|
||||
|
||||
$return = curl_exec($ch);
|
||||
|
||||
$result = array();
|
||||
$api_array = json_decode($return, TRUE);
|
||||
print_r($api_array);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function api_login($username, $password)
|
||||
{
|
||||
// http://10.10.123.63:9000/api/login?email=ragil@simrs&password=gantenggantengserigala2022
|
||||
|
||||
$url = "http://10.10.123.63:9000/api/login?email=" . $username . "&password=" . $password;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_URL => $url
|
||||
]);
|
||||
|
||||
$return = curl_exec($ch);
|
||||
|
||||
$result = array();
|
||||
$api_array = json_decode($return, TRUE);
|
||||
print_r($api_array);
|
||||
//print_r($api_array['code']);
|
||||
/*if ($api_array['code'] == '200') {
|
||||
$result['status'] = TRUE;
|
||||
$result['content'] = $api_array['content'];
|
||||
} else {
|
||||
$result['status'] = FALSE;
|
||||
$result['content'] = "connect api failed, try again";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class Apiconection extends CI_Controller{
|
||||
public function api_connect($param, $token, $value)
|
||||
{
|
||||
|
||||
//$url = "http://10.10.123.63:9000/api/pasien/10026543";
|
||||
$url = "http://10.10.123.63:9000/api/" . $param . "/" . $value;
|
||||
|
||||
//print_r($url);
|
||||
$authorization = "x-token:" . $token;
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [$authorization],
|
||||
CURLOPT_URL => $url
|
||||
]);
|
||||
|
||||
$return = curl_exec($ch);
|
||||
|
||||
$result = array();
|
||||
$api_array = json_decode($return, TRUE);
|
||||
print_r($api_array);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function api_login($username, $password)
|
||||
{
|
||||
// http://10.10.123.63:9000/api/login?email=ragil@simrs&password=gantenggantengserigala2022
|
||||
|
||||
$url = "http://10.10.123.63:9000/api/login?email=" . $username . "&password=" . $password;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_URL => $url
|
||||
]);
|
||||
|
||||
$return = curl_exec($ch);
|
||||
|
||||
$result = array();
|
||||
$api_array = json_decode($return, TRUE);
|
||||
print_r($api_array);
|
||||
//print_r($api_array['code']);
|
||||
/*if ($api_array['code'] == '200') {
|
||||
$result['status'] = TRUE;
|
||||
$result['content'] = $api_array['content'];
|
||||
} else {
|
||||
$result['status'] = FALSE;
|
||||
$result['content'] = "connect api failed, try again";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class Login extends CI_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
public function index($error = NULL){
|
||||
$data['error']=$error;
|
||||
$this->load->view('login/v_login',$data);
|
||||
}
|
||||
public function process(){
|
||||
$this->load->model('m_login');
|
||||
$result = $this->m_login->validate();
|
||||
if(! $result){
|
||||
$error = '<div class="alert alert-danger alert-dismissable">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
|
||||
<i class="icon fa fa-ban"></i> Username atau Password Salah!
|
||||
</div>';
|
||||
$this->index($error);
|
||||
}else{
|
||||
redirect('index.php');
|
||||
}
|
||||
}
|
||||
public function logout(){
|
||||
$this->session->sess_destroy();
|
||||
redirect('index.php/login');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
//-------------ID user login = 18
|
||||
|
||||
class Ps_datapenunjang extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '18');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Data Penunjang';
|
||||
$data['main_content'] = 'datapenunjang/v_datapenunjang';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_datapenunjang');
|
||||
$datapenunjang = $this->m_datapenunjang->index();
|
||||
$this->load->vars('dp', $datapenunjang);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->index();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->index();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->index();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dpjp = $this->m_dokter->index();
|
||||
$this->load->vars('dpjp', $dpjp);
|
||||
|
||||
$this->load->model('m_datapenunjang');
|
||||
$ro = $this->m_datapenunjang->radiologi();
|
||||
$this->load->vars('rolist', $ro);
|
||||
|
||||
$this->load->model('m_datapenunjang');
|
||||
$lb = $this->m_datapenunjang->lab();
|
||||
$this->load->vars('lablist', $lb);
|
||||
|
||||
$this->load->model('m_datapenunjang');
|
||||
$lbpa = $this->m_datapenunjang->labpa();
|
||||
$this->load->vars('labpalist', $lbpa);
|
||||
|
||||
$this->load->model('m_datapenunjang');
|
||||
$lbm = $this->m_datapenunjang->labmikro();
|
||||
$this->load->vars('labmikrolist', $lbm);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
//-------------ID user login = 19
|
||||
|
||||
class Ps_dataresume extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '19');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Data Resume';
|
||||
$data['main_content'] = 'dataresume/v_dataresume';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_dataresume');
|
||||
$dataresume = $this->m_dataresume->index();
|
||||
$this->load->vars('dr', $dataresume);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->index();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->index();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->index();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dpjp = $this->m_dokter->index();
|
||||
$this->load->vars('dpjp', $dpjp);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
//-------------ID user login = 7
|
||||
|
||||
class Ps_dokter extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '7');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Dokter';
|
||||
$data['main_content'] = 'master/dokter/v_dokter';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->index();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Dokter';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/dokter/form_dokter';
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Dokter';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/dokter/form_dokter';
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_dokter');
|
||||
$this->m_dokter->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Dokter baru');
|
||||
redirect('index.php/ps_dokter');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Dokter';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/dokter/form_dokter';
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->edit($id);
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$setpass = $this->input->post('passworduser');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
if(!empty($setpass)){
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Dokter';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/dokter/form_dokter';
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->edit($id);
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Dokter');
|
||||
$this->load->model('m_dokter');
|
||||
$this->m_dokter->prosesedit();
|
||||
redirect('index.php/ps_dokter');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Dokter';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/dokter/form_dokter';
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->edit($id);
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Dokter');
|
||||
$this->load->model('m_dokter');
|
||||
$this->m_dokter->delete($id);
|
||||
redirect('index.php/ps_dokter');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Dokter');
|
||||
$this->load->model('m_dokter');
|
||||
$this->m_dokter->disabled($id);
|
||||
redirect('index.php/ps_dokter');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_dokter');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Dokter');
|
||||
$this->load->model('m_dokter');
|
||||
$this->m_dokter->aktif($id);
|
||||
redirect('index.php/ps_dokter');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
//-------------ID hak akses = 3
|
||||
|
||||
class Ps_hakakses extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '3');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Hak Akses';
|
||||
$data['main_content'] = 'setting/hakakses/v_hakakses';
|
||||
$data['error']=$error;
|
||||
$this->load->model('m_tipeuser');
|
||||
$hakakses = $this->m_tipeuser->index();
|
||||
$this->load->vars('ha', $hakakses);
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Tipe User';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'setting/hakakses/form_tipeuser';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namatipeuser','Nama Tipe User','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Tipe User';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'setting/hakakses/form_tipeuser';
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_tipeuser');
|
||||
$this->m_tipeuser->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Tipe User baru');
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Tipe User';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'setting/hakakses/form_tipeuser';
|
||||
$this->load->model('m_tipeuser');
|
||||
$hakakses = $this->m_tipeuser->edit($id);
|
||||
$this->load->vars('ha', $hakakses);
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namatipeuser','Nama Tipe User','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Tipe User';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'setting/hakakses/form_tipeuser';
|
||||
$this->load->model('m_tipeuser');
|
||||
$hakakses = $this->m_tipeuser->edit($id);
|
||||
$this->load->vars('ha', $hakakses);
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Tipe User');
|
||||
$this->load->model('m_tipeuser');
|
||||
$this->m_tipeuser->prosesedit();
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Tipe User';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'setting/hakakses/form_tipeuser';
|
||||
$this->load->model('m_tipeuser');
|
||||
$hakakses = $this->m_tipeuser->view($id);
|
||||
$this->load->vars('ha', $hakakses);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Tipe User');
|
||||
$this->load->model('m_tipeuser');
|
||||
$this->m_tipeuser->delete($id);
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
|
||||
//--------------------------------------------------HAK AKSES---------------------------------------------------------//
|
||||
public function edithakakses($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Hak Akses Menu';
|
||||
$data['actionform'] = 'prosesedithakakses';
|
||||
$data['main_content'] = 'setting/hakakses/form_hakakses';
|
||||
$data['iduserpost']=$id;
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->edit($id);
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->model('m_menu');
|
||||
$menu = $this->m_menu->index();
|
||||
$this->load->vars('mn', $menu);
|
||||
|
||||
$this->load->model('m_menu');
|
||||
$hakakses = $this->m_menu->hakakses($id);
|
||||
$this->load->vars('um', $hakakses);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data karyawan
|
||||
public function prosesedithakakses() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->edit($id);
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->model('m_menu');
|
||||
$menu = $this->m_menu->index();
|
||||
$this->load->vars('mn', $menu);
|
||||
|
||||
$this->load->model('m_menu');
|
||||
$hakakses = $this->m_menu->hakakses($id);
|
||||
$this->load->vars('um', $hakakses);
|
||||
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit hakakses');
|
||||
$this->load->model('m_hakakses');
|
||||
$this->m_hakakses->prosesedithakakses();
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Tipe User');
|
||||
$this->load->model('m_tipeuser');
|
||||
$this->m_tipeuser->disabled($id);
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_hakakses');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Tipe User');
|
||||
$this->load->model('m_tipeuser');
|
||||
$this->m_tipeuser->aktif($id);
|
||||
redirect('index.php/ps_hakakses');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
//-------------ID user login = 13
|
||||
|
||||
class Ps_jadwaldokter extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '13');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Jadwal Dokter';
|
||||
$data['main_content'] = 'jadwaldokter/v_jadwaldokter';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$jadwaldokter = $this->m_jadwaldokter->index();
|
||||
$this->load->vars('jd', $jadwaldokter);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add($bulan,$tahun) {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Jadwal Dokter';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'jadwaldokter/form_jadwaldokter';
|
||||
|
||||
$data['databulan'] = $bulan;
|
||||
$data['datatahun'] = $tahun;
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$jadwaldokter = $this->m_jadwaldokter->index();
|
||||
$this->load->vars('jd', $jadwaldokter);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$spesialis = $this->m_jadwaldokter->spesialisstatus();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$dokter = $this->m_jadwaldokter->dokterstatus();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$this->m_jadwaldokter->prosesedit();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Jadwal Dokter');
|
||||
redirect('index.php/ps_jadwaldokter');
|
||||
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($bulan,$tahun) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Jadwal Dokter';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'jadwaldokter/form_jadwaldokter';
|
||||
|
||||
$data['databulan'] = $bulan;
|
||||
$data['datatahun'] = $tahun;
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$jadwaldokter = $this->m_jadwaldokter->index();
|
||||
$this->load->vars('jd', $jadwaldokter);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$spesialis = $this->m_jadwaldokter->spesialisstatus();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$dokter = $this->m_jadwaldokter->dokterstatus();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Jadwal Dokter');
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$this->m_jadwaldokter->prosesedit();
|
||||
redirect('index.php/ps_jadwaldokter');
|
||||
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($bulan,$tahun) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Jadwal Dokter';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'jadwaldokter/form_jadwaldokter';
|
||||
|
||||
$data['databulan'] = $bulan;
|
||||
$data['datatahun'] = $tahun;
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$jadwaldokter = $this->m_jadwaldokter->index();
|
||||
$this->load->vars('jd', $jadwaldokter);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$spesialis = $this->m_jadwaldokter->spesialisstatus();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$dokter = $this->m_jadwaldokter->dokterstatus();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($bulan,$tahun) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_jadwaldokter');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Jadwal Dokter');
|
||||
$this->load->model('m_jadwaldokter');
|
||||
$this->m_jadwaldokter->delete($bulan,$tahun);
|
||||
redirect('index.php/ps_jadwaldokter');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
//-------------ID user login = 16
|
||||
|
||||
class Ps_laboratorium extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '16');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Laboratorium';
|
||||
$data['main_content'] = 'master/laboratorium/v_laboratorium';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->index();
|
||||
$this->load->vars('la', $laboratorium);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Laboratorium';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/laboratorium/form_laboratorium';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Pemeriksaan','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Laboratorium';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/laboratorium/form_laboratorium';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Pemeriksaan Laboratorium baru');
|
||||
redirect('index.php/ps_laboratorium');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Laboratorium';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/laboratorium/form_laboratorium';
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->edit($id);
|
||||
$this->load->vars('la', $laboratorium);
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->editdetail($id);
|
||||
$this->load->vars('lad', $laboratorium);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Pemeriksaan','required');
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Laboratorium';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/laboratorium/form_laboratorium';
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->edit($id);
|
||||
$this->load->vars('la', $laboratorium);
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->editdetail($id);
|
||||
$this->load->vars('lad', $laboratorium);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Laboratorium');
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->prosesedit();
|
||||
redirect('index.php/ps_laboratorium');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Laboratorium';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/laboratorium/form_laboratorium';
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->edit($id);
|
||||
$this->load->vars('la', $laboratorium);
|
||||
|
||||
$this->load->model('m_laboratorium');
|
||||
$laboratorium = $this->m_laboratorium->editdetail($id);
|
||||
$this->load->vars('lad', $laboratorium);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Pemeriksaan Laboratorium');
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->delete($id);
|
||||
redirect('index.php/ps_laboratorium');
|
||||
}
|
||||
|
||||
function deletedetail($id,$mlid) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Detail Pemeriksaan Laboratorium');
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->deletedetail($id);
|
||||
redirect('index.php/ps_laboratorium/edit/'.$mlid);
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Pemeriksaan Laboratorium');
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->disabled($id);
|
||||
|
||||
redirect('index.php/ps_laboratorium');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_laboratorium');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Pemeriksaan Laboratorium');
|
||||
$this->load->model('m_laboratorium');
|
||||
$this->m_laboratorium->aktif($id);
|
||||
|
||||
redirect('index.php/ps_laboratorium');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
//-------------ID user login = 6
|
||||
|
||||
class Ps_pasien extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '6');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Pasien';
|
||||
$data['main_content'] = 'master/pasien/v_pasien';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->index();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Pasien';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Pasien';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan pasien baru');
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Pasien';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$setpass = $this->input->post('passworduser');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
if(!empty($setpass)){
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Pasien';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->prosesedit();
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Pasien';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->delete($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->disabled($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->aktif($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
//-------------ID user login = 11
|
||||
|
||||
class Ps_pemeriksaan extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date', 'url'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '11');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Pemeriksaan Penunjang';
|
||||
$data['main_content'] = 'pemeriksaan/v_pemeriksaan';
|
||||
$data['error']=$error;
|
||||
if(! $this->input->post('reservation')){
|
||||
$date1 = date("m/d/Y");
|
||||
$date2 = date("m/d/Y");
|
||||
}else{
|
||||
$datemya = explode("-",$this->input->post('reservation'));
|
||||
$date1 = $datemya[0];
|
||||
$date2 = $datemya[1];
|
||||
}
|
||||
$data['daterange'] = $date1." - ".$date2;
|
||||
$data['spnya'] = $this->input->post('spesialis');
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$pemeriksaan = $this->m_pemeriksaan->search();
|
||||
$this->load->vars('pm', $pemeriksaan);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function addpermin($ket) {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page tambah---------//
|
||||
$data['ket'] = "1";
|
||||
$data['pelayanan'] = $ket;
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'pemeriksaan/form_permin_pemeriksaan';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->pelayanan($ket);
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('pasien','Nama Pasien','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['ket'] = "1";
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'pemeriksaan/form_permin_pemeriksaan';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Permintaan Pem. Penunjang baru');
|
||||
redirect('index.php/ps_pemeriksaan');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id,$ket) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page edit---------//
|
||||
$data['ket'] = $ket;
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'pemeriksaan/form_permin_pemeriksaan';
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$pemeriksaan = $this->m_pemeriksaan->edit($id);
|
||||
$this->load->vars('pm', $pemeriksaan);
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$ro = $this->m_pemeriksaan->radiologi($id);
|
||||
$this->load->vars('rolist', $ro);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$la = $this->m_pemeriksaan->lab($id);
|
||||
$this->load->vars('lalist', $la);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$lp = $this->m_pemeriksaan->labpa($id);
|
||||
$this->load->vars('lapalist', $lp);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$lm = $this->m_pemeriksaan->labmikro($id);
|
||||
$this->load->vars('lamklist', $lm);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$ket= $this->input->post('keter');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
if($ket=="2"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit permintaan Pememeriksaan Penunjang');
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->proseseditpermin();
|
||||
redirect('index.php/ps_pemeriksaan');
|
||||
}else{
|
||||
$namafile = $this->input->post('setnorm')."_".date('ymdhis');
|
||||
|
||||
if($this->session->userdata('s_petugas_rssapintar')==1){
|
||||
$config['upload_path'] = './document/radiologi';
|
||||
$config['allowed_types'] = 'jpg|pdf';
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['max_size'] = 2000;
|
||||
$config['file_name'] = $namafile;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( !$this->upload->do_upload('fileradiologi')){
|
||||
$this->session->set_flashdata('messagedanger', $this->upload->display_errors());
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}else{
|
||||
if($ket=="4"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengisi Pemeriksaan Penunjang Radiologi');
|
||||
}elseif($ket=="3"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Penunjang Radiologi');
|
||||
}
|
||||
$filenya = explode("/",$_FILES['fileradiologi']['type']);
|
||||
if($filenya[1]=="jpeg"){
|
||||
$filenya[1]="jpg";
|
||||
}
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->proseseditupload($namafile.".".$filenya[1]);
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==2){
|
||||
$config['upload_path'] = './document/lab';
|
||||
$config['allowed_types'] = 'jpg|pdf';
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['max_size'] = 2000;
|
||||
$config['file_name'] = $namafile;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( !$this->upload->do_upload('filelab')){
|
||||
$this->session->set_flashdata('messagedanger', $this->upload->display_errors());
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}else{
|
||||
if($ket=="4"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengisi Pemeriksaan Penunjang Lab');
|
||||
}elseif($ket=="3"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Penunjang Lab');
|
||||
}
|
||||
$filenya = explode("/",$_FILES['filelab']['type']);
|
||||
if($filenya[1]=="jpeg"){
|
||||
$filenya[1]="jpg";
|
||||
}
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->proseseditupload($namafile.".".$filenya[1]);
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==3){
|
||||
$config['upload_path'] = './document/labpa';
|
||||
$config['allowed_types'] = 'jpg|pdf';
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['max_size'] = 2000;
|
||||
$config['file_name'] = $namafile;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( !$this->upload->do_upload('filelabpa')){
|
||||
$this->session->set_flashdata('messagedanger', $this->upload->display_errors());
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}else{
|
||||
if($ket=="4"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengisi Pemeriksaan Penunjang Lab PA');
|
||||
}elseif($ket=="3"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Penunjang Lab PA');
|
||||
}
|
||||
$filenya = explode("/",$_FILES['filelabpa']['type']);
|
||||
if($filenya[1]=="jpeg"){
|
||||
$filenya[1]="jpg";
|
||||
}
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->proseseditupload($namafile.".".$filenya[1]);
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==4){
|
||||
$config['upload_path'] = './document/labmikro';
|
||||
$config['allowed_types'] = 'jpg|pdf';
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['max_size'] = 2000;
|
||||
$config['file_name'] = $namafile;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( !$this->upload->do_upload('filelabmikro')){
|
||||
$this->session->set_flashdata('messagedanger', $this->upload->display_errors());
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}else{
|
||||
if($ket=="4"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengisi Pemeriksaan Penunjang Lab Mikro');
|
||||
}elseif($ket=="3"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Penunjang Lab Mikro');
|
||||
}
|
||||
$filenya = explode("/",$_FILES['filelabmikro']['type']);
|
||||
if($filenya[1]=="jpeg"){
|
||||
$filenya[1]="jpg";
|
||||
}
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->proseseditupload($namafile.".".$filenya[1]);
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deletefile($idpfp,$idpp,$ket) {
|
||||
//----start validate page delete-------//
|
||||
//if($this->vardelete==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus file penunjang');
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$this->m_pemeriksaan->deletefile($idpfp);
|
||||
redirect('index.php/ps_pemeriksaan/edit/'.$idpp.'/'.$ket);
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_pemeriksaan');}
|
||||
//----end validate page view---------//
|
||||
$data['ket'] = "5";
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'pemeriksaan/form_permin_pemeriksaan';
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$pemeriksaan = $this->m_pemeriksaan->edit($id);
|
||||
$this->load->vars('pm', $pemeriksaan);
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$ro = $this->m_pemeriksaan->radiologi($id);
|
||||
$this->load->vars('rolist', $ro);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$la = $this->m_pemeriksaan->lab($id);
|
||||
$this->load->vars('lalist', $la);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$lp = $this->m_pemeriksaan->labpa($id);
|
||||
$this->load->vars('lapalist', $lp);
|
||||
|
||||
$this->load->model('m_pemeriksaan');
|
||||
$lm = $this->m_pemeriksaan->labmikro($id);
|
||||
$this->load->vars('lamklist', $lm);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
function deletedokter($id,$ket) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Resume Dokter');
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->deletedokter($id);
|
||||
redirect('index.php/ps_resume/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Resume');
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->delete($id);
|
||||
redirect('index.php/ps_resume');
|
||||
}
|
||||
|
||||
function datapasien(){
|
||||
$id = $this->input->post('pasien');
|
||||
$query = $this->db->query("select * from master_user
|
||||
where mu_id='$id'");
|
||||
foreach ($query->result() as $row){
|
||||
$data[] = $row;
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
//-------------ID user login = 15
|
||||
|
||||
class Ps_petugas extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '15');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Petugas';
|
||||
$data['main_content'] = 'master/petugas/v_petugas';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_petugas');
|
||||
$petugas = $this->m_petugas->index();
|
||||
$this->load->vars('pt', $petugas);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Petugas';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/petugas/form_petugas';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Petugas';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/petugas/form_petugas';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_petugas');
|
||||
$this->m_petugas->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Petugas baru');
|
||||
redirect('index.php/ps_petugas');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Petugas';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/petugas/form_petugas';
|
||||
|
||||
$this->load->model('m_petugas');
|
||||
$petugas = $this->m_petugas->edit($id);
|
||||
$this->load->vars('pt', $petugas);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$setpass = $this->input->post('passworduser');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
if(!empty($setpass)){
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Petugas';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/petugas/form_petugas';
|
||||
|
||||
$this->load->model('m_petugas');
|
||||
$petugas = $this->m_petugas->edit($id);
|
||||
$this->load->vars('pt', $petugas);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Petugas');
|
||||
$this->load->model('m_petugas');
|
||||
$this->m_petugas->prosesedit();
|
||||
redirect('index.php/ps_petugas');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Petugas';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/petugas/form_petugas';
|
||||
|
||||
$this->load->model('m_petugas');
|
||||
$petugas = $this->m_petugas->edit($id);
|
||||
$this->load->vars('pt', $petugas);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Petugas');
|
||||
$this->load->model('m_petugas');
|
||||
$this->m_petugas->delete($id);
|
||||
redirect('index.php/ps_petugas');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Petugas');
|
||||
$this->load->model('m_petugas');
|
||||
$this->m_petugas->disabled($id);
|
||||
redirect('index.php/ps_petugas');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_petugas');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Petugas');
|
||||
$this->load->model('m_petugas');
|
||||
$this->m_petugas->aktif($id);
|
||||
redirect('index.php/ps_petugas');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
//-------------ID user login = 14
|
||||
|
||||
class Ps_profile extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '14');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Profile';
|
||||
$data['main_content'] = 'profile/v_profile';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_profile');
|
||||
$profile = $this->m_profile->index();
|
||||
$this->load->vars('pf', $profile);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Pasien';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Pasien';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan pasien baru');
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Pasien';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$setpass = $this->input->post('passworduser');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
if(!empty($setpass)){
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Pasien';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->prosesedit();
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Pasien';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/pasien/form_pasien';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->edit($id);
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->delete($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->disabled($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Pasien');
|
||||
$this->load->model('m_pasien');
|
||||
$this->m_pasien->aktif($id);
|
||||
redirect('index.php/ps_pasien');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
//-------------ID user login = 17
|
||||
|
||||
class Ps_radiologi extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '17');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Radiologi';
|
||||
$data['main_content'] = 'master/radiologi/v_radiologi';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->index();
|
||||
$this->load->vars('ro', $radiologi);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Radiologi';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/radiologi/form_radiologi';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Pemeriksaan','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Radiologi';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/radiologi/form_radiologi';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Pemeriksaan Radiologi baru');
|
||||
redirect('index.php/ps_radiologi');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Radiologi';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/radiologi/form_radiologi';
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->edit($id);
|
||||
$this->load->vars('ro', $radiologi);
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->editdetail($id);
|
||||
$this->load->vars('rod', $radiologi);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Pemeriksaan','required');
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Radiologi';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/radiologi/form_radiologi';
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->edit($id);
|
||||
$this->load->vars('ro', $radiologi);
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->editdetail($id);
|
||||
$this->load->vars('rod', $radiologi);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pemeriksaan Radiologi');
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->prosesedit();
|
||||
redirect('index.php/ps_radiologi');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Radiologi';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/radiologi/form_radiologi';
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->edit($id);
|
||||
$this->load->vars('ro', $radiologi);
|
||||
|
||||
$this->load->model('m_radiologi');
|
||||
$radiologi = $this->m_radiologi->editdetail($id);
|
||||
$this->load->vars('rod', $radiologi);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Pemeriksaan Radiologi');
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->delete($id);
|
||||
redirect('index.php/ps_radiologi');
|
||||
}
|
||||
|
||||
function deletedetail($id,$mroid) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Detail Pemeriksaan Radiologi');
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->deletedetail($id);
|
||||
redirect('index.php/ps_radiologi/edit/'.$mroid);
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Pemeriksaan Radiologi');
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->disabled($id);
|
||||
|
||||
redirect('index.php/ps_radiologi');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_radiologi');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Pemeriksaan Radiologi');
|
||||
$this->load->model('m_radiologi');
|
||||
$this->m_radiologi->aktif($id);
|
||||
|
||||
redirect('index.php/ps_radiologi');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
//-------------ID user login = 10
|
||||
|
||||
class Ps_resume extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '10');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Resume';
|
||||
$data['main_content'] = 'resume/v_resume';
|
||||
$data['error']=$error;
|
||||
if(! $this->input->post('reservation')){
|
||||
$date1 = date("m/d/Y");
|
||||
$date2 = date("m/d/Y");
|
||||
}else{
|
||||
$datemya = explode("-",$this->input->post('reservation'));
|
||||
$date1 = $datemya[0];
|
||||
$date2 = $datemya[1];
|
||||
}
|
||||
$data['daterange'] = $date1." - ".$date2;
|
||||
$data['spnya'] = $this->input->post('spesialis');
|
||||
|
||||
$this->load->model('m_resume');
|
||||
$resume = $this->m_resume->search();
|
||||
$this->load->vars('rs', $resume);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function addpetugas($ket) {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page tambah---------//
|
||||
$data['ket'] = "1";
|
||||
$data['pelayanan'] = $ket;
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'resume/form_petugas_resume';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->pelayanan($ket);
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('pasien','Nama Pasien','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['ket'] = "1";
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'resume/form_petugas_resume';
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->insert_petugas();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Permintaan Resume baru');
|
||||
redirect('index.php/ps_resume');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id,$ket) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page edit---------//
|
||||
$data['ket'] = $ket;
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'resume/form_petugas_resume';
|
||||
|
||||
$this->load->model('m_resume');
|
||||
$resume = $this->m_resume->edit_petugas($id);
|
||||
$this->load->vars('rs', $resume);
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$ket= $this->input->post('keter');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
if($ket=="2"){
|
||||
$this->form_validation->set_rules('pasien','Pasien','required');
|
||||
}else{
|
||||
$this->form_validation->set_rules('dpjp','DPJP','required');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['ket'] = $ket;
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'resume/form_petugas_resume';
|
||||
|
||||
$this->load->model('m_resume');
|
||||
$resume = $this->m_resume->edit_petugas($id);
|
||||
$this->load->vars('rs', $resume);
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
if($ket=="2"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit permintaan Resume');
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->proseseditpetugas();
|
||||
redirect('index.php/ps_resume');
|
||||
}else{
|
||||
if($ket=="3"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Resume');
|
||||
}elseif($ket=="4"){
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengisi Resume');
|
||||
}
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->proseseditdokter();
|
||||
redirect('index.php/ps_resume');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page view---------//
|
||||
$data['ket'] = "5";
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'resume/form_petugas_resume';
|
||||
|
||||
$this->load->model('m_resume');
|
||||
$resume = $this->m_resume->edit_petugas($id);
|
||||
$this->load->vars('rs', $resume);
|
||||
|
||||
$this->load->model('m_pasien');
|
||||
$pasien = $this->m_pasien->statusaktif();
|
||||
$this->load->vars('ps', $pasien);
|
||||
|
||||
$this->load->model('m_dokter');
|
||||
$dokter = $this->m_dokter->statusaktif();
|
||||
$this->load->vars('dk', $dokter);
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruang = $this->m_ruangan->status();
|
||||
$this->load->vars('ru', $ruang);
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->status();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
function deletedokter($id,$ket) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Resume Dokter');
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->deletedokter($id);
|
||||
redirect('index.php/ps_resume/edit/'.$id.'/'.$ket);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_resume');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Resume');
|
||||
$this->load->model('m_resume');
|
||||
$this->m_resume->delete($id);
|
||||
redirect('index.php/ps_resume');
|
||||
}
|
||||
|
||||
function datapasien(){
|
||||
$id = $this->input->post('pasien');
|
||||
$query = $this->db->query("select * from master_user
|
||||
where mu_id='$id'");
|
||||
foreach ($query->result() as $row){
|
||||
$data[] = $row;
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
//-------------ID user login = 9
|
||||
|
||||
class Ps_ruangan extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '9');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Ruang';
|
||||
$data['main_content'] = 'master/ruangan/v_ruangan';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruangan = $this->m_ruangan->index();
|
||||
$this->load->vars('ru', $ruangan);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Ruang';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/ruangan/form_ruangan';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Ruang','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Ruang';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/ruangan/form_ruangan';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_ruangan');
|
||||
$this->m_ruangan->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Ruang baru');
|
||||
redirect('index.php/ps_ruangan');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Ruang';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/ruangan/form_ruangan';
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruangan = $this->m_ruangan->edit($id);
|
||||
$this->load->vars('ru', $ruangan);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Ruang','required');
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Ruang';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/ruangan/form_ruangan';
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruangan = $this->m_ruangan->edit($id);
|
||||
$this->load->vars('ru', $ruangan);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Ruang');
|
||||
$this->load->model('m_ruangan');
|
||||
$this->m_ruangan->prosesedit();
|
||||
redirect('index.php/ps_ruangan');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Ruang';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/ruangan/form_ruangan';
|
||||
|
||||
$this->load->model('m_ruangan');
|
||||
$ruangan = $this->m_ruangan->edit($id);
|
||||
$this->load->vars('ru', $ruangan);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Ruang');
|
||||
$this->load->model('m_ruangan');
|
||||
$this->m_ruangan->delete($id);
|
||||
redirect('index.php/ps_ruangan');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Ruang');
|
||||
$this->load->model('m_ruangan');
|
||||
$this->m_ruangan->disabled($id);
|
||||
redirect('index.php/ps_ruangan');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_ruangan');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Ruang');
|
||||
$this->load->model('m_ruangan');
|
||||
$this->m_ruangan->aktif($id);
|
||||
redirect('index.php/ps_ruangan');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
//-------------ID user login = 8
|
||||
|
||||
class Ps_spesialis extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '8');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'Spesialis';
|
||||
$data['main_content'] = 'master/spesialis/v_spesialis';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->index();
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah Spesialis';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/spesialis/form_spesialis';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Spesialis','required');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah Spesialis';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'master/spesialis/form_spesialis';
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_spesialis');
|
||||
$this->m_spesialis->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan Spesialis baru');
|
||||
redirect('index.php/ps_spesialis');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit Spesialis';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/spesialis/form_spesialis';
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->edit($id);
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('nama','Nama Spesialis','required');
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit Spesialis';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'master/spesialis/form_spesialis';
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->edit($id);
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit Spesialis');
|
||||
$this->load->model('m_spesialis');
|
||||
$this->m_spesialis->prosesedit();
|
||||
redirect('index.php/ps_spesialis');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View Spesialis';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'master/spesialis/form_spesialis';
|
||||
|
||||
$this->load->model('m_spesialis');
|
||||
$spesialis = $this->m_spesialis->edit($id);
|
||||
$this->load->vars('sp', $spesialis);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus Spesialis');
|
||||
$this->load->model('m_spesialis');
|
||||
$this->m_spesialis->delete($id);
|
||||
redirect('index.php/ps_spesialis');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled Spesialis');
|
||||
$this->load->model('m_spesialis');
|
||||
$this->m_spesialis->disabled($id);
|
||||
redirect('index.php/ps_spesialis');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_spesialis');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan Spesialis');
|
||||
$this->load->model('m_spesialis');
|
||||
$this->m_spesialis->aktif($id);
|
||||
redirect('index.php/ps_spesialis');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
//-------------ID user login = 4
|
||||
|
||||
class Ps_userlogin extends CI_Controller {
|
||||
|
||||
//-----------start variables for check action access----------//
|
||||
public $vartambah = null;
|
||||
public $varedit = null;
|
||||
public $vardelete = null;
|
||||
public $varview = null;
|
||||
//-----------start variables for check action access----------//
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
$this->load->helper(array('form', 'date'));
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
|
||||
//--------------start check access this form page-------------//
|
||||
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar'));
|
||||
$this->db->where('mum_menu_id', '4');
|
||||
$cekMenu = $this->db->get('master_user_menu');
|
||||
$rowcount = $cekMenu->num_rows();
|
||||
if($rowcount==0){
|
||||
redirect('index.php');
|
||||
}else{
|
||||
foreach ($cekMenu->result() as $cm)
|
||||
{
|
||||
$this->vartambah=$cm->mum_tambah;
|
||||
$this->varedit=$cm->mum_ubah;
|
||||
$this->vardelete=$cm->mum_hapus;
|
||||
$this->varview=$cm->mum_lihat;
|
||||
}
|
||||
}
|
||||
//--------------end check access this form page-------------//
|
||||
}
|
||||
|
||||
public function index($error = NULL) {
|
||||
$data['title'] = 'User Login';
|
||||
$data['main_content'] = 'setting/userlogin/v_userlogin';
|
||||
$data['error']=$error;
|
||||
|
||||
$this->load->model('m_userlogin');
|
||||
$userlogin = $this->m_userlogin->index();
|
||||
$this->load->vars('ul', $userlogin);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
// fungsi untuk menampilkan form tambah data
|
||||
public function add() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page tambah---------//
|
||||
$data['title'] = 'Tambah User Login';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'setting/userlogin/form_userlogin';
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->index();
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk memproses penambahan dengan memanggil model
|
||||
public function prosesadd() {
|
||||
//----start validate page tambah-------//
|
||||
if($this->vartambah==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page tambah---------//
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Tambah User Login';
|
||||
$data['actionform'] = 'prosesadd';
|
||||
$data['main_content'] = 'setting/userlogin/form_userlogin';
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->index();
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}else{
|
||||
$this->load->model('m_userlogin');
|
||||
$this->m_userlogin->insert();
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menambahkan user login baru');
|
||||
redirect('index.php/ps_userlogin');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form edit data dengan data terpilih
|
||||
public function edit($id) {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page edit---------//
|
||||
$data['title'] = 'Edit User Login';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'setting/userlogin/form_userlogin';
|
||||
|
||||
$this->load->model('m_userlogin');
|
||||
$userlogin = $this->m_userlogin->edit($id);
|
||||
$this->load->vars('ul', $userlogin);
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->index();
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//funsi untuk memproses update data
|
||||
public function prosesedit() {
|
||||
//----start validate page edit-------//
|
||||
if($this->varedit==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page edit---------//
|
||||
$id = $this->input->post('id');
|
||||
$setpass = $this->input->post('passworduser');
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('namauser','Nama User','required');
|
||||
if(!empty($setpass)){
|
||||
$this->form_validation->set_rules('passworduser','Password User','required');
|
||||
$this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]');
|
||||
}
|
||||
if($this->form_validation->run()==FALSE){
|
||||
$data['title'] = 'Edit User Login';
|
||||
$data['actionform'] = 'prosesedit';
|
||||
$data['main_content'] = 'setting/userlogin/form_userlogin';
|
||||
|
||||
$this->load->model('m_userlogin');
|
||||
$userlogin = $this->m_userlogin->edit($id);
|
||||
$this->load->vars('ul', $userlogin);
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->index();
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
else{
|
||||
$this->session->set_flashdata('message', 'Anda berhasil mengedit User Login');
|
||||
$this->load->model('m_userlogin');
|
||||
$this->m_userlogin->prosesedit();
|
||||
redirect('index.php/ps_userlogin');
|
||||
}
|
||||
}
|
||||
|
||||
//fungsi untuk menampilkan form view data dengan data terpilih
|
||||
public function view($id) {
|
||||
//----start validate page view-------//
|
||||
if($this->varview==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page view---------//
|
||||
$data['title'] = 'View User Login';
|
||||
$data['actionform'] = 'prosesview';
|
||||
$data['main_content'] = 'setting/userlogin/form_userlogin';
|
||||
|
||||
$this->load->model('m_userlogin');
|
||||
$userlogin = $this->m_userlogin->edit($id);
|
||||
$this->load->vars('ul', $userlogin);
|
||||
|
||||
$this->load->model('m_tipeuser');
|
||||
$tipeuser = $this->m_tipeuser->index();
|
||||
$this->load->vars('tu', $tipeuser);
|
||||
|
||||
$this->load->view('includes/template', $data);
|
||||
}
|
||||
|
||||
//fungsi untuk delete
|
||||
function delete($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil menghapus User Login');
|
||||
$this->load->model('m_userlogin');
|
||||
$this->m_userlogin->delete($id);
|
||||
redirect('index.php/ps_userlogin');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil disabled User Login');
|
||||
$this->load->model('m_userlogin');
|
||||
$this->m_userlogin->disabled($id);
|
||||
redirect('index.php/ps_userlogin');
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
//----start validate page delete-------//
|
||||
if($this->vardelete==null){redirect('index.php/ps_userlogin');}
|
||||
//----end validate page delete---------//
|
||||
$this->session->set_flashdata('message', 'Anda berhasil aktifkan User Login');
|
||||
$this->load->model('m_userlogin');
|
||||
$this->m_userlogin->aktif($id);
|
||||
redirect('index.php/ps_userlogin');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Welcome extends CI_Controller
|
||||
{
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->check_isvalidated();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Themplate AdminLTE3';
|
||||
$data['main_content'] = 'home/v_home';
|
||||
$this->load->view('includes/template', $data);
|
||||
|
||||
}
|
||||
private function check_isvalidated(){
|
||||
if(! $this->session->userdata('validated_rssapintar')){
|
||||
redirect('index.php/login');
|
||||
}
|
||||
}
|
||||
public function do_logout(){
|
||||
$this->session->sess_destroy();
|
||||
redirect('login');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>404 Page Not Found</title>
|
||||
<style type="text/css">
|
||||
|
||||
::selection{ background-color: #E13300; color: white; }
|
||||
::moz-selection{ background-color: #E13300; color: white; }
|
||||
::webkit-selection{ background-color: #E13300; color: white; }
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||
color: #4F5155;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #003399;
|
||||
background-color: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid #D0D0D0;
|
||||
font-size: 19px;
|
||||
font-weight: normal;
|
||||
margin: 0 0 14px 0;
|
||||
padding: 14px 15px 10px 15px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #002166;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin: 10px;
|
||||
border: 1px solid #D0D0D0;
|
||||
-webkit-box-shadow: 0 0 8px #D0D0D0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 12px 15px 12px 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Database Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
::selection{ background-color: #E13300; color: white; }
|
||||
::moz-selection{ background-color: #E13300; color: white; }
|
||||
::webkit-selection{ background-color: #E13300; color: white; }
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||
color: #4F5155;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #003399;
|
||||
background-color: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid #D0D0D0;
|
||||
font-size: 19px;
|
||||
font-weight: normal;
|
||||
margin: 0 0 14px 0;
|
||||
padding: 14px 15px 10px 15px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #002166;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin: 10px;
|
||||
border: 1px solid #D0D0D0;
|
||||
-webkit-box-shadow: 0 0 8px #D0D0D0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 12px 15px 12px 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
::selection{ background-color: #E13300; color: white; }
|
||||
::moz-selection{ background-color: #E13300; color: white; }
|
||||
::webkit-selection{ background-color: #E13300; color: white; }
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||
color: #4F5155;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #003399;
|
||||
background-color: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid #D0D0D0;
|
||||
font-size: 19px;
|
||||
font-weight: normal;
|
||||
margin: 0 0 14px 0;
|
||||
padding: 14px 15px 10px 15px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #002166;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin: 10px;
|
||||
border: 1px solid #D0D0D0;
|
||||
-webkit-box-shadow: 0 0 8px #D0D0D0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 12px 15px 12px 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
|
||||
|
||||
<h4>A PHP Error was encountered</h4>
|
||||
|
||||
<p>Severity: <?php echo $severity; ?></p>
|
||||
<p>Message: <?php echo $message; ?></p>
|
||||
<p>Filename: <?php echo $filepath; ?></p>
|
||||
<p>Line Number: <?php echo $line; ?></p>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,398 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CodeIgniter Curl Class
|
||||
*
|
||||
* Work with remote servers via cURL much easier than using the native PHP bindings.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author Philip Sturgeon
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
* @link http://philsturgeon.co.uk/code/codeigniter-curl
|
||||
*/
|
||||
class Curl {
|
||||
|
||||
protected $_ci; // CodeIgniter instance
|
||||
protected $response = ''; // Contains the cURL response for debug
|
||||
protected $session; // Contains the cURL handler for a session
|
||||
protected $url; // URL of the session
|
||||
protected $options = array(); // Populates curl_setopt_array
|
||||
protected $headers = array(); // Populates extra HTTP headers
|
||||
public $error_code; // Error code returned as an int
|
||||
public $error_string; // Error message returned as a string
|
||||
public $info; // Returned after request (elapsed time, etc)
|
||||
|
||||
function __construct($url = '')
|
||||
{
|
||||
$this->_ci = & get_instance();
|
||||
log_message('debug', 'cURL Class Initialized');
|
||||
|
||||
if ( ! $this->is_enabled())
|
||||
{
|
||||
log_message('error', 'cURL Class - PHP was not built with cURL enabled. Rebuild PHP with --with-curl to use cURL.');
|
||||
}
|
||||
|
||||
$url AND $this->create($url);
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
if (in_array($method, array('simple_get', 'simple_post', 'simple_put', 'simple_delete', 'simple_patch')))
|
||||
{
|
||||
// Take off the "simple_" and past get/post/put/delete/patch to _simple_call
|
||||
$verb = str_replace('simple_', '', $method);
|
||||
array_unshift($arguments, $verb);
|
||||
return call_user_func_array(array($this, '_simple_call'), $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
* SIMPLE METHODS
|
||||
* Using these methods you can make a quick and easy cURL call with one line.
|
||||
* ================================================================================= */
|
||||
|
||||
public function _simple_call($method, $url, $params = array(), $options = array())
|
||||
{
|
||||
// Get acts differently, as it doesnt accept parameters in the same way
|
||||
if ($method === 'get')
|
||||
{
|
||||
// If a URL is provided, create new session
|
||||
$this->create($url.($params ? '?'.http_build_query($params, NULL, '&') : ''));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// If a URL is provided, create new session
|
||||
$this->create($url);
|
||||
|
||||
$this->{$method}($params);
|
||||
}
|
||||
|
||||
// Add in the specific options provided
|
||||
$this->options($options);
|
||||
|
||||
return $this->execute();
|
||||
}
|
||||
|
||||
public function simple_ftp_get($url, $file_path, $username = '', $password = '')
|
||||
{
|
||||
// If there is no ftp:// or any protocol entered, add ftp://
|
||||
if ( ! preg_match('!^(ftp|sftp)://! i', $url))
|
||||
{
|
||||
$url = 'ftp://' . $url;
|
||||
}
|
||||
|
||||
// Use an FTP login
|
||||
if ($username != '')
|
||||
{
|
||||
$auth_string = $username;
|
||||
|
||||
if ($password != '')
|
||||
{
|
||||
$auth_string .= ':' . $password;
|
||||
}
|
||||
|
||||
// Add the user auth string after the protocol
|
||||
$url = str_replace('://', '://' . $auth_string . '@', $url);
|
||||
}
|
||||
|
||||
// Add the filepath
|
||||
$url .= $file_path;
|
||||
|
||||
$this->option(CURLOPT_BINARYTRANSFER, TRUE);
|
||||
$this->option(CURLOPT_VERBOSE, TRUE);
|
||||
|
||||
return $this->execute();
|
||||
}
|
||||
|
||||
/* =================================================================================
|
||||
* ADVANCED METHODS
|
||||
* Use these methods to build up more complex queries
|
||||
* ================================================================================= */
|
||||
|
||||
public function post($params = array(), $options = array())
|
||||
{
|
||||
// If its an array (instead of a query string) then format it correctly
|
||||
if (is_array($params))
|
||||
{
|
||||
$params = http_build_query($params, NULL, '&');
|
||||
}
|
||||
|
||||
// Add in the specific options provided
|
||||
$this->options($options);
|
||||
|
||||
$this->http_method('post');
|
||||
|
||||
$this->option(CURLOPT_POST, TRUE);
|
||||
$this->option(CURLOPT_POSTFIELDS, $params);
|
||||
}
|
||||
|
||||
public function put($params = array(), $options = array())
|
||||
{
|
||||
// If its an array (instead of a query string) then format it correctly
|
||||
if (is_array($params))
|
||||
{
|
||||
$params = http_build_query($params, NULL, '&');
|
||||
}
|
||||
|
||||
// Add in the specific options provided
|
||||
$this->options($options);
|
||||
|
||||
$this->http_method('put');
|
||||
$this->option(CURLOPT_POSTFIELDS, $params);
|
||||
|
||||
// Override method, I think this overrides $_POST with PUT data but... we'll see eh?
|
||||
$this->option(CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: PUT'));
|
||||
}
|
||||
|
||||
public function patch($params = array(), $options = array())
|
||||
{
|
||||
// If its an array (instead of a query string) then format it correctly
|
||||
if (is_array($params))
|
||||
{
|
||||
$params = http_build_query($params, NULL, '&');
|
||||
}
|
||||
|
||||
// Add in the specific options provided
|
||||
$this->options($options);
|
||||
|
||||
$this->http_method('patch');
|
||||
$this->option(CURLOPT_POSTFIELDS, $params);
|
||||
|
||||
// Override method, I think this overrides $_POST with PATCH data but... we'll see eh?
|
||||
$this->option(CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: PATCH'));
|
||||
}
|
||||
|
||||
public function delete($params, $options = array())
|
||||
{
|
||||
// If its an array (instead of a query string) then format it correctly
|
||||
if (is_array($params))
|
||||
{
|
||||
$params = http_build_query($params, NULL, '&');
|
||||
}
|
||||
|
||||
// Add in the specific options provided
|
||||
$this->options($options);
|
||||
|
||||
$this->http_method('delete');
|
||||
|
||||
$this->option(CURLOPT_POSTFIELDS, $params);
|
||||
}
|
||||
|
||||
public function set_cookies($params = array())
|
||||
{
|
||||
if (is_array($params))
|
||||
{
|
||||
$params = http_build_query($params, NULL, '&');
|
||||
}
|
||||
|
||||
$this->option(CURLOPT_COOKIE, $params);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function http_header($header, $content = NULL)
|
||||
{
|
||||
$this->headers[] = $content ? $header . ': ' . $content : $header;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function http_method($method)
|
||||
{
|
||||
$this->options[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function http_login($username = '', $password = '', $type = 'any')
|
||||
{
|
||||
$this->option(CURLOPT_HTTPAUTH, constant('CURLAUTH_' . strtoupper($type)));
|
||||
$this->option(CURLOPT_USERPWD, $username . ':' . $password);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function proxy($url = '', $port = 80)
|
||||
{
|
||||
$this->option(CURLOPT_HTTPPROXYTUNNEL, TRUE);
|
||||
$this->option(CURLOPT_PROXY, $url . ':' . $port);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function proxy_login($username = '', $password = '')
|
||||
{
|
||||
$this->option(CURLOPT_PROXYUSERPWD, $username . ':' . $password);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ssl($verify_peer = TRUE, $verify_host = 2, $path_to_cert = NULL)
|
||||
{
|
||||
if ($verify_peer)
|
||||
{
|
||||
$this->option(CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
$this->option(CURLOPT_SSL_VERIFYHOST, $verify_host);
|
||||
if (isset($path_to_cert)) {
|
||||
$path_to_cert = realpath($path_to_cert);
|
||||
$this->option(CURLOPT_CAINFO, $path_to_cert);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->option(CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
$this->option(CURLOPT_SSL_VERIFYHOST, $verify_host);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function options($options = array())
|
||||
{
|
||||
// Merge options in with the rest - done as array_merge() does not overwrite numeric keys
|
||||
foreach ($options as $option_code => $option_value)
|
||||
{
|
||||
$this->option($option_code, $option_value);
|
||||
}
|
||||
|
||||
// Set all options provided
|
||||
curl_setopt_array($this->session, $this->options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function option($code, $value, $prefix = 'opt')
|
||||
{
|
||||
if (is_string($code) && !is_numeric($code))
|
||||
{
|
||||
$code = constant('CURL' . strtoupper($prefix) . '_' . strtoupper($code));
|
||||
}
|
||||
|
||||
$this->options[$code] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Start a session from a URL
|
||||
public function create($url)
|
||||
{
|
||||
// If no a protocol in URL, assume its a CI link
|
||||
if ( ! preg_match('!^\w+://! i', $url))
|
||||
{
|
||||
$this->_ci->load->helper('url');
|
||||
$url = site_url($url);
|
||||
}
|
||||
|
||||
$this->url = $url;
|
||||
$this->session = curl_init($this->url);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// End a session and return the results
|
||||
public function execute()
|
||||
{
|
||||
// Set two default options, and merge any extra ones in
|
||||
if ( ! isset($this->options[CURLOPT_TIMEOUT]))
|
||||
{
|
||||
$this->options[CURLOPT_TIMEOUT] = 30;
|
||||
}
|
||||
if ( ! isset($this->options[CURLOPT_RETURNTRANSFER]))
|
||||
{
|
||||
$this->options[CURLOPT_RETURNTRANSFER] = TRUE;
|
||||
}
|
||||
if ( ! isset($this->options[CURLOPT_FAILONERROR]))
|
||||
{
|
||||
$this->options[CURLOPT_FAILONERROR] = TRUE;
|
||||
}
|
||||
|
||||
// Only set follow location if not running securely
|
||||
if ( ! ini_get('safe_mode') && ! ini_get('open_basedir'))
|
||||
{
|
||||
// Ok, follow location is not set already so lets set it to true
|
||||
if ( ! isset($this->options[CURLOPT_FOLLOWLOCATION]))
|
||||
{
|
||||
$this->options[CURLOPT_FOLLOWLOCATION] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($this->headers))
|
||||
{
|
||||
$this->option(CURLOPT_HTTPHEADER, $this->headers);
|
||||
}
|
||||
|
||||
$this->options();
|
||||
|
||||
// Execute the request & and hide all output
|
||||
$this->response = curl_exec($this->session);
|
||||
$this->info = curl_getinfo($this->session);
|
||||
|
||||
// Request failed
|
||||
if ($this->response === FALSE)
|
||||
{
|
||||
$errno = curl_errno($this->session);
|
||||
$error = curl_error($this->session);
|
||||
|
||||
curl_close($this->session);
|
||||
$this->set_defaults();
|
||||
|
||||
$this->error_code = $errno;
|
||||
$this->error_string = $error;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Request successful
|
||||
else
|
||||
{
|
||||
curl_close($this->session);
|
||||
$this->last_response = $this->response;
|
||||
$this->set_defaults();
|
||||
return $this->last_response;
|
||||
}
|
||||
}
|
||||
|
||||
public function is_enabled()
|
||||
{
|
||||
return function_exists('curl_init');
|
||||
}
|
||||
|
||||
public function debug()
|
||||
{
|
||||
echo "=============================================<br/>\n";
|
||||
echo "<h2>CURL Test</h2>\n";
|
||||
echo "=============================================<br/>\n";
|
||||
echo "<h3>Response</h3>\n";
|
||||
echo "<code>" . nl2br(htmlentities($this->last_response)) . "</code><br/>\n\n";
|
||||
|
||||
if ($this->error_string)
|
||||
{
|
||||
echo "=============================================<br/>\n";
|
||||
echo "<h3>Errors</h3>";
|
||||
echo "<strong>Code:</strong> " . $this->error_code . "<br/>\n";
|
||||
echo "<strong>Message:</strong> " . $this->error_string . "<br/>\n";
|
||||
}
|
||||
|
||||
echo "=============================================<br/>\n";
|
||||
echo "<h3>Info</h3>";
|
||||
echo "<pre>";
|
||||
print_r($this->info);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
public function debug_request()
|
||||
{
|
||||
return array(
|
||||
'url' => $this->url
|
||||
);
|
||||
}
|
||||
|
||||
public function set_defaults()
|
||||
{
|
||||
$this->response = '';
|
||||
$this->headers = array();
|
||||
$this->options = array();
|
||||
$this->error_code = NULL;
|
||||
$this->error_string = '';
|
||||
$this->session = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file Curl.php */
|
||||
/* Location: ./application/libraries/Curl.php */
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class m_pdf {
|
||||
|
||||
function m_pdf()
|
||||
{
|
||||
$CI = & get_instance();
|
||||
log_message('Debug', 'mPDF class is loaded.');
|
||||
}
|
||||
|
||||
function load($param=NULL)
|
||||
{
|
||||
include_once APPPATH.'/third_party/mpdf/mpdf.php';
|
||||
|
||||
if ($params == NULL)
|
||||
{
|
||||
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
|
||||
}
|
||||
|
||||
//return new mPDF($param);
|
||||
return new mPDF();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class M_datapenunjang extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$this->db->order_by('pp_date_pemeriksaan', 'DESC');
|
||||
$this->db->where('pp_user_pasien_id', $this->session->userdata('s_ID_User_rssapintar'));
|
||||
$query = $this->db->get('proses_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function radiologi(){
|
||||
$this->db->where('pfp_ket', 1);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function lab(){
|
||||
$this->db->where('pfp_ket', 2);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function labpa(){
|
||||
$this->db->where('pfp_ket', 3);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function labmikro(){
|
||||
$this->db->where('pfp_ket', 4);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
class M_dataresume extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$this->db->order_by('pr_date_resume', 'DESC');
|
||||
$this->db->where('pr_user_pasien_id', $this->session->userdata('s_ID_User_rssapintar'));
|
||||
$query = $this->db->get('proses_resume');
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
class M_dokter extends CI_Model {
|
||||
function index() {
|
||||
$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->join('master_spesialis', 'master_user.mu_spesialis_id = master_spesialis.ms_id','left');
|
||||
$this->db->where('mu_tipeuser_id', '5');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function statusaktif() {
|
||||
$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->join('master_spesialis', 'master_user.mu_spesialis_id = master_spesialis.ms_id','left');
|
||||
$this->db->where('mu_tipeuser_id', '5');
|
||||
$this->db->where('mu_status', '1');
|
||||
$this->db->where('mu_dpjp_ket', '1');
|
||||
$this->db->order_by("ms_nama", "asc");
|
||||
$this->db->order_by("mu_nama_lengkap", "asc");
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert_userlogin = array(
|
||||
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "5",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkap'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_spesialis_id' => $this->input->post('spesialis'),
|
||||
'mu_dpjp_ket' => $this->input->post('dpjp'),
|
||||
);
|
||||
$insert = $this->db->insert('master_user', $insert_userlogin);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$password = $this->input->post('passworduser');
|
||||
if(empty($password)){
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkap'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_tipeuser_id' => "5",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_spesialis_id' => $this->input->post('spesialis'),
|
||||
'mu_dpjp_ket' => $this->input->post('dpjp'),
|
||||
);
|
||||
}else{
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "5",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_spesialis_id' => $this->input->post('spesialis'),
|
||||
'mu_dpjp_ket' => $this->input->post('dpjp'),
|
||||
);
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_userlogin);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->delete('master_user');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 0,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 1,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
class M_hakakses extends CI_Model {
|
||||
|
||||
function prosesedithakakses() {
|
||||
$this->db->where('mum_tipeuser_id', $this->input->post('id'));
|
||||
$this->db->delete('master_user_menu');
|
||||
|
||||
if(isset($_POST['akses'])){
|
||||
$postakses= $_POST['akses'];
|
||||
foreach($postakses as $key1 =>$valueakses)
|
||||
{
|
||||
$tambahaction=null;
|
||||
$editaction=null;
|
||||
$deleteaction=null;
|
||||
$dataakses= explode ("-",$valueakses);
|
||||
|
||||
if(isset($_POST['tambah'])){
|
||||
$posttambah= $_POST['tambah'];
|
||||
foreach($posttambah as $key2 =>$valuetambah)
|
||||
{
|
||||
if($dataakses[1]==$valuetambah){
|
||||
$tambahaction="tambah";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_POST['edit'])){
|
||||
$postedit= $_POST['edit'];
|
||||
foreach($postedit as $key3 =>$valueedit)
|
||||
{
|
||||
if($dataakses[1]==$valueedit){
|
||||
$editaction="ubah";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_POST['delete'])){
|
||||
$postdelete= $_POST['delete'];
|
||||
foreach($postdelete as $key4 =>$valuedelete)
|
||||
{
|
||||
if($dataakses[1]==$valuedelete){
|
||||
$deleteaction="hapus";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_POST['view'])){
|
||||
$postview= $_POST['view'];
|
||||
foreach($postview as $key5 =>$valueview)
|
||||
{
|
||||
if($dataakses[1]==$valueview){
|
||||
$viewaction="lihat";
|
||||
}
|
||||
}
|
||||
}
|
||||
$insert_hakakses = array(
|
||||
'mum_tipeuser_id' => $this->input->post('id'),
|
||||
'mum_menu_id' => $dataakses[1],
|
||||
'mum_lihat' => $viewaction,
|
||||
'mum_tambah' => $tambahaction,
|
||||
'mum_ubah' => $editaction,
|
||||
'mum_hapus' => $deleteaction,
|
||||
);
|
||||
|
||||
$insert = $this->db->insert('master_user_menu', $insert_hakakses);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
class M_jadwaldokter extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$this->db->order_by('pjd_date', 'ASC');
|
||||
$this->db->order_by('pjd_user_dokter_id', 'ASC');
|
||||
$query = $this->db->get('proses_jadwal_dokter');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function spesialisstatus() {
|
||||
$this->db->order_by('ms_nama', 'ASC');
|
||||
$this->db->where('ms_status', 1);
|
||||
$query = $this->db->get('master_spesialis');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function dokterstatus() {
|
||||
$this->db->join('master_spesialis', 'master_spesialis.ms_id = master_user.mu_spesialis_id','left');
|
||||
$this->db->order_by('ms_nama', 'ASC');
|
||||
$this->db->order_by('mu_nama_lengkap', 'ASC');
|
||||
$this->db->where('mu_status', 1);
|
||||
$this->db->where('mu_tipeuser_id', 5);
|
||||
$this->db->where('mu_dpjp_ket', 1);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
// function insert() {
|
||||
// $dokter = $_POST['iddokter'];$num=0;
|
||||
// foreach($dokter as $key =>$datanya)
|
||||
// {
|
||||
// if($_POST['jam'][$num]!=""){
|
||||
// $insert = array(
|
||||
// 'pjd_date' => $_POST['tanggal'][$num],
|
||||
// 'pjd_time_mulai' => $_POST['jam'][$num],
|
||||
// 'pjd_user_dokter_id' => $_POST['iddokter'][$num],
|
||||
// );
|
||||
// $insert = $this->db->insert('proses_jadwal_dokter', $insert);
|
||||
// }
|
||||
// $num++;
|
||||
// }
|
||||
// }
|
||||
|
||||
function prosesedit() {
|
||||
$dokter = $_POST['iddokter'];$num=0;
|
||||
foreach($dokter as $key =>$datanya)
|
||||
{
|
||||
if($_POST['jam'][$num]!=""||$_POST['idket'][$num]!=""){
|
||||
$update = array(
|
||||
'pjd_date' => $_POST['tanggal'][$num],
|
||||
'pjd_time_mulai' => $_POST['jam'][$num],
|
||||
'pjd_user_dokter_id' => $_POST['iddokter'][$num],
|
||||
);
|
||||
if($_POST['idket'][$num]==0){
|
||||
if($_POST['jam'][$num]!=""){
|
||||
$insert = $this->db->insert('proses_jadwal_dokter', $update);
|
||||
}
|
||||
}else{
|
||||
$id = $_POST['idket'][$num];
|
||||
$this->db->where('pjd_id', $id);
|
||||
$this->db->update('proses_jadwal_dokter', $update);
|
||||
}
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function delete($bulan, $tahun) {
|
||||
$setbulan="";
|
||||
if($bulan<=9){$setbulan="0".$bulan;}else{$sethari=$setbulan;}
|
||||
|
||||
$this->db->like("pjd_date", "$tahun-$setbulan", "both");
|
||||
$this->db->delete('proses_jadwal_dokter');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
class M_laboratorium extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('master_laboratorium');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function status() {
|
||||
$this->db->where('ml_status', 1);
|
||||
$query = $this->db->get('master_laboratorium');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function statusdetail() {
|
||||
$this->db->join('master_laboratorium', 'master_laboratorium.ml_id = master_laboratorium_detail.mld_ml_id','left');
|
||||
$this->db->order_by('ml_nama', 'ASC');
|
||||
$this->db->order_by('mld_nama', 'ASC');
|
||||
$this->db->where('mld_status', 1);
|
||||
$query = $this->db->get('master_laboratorium_detail');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert = array(
|
||||
'ml_nama' => $this->input->post('nama'),
|
||||
'ml_keterangan' => $this->input->post('keterangan'),
|
||||
'ml_status' => 1,
|
||||
);
|
||||
$insert = $this->db->insert('master_laboratorium', $insert);
|
||||
$id = $this->db->insert_id();
|
||||
|
||||
$status = $_POST['statusdetail'];$num=0;
|
||||
foreach($status as $key =>$datanya)
|
||||
{
|
||||
$insert_data = array(
|
||||
'mld_nama' => $_POST['detail'][$num],
|
||||
'mld_keterangan' => $_POST['ket'][$num],
|
||||
'mld_status' => $_POST['statusdetail'][$num],
|
||||
'mld_ml_id' => $id,
|
||||
);
|
||||
$insert = $this->db->insert('master_laboratorium_detail', $insert_data);
|
||||
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('ml_id', $id);
|
||||
$query = $this->db->get('master_laboratorium');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function editdetail($id) {
|
||||
$this->db->where('mld_ml_id', $id);
|
||||
$query = $this->db->get('master_laboratorium_detail');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$update = array(
|
||||
'ml_nama' => $this->input->post('nama'),
|
||||
'ml_keterangan' => $this->input->post('keterangan'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('ml_id', $id);
|
||||
$this->db->update('master_laboratorium', $update);
|
||||
|
||||
$status = $_POST['statusdetail'];$num=0;
|
||||
foreach($status as $key =>$datanya)
|
||||
{
|
||||
$data = array(
|
||||
'mld_nama' => $_POST['detail'][$num],
|
||||
'mld_keterangan' => $_POST['ket'][$num],
|
||||
'mld_status' => $_POST['statusdetail'][$num],
|
||||
'mld_ml_id' => $id,
|
||||
);
|
||||
if($_POST['baru'][$num]=="2"){
|
||||
$this->db->where('mld_id', $_POST['iddetail'][$num]);
|
||||
$this->db->update('master_laboratorium_detail', $data);
|
||||
}else{
|
||||
$insert = $this->db->insert('master_laboratorium_detail', $data);
|
||||
}
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('ml_id', $id);
|
||||
$this->db->delete('master_laboratorium');
|
||||
|
||||
$this->db->where('mld_ml_id', $id);
|
||||
$this->db->delete('master_laboratorium_detail');
|
||||
}
|
||||
|
||||
function deletedetail($id) {
|
||||
$this->db->where('mld_id', $id);
|
||||
$this->db->delete('master_laboratorium_detail');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'ml_status' => 0,
|
||||
);
|
||||
$this->db->where('ml_id', $id);
|
||||
$this->db->update('master_laboratorium', $update_data);
|
||||
|
||||
$update_data_detail = array(
|
||||
'mld_status' => 0,
|
||||
);
|
||||
$this->db->where('mld_ml_id', $id);
|
||||
$this->db->update('master_laboratorium_detail', $update_data_detail);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'ml_status' => 1,
|
||||
);
|
||||
$this->db->where('ml_id', $id);
|
||||
$this->db->update('master_laboratorium', $update_data);
|
||||
|
||||
$update_data_detail = array(
|
||||
'mld_status' => 1,
|
||||
);
|
||||
$this->db->where('mld_ml_id', $id);
|
||||
$this->db->update('master_laboratorium_detail', $update_data_detail);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class M_login extends CI_Model{
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
public function validate(){
|
||||
$username = $this->security->xss_clean($this->input->post('username'));
|
||||
$password = md5($this->security->xss_clean($this->input->post('password')));
|
||||
$this->db->join('master_spesialis', 'master_user.mu_spesialis_id = master_spesialis.ms_id','left');
|
||||
$this->db->where('mu_nama_user', $username);
|
||||
$this->db->where('mu_password', $password);
|
||||
$query = $this->db->get('master_user');
|
||||
if($query->num_rows() == 1)
|
||||
{
|
||||
|
||||
$row = $query->row();
|
||||
$data = array(
|
||||
's_ID_User_rssapintar' => $row->mu_id,
|
||||
's_nama_rssapintar' => $row->mu_nama_lengkap,
|
||||
's_FK_TipeUser_rssapintar' => $row->mu_tipeuser_id,
|
||||
's_ID_Spesialis_rssapintar' => $row->ms_id,
|
||||
's_Spesialis_rssapintar' => $row->ms_nama,
|
||||
's_petugas_rssapintar' => $row->mu_petugas_penunjang,
|
||||
'validated_rssapintar' => true
|
||||
);
|
||||
$this->session->set_userdata($data);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class M_menu extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$this->db->order_by('mm_urutan', 'ASC');
|
||||
$this->db->where('mm_aktif', "1");
|
||||
$query = $this->db->get('master_menu');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function hakakses($id) {
|
||||
$this->db->where('mum_tipeuser_id', $id);
|
||||
$query = $this->db->get('master_user_menu');
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
class M_pasien extends CI_Model {
|
||||
function index() {
|
||||
//$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->where('mu_tipeuser_id', '6');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function statusaktif() {
|
||||
$this->db->where('mu_status', '1');
|
||||
$this->db->where('mu_tipeuser_id', '6');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert_userlogin = array(
|
||||
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
$insert = $this->db->insert('master_user', $insert_userlogin);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$password = $this->input->post('passworduser');
|
||||
if(empty($password)){
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
}else{
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_userlogin);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->delete('master_user');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 0,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 1,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
class M_pemeriksaan extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$this->db->join('master_spesialis', 'master_spesialis.ms_id = proses_pemeriksaan.pp_spesialis_id','left');
|
||||
$this->db->join('master_ruang', 'master_ruang.mr_id = proses_pemeriksaan.pp_ruang_id','left');
|
||||
$this->db->join('master_user', 'master_user.mu_id = proses_pemeriksaan.pp_user_pasien_id','left');
|
||||
$this->db->like("pp_date_pemeriksaan", date("Y-m-d") , "both");
|
||||
$query = $this->db->get('proses_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function search() {
|
||||
if(! $this->input->post('reservation')){
|
||||
$date1 = date("Y-m-d");
|
||||
$date2 = date("Y-m-d");
|
||||
}else{
|
||||
$datemya = explode("-",$this->input->post('reservation'));
|
||||
$date1 = date("Y-m-d", strtotime($datemya[0]));
|
||||
$date2 = date("Y-m-d", strtotime($datemya[1]));
|
||||
}
|
||||
|
||||
$spesialis = "";
|
||||
if($this->input->post('spesialis')!="0"){
|
||||
$this->db->where('pp_spesialis_id', $this->input->post('spesialis'));
|
||||
}
|
||||
$this->db->join('master_spesialis', 'master_spesialis.ms_id = proses_pemeriksaan.pp_spesialis_id','left');
|
||||
$this->db->join('master_ruang', 'master_ruang.mr_id = proses_pemeriksaan.pp_ruang_id','left');
|
||||
$this->db->join('master_user', 'master_user.mu_id = proses_pemeriksaan.pp_user_pasien_id','left');
|
||||
$this->db->where('pp_date_pemeriksaan >=', $date1.' 00:00:00');
|
||||
$this->db->where('pp_date_pemeriksaan <=', $date2.' 23:59:59');
|
||||
$query = $this->db->get('proses_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$originalDate = $this->input->post('tanggal');
|
||||
$originalTime = $this->input->post('waktu');
|
||||
$newDate = date("Y-m-d", strtotime($originalDate));
|
||||
$newTime = date("H:i:s", strtotime($originalTime));
|
||||
$datetime = $newDate." ".$newTime;
|
||||
|
||||
$insert = array(
|
||||
'pp_date_pemeriksaan' => $datetime,
|
||||
'pp_user_pasien_id' => $this->input->post('pasien'),
|
||||
'pp_ruang_id' => $this->input->post('ruang'),
|
||||
'pp_spesialis_id' => $this->input->post('spesialis'),
|
||||
'pp_status' => "1",
|
||||
'pp_jenis_pelayanan' => $this->input->post('pelayanan'),
|
||||
'pp_user_dokter_dpjp_id'=> $this->input->post('dpjp'),
|
||||
'pp_radiologi' => $this->input->post('radiologi'),
|
||||
'pp_lab_pk' => $this->input->post('laborat'),
|
||||
'pp_lab_pa' => $this->input->post('laboratpa'),
|
||||
'pp_lab_mikro' => $this->input->post('laboratmikro'),
|
||||
'pp_user_dokter_id' => $this->input->post('iddokter'),
|
||||
);
|
||||
$insert = $this->db->insert('proses_pemeriksaan', $insert);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$query = '
|
||||
SELECT *,
|
||||
udok.mu_id AS dok_id,
|
||||
udok.mu_nama_lengkap AS dok_nama,
|
||||
|
||||
udpjp.mu_id AS dpjp_id,
|
||||
udpjp.mu_nama_lengkap AS dpjp_nama,
|
||||
|
||||
masp.ms_nama AS sp_nama,
|
||||
masp.ms_kode AS sp_kode,
|
||||
|
||||
upas.mu_id AS pas_id,
|
||||
upas.mu_nama_lengkap AS pas_nama,
|
||||
upas.mu_no_rekamedik AS pas_rm,
|
||||
upas.mu_NIK AS pas_nik,
|
||||
upas.mu_alamat_KTP AS pas_alamat,
|
||||
upas.mu_alamat_domisili AS pas_domisili,
|
||||
upas.mu_telepon_1 AS pas_telp1,
|
||||
upas.mu_telepon_2 AS pas_telp2,
|
||||
upas.mu_tanggal_lahir AS pas_tgl_lahir,
|
||||
upas.mu_gol_darah AS pas_gd,
|
||||
upas.mu_berat_badan AS pas_bb,
|
||||
upas.mu_tinggi_badan AS pas_tb,
|
||||
upas.mu_warna_kulit AS pas_wk,
|
||||
upas.mu_jenis_kelamin AS pas_jk,
|
||||
upas.mu_gambar AS pas_gambar,
|
||||
|
||||
ruang.mr_kode AS ru_id,
|
||||
ruang.mr_kode AS ru_kode,
|
||||
ruang.mr_nama AS ru_nama,
|
||||
|
||||
spdok.ms_nama AS spdok_nama,
|
||||
spdok.ms_kode AS spdok_kode,
|
||||
|
||||
spdpjp.ms_nama AS spdpjp_nama,
|
||||
spdpjp.ms_kode AS spdpjp_kode
|
||||
|
||||
FROM proses_pemeriksaan
|
||||
|
||||
LEFT JOIN master_user AS udok ON (udok.mu_id=pp_user_dokter_id)
|
||||
LEFT JOIN master_user AS upas ON (upas.mu_id=pp_user_pasien_id)
|
||||
LEFT JOIN master_user AS udpjp ON (udpjp.mu_id=pp_user_dokter_dpjp_id)
|
||||
LEFT JOIN master_ruang AS ruang ON (ruang.mr_id=pp_ruang_id)
|
||||
|
||||
LEFT JOIN master_spesialis AS masp ON (masp.ms_id=pp_spesialis_id)
|
||||
LEFT JOIN master_spesialis AS spdok ON (spdok.ms_id=udok.mu_spesialis_id)
|
||||
LEFT JOIN master_spesialis AS spdpjp ON (spdpjp.ms_id=udpjp.mu_spesialis_id)
|
||||
|
||||
WHERE pp_id = '.$id.'
|
||||
';
|
||||
$result = $this->db->query($query);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function proseseditpermin() {
|
||||
$originalDate = $this->input->post('tanggal');
|
||||
$originalTime = $this->input->post('waktu');
|
||||
$newDate = date("Y-m-d", strtotime($originalDate));
|
||||
$newTime = date("H:i:s", strtotime($originalTime));
|
||||
$datetime = $newDate." ".$newTime;
|
||||
|
||||
if($this->input->post('setdat')=="0"){
|
||||
$update = array(
|
||||
'pp_date_pemeriksaan' => $datetime,
|
||||
'pp_user_pasien_id' => $this->input->post('pasien'),
|
||||
'pp_ruang_id' => $this->input->post('ruang'),
|
||||
'pp_spesialis_id' => $this->input->post('spesialis'),
|
||||
'pp_status' => "1",
|
||||
'pp_jenis_pelayanan' => $this->input->post('pelayanan'),
|
||||
'pp_user_dokter_dpjp_id'=> $this->input->post('dpjp'),
|
||||
'pp_radiologi' => $this->input->post('radiologi'),
|
||||
'pp_lab_pk' => $this->input->post('laborat'),
|
||||
'pp_lab_pa' => $this->input->post('laboratpa'),
|
||||
'pp_lab_mikro' => $this->input->post('laboratmikro'),
|
||||
'pp_user_dokter_id' => $this->input->post('iddokter'),
|
||||
);
|
||||
}else{
|
||||
$update = array(
|
||||
'pp_radiologi' => $this->input->post('radiologi'),
|
||||
'pp_lab_pk' => $this->input->post('laborat'),
|
||||
'pp_lab_pa' => $this->input->post('laboratpa'),
|
||||
'pp_lab_mikro' => $this->input->post('laboratmikro'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pp_id', $id);
|
||||
$this->db->update('proses_pemeriksaan', $update);
|
||||
}
|
||||
|
||||
function proseseditupload($nama) {
|
||||
if($this->session->userdata('s_petugas_rssapintar')==1){
|
||||
$insert = array(
|
||||
'pfp_nama' => $nama,
|
||||
'pfp_pp_id' => $this->input->post('id'),
|
||||
'pfp_ket' => 1,
|
||||
'pfp_keterangan' => $this->input->post('ketfileradiologi'),
|
||||
'pfp_datetime' => date("Y-m-d H:i:s"),
|
||||
);
|
||||
$insert = $this->db->insert('proses_file_pemeriksaan', $insert);
|
||||
|
||||
$update = array(
|
||||
'pp_radiologi' => "2",
|
||||
//'pp_date_hasil'=> date("Y-m-d H:i:s"),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pp_id', $id);
|
||||
$this->db->update('proses_pemeriksaan', $update);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==2){
|
||||
$insert = array(
|
||||
'pfp_nama' => $nama,
|
||||
'pfp_pp_id' => $this->input->post('id'),
|
||||
'pfp_ket' => 2,
|
||||
'pfp_keterangan' => $this->input->post('ketfilelab'),
|
||||
'pfp_datetime' => date("Y-m-d H:i:s"),
|
||||
);
|
||||
$insert = $this->db->insert('proses_file_pemeriksaan', $insert);
|
||||
|
||||
$update = array(
|
||||
'pp_lab_pk' => "2",
|
||||
//'pp_date_hasil'=> date("Y-m-d H:i:s"),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pp_id', $id);
|
||||
$this->db->update('proses_pemeriksaan', $update);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==3){
|
||||
$insert = array(
|
||||
'pfp_nama' => $nama,
|
||||
'pfp_pp_id' => $this->input->post('id'),
|
||||
'pfp_ket' => 3,
|
||||
'pfp_keterangan' => $this->input->post('ketfilelabpa'),
|
||||
'pfp_datetime' => date("Y-m-d H:i:s"),
|
||||
);
|
||||
$insert = $this->db->insert('proses_file_pemeriksaan', $insert);
|
||||
|
||||
$update = array(
|
||||
'pp_lab_pa' => "2",
|
||||
//'pp_date_hasil'=> date("Y-m-d H:i:s"),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pp_id', $id);
|
||||
$this->db->update('proses_pemeriksaan', $update);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==4){
|
||||
$insert = array(
|
||||
'pfp_nama' => $nama,
|
||||
'pfp_pp_id' => $this->input->post('id'),
|
||||
'pfp_ket' => 4,
|
||||
'pfp_keterangan' => $this->input->post('ketfilelabmikro'),
|
||||
'pfp_datetime' => date("Y-m-d H:i:s"),
|
||||
);
|
||||
$insert = $this->db->insert('proses_file_pemeriksaan', $insert);
|
||||
|
||||
$update = array(
|
||||
'pp_lab_mikro' => "2",
|
||||
//'pp_date_hasil'=> date("Y-m-d H:i:s"),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pp_id', $id);
|
||||
$this->db->update('proses_pemeriksaan', $update);
|
||||
}
|
||||
}
|
||||
|
||||
function deletefile($id) {
|
||||
$this->db->where('pfp_id', $id);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
$data = $query->result();
|
||||
foreach($data as $dat){
|
||||
if($this->session->userdata('s_petugas_rssapintar')==1){
|
||||
unlink("./document/radiologi/".$dat->pfp_nama);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==2){
|
||||
unlink("./document/lab/".$dat->pfp_nama);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==3){
|
||||
unlink("./document/labpa/".$dat->pfp_nama);
|
||||
}elseif($this->session->userdata('s_petugas_rssapintar')==4){
|
||||
unlink("./document/labmikro/".$dat->pfp_nama);
|
||||
}
|
||||
|
||||
}
|
||||
$this->db->where('pfp_id', $id);
|
||||
$this->db->delete('proses_file_pemeriksaan');
|
||||
}
|
||||
|
||||
function radiologi($id){
|
||||
$this->db->where('pfp_pp_id', $id);
|
||||
$this->db->where('pfp_ket', 1);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function lab($id){
|
||||
$this->db->where('pfp_pp_id', $id);
|
||||
$this->db->where('pfp_ket', 2);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function labpa($id){
|
||||
$this->db->where('pfp_pp_id', $id);
|
||||
$this->db->where('pfp_ket', 3);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function labmikro($id){
|
||||
$this->db->where('pfp_pp_id', $id);
|
||||
$this->db->where('pfp_ket', 4);
|
||||
$query = $this->db->get('proses_file_pemeriksaan');
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
class M_petugas extends CI_Model {
|
||||
function index() {
|
||||
$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->where('mu_tipeuser_id', '4');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$petugas = $this->input->post('petugas');
|
||||
if($this->input->post('petugas')=="5"){
|
||||
$petugas = null;
|
||||
}
|
||||
$insert_userlogin = array(
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "4",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkap'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_petugas_penunjang' => $petugas,
|
||||
);
|
||||
$insert = $this->db->insert('master_user', $insert_userlogin);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$password = $this->input->post('passworduser');
|
||||
$petugas = $this->input->post('petugas');
|
||||
if($this->input->post('petugas')=="5"){
|
||||
$petugas = null;
|
||||
}
|
||||
if(empty($password)){
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkap'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_tipeuser_id' => "4",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_petugas_penunjang' => $petugas,
|
||||
);
|
||||
}else{
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "4",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_petugas_penunjang' => $petugas,
|
||||
);
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_userlogin);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->delete('master_user');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 0,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 1,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
class M_profile extends CI_Model {
|
||||
function index() {
|
||||
//$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->where('mu_id', $this->session->userdata('s_ID_User_rssapintar'));
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function statusaktif() {
|
||||
$this->db->where('mu_status', '1');
|
||||
$this->db->where('mu_tipeuser_id', '6');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert_userlogin = array(
|
||||
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
$insert = $this->db->insert('master_user', $insert_userlogin);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$password = $this->input->post('passworduser');
|
||||
if(empty($password)){
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
}else{
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkappasien'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => "6",
|
||||
'mu_status' => $this->input->post('status'),
|
||||
'mu_no_rekamedik' => $this->input->post('normpasien'),
|
||||
'mu_NIK' => $this->input->post('nikpasien'),
|
||||
'mu_alamat_KTP' => $this->input->post('alamatktp'),
|
||||
'mu_alamat_domisili'=> $this->input->post('alamatdomisili'),
|
||||
'mu_telepon_1' => $this->input->post('telpon1'),
|
||||
'mu_telepon_2' => $this->input->post('telpon2'),
|
||||
'mu_tanggal_lahir' => date("Y-m-d", strtotime($this->input->post('tgllahir'))),
|
||||
'mu_jenis_kelamin' => $this->input->post('jkuser'),
|
||||
'mu_gol_darah' => $this->input->post('golongandarah'),
|
||||
'mu_berat_badan' => $this->input->post('beratbadan'),
|
||||
'mu_tinggi_badan' => $this->input->post('tinggibadan'),
|
||||
'mu_warna_kulit' => $this->input->post('warnakulit'),
|
||||
);
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_userlogin);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->delete('master_user');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 0,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 1,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
class M_proseshistory extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('laporan_proses_history');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert($tabel,$ket) {
|
||||
$insert_data = array(
|
||||
'lph_tabel' => $tabel,
|
||||
'lph_keterangan' => $ket,
|
||||
'lph_query' => $this->db->last_query(),
|
||||
'lph_datetime' => date("Y-m-d H:i"),
|
||||
'lph_user_id' => $this->session->userdata('s_ID_User_rssapintar'),
|
||||
);
|
||||
$insert = $this->db->insert('laporan_proses_history', $insert_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
class M_radiologi extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('master_radiologi');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function status() {
|
||||
$this->db->order_by('mro_nama', 'ASC');
|
||||
$this->db->where('mro_status', 1);
|
||||
$query = $this->db->get('master_radiologi');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function statusdetail() {
|
||||
$this->db->join('master_radiologi', 'master_radiologi.mro_id = master_radiologi_detail.mrod_mro_id','left');
|
||||
$this->db->order_by('mro_nama', 'ASC');
|
||||
$this->db->order_by('mrod_nama', 'ASC');
|
||||
$this->db->where('mrod_status', 1);
|
||||
$query = $this->db->get('master_radiologi_detail');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert = array(
|
||||
'mro_nama' => $this->input->post('nama'),
|
||||
'mro_keterangan' => $this->input->post('keterangan'),
|
||||
'mro_status' => 1,
|
||||
);
|
||||
$insert = $this->db->insert('master_radiologi', $insert);
|
||||
$id = $this->db->insert_id();
|
||||
|
||||
$status = $_POST['statusdetail'];$num=0;
|
||||
foreach($status as $key =>$datanya)
|
||||
{
|
||||
$insert_data = array(
|
||||
'mrod_nama' => $_POST['detail'][$num],
|
||||
'mrod_keterangan' => $_POST['ket'][$num],
|
||||
'mrod_status' => $_POST['statusdetail'][$num],
|
||||
'mrod_mro_id' => $id,
|
||||
);
|
||||
$insert = $this->db->insert('master_radiologi_detail', $insert_data);
|
||||
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mro_id', $id);
|
||||
$query = $this->db->get('master_radiologi');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function editdetail($id) {
|
||||
$this->db->where('mrod_mro_id', $id);
|
||||
$query = $this->db->get('master_radiologi_detail');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$update = array(
|
||||
'mro_nama' => $this->input->post('nama'),
|
||||
'mro_keterangan' => $this->input->post('keterangan'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mro_id', $id);
|
||||
$this->db->update('master_radiologi', $update);
|
||||
|
||||
$status = $_POST['statusdetail'];$num=0;
|
||||
foreach($status as $key =>$datanya)
|
||||
{
|
||||
$data = array(
|
||||
'mrod_nama' => $_POST['detail'][$num],
|
||||
'mrod_keterangan' => $_POST['ket'][$num],
|
||||
'mrod_status' => $_POST['statusdetail'][$num],
|
||||
'mrod_mro_id' => $id,
|
||||
);
|
||||
if($_POST['baru'][$num]=="2"){
|
||||
$this->db->where('mrod_id', $_POST['iddetail'][$num]);
|
||||
$this->db->update('master_radiologi_detail', $data);
|
||||
}else{
|
||||
$insert = $this->db->insert('master_radiologi_detail', $data);
|
||||
}
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mro_id', $id);
|
||||
$this->db->delete('master_radiologi');
|
||||
|
||||
$this->db->where('mrod_mro_id', $id);
|
||||
$this->db->delete('master_radiologi_detail');
|
||||
}
|
||||
|
||||
function deletedetail($id) {
|
||||
$this->db->where('mrod_id', $id);
|
||||
$this->db->delete('master_radiologi_detail');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mro_status' => 0,
|
||||
);
|
||||
$this->db->where('mro_id', $id);
|
||||
$this->db->update('master_radiologi', $update_data);
|
||||
|
||||
$update_data_detail = array(
|
||||
'mrod_status' => 0,
|
||||
);
|
||||
$this->db->where('mrod_mro_id', $id);
|
||||
$this->db->update('master_radiologi_detail', $update_data_detail);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mro_status' => 1,
|
||||
);
|
||||
$this->db->where('mro_id', $id);
|
||||
$this->db->update('master_radiologi', $update_data);
|
||||
|
||||
$update_data_detail = array(
|
||||
'mrod_status' => 1,
|
||||
);
|
||||
$this->db->where('mrod_mro_id', $id);
|
||||
$this->db->update('master_radiologi_detail', $update_data_detail);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
class M_resume extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = '
|
||||
SELECT pr_id,pr_diagnosa,pr_tindakan,pr_keterangan,pr_date_resume,pr_status,pr_jenis_pelayanan,
|
||||
udok.mu_id AS dok_id,
|
||||
udok.mu_nama_lengkap AS dok_nama,
|
||||
|
||||
masp.ms_nama AS sp_nama,
|
||||
masp.ms_kode AS sp_kode,
|
||||
|
||||
upas.mu_id AS pas_id,
|
||||
upas.mu_nama_lengkap AS pas_nama,
|
||||
upas.mu_no_rekamedik AS pas_rm,
|
||||
upas.mu_NIK AS pas_nik,
|
||||
upas.mu_alamat_KTP AS pas_alamat,
|
||||
upas.mu_alamat_domisili AS pas_domisili,
|
||||
upas.mu_telepon_1 AS pas_telp1,
|
||||
upas.mu_telepon_2 AS pas_telp2,
|
||||
upas.mu_tanggal_lahir AS pas_tgl_lahir,
|
||||
upas.mu_gol_darah AS pas_gd,
|
||||
upas.mu_berat_badan AS pas_bb,
|
||||
upas.mu_tinggi_badan AS pas_tb,
|
||||
upas.mu_warna_kulit AS pas_wk,
|
||||
upas.mu_jenis_kelamin AS pas_jk,
|
||||
upas.mu_gambar AS pas_gambar,
|
||||
|
||||
ruang.mr_kode AS ru_id,
|
||||
ruang.mr_kode AS ru_kode,
|
||||
ruang.mr_nama AS ru_nama
|
||||
|
||||
FROM proses_resume
|
||||
|
||||
LEFT JOIN master_user AS udok ON (udok.mu_id=pr_user_dokter_id)
|
||||
LEFT JOIN master_user AS upas ON (upas.mu_id=pr_user_pasien_id)
|
||||
LEFT JOIN master_spesialis AS masp ON (masp.ms_id=pr_spesialis_id)
|
||||
LEFT JOIN master_ruang AS ruang ON (ruang.mr_id=pr_ruang_id)
|
||||
|
||||
WHERE pr_date_resume LIKE "%'.date("Y-m-d").'%"
|
||||
';
|
||||
$result = $this->db->query($query);
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
|
||||
function search() {
|
||||
if(! $this->input->post('reservation')){
|
||||
$date1 = date("Y-m-d");
|
||||
$date2 = date("Y-m-d");
|
||||
}else{
|
||||
$datemya = explode("-",$this->input->post('reservation'));
|
||||
$date1 = date("Y-m-d", strtotime($datemya[0]));
|
||||
$date2 = date("Y-m-d", strtotime($datemya[1]));
|
||||
}
|
||||
|
||||
$spesialis = "";
|
||||
if($this->input->post('spesialis')!="0"){
|
||||
$spesialis = 'AND pr_spesialis_id = "'.$this->input->post('spesialis').'"';
|
||||
}
|
||||
$query = '
|
||||
SELECT pr_id,pr_diagnosa,pr_tindakan,pr_keterangan,pr_date_resume,pr_status,pr_jenis_pelayanan,pr_user_dokter_id,pr_spesialis_id,
|
||||
udok.mu_id AS dok_id,
|
||||
udok.mu_nama_lengkap AS dok_nama,
|
||||
|
||||
masp.ms_nama AS sp_nama,
|
||||
masp.ms_kode AS sp_kode,
|
||||
|
||||
upas.mu_id AS pas_id,
|
||||
upas.mu_nama_lengkap AS pas_nama,
|
||||
upas.mu_no_rekamedik AS pas_rm,
|
||||
upas.mu_NIK AS pas_nik,
|
||||
upas.mu_alamat_KTP AS pas_alamat,
|
||||
upas.mu_alamat_domisili AS pas_domisili,
|
||||
upas.mu_telepon_1 AS pas_telp1,
|
||||
upas.mu_telepon_2 AS pas_telp2,
|
||||
upas.mu_tanggal_lahir AS pas_tgl_lahir,
|
||||
upas.mu_gol_darah AS pas_gd,
|
||||
upas.mu_berat_badan AS pas_bb,
|
||||
upas.mu_tinggi_badan AS pas_tb,
|
||||
upas.mu_warna_kulit AS pas_wk,
|
||||
upas.mu_jenis_kelamin AS pas_jk,
|
||||
upas.mu_gambar AS pas_gambar,
|
||||
|
||||
ruang.mr_kode AS ru_id,
|
||||
ruang.mr_kode AS ru_kode,
|
||||
ruang.mr_nama AS ru_nama
|
||||
|
||||
FROM proses_resume
|
||||
|
||||
LEFT JOIN master_user AS udok ON (udok.mu_id=pr_user_dokter_id)
|
||||
LEFT JOIN master_user AS upas ON (upas.mu_id=pr_user_pasien_id)
|
||||
LEFT JOIN master_spesialis AS masp ON (masp.ms_id=pr_spesialis_id)
|
||||
LEFT JOIN master_ruang AS ruang ON (ruang.mr_id=pr_ruang_id)
|
||||
|
||||
WHERE pr_date_resume between "'.$date1.' 00:00:00" AND "'.$date2.' 23:59:59"
|
||||
|
||||
'.$spesialis.'
|
||||
|
||||
';
|
||||
$result = $this->db->query($query);
|
||||
|
||||
return $result->result();
|
||||
}
|
||||
|
||||
function status_petugas() {
|
||||
$this->db->join('master_user', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$this->db->where('pr_status', 1);
|
||||
$query = $this->db->get('proses_resume');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function status_dokter() {
|
||||
$this->db->where('pr_status', 2);
|
||||
$query = $this->db->get('proses_resume');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert_petugas() {
|
||||
$originalDate = $this->input->post('tanggal');
|
||||
$originalTime = $this->input->post('waktu');
|
||||
$newDate = date("Y-m-d", strtotime($originalDate));
|
||||
$newTime = date("H:i:s", strtotime($originalTime));
|
||||
$datetime = $newDate." ".$newTime;
|
||||
|
||||
$insert = array(
|
||||
'pr_user_pasien_id' => $this->input->post('pasien'),
|
||||
'pr_ruang_id' => $this->input->post('ruang'),
|
||||
'pr_spesialis_id' => $this->input->post('spesialis'),
|
||||
'pr_date_resume' => $datetime,
|
||||
'pr_status' => "1",
|
||||
'pr_jenis_pelayanan'=> $this->input->post('pelayanan'),
|
||||
);
|
||||
$insert = $this->db->insert('proses_resume', $insert);
|
||||
}
|
||||
|
||||
function edit_petugas($id) {
|
||||
$query = '
|
||||
SELECT pr_id,pr_diagnosa,pr_tindakan,pr_keterangan,pr_date_resume,pr_status,pr_user_pasien_id,pr_ruang_id,pr_spesialis_id,pr_jenis_pelayanan,
|
||||
udok.mu_id AS dok_id,
|
||||
udok.mu_nama_lengkap AS dok_nama,
|
||||
|
||||
udpjp.mu_id AS dpjp_id,
|
||||
udpjp.mu_nama_lengkap AS dpjp_nama,
|
||||
|
||||
masp.ms_nama AS sp_nama,
|
||||
masp.ms_kode AS sp_kode,
|
||||
|
||||
upas.mu_id AS pas_id,
|
||||
upas.mu_nama_lengkap AS pas_nama,
|
||||
upas.mu_no_rekamedik AS pas_rm,
|
||||
upas.mu_NIK AS pas_nik,
|
||||
upas.mu_alamat_KTP AS pas_alamat,
|
||||
upas.mu_alamat_domisili AS pas_domisili,
|
||||
upas.mu_telepon_1 AS pas_telp1,
|
||||
upas.mu_telepon_2 AS pas_telp2,
|
||||
upas.mu_tanggal_lahir AS pas_tgl_lahir,
|
||||
upas.mu_gol_darah AS pas_gd,
|
||||
upas.mu_berat_badan AS pas_bb,
|
||||
upas.mu_tinggi_badan AS pas_tb,
|
||||
upas.mu_warna_kulit AS pas_wk,
|
||||
upas.mu_jenis_kelamin AS pas_jk,
|
||||
upas.mu_gambar AS pas_gambar,
|
||||
|
||||
ruang.mr_kode AS ru_id,
|
||||
ruang.mr_kode AS ru_kode,
|
||||
ruang.mr_nama AS ru_nama,
|
||||
|
||||
spdok.ms_nama AS spdok_nama,
|
||||
spdok.ms_kode AS spdok_kode,
|
||||
|
||||
spdpjp.ms_nama AS spdpjp_nama,
|
||||
spdpjp.ms_kode AS spdpjp_kode
|
||||
|
||||
FROM proses_resume
|
||||
|
||||
LEFT JOIN master_user AS udok ON (udok.mu_id=pr_user_dokter_id)
|
||||
LEFT JOIN master_user AS upas ON (upas.mu_id=pr_user_pasien_id)
|
||||
LEFT JOIN master_user AS udpjp ON (udpjp.mu_id=pr_user_dokter_dpjp_id)
|
||||
LEFT JOIN master_ruang AS ruang ON (ruang.mr_id=pr_ruang_id)
|
||||
|
||||
LEFT JOIN master_spesialis AS masp ON (masp.ms_id=pr_spesialis_id)
|
||||
LEFT JOIN master_spesialis AS spdok ON (spdok.ms_id=udok.mu_spesialis_id)
|
||||
LEFT JOIN master_spesialis AS spdpjp ON (spdpjp.ms_id=udpjp.mu_spesialis_id)
|
||||
|
||||
WHERE pr_id = '.$id.'
|
||||
';
|
||||
$result = $this->db->query($query);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function proseseditpetugas() {
|
||||
$originalDate = $this->input->post('tanggal');
|
||||
$originalTime = $this->input->post('waktu');
|
||||
$newDate = date("Y-m-d", strtotime($originalDate));
|
||||
$newTime = date("H:i:s", strtotime($originalTime));
|
||||
$datetime = $newDate." ".$newTime;
|
||||
|
||||
$update = array(
|
||||
'pr_user_pasien_id' => $this->input->post('pasien'),
|
||||
'pr_ruang_id' => $this->input->post('ruang'),
|
||||
'pr_spesialis_id' => $this->input->post('spesialis'),
|
||||
'pr_date_resume' => $datetime,
|
||||
//'pr_status' => "1",
|
||||
'pr_jenis_pelayanan'=> $this->input->post('pelayanan'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pr_id', $id);
|
||||
$this->db->update('proses_resume', $update);
|
||||
}
|
||||
|
||||
function proseseditdokter() {
|
||||
$update = array(
|
||||
'pr_user_dokter_id' => $this->input->post('iddokter'),
|
||||
'pr_user_dokter_dpjp_id' => $this->input->post('dpjp'),
|
||||
'pr_diagnosa' => $this->input->post('diagnosa'),
|
||||
'pr_tindakan' => $this->input->post('tindakan'),
|
||||
'pr_keterangan' => $this->input->post('keterangan'),
|
||||
'pr_status' => "2",
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('pr_id', $id);
|
||||
$this->db->update('proses_resume', $update);
|
||||
}
|
||||
|
||||
function deletedokter($id) {
|
||||
$update = array(
|
||||
'pr_user_dokter_id' => null,
|
||||
'pr_user_dokter_dpjp_id' => null,
|
||||
'pr_diagnosa' => null,
|
||||
'pr_tindakan' => null,
|
||||
'pr_keterangan' => null,
|
||||
'pr_status' => "1",
|
||||
);
|
||||
$this->db->where('pr_id', $id);
|
||||
$this->db->update('proses_resume', $update);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('pr_id', $id);
|
||||
$this->db->delete('proses_resume');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
class M_ruangan extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('master_ruang');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function status() {
|
||||
$this->db->where('mr_status', 1);
|
||||
$query = $this->db->get('master_ruang');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function pelayanan($pel) {
|
||||
$this->db->where('mr_status', 1);
|
||||
$this->db->where('mr_pelayanan', $pel);
|
||||
$query = $this->db->get('master_ruang');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert = array(
|
||||
'mr_nama' => $this->input->post('nama'),
|
||||
'mr_kode' => $this->input->post('kode'),
|
||||
'mr_status' => $this->input->post('status'),
|
||||
'mr_pelayanan' => $this->input->post('pelayanan'),
|
||||
);
|
||||
$insert = $this->db->insert('master_ruang', $insert);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mr_id', $id);
|
||||
$query = $this->db->get('master_ruang');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$update = array(
|
||||
'mr_nama' => $this->input->post('nama'),
|
||||
'mr_kode' => $this->input->post('kode'),
|
||||
'mr_status' => $this->input->post('status'),
|
||||
'mr_pelayanan' => $this->input->post('pelayanan'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mr_id', $id);
|
||||
$this->db->update('master_ruang', $update);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mr_id', $id);
|
||||
$this->db->delete('master_ruang');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mr_status' => 0,
|
||||
);
|
||||
$this->db->where('mr_id', $id);
|
||||
$this->db->update('master_ruang', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mr_status' => 1,
|
||||
);
|
||||
$this->db->where('mr_id', $id);
|
||||
$this->db->update('master_ruang', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class M_spesialis extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('master_spesialis');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function status() {
|
||||
$this->db->where('ms_status', 1);
|
||||
$query = $this->db->get('master_spesialis');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert = array(
|
||||
'ms_nama' => $this->input->post('nama'),
|
||||
'ms_kode' => $this->input->post('kode'),
|
||||
'ms_status' => $this->input->post('status'),
|
||||
);
|
||||
$insert = $this->db->insert('master_spesialis', $insert);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('ms_id', $id);
|
||||
$query = $this->db->get('master_spesialis');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$update = array(
|
||||
'ms_nama' => $this->input->post('nama'),
|
||||
'ms_kode' => $this->input->post('kode'),
|
||||
'ms_status' => $this->input->post('status'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('ms_id', $id);
|
||||
$this->db->update('master_spesialis', $update);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('ms_id', $id);
|
||||
$this->db->delete('master_spesialis');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'ms_status' => 0,
|
||||
);
|
||||
$this->db->where('ms_id', $id);
|
||||
$this->db->update('master_spesialis', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'ms_status' => 1,
|
||||
);
|
||||
$this->db->where('ms_id', $id);
|
||||
$this->db->update('master_spesialis', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class M_tipeuser extends CI_Model {
|
||||
|
||||
function index() {
|
||||
$query = $this->db->get('master_tipeuser');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function tipeuserstatus() {
|
||||
$this->db->where('mt_status', 1);
|
||||
$query = $this->db->get('master_tipeuser');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert_tipeuser = array(
|
||||
'mt_nama' => $this->input->post('namatipeuser'),
|
||||
'mt_status' => $this->input->post('status'),
|
||||
);
|
||||
$insert = $this->db->insert('master_tipeuser', $insert_tipeuser);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mt_id', $id);
|
||||
$query = $this->db->get('master_tipeuser');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$update_tipeuser = array(
|
||||
'mt_nama' => $this->input->post('namatipeuser'),
|
||||
'mt_status' => $this->input->post('status'),
|
||||
);
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mt_id', $id);
|
||||
$this->db->update('master_tipeuser', $update_tipeuser);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mt_id', $id);
|
||||
$this->db->delete('master_tipeuser');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mt_status' => 0,
|
||||
);
|
||||
$this->db->where('mt_id', $id);
|
||||
$this->db->update('master_tipeuser', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mt_status' => 1,
|
||||
);
|
||||
$this->db->where('mt_id', $id);
|
||||
$this->db->update('master_tipeuser', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
class M_userlogin extends CI_Model {
|
||||
function index() {
|
||||
$this->db->join('master_tipeuser', 'master_tipeuser.mt_id = master_user.mu_tipeuser_id','left');
|
||||
$query = $this->db->get('master_user');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function insert() {
|
||||
$insert_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkapuser'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => $this->input->post('tipeuser'),
|
||||
'mu_status' => $this->input->post('status'),
|
||||
);
|
||||
$insert = $this->db->insert('master_user', $insert_userlogin);
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$query = $this->db->get('master_user');
|
||||
return $query;
|
||||
}
|
||||
|
||||
function prosesedit() {
|
||||
$loketdat = $this->input->post('loket');if(empty($loketdat)){$loketdat=null;}
|
||||
$klinik = $this->input->post('klinik');if(empty($klinik)){$klinik=null;}
|
||||
$password = $this->input->post('passworduser');
|
||||
if(empty($password)){
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkapuser'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_tipeuser_id' => $this->input->post('tipeuser'),
|
||||
'mu_status' => $this->input->post('status'),
|
||||
);
|
||||
}else{
|
||||
$update_userlogin = array(
|
||||
'mu_nama_lengkap' => $this->input->post('namalengkapuser'),
|
||||
'mu_nama_user' => $this->input->post('namauser'),
|
||||
'mu_password' => md5($this->input->post('passworduser')),
|
||||
'mu_tipeuser_id' => $this->input->post('tipeuser'),
|
||||
'mu_status' => $this->input->post('status'),
|
||||
);
|
||||
}
|
||||
$id = $this->input->post('id');
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_userlogin);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->delete('master_user');
|
||||
}
|
||||
|
||||
function disabled($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 0,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
|
||||
function aktif($id) {
|
||||
$update_data = array(
|
||||
'mu_status' => 1,
|
||||
);
|
||||
$this->db->where('mu_id', $id);
|
||||
$this->db->update('master_user', $update_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
+1153
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
PHPExcel_Autoloader::register();
|
||||
// As we always try to run the autoloader before anything else, we can use it to do a few
|
||||
// simple checks and initialisations
|
||||
//PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
PHPExcel_Shared_String::buildCharacterSets();
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
if (function_exists('__autoload')) {
|
||||
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
// Register ourselves with SPL
|
||||
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
|
||||
} else {
|
||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload a class identified by name
|
||||
*
|
||||
* @param string $pClassName Name of the object to load
|
||||
*/
|
||||
public static function load($pClassName)
|
||||
{
|
||||
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
|
||||
// Either already loaded, or not a PHPExcel class request
|
||||
return false;
|
||||
}
|
||||
|
||||
$pClassFilePath = PHPEXCEL_ROOT .
|
||||
str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||
// Can't load
|
||||
return false;
|
||||
}
|
||||
|
||||
require($pClassFilePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_APC
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
if (!apc_store(
|
||||
$this->cachePrefix . $this->currentObjectID . '.cache',
|
||||
serialize($this->currentObject),
|
||||
$this->cacheTime
|
||||
)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @throws PHPExcel_Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @throws PHPExcel_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
|
||||
}
|
||||
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if ($this->currentObject !== null) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||
{
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if ($this->cachePrefix === null) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
apc_delete($this->cachePrefix . $cellID . '.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_CacheBase
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
abstract class PHPExcel_CachedObjectStorage_CacheBase
|
||||
{
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentObjectID = null;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $currentCellIsDirty = true;
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
* and indexed by their coordinate address within the worksheet
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $cellCache = array();
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
// Set our parent worksheet.
|
||||
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
||||
// they are woken from a serialized state
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parent worksheet for this cell collection
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry exists in the cache
|
||||
return isset($this->cellCache[$pCoord]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
$this->currentCellIsDirty = true;
|
||||
if (isset($this->cellCache[$fromAddress])) {
|
||||
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
|
||||
unset($this->cellCache[$fromAddress]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell)
|
||||
{
|
||||
return $this->addCacheData($cell->getCoordinate(), $cell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
if (is_object($this->cellCache[$pCoord])) {
|
||||
$this->cellCache[$pCoord]->detach();
|
||||
unset($this->cellCache[$pCoord]);
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
return array_keys($this->cellCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSortedCellList()
|
||||
{
|
||||
$sortKeys = array();
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
return array_values($sortKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet column and highest row that have cell records
|
||||
*
|
||||
* @return array Highest column name and highest row number
|
||||
*/
|
||||
public function getHighestRowAndColumn()
|
||||
{
|
||||
// Lookup highest column and highest row
|
||||
$col = array('A' => '1A');
|
||||
$row = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
$row[$r] = $r;
|
||||
$col[$c] = strlen($c).$c;
|
||||
}
|
||||
if (!empty($row)) {
|
||||
// Determine highest column and row
|
||||
$highestRow = max($row);
|
||||
$highestColumn = substr(max($col), 1);
|
||||
}
|
||||
|
||||
return array(
|
||||
'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell address of the currently active cell object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentAddress()
|
||||
{
|
||||
return $this->currentObjectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column address of the currently active cell object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentColumn()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the row address of the currently active cell object
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCurrentRow()
|
||||
{
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return (integer) $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet column
|
||||
*
|
||||
* @param string $row Return the highest column for the specified row,
|
||||
* or the highest column of any row if no row number is passed
|
||||
* @return string Highest column name
|
||||
*/
|
||||
public function getHighestColumn($row = null)
|
||||
{
|
||||
if ($row == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['column'];
|
||||
}
|
||||
|
||||
$columnList = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($r != $row) {
|
||||
continue;
|
||||
}
|
||||
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
|
||||
}
|
||||
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet row
|
||||
*
|
||||
* @param string $column Return the highest row for the specified column,
|
||||
* or the highest row of any column if no column letter is passed
|
||||
* @return int Highest row number
|
||||
*/
|
||||
public function getHighestRow($column = null)
|
||||
{
|
||||
if ($column == null) {
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
$rowList = array(0);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($c != $column) {
|
||||
continue;
|
||||
}
|
||||
$rowList[] = $r;
|
||||
}
|
||||
|
||||
return max($rowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique ID for cache referencing
|
||||
*
|
||||
* @return string Unique Reference
|
||||
*/
|
||||
protected function getUniqueID()
|
||||
{
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
return uniqid($baseUnique, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
$this->parent = $parent;
|
||||
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
|
||||
$this->currentObject->attach($this);
|
||||
}
|
||||
} // function copyCellCollection()
|
||||
|
||||
/**
|
||||
* Remove a row, deleting all cells in that row
|
||||
*
|
||||
* @param string $row Row number to remove
|
||||
* @return void
|
||||
*/
|
||||
public function removeRow($row)
|
||||
{
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($r == $row) {
|
||||
$this->deleteCacheData($coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a column, deleting all cells in that column
|
||||
*
|
||||
* @param string $column Column ID to remove
|
||||
* @return void
|
||||
*/
|
||||
public function removeColumn($column)
|
||||
{
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
if ($c == $column) {
|
||||
$this->deleteCacheData($coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fileName = null;
|
||||
|
||||
/**
|
||||
* File handle for this cache file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Directory/Folder where the cache file is located
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cacheDirectory = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = array(
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||
);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy($this->fileName, $newFileName);
|
||||
$this->fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||
{
|
||||
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
|
||||
? $arguments['dir']
|
||||
: PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->fileHandle)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
unlink($this->fileName);
|
||||
}
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_ICache
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
interface PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Fetch a cell from cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList();
|
||||
|
||||
/**
|
||||
* Get the list of all cell addresses currently held in cache sorted by column and row
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSortedCellList();
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable();
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Igbinary
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('igbinary_serialize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memcache
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Memcache interface
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $memcache = null;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$obj = serialize($this->currentObject);
|
||||
if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
|
||||
}
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in Memcache
|
||||
$success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Memcache
|
||||
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
|
||||
}
|
||||
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||
{
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->cachePrefix)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->memcache = new Memcache();
|
||||
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
|
||||
throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
|
||||
}
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Memcache error handler
|
||||
*
|
||||
* @param string $host Memcache server
|
||||
* @param integer $port Memcache port
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function failureCallback($host, $port)
|
||||
{
|
||||
throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
$this->memcache->delete($this->cachePrefix.$cellID . '.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memory
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Dummy method callable from CacheBase, but unused by Memory cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
$this->cellCache[$pCoord] = $cell;
|
||||
|
||||
// Set current entry to the new/updated entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
$this->currentObjectID = null;
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
// Return requested entry
|
||||
return $this->cellCache[$pCoord];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = array();
|
||||
foreach ($this->cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($this);
|
||||
}
|
||||
|
||||
$this->cellCache = $newCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||
foreach ($this->cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Memory limit to use before reverting to file cache
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $memoryCacheSize = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
|
||||
$this->cellCache[$this->currentObjectID] = array(
|
||||
'ptr' => ftell($this->fileHandle),
|
||||
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
|
||||
);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Open a new stream for the cell cache data
|
||||
$newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||
// Copy the existing cell cache data to the new stream
|
||||
fseek($this->fileHandle, 0);
|
||||
while (!feof($this->fileHandle)) {
|
||||
fwrite($newFileHandle, fread($this->fileHandle, 1024));
|
||||
}
|
||||
$this->fileHandle = $newFileHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||
{
|
||||
$this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->fileHandle)) {
|
||||
$this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
}
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $DBHandle = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
$cellResult = $cellResultSet->fetchSingle();
|
||||
$this->currentObject = unserialize($cellResult);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
if (!$this->DBHandle->queryExec($query)) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
|
||||
if ($cellIdsResult === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
$cellKeys = array();
|
||||
foreach ($cellIdsResult as $row) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->TableName)
|
||||
) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->TableName = $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->DBHandle)) {
|
||||
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->DBHandle = new SQLiteDatabase($_DBName);
|
||||
if ($this->DBHandle === false) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
|
||||
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->DBHandle)) {
|
||||
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
|
||||
}
|
||||
$this->DBHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite3
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $DBHandle = null;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 select query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $selectQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 insert query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $insertQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 update query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $updateQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 delete query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $deleteQuery;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||
$result = $this->insertQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
if ($cellData === false) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
$this->currentObject = unserialize($cellData['value']);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
return ($cellData === false) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
*
|
||||
* @param string $fromAddress Current address of the cell to move
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||
$result = $this->updateQuery->execute();
|
||||
if ($result === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->query($query);
|
||||
if ($cellIdsResult === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$cellKeys = array();
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->TableName)
|
||||
) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->TableName = $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->DBHandle)) {
|
||||
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->DBHandle = new SQLite3($_DBName);
|
||||
if ($this->DBHandle === false) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
|
||||
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
|
||||
$this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
|
||||
$this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->DBHandle)) {
|
||||
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
|
||||
$this->DBHandle->close();
|
||||
}
|
||||
$this->DBHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!class_exists('SQLite3', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Wincache
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$obj = serialize($this->currentObject);
|
||||
if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
|
||||
if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||
}
|
||||
} else {
|
||||
if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||
}
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
$obj = null;
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
||||
}
|
||||
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the WinCache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments)
|
||||
{
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->cachePrefix)) {
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach ($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorageFactory
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorageFactory
|
||||
{
|
||||
const cache_in_memory = 'Memory';
|
||||
const cache_in_memory_gzip = 'MemoryGZip';
|
||||
const cache_in_memory_serialized = 'MemorySerialized';
|
||||
const cache_igbinary = 'Igbinary';
|
||||
const cache_to_discISAM = 'DiscISAM';
|
||||
const cache_to_apc = 'APC';
|
||||
const cache_to_memcache = 'Memcache';
|
||||
const cache_to_phpTemp = 'PHPTemp';
|
||||
const cache_to_wincache = 'Wincache';
|
||||
const cache_to_sqlite = 'SQLite';
|
||||
const cache_to_sqlite3 = 'SQLite3';
|
||||
|
||||
/**
|
||||
* Name of the method used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $cacheStorageMethod = null;
|
||||
|
||||
/**
|
||||
* Name of the class used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $cacheStorageClass = null;
|
||||
|
||||
/**
|
||||
* List of all possible cache storage methods
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $storageMethods = array(
|
||||
self::cache_in_memory,
|
||||
self::cache_in_memory_gzip,
|
||||
self::cache_in_memory_serialized,
|
||||
self::cache_igbinary,
|
||||
self::cache_to_phpTemp,
|
||||
self::cache_to_discISAM,
|
||||
self::cache_to_apc,
|
||||
self::cache_to_memcache,
|
||||
self::cache_to_wincache,
|
||||
self::cache_to_sqlite,
|
||||
self::cache_to_sqlite3,
|
||||
);
|
||||
|
||||
/**
|
||||
* Default arguments for each cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $storageMethodDefaultParameters = array(
|
||||
self::cache_in_memory => array(
|
||||
),
|
||||
self::cache_in_memory_gzip => array(
|
||||
),
|
||||
self::cache_in_memory_serialized => array(
|
||||
),
|
||||
self::cache_igbinary => array(
|
||||
),
|
||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||
),
|
||||
self::cache_to_discISAM => array( 'dir' => null
|
||||
),
|
||||
self::cache_to_apc => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
|
||||
'memcachePort' => 11211,
|
||||
'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_wincache => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_sqlite => array(
|
||||
),
|
||||
self::cache_to_sqlite3 => array(
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Arguments for the active cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $storageMethodParameters = array();
|
||||
|
||||
/**
|
||||
* Return the current cache storage method
|
||||
*
|
||||
* @return string|null
|
||||
**/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return self::$cacheStorageMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current cache storage class
|
||||
*
|
||||
* @return PHPExcel_CachedObjectStorage_ICache|null
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$cacheStorageClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all possible cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$storageMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all available cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = array();
|
||||
foreach (self::$storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
|
||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
}
|
||||
}
|
||||
return $activeMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify the cache storage method to use
|
||||
*
|
||||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @param array of mixed $arguments Additional arguments to pass to the cell caching class
|
||||
* when instantiating
|
||||
* @return boolean
|
||||
**/
|
||||
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
||||
{
|
||||
if (!in_array($method, self::$storageMethods)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||
if (!call_user_func(array( $cacheStorageClass,
|
||||
'cacheMethodIsAvailable'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
|
||||
foreach ($arguments as $k => $v) {
|
||||
if (array_key_exists($k, self::$storageMethodParameters[$method])) {
|
||||
self::$storageMethodParameters[$method][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
|
||||
self::$cacheStorageMethod = $method;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the cache storage
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
|
||||
* @return PHPExcel_CachedObjectStorage_ICache
|
||||
**/
|
||||
public static function getInstance(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$cacheMethodIsAvailable = true;
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new self::$cacheStorageClass(
|
||||
$parent,
|
||||
self::$storageMethodParameters[self::$cacheStorageMethod]
|
||||
);
|
||||
if ($instance !== null) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache storage
|
||||
*
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$cacheStorageMethod = null;
|
||||
self::$cacheStorageClass = null;
|
||||
self::$storageMethodParameters = array();
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
{
|
||||
/**
|
||||
* The call stack for calculated cells
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $stack = array();
|
||||
|
||||
/**
|
||||
* Return the number of entries on the stack
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a new entry onto the stack
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function push($value)
|
||||
{
|
||||
$this->stack[$value] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the last entry from the stack
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function pop()
|
||||
{
|
||||
return array_pop($this->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see if a specified entry exists on the stack
|
||||
*
|
||||
* @param mixed $value The value to test
|
||||
*/
|
||||
public function onStack($value)
|
||||
{
|
||||
return isset($this->stack[$value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the stack
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->stack = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of all entries on the stack
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function showStack()
|
||||
{
|
||||
return $this->stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_CalcEngine_Logger
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_CalcEngine_Logger
|
||||
{
|
||||
/**
|
||||
* Flag to determine whether a debug log should be generated by the calculation engine
|
||||
* If true, then a debug log will be generated
|
||||
* If false, then a debug log will not be generated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $writeDebugLog = false;
|
||||
|
||||
/**
|
||||
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||
* If true, then a debug log will be echoed
|
||||
* If false, then a debug log will not be echoed
|
||||
* A debug log can only be echoed if it is generated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $echoDebugLog = false;
|
||||
|
||||
/**
|
||||
* The debug log generated by the calculation engine
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $debugLog = array();
|
||||
|
||||
/**
|
||||
* The calculation engine cell reference stack
|
||||
*
|
||||
* @var PHPExcel_CalcEngine_CyclicReferenceStack
|
||||
*/
|
||||
private $cellStack;
|
||||
|
||||
/**
|
||||
* Instantiate a Calculation engine logger
|
||||
*
|
||||
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
|
||||
*/
|
||||
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
|
||||
{
|
||||
$this->cellStack = $stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable Calculation engine logging
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setWriteDebugLog($pValue = false)
|
||||
{
|
||||
$this->writeDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether calculation engine logging is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getWriteDebugLog()
|
||||
{
|
||||
return $this->writeDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable echoing of debug log information
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setEchoDebugLog($pValue = false)
|
||||
{
|
||||
$this->echoDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether echoing of debug log information is enabled or disabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEchoDebugLog()
|
||||
{
|
||||
return $this->echoDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an entry to the calculation engine debug log
|
||||
*/
|
||||
public function writeDebugLog()
|
||||
{
|
||||
// Only write the debug log if logging is enabled
|
||||
if ($this->writeDebugLog) {
|
||||
$message = implode(func_get_args());
|
||||
$cellReference = implode(' -> ', $this->cellStack->showStack());
|
||||
if ($this->echoDebugLog) {
|
||||
echo $cellReference,
|
||||
($this->cellStack->count() > 0 ? ' => ' : ''),
|
||||
$message,
|
||||
PHP_EOL;
|
||||
}
|
||||
$this->debugLog[] = $cellReference .
|
||||
($this->cellStack->count() > 0 ? ' => ' : '') .
|
||||
$message;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the calculation engine debug log
|
||||
*/
|
||||
public function clearLog()
|
||||
{
|
||||
$this->debugLog = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the calculation engine debug log
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLog()
|
||||
{
|
||||
return $this->debugLog;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,676 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Database
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Database
|
||||
{
|
||||
/**
|
||||
* fieldExtract
|
||||
*
|
||||
* Extracts the column ID to use for the data field.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param mixed $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @return string|NULL
|
||||
*
|
||||
*/
|
||||
private static function fieldExtract($database, $field)
|
||||
{
|
||||
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
|
||||
$fieldNames = array_map('strtoupper', array_shift($database));
|
||||
|
||||
if (is_numeric($field)) {
|
||||
$keys = array_keys($fieldNames);
|
||||
return $keys[$field-1];
|
||||
}
|
||||
$key = array_search($field, $fieldNames);
|
||||
return ($key) ? $key : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* filter
|
||||
*
|
||||
* Parses the selection criteria, extracts the database rows that match those criteria, and
|
||||
* returns that subset of rows.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return array of mixed
|
||||
*
|
||||
*/
|
||||
private static function filter($database, $criteria)
|
||||
{
|
||||
$fieldNames = array_shift($database);
|
||||
$criteriaNames = array_shift($criteria);
|
||||
|
||||
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
|
||||
$testConditions = $testValues = array();
|
||||
$testConditionsCount = 0;
|
||||
foreach ($criteriaNames as $key => $criteriaName) {
|
||||
$testCondition = array();
|
||||
$testConditionCount = 0;
|
||||
foreach ($criteria as $row => $criterion) {
|
||||
if ($criterion[$key] > '') {
|
||||
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::ifCondition($criterion[$key]);
|
||||
$testConditionCount++;
|
||||
}
|
||||
}
|
||||
if ($testConditionCount > 1) {
|
||||
$testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
|
||||
$testConditionsCount++;
|
||||
} elseif ($testConditionCount == 1) {
|
||||
$testConditions[] = $testCondition[0];
|
||||
$testConditionsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($testConditionsCount > 1) {
|
||||
$testConditionSet = 'AND(' . implode(',', $testConditions) . ')';
|
||||
} elseif ($testConditionsCount == 1) {
|
||||
$testConditionSet = $testConditions[0];
|
||||
}
|
||||
|
||||
// Loop through each row of the database
|
||||
foreach ($database as $dataRow => $dataValues) {
|
||||
// Substitute actual values from the database row for our [:placeholders]
|
||||
$testConditionList = $testConditionSet;
|
||||
foreach ($criteriaNames as $key => $criteriaName) {
|
||||
$k = array_search($criteriaName, $fieldNames);
|
||||
if (isset($dataValues[$k])) {
|
||||
$dataValue = $dataValues[$k];
|
||||
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::wrapResult(strtoupper($dataValue)) : $dataValue;
|
||||
$testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList);
|
||||
}
|
||||
}
|
||||
// evaluate the criteria against the row data
|
||||
$result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
|
||||
// If the row failed to meet the criteria, remove it from the database
|
||||
if (!$result) {
|
||||
unset($database[$dataRow]);
|
||||
}
|
||||
}
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
|
||||
private static function getFilteredColumn($database, $field, $criteria)
|
||||
{
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::filter($database, $criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach ($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
return $colData;
|
||||
}
|
||||
|
||||
/**
|
||||
* DAVERAGE
|
||||
*
|
||||
* Averages the values in a column of a list or database that match conditions you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DAVERAGE($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::AVERAGE(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNT
|
||||
*
|
||||
* Counts the cells that contain numbers in a column of a list or database that match conditions
|
||||
* that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DCOUNT(database,[field],criteria)
|
||||
*
|
||||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNT($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::COUNT(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNTA
|
||||
*
|
||||
* Counts the nonblank cells in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DCOUNTA(database,[field],criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNTA($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::filter($database, $criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach ($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::COUNTA(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DGET
|
||||
*
|
||||
* Extracts a single value from a column of a list or database that matches conditions that you
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DGET(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return mixed
|
||||
*
|
||||
*/
|
||||
public static function DGET($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
$colData = self::getFilteredColumn($database, $field, $criteria);
|
||||
if (count($colData) > 1) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
|
||||
return $colData[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DMAX
|
||||
*
|
||||
* Returns the largest number in a column of a list or database that matches conditions you that
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DMAX(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMAX($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::MAX(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DMIN
|
||||
*
|
||||
* Returns the smallest number in a column of a list or database that matches conditions you that
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DMIN(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMIN($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::MIN(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DPRODUCT
|
||||
*
|
||||
* Multiplies the values in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DPRODUCT(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DPRODUCT($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_MathTrig::PRODUCT(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEV
|
||||
*
|
||||
* Estimates the standard deviation of a population based on a sample by using the numbers in a
|
||||
* column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSTDEV(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEV($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::STDEV(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEVP
|
||||
*
|
||||
* Calculates the standard deviation of a population based on the entire population by using the
|
||||
* numbers in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSTDEVP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEVP($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::STDEVP(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DSUM
|
||||
*
|
||||
* Adds the numbers in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSUM(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSUM($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_MathTrig::SUM(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DVAR
|
||||
*
|
||||
* Estimates the variance of a population based on a sample by using the numbers in a column
|
||||
* of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DVAR(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVAR($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::VARFunc(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DVARP
|
||||
*
|
||||
* Calculates the variance of a population based on the entire population by using the numbers
|
||||
* in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DVARP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVARP($database, $field, $criteria)
|
||||
{
|
||||
$field = self::fieldExtract($database, $field);
|
||||
if (is_null($field)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::VARP(
|
||||
self::getFilteredColumn($database, $field, $criteria)
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Exception
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* Register errorhandler
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister errorhandler
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,622 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
class PHPExcel_Calculation_FormulaParser
|
||||
{
|
||||
/* Character constants */
|
||||
const QUOTE_DOUBLE = '"';
|
||||
const QUOTE_SINGLE = '\'';
|
||||
const BRACKET_CLOSE = ']';
|
||||
const BRACKET_OPEN = '[';
|
||||
const BRACE_OPEN = '{';
|
||||
const BRACE_CLOSE = '}';
|
||||
const PAREN_OPEN = '(';
|
||||
const PAREN_CLOSE = ')';
|
||||
const SEMICOLON = ';';
|
||||
const WHITESPACE = ' ';
|
||||
const COMMA = ',';
|
||||
const ERROR_START = '#';
|
||||
|
||||
const OPERATORS_SN = "+-";
|
||||
const OPERATORS_INFIX = "+-*/^&=><";
|
||||
const OPERATORS_POSTFIX = "%";
|
||||
|
||||
/**
|
||||
* Formula
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $formula;
|
||||
|
||||
/**
|
||||
* Tokens
|
||||
*
|
||||
* @var PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
private $tokens = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* @param string $pFormula Formula to parse
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function __construct($pFormula = '')
|
||||
{
|
||||
// Check parameters
|
||||
if (is_null($pFormula)) {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed: formula");
|
||||
}
|
||||
|
||||
// Initialise values
|
||||
$this->formula = trim($pFormula);
|
||||
// Parse!
|
||||
$this->parseToTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula()
|
||||
{
|
||||
return $this->formula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token
|
||||
*
|
||||
* @param int $pId Token id
|
||||
* @return string
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function getToken($pId = 0)
|
||||
{
|
||||
if (isset($this->tokens[$pId])) {
|
||||
return $this->tokens[$pId];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token count
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenCount()
|
||||
{
|
||||
return count($this->tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tokens
|
||||
*
|
||||
* @return PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
public function getTokens()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse to tokens
|
||||
*/
|
||||
private function parseToTokens()
|
||||
{
|
||||
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
|
||||
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
|
||||
|
||||
// Check if the formula has a valid starting =
|
||||
$formulaLength = strlen($this->formula);
|
||||
if ($formulaLength < 2 || $this->formula{0} != '=') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variables
|
||||
$tokens1 = $tokens2 = $stack = array();
|
||||
$inString = $inPath = $inRange = $inError = false;
|
||||
$token = $previousToken = $nextToken = null;
|
||||
|
||||
$index = 1;
|
||||
$value = '';
|
||||
|
||||
$ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A");
|
||||
$COMPARATORS_MULTI = array(">=", "<=", "<>");
|
||||
|
||||
while ($index < $formulaLength) {
|
||||
// state-dependent character evaluation (order is important)
|
||||
|
||||
// double-quoted strings
|
||||
// embeds are doubled
|
||||
// end marks token
|
||||
if ($inString) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
||||
++$index;
|
||||
} else {
|
||||
$inString = false;
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT);
|
||||
$value = "";
|
||||
}
|
||||
} else {
|
||||
$value .= $this->formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// single-quoted strings (links)
|
||||
// embeds are double
|
||||
// end does not mark a token
|
||||
if ($inPath) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
||||
++$index;
|
||||
} else {
|
||||
$inPath = false;
|
||||
}
|
||||
} else {
|
||||
$value .= $this->formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// bracked strings (R1C1 range index or linked workbook name)
|
||||
// no embeds (changed to "()" by Excel)
|
||||
// end does not mark a token
|
||||
if ($inRange) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
||||
$inRange = false;
|
||||
}
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// error values
|
||||
// end marks a token, determined from absolute list of values
|
||||
if ($inError) {
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
if (in_array($value, $ERRORS)) {
|
||||
$inError = false;
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR);
|
||||
$value = "";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// scientific notation check
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 1) {
|
||||
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// independent character evaluation (order not important)
|
||||
|
||||
// establish state-dependent character evaluations
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if (strlen($value > 0)) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inString = true;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inPath = true;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
||||
$inRange = true;
|
||||
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inError = true;
|
||||
$value .= PHPExcel_Calculation_FormulaParser::ERROR_START;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// mark start and end of arrays and array rows
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAY", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// trim white-space
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||
++$index;
|
||||
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
||||
++$index;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// multi-character comparators
|
||||
if (($index + 2) <= $formulaLength) {
|
||||
if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
$index += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// standard infix operators
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// standard postfix operators (only one)
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// start subexpression or function
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
||||
if (strlen($value) > 0) {
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
$value = "";
|
||||
} else {
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// function, subexpression, or array parameters, or operand unions
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$stack[] = $tmp;
|
||||
|
||||
if ($tmp->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_UNION);
|
||||
} else {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// stop subexpression
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// token accumulation
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
}
|
||||
|
||||
// dump remaining accumulation
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
}
|
||||
|
||||
// move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
|
||||
$tokenCount = count($tokens1);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
$token = $tokens1[$i];
|
||||
if (isset($tokens1[$i - 1])) {
|
||||
$previousToken = $tokens1[$i - 1];
|
||||
} else {
|
||||
$previousToken = null;
|
||||
}
|
||||
if (isset($tokens1[$i + 1])) {
|
||||
$nextToken = $tokens1[$i + 1];
|
||||
} else {
|
||||
$nextToken = null;
|
||||
}
|
||||
|
||||
if (is_null($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() != PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) {
|
||||
$tokens2[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($previousToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($nextToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! (
|
||||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tokens2[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION);
|
||||
}
|
||||
|
||||
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
|
||||
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
|
||||
$this->tokens = array();
|
||||
|
||||
$tokenCount = count($tokens2);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
$token = $tokens2[$i];
|
||||
if (isset($tokens2[$i - 1])) {
|
||||
$previousToken = $tokens2[$i - 1];
|
||||
} else {
|
||||
$previousToken = null;
|
||||
}
|
||||
if (isset($tokens2[$i + 1])) {
|
||||
$nextToken = $tokens2[$i + 1];
|
||||
} else {
|
||||
$nextToken = null;
|
||||
}
|
||||
|
||||
if (is_null($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
||||
if ($i == 0) {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
}
|
||||
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
||||
if ($i == 0) {
|
||||
continue;
|
||||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
|
||||
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} elseif ($token->getValue() == "&") {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
}
|
||||
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND &&
|
||||
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (!is_numeric($token->getValue())) {
|
||||
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE);
|
||||
}
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
|
||||
}
|
||||
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
if (strlen($token->getValue() > 0)) {
|
||||
if (substr($token->getValue(), 0, 1) == "@") {
|
||||
$token->setValue(substr($token->getValue(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->tokens[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
class PHPExcel_Calculation_FormulaToken
|
||||
{
|
||||
/* Token types */
|
||||
const TOKEN_TYPE_NOOP = 'Noop';
|
||||
const TOKEN_TYPE_OPERAND = 'Operand';
|
||||
const TOKEN_TYPE_FUNCTION = 'Function';
|
||||
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
|
||||
const TOKEN_TYPE_ARGUMENT = 'Argument';
|
||||
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
|
||||
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
|
||||
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
|
||||
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
|
||||
const TOKEN_TYPE_UNKNOWN = 'Unknown';
|
||||
|
||||
/* Token subtypes */
|
||||
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
||||
const TOKEN_SUBTYPE_START = 'Start';
|
||||
const TOKEN_SUBTYPE_STOP = 'Stop';
|
||||
const TOKEN_SUBTYPE_TEXT = 'Text';
|
||||
const TOKEN_SUBTYPE_NUMBER = 'Number';
|
||||
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
|
||||
const TOKEN_SUBTYPE_ERROR = 'Error';
|
||||
const TOKEN_SUBTYPE_RANGE = 'Range';
|
||||
const TOKEN_SUBTYPE_MATH = 'Math';
|
||||
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
|
||||
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
|
||||
const TOKEN_SUBTYPE_UNION = 'Union';
|
||||
|
||||
/**
|
||||
* Value
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tokenType;
|
||||
|
||||
/**
|
||||
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tokenSubType;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
|
||||
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
|
||||
*/
|
||||
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||
{
|
||||
// Initialise values
|
||||
$this->value = $pValue;
|
||||
$this->tokenType = $pTokenType;
|
||||
$this->tokenSubType = $pTokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenType()
|
||||
{
|
||||
return $this->tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token Type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
|
||||
{
|
||||
$this->tokenType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenSubType()
|
||||
{
|
||||
return $this->tokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token SubType
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||
{
|
||||
$this->tokenSubType = $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Function
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Function
|
||||
{
|
||||
/* Function categories */
|
||||
const CATEGORY_CUBE = 'Cube';
|
||||
const CATEGORY_DATABASE = 'Database';
|
||||
const CATEGORY_DATE_AND_TIME = 'Date and Time';
|
||||
const CATEGORY_ENGINEERING = 'Engineering';
|
||||
const CATEGORY_FINANCIAL = 'Financial';
|
||||
const CATEGORY_INFORMATION = 'Information';
|
||||
const CATEGORY_LOGICAL = 'Logical';
|
||||
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
|
||||
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
||||
const CATEGORY_STATISTICAL = 'Statistical';
|
||||
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
||||
|
||||
/**
|
||||
* Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Excel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $excelName;
|
||||
|
||||
/**
|
||||
* PHPExcel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $phpExcelName;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_Function
|
||||
*
|
||||
* @param string $pCategory Category (represented by CATEGORY_*)
|
||||
* @param string $pExcelName Excel function name
|
||||
* @param string $pPHPExcelName PHPExcel function mapping
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
|
||||
{
|
||||
if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
|
||||
// Initialise values
|
||||
$this->category = $pCategory;
|
||||
$this->excelName = $pExcelName;
|
||||
$this->phpExcelName = $pPHPExcelName;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @param string $value
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function setCategory($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$this->category = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Excel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExcelName()
|
||||
{
|
||||
return $this->excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Excel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setExcelName($value)
|
||||
{
|
||||
$this->excelName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPHPExcelName()
|
||||
{
|
||||
return $this->phpExcelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PHPExcel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setPHPExcelName($value)
|
||||
{
|
||||
$this->phpExcelName = $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,760 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/** MAX_VALUE */
|
||||
define('MAX_VALUE', 1.2e308);
|
||||
|
||||
/** 2 / PI */
|
||||
define('M_2DIVPI', 0.63661977236758134307553505349006);
|
||||
|
||||
/** MAX_ITERATIONS */
|
||||
define('MAX_ITERATIONS', 256);
|
||||
|
||||
/** PRECISION */
|
||||
define('PRECISION', 8.88E-016);
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Functions
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Functions
|
||||
{
|
||||
|
||||
/** constants */
|
||||
const COMPATIBILITY_EXCEL = 'Excel';
|
||||
const COMPATIBILITY_GNUMERIC = 'Gnumeric';
|
||||
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
|
||||
|
||||
const RETURNDATE_PHP_NUMERIC = 'P';
|
||||
const RETURNDATE_PHP_OBJECT = 'O';
|
||||
const RETURNDATE_EXCEL = 'E';
|
||||
|
||||
|
||||
/**
|
||||
* Compatibility mode to use for error checking and responses
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
|
||||
|
||||
/**
|
||||
* Data Type to use when returning date values
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
protected static $returnDateType = self::RETURNDATE_EXCEL;
|
||||
|
||||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
protected static $errorCodes = array(
|
||||
'null' => '#NULL!',
|
||||
'divisionbyzero' => '#DIV/0!',
|
||||
'value' => '#VALUE!',
|
||||
'reference' => '#REF!',
|
||||
'name' => '#NAME?',
|
||||
'num' => '#NUM!',
|
||||
'na' => '#N/A',
|
||||
'gettingdata' => '#GETTING_DATA'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Set the Compatibility Mode
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @param string $compatibilityMode Compatibility Mode
|
||||
* Permitted values are:
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* @return boolean (Success or Failure)
|
||||
*/
|
||||
public static function setCompatibilityMode($compatibilityMode)
|
||||
{
|
||||
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
|
||||
self::$compatibilityMode = $compatibilityMode;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current Compatibility Mode
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @return string Compatibility Mode
|
||||
* Possible Return values are:
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
*/
|
||||
public static function getCompatibilityMode()
|
||||
{
|
||||
return self::$compatibilityMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @param string $returnDateType Return Date Format
|
||||
* Permitted values are:
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setReturnDateType($returnDateType)
|
||||
{
|
||||
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
|
||||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
|
||||
($returnDateType == self::RETURNDATE_EXCEL)) {
|
||||
self::$returnDateType = $returnDateType;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
|
||||
*
|
||||
* @access public
|
||||
* @category Function Configuration
|
||||
* @return string Return Date Format
|
||||
* Possible Return values are:
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
*/
|
||||
public static function getReturnDateType()
|
||||
{
|
||||
return self::$returnDateType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DUMMY
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
public static function DUMMY()
|
||||
{
|
||||
return '#Not Yet Implemented';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DIV0
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
public static function DIV0()
|
||||
{
|
||||
return self::$errorCodes['divisionbyzero'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NA
|
||||
*
|
||||
* Excel Function:
|
||||
* =NA()
|
||||
*
|
||||
* Returns the error value #N/A
|
||||
* #N/A is the error value that means "no value is available."
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return string #N/A!
|
||||
*/
|
||||
public static function NA()
|
||||
{
|
||||
return self::$errorCodes['na'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NaN
|
||||
*
|
||||
* Returns the error value #NUM!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NUM!
|
||||
*/
|
||||
public static function NaN()
|
||||
{
|
||||
return self::$errorCodes['num'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NAME
|
||||
*
|
||||
* Returns the error value #NAME?
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NAME?
|
||||
*/
|
||||
public static function NAME()
|
||||
{
|
||||
return self::$errorCodes['name'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* REF
|
||||
*
|
||||
* Returns the error value #REF!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #REF!
|
||||
*/
|
||||
public static function REF()
|
||||
{
|
||||
return self::$errorCodes['reference'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NULL
|
||||
*
|
||||
* Returns the error value #NULL!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #NULL!
|
||||
*/
|
||||
public static function NULL()
|
||||
{
|
||||
return self::$errorCodes['null'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VALUE
|
||||
*
|
||||
* Returns the error value #VALUE!
|
||||
*
|
||||
* @access public
|
||||
* @category Error Returns
|
||||
* @return string #VALUE!
|
||||
*/
|
||||
public static function VALUE()
|
||||
{
|
||||
return self::$errorCodes['value'];
|
||||
}
|
||||
|
||||
|
||||
public static function isMatrixValue($idx)
|
||||
{
|
||||
return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
|
||||
}
|
||||
|
||||
|
||||
public static function isValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') == 0);
|
||||
}
|
||||
|
||||
|
||||
public static function isCellValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') > 1);
|
||||
}
|
||||
|
||||
|
||||
public static function ifCondition($condition)
|
||||
{
|
||||
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
if (!isset($condition{0})) {
|
||||
$condition = '=""';
|
||||
}
|
||||
if (!in_array($condition{0}, array('>', '<', '='))) {
|
||||
if (!is_numeric($condition)) {
|
||||
$condition = PHPExcel_Calculation::wrapResult(strtoupper($condition));
|
||||
}
|
||||
return '=' . $condition;
|
||||
} else {
|
||||
preg_match('/([<>=]+)(.*)/', $condition, $matches);
|
||||
list(, $operator, $operand) = $matches;
|
||||
|
||||
if (!is_numeric($operand)) {
|
||||
$operand = str_replace('"', '""', $operand);
|
||||
$operand = PHPExcel_Calculation::wrapResult(strtoupper($operand));
|
||||
}
|
||||
|
||||
return $operator.$operand;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ERROR_TYPE
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function ERROR_TYPE($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
$i = 1;
|
||||
foreach (self::$errorCodes as $errorCode) {
|
||||
if ($value === $errorCode) {
|
||||
return $i;
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
return self::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_BLANK
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_BLANK($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$value = self::flattenSingleValue($value);
|
||||
}
|
||||
|
||||
return is_null($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ERR
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ERR($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return self::IS_ERROR($value) && (!self::IS_NA($value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ERROR
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ERROR($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
return in_array($value, array_values(self::$errorCodes));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NA
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NA($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return ($value === self::NA());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_EVEN
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_EVEN($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if ($value === null) {
|
||||
return self::NAME();
|
||||
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
|
||||
return self::VALUE();
|
||||
}
|
||||
|
||||
return ($value % 2 == 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_ODD
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ODD($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if ($value === null) {
|
||||
return self::NAME();
|
||||
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
|
||||
return self::VALUE();
|
||||
}
|
||||
|
||||
return (abs($value) % 2 == 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NUMBER
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NUMBER($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
return is_numeric($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_LOGICAL
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_LOGICAL($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return is_bool($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_TEXT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_TEXT($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return (is_string($value) && !self::IS_ERROR($value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IS_NONTEXT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NONTEXT($value = null)
|
||||
{
|
||||
return !self::IS_TEXT($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VERSION
|
||||
*
|
||||
* @return string Version information
|
||||
*/
|
||||
public static function VERSION()
|
||||
{
|
||||
return 'PHPExcel ##VERSION##, ##DATE##';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* N
|
||||
*
|
||||
* Returns a value converted to a number
|
||||
*
|
||||
* @param value The value you want converted
|
||||
* @return number N converts values listed in the following table
|
||||
* If value is or refers to N returns
|
||||
* A number That number
|
||||
* A date The serial number of that date
|
||||
* TRUE 1
|
||||
* FALSE 0
|
||||
* An error value The error value
|
||||
* Anything else 0
|
||||
*/
|
||||
public static function N($value = null)
|
||||
{
|
||||
while (is_array($value)) {
|
||||
$value = array_shift($value);
|
||||
}
|
||||
|
||||
switch (gettype($value)) {
|
||||
case 'double':
|
||||
case 'float':
|
||||
case 'integer':
|
||||
return $value;
|
||||
case 'boolean':
|
||||
return (integer) $value;
|
||||
case 'string':
|
||||
// Errors
|
||||
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
||||
return $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TYPE
|
||||
*
|
||||
* Returns a number that identifies the type of a value
|
||||
*
|
||||
* @param value The value you want tested
|
||||
* @return number N converts values listed in the following table
|
||||
* If value is or refers to N returns
|
||||
* A number 1
|
||||
* Text 2
|
||||
* Logical Value 4
|
||||
* An error value 16
|
||||
* Array or Matrix 64
|
||||
*/
|
||||
public static function TYPE($value = null)
|
||||
{
|
||||
$value = self::flattenArrayIndexed($value);
|
||||
if (is_array($value) && (count($value) > 1)) {
|
||||
end($value);
|
||||
$a = key($value);
|
||||
// Range of cells is an error
|
||||
if (self::isCellValue($a)) {
|
||||
return 16;
|
||||
// Test for Matrix
|
||||
} elseif (self::isMatrixValue($a)) {
|
||||
return 64;
|
||||
}
|
||||
} elseif (empty($value)) {
|
||||
// Empty Cell
|
||||
return 1;
|
||||
}
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (($value === null) || (is_float($value)) || (is_int($value))) {
|
||||
return 1;
|
||||
} elseif (is_bool($value)) {
|
||||
return 4;
|
||||
} elseif (is_array($value)) {
|
||||
return 64;
|
||||
} elseif (is_string($value)) {
|
||||
// Errors
|
||||
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
||||
return 16;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a multi-dimensional array to a simple 1-dimensional array
|
||||
*
|
||||
* @param array $array Array to be flattened
|
||||
* @return array Flattened array
|
||||
*/
|
||||
public static function flattenArray($array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return (array) $array;
|
||||
}
|
||||
|
||||
$arrayValues = array();
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $val) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $v) {
|
||||
$arrayValues[] = $v;
|
||||
}
|
||||
} else {
|
||||
$arrayValues[] = $val;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$arrayValues[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $arrayValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
|
||||
*
|
||||
* @param array $array Array to be flattened
|
||||
* @return array Flattened array
|
||||
*/
|
||||
public static function flattenArrayIndexed($array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return (array) $array;
|
||||
}
|
||||
|
||||
$arrayValues = array();
|
||||
foreach ($array as $k1 => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k2 => $val) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k3 => $v) {
|
||||
$arrayValues[$k1.'.'.$k2.'.'.$k3] = $v;
|
||||
}
|
||||
} else {
|
||||
$arrayValues[$k1.'.'.$k2] = $val;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$arrayValues[$k1] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $arrayValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array to a single scalar value by extracting the first element
|
||||
*
|
||||
* @param mixed $value Array or scalar value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function flattenSingleValue($value = '')
|
||||
{
|
||||
while (is_array($value)) {
|
||||
$value = array_pop($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// There are a few mathematical functions that aren't available on all versions of PHP for all platforms
|
||||
// These functions aren't available in Windows implementations of PHP prior to version 5.3.0
|
||||
// So we test if they do exist for this version of PHP/operating platform; and if not we create them
|
||||
//
|
||||
if (!function_exists('acosh')) {
|
||||
function acosh($x)
|
||||
{
|
||||
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
|
||||
} // function acosh()
|
||||
}
|
||||
|
||||
if (!function_exists('asinh')) {
|
||||
function asinh($x)
|
||||
{
|
||||
return log($x + sqrt(1 + $x * $x));
|
||||
} // function asinh()
|
||||
}
|
||||
|
||||
if (!function_exists('atanh')) {
|
||||
function atanh($x)
|
||||
{
|
||||
return (log(1 + $x) - log(1 - $x)) / 2;
|
||||
} // function atanh()
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Strangely, PHP doesn't have a mb_str_replace multibyte function
|
||||
// As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set
|
||||
//
|
||||
if ((!function_exists('mb_str_replace')) &&
|
||||
(function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
|
||||
function mb_str_replace($search, $replace, $subject)
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
$ret = array();
|
||||
foreach ($subject as $key => $val) {
|
||||
$ret[$key] = mb_str_replace($search, $replace, $val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
foreach ((array) $search as $key => $s) {
|
||||
if ($s == '' && $s !== 0) {
|
||||
continue;
|
||||
}
|
||||
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
|
||||
$pos = mb_strpos($subject, $s, 0, 'UTF-8');
|
||||
while ($pos !== false) {
|
||||
$subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
|
||||
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
|
||||
}
|
||||
}
|
||||
return $subject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Logical
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Logical
|
||||
{
|
||||
/**
|
||||
* TRUE
|
||||
*
|
||||
* Returns the boolean TRUE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =TRUE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean True
|
||||
*/
|
||||
public static function TRUE()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FALSE
|
||||
*
|
||||
* Returns the boolean FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =FALSE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean False
|
||||
*/
|
||||
public static function FALSE()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_AND
|
||||
*
|
||||
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =AND(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical AND of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_AND()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = true;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue && $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = true;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_OR
|
||||
*
|
||||
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =OR(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical OR of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_OR()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = false;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue || $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = true;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NOT
|
||||
*
|
||||
* Returns the boolean inverse of the argument.
|
||||
*
|
||||
* Excel Function:
|
||||
* =NOT(logical)
|
||||
*
|
||||
* The argument must evaluate to a logical value such as TRUE or FALSE
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||
* @return boolean The boolean inverse of the argument.
|
||||
*/
|
||||
public static function NOT($logical = false)
|
||||
{
|
||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||
if (is_string($logical)) {
|
||||
$logical = strtoupper($logical);
|
||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||
return false;
|
||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||
return true;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
return !$logical;
|
||||
}
|
||||
|
||||
/**
|
||||
* STATEMENT_IF
|
||||
*
|
||||
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =IF(condition[,returnIfTrue[,returnIfFalse]])
|
||||
*
|
||||
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
|
||||
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
|
||||
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
|
||||
* This argument can use any comparison calculation operator.
|
||||
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
|
||||
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
|
||||
* then the IF function returns the text "Within budget"
|
||||
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
|
||||
* the logical value TRUE for this argument.
|
||||
* ReturnIfTrue can be another formula.
|
||||
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
|
||||
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
|
||||
* then the IF function returns the text "Over budget".
|
||||
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
|
||||
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
|
||||
* ReturnIfFalse can be another formula.
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $condition Condition to evaluate
|
||||
* @param mixed $returnIfTrue Value to return when condition is true
|
||||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||
*/
|
||||
public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
|
||||
{
|
||||
$condition = (is_null($condition)) ? true : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? false : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||
|
||||
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* IFERROR
|
||||
*
|
||||
* Excel Function:
|
||||
* =IFERROR(testValue,errorpart)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $testValue Value to check, is also the value returned when no error
|
||||
* @param mixed $errorpart Value to return when testValue is an error condition
|
||||
* @return mixed The value of errorpart or testValue determined by error condition
|
||||
*/
|
||||
public static function IFERROR($testValue = '', $errorpart = '')
|
||||
{
|
||||
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
|
||||
|
||||
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_LookupRef
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_LookupRef
|
||||
{
|
||||
/**
|
||||
* CELL_ADDRESS
|
||||
*
|
||||
* Creates a cell address as text, given specified row and column numbers.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText])
|
||||
*
|
||||
* @param row Row number to use in the cell reference
|
||||
* @param column Column number to use in the cell reference
|
||||
* @param relativity Flag indicating the type of reference to return
|
||||
* 1 or omitted Absolute
|
||||
* 2 Absolute row; relative column
|
||||
* 3 Relative row; absolute column
|
||||
* 4 Relative
|
||||
* @param referenceStyle A logical value that specifies the A1 or R1C1 reference style.
|
||||
* TRUE or omitted CELL_ADDRESS returns an A1-style reference
|
||||
* FALSE CELL_ADDRESS returns an R1C1-style reference
|
||||
* @param sheetText Optional Name of worksheet to use
|
||||
* @return string
|
||||
*/
|
||||
public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '')
|
||||
{
|
||||
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
|
||||
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column);
|
||||
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity);
|
||||
$sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText);
|
||||
|
||||
if (($row < 1) || ($column < 1)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if ($sheetText > '') {
|
||||
if (strpos($sheetText, ' ') !== false) {
|
||||
$sheetText = "'".$sheetText."'";
|
||||
}
|
||||
$sheetText .='!';
|
||||
}
|
||||
if ((!is_bool($referenceStyle)) || $referenceStyle) {
|
||||
$rowRelative = $columnRelative = '$';
|
||||
$column = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
if (($relativity == 2) || ($relativity == 4)) {
|
||||
$columnRelative = '';
|
||||
}
|
||||
if (($relativity == 3) || ($relativity == 4)) {
|
||||
$rowRelative = '';
|
||||
}
|
||||
return $sheetText.$columnRelative.$column.$rowRelative.$row;
|
||||
} else {
|
||||
if (($relativity == 2) || ($relativity == 4)) {
|
||||
$column = '['.$column.']';
|
||||
}
|
||||
if (($relativity == 3) || ($relativity == 4)) {
|
||||
$row = '['.$row.']';
|
||||
}
|
||||
return $sheetText.'R'.$row.'C'.$column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COLUMN
|
||||
*
|
||||
* Returns the column number of the given cell reference
|
||||
* If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
|
||||
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
|
||||
* reference of the cell in which the COLUMN function appears; otherwise this function returns 0.
|
||||
*
|
||||
* Excel Function:
|
||||
* =COLUMN([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the column numbers
|
||||
* @return integer or array of integer
|
||||
*/
|
||||
public static function COLUMN($cellAddress = null)
|
||||
{
|
||||
if (is_null($cellAddress) || trim($cellAddress) === '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_array($cellAddress)) {
|
||||
foreach ($cellAddress as $columnKey => $value) {
|
||||
$columnKey = preg_replace('/[^a-z]/i', '', $columnKey);
|
||||
return (integer) PHPExcel_Cell::columnIndexFromString($columnKey);
|
||||
}
|
||||
} else {
|
||||
if (strpos($cellAddress, '!') !== false) {
|
||||
list($sheet, $cellAddress) = explode('!', $cellAddress);
|
||||
}
|
||||
if (strpos($cellAddress, ':') !== false) {
|
||||
list($startAddress, $endAddress) = explode(':', $cellAddress);
|
||||
$startAddress = preg_replace('/[^a-z]/i', '', $startAddress);
|
||||
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
|
||||
$returnValue = array();
|
||||
do {
|
||||
$returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress);
|
||||
} while ($startAddress++ != $endAddress);
|
||||
return $returnValue;
|
||||
} else {
|
||||
$cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress);
|
||||
return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* COLUMNS
|
||||
*
|
||||
* Returns the number of columns in an array or reference.
|
||||
*
|
||||
* Excel Function:
|
||||
* =COLUMNS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
|
||||
* @return integer The number of columns in cellAddress
|
||||
*/
|
||||
public static function COLUMNS($cellAddress = null)
|
||||
{
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
reset($cellAddress);
|
||||
$isMatrix = (is_numeric(key($cellAddress)));
|
||||
list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
return $rows;
|
||||
} else {
|
||||
return $columns;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROW
|
||||
*
|
||||
* Returns the row number of the given cell reference
|
||||
* If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
|
||||
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
|
||||
* reference of the cell in which the ROW function appears; otherwise this function returns 0.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ROW([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the row numbers
|
||||
* @return integer or array of integer
|
||||
*/
|
||||
public static function ROW($cellAddress = null)
|
||||
{
|
||||
if (is_null($cellAddress) || trim($cellAddress) === '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_array($cellAddress)) {
|
||||
foreach ($cellAddress as $columnKey => $rowValue) {
|
||||
foreach ($rowValue as $rowKey => $cellValue) {
|
||||
return (integer) preg_replace('/[^0-9]/i', '', $rowKey);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (strpos($cellAddress, '!') !== false) {
|
||||
list($sheet, $cellAddress) = explode('!', $cellAddress);
|
||||
}
|
||||
if (strpos($cellAddress, ':') !== false) {
|
||||
list($startAddress, $endAddress) = explode(':', $cellAddress);
|
||||
$startAddress = preg_replace('/[^0-9]/', '', $startAddress);
|
||||
$endAddress = preg_replace('/[^0-9]/', '', $endAddress);
|
||||
$returnValue = array();
|
||||
do {
|
||||
$returnValue[][] = (integer) $startAddress;
|
||||
} while ($startAddress++ != $endAddress);
|
||||
return $returnValue;
|
||||
} else {
|
||||
list($cellAddress) = explode(':', $cellAddress);
|
||||
return (integer) preg_replace('/[^0-9]/', '', $cellAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROWS
|
||||
*
|
||||
* Returns the number of rows in an array or reference.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ROWS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
|
||||
* @return integer The number of rows in cellAddress
|
||||
*/
|
||||
public static function ROWS($cellAddress = null)
|
||||
{
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
reset($cellAddress);
|
||||
$isMatrix = (is_numeric(key($cellAddress)));
|
||||
list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
return $columns;
|
||||
} else {
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HYPERLINK
|
||||
*
|
||||
* Excel Function:
|
||||
* =HYPERLINK(linkURL,displayName)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param string $linkURL Value to check, is also the value returned when no error
|
||||
* @param string $displayName Value to return when testValue is an error condition
|
||||
* @param PHPExcel_Cell $pCell The cell to set the hyperlink in
|
||||
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
|
||||
*/
|
||||
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
|
||||
$linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL);
|
||||
$displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName);
|
||||
|
||||
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
if ((is_object($displayName)) || trim($displayName) == '') {
|
||||
$displayName = $linkURL;
|
||||
}
|
||||
|
||||
$pCell->getHyperlink()->setUrl($linkURL);
|
||||
$pCell->getHyperlink()->setTooltip($displayName);
|
||||
|
||||
return $displayName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INDIRECT
|
||||
*
|
||||
* Returns the reference specified by a text string.
|
||||
* References are immediately evaluated to display their contents.
|
||||
*
|
||||
* Excel Function:
|
||||
* =INDIRECT(cellAddress)
|
||||
*
|
||||
* NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
|
||||
*
|
||||
* @param cellAddress $cellAddress The cell address of the current cell (containing this formula)
|
||||
* @param PHPExcel_Cell $pCell The current cell (containing this formula)
|
||||
* @return mixed The cells referenced by cellAddress
|
||||
*
|
||||
* @todo Support for the optional a1 parameter introduced in Excel 2010
|
||||
*
|
||||
*/
|
||||
public static function INDIRECT($cellAddress = null, PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$cellAddress1 = $cellAddress;
|
||||
$cellAddress2 = null;
|
||||
if (strpos($cellAddress, ':') !== false) {
|
||||
list($cellAddress1, $cellAddress2) = explode(':', $cellAddress);
|
||||
}
|
||||
|
||||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
|
||||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
|
||||
if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
if (strpos($cellAddress, '!') !== false) {
|
||||
list($sheetName, $cellAddress) = explode('!', $cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, false);
|
||||
}
|
||||
|
||||
if (strpos($cellAddress, '!') !== false) {
|
||||
list($sheetName, $cellAddress) = explode('!', $cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* OFFSET
|
||||
*
|
||||
* Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
|
||||
* The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
|
||||
* the number of columns to be returned.
|
||||
*
|
||||
* Excel Function:
|
||||
* =OFFSET(cellAddress, rows, cols, [height], [width])
|
||||
*
|
||||
* @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or
|
||||
* range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value.
|
||||
* @param rows The number of rows, up or down, that you want the upper-left cell to refer to.
|
||||
* Using 5 as the rows argument specifies that the upper-left cell in the reference is
|
||||
* five rows below reference. Rows can be positive (which means below the starting reference)
|
||||
* or negative (which means above the starting reference).
|
||||
* @param cols The number of columns, to the left or right, that you want the upper-left cell of the result
|
||||
* to refer to. Using 5 as the cols argument specifies that the upper-left cell in the
|
||||
* reference is five columns to the right of reference. Cols can be positive (which means
|
||||
* to the right of the starting reference) or negative (which means to the left of the
|
||||
* starting reference).
|
||||
* @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
|
||||
* @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
|
||||
* @return string A reference to a cell or range of cells
|
||||
*/
|
||||
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null)
|
||||
{
|
||||
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
|
||||
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns);
|
||||
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height);
|
||||
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width);
|
||||
if ($cellAddress == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
if (!is_object($pCell)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$sheetName = null;
|
||||
if (strpos($cellAddress, "!")) {
|
||||
list($sheetName, $cellAddress) = explode("!", $cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
}
|
||||
if (strpos($cellAddress, ":")) {
|
||||
list($startCell, $endCell) = explode(":", $cellAddress);
|
||||
} else {
|
||||
$startCell = $endCell = $cellAddress;
|
||||
}
|
||||
list($startCellColumn, $startCellRow) = PHPExcel_Cell::coordinateFromString($startCell);
|
||||
list($endCellColumn, $endCellRow) = PHPExcel_Cell::coordinateFromString($endCell);
|
||||
|
||||
$startCellRow += $rows;
|
||||
$startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1;
|
||||
$startCellColumn += $columns;
|
||||
|
||||
if (($startCellRow <= 0) || ($startCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1;
|
||||
if (($width != null) && (!is_object($width))) {
|
||||
$endCellColumn = $startCellColumn + $width - 1;
|
||||
} else {
|
||||
$endCellColumn += $columns;
|
||||
}
|
||||
$startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn);
|
||||
|
||||
if (($height != null) && (!is_object($height))) {
|
||||
$endCellRow = $startCellRow + $height - 1;
|
||||
} else {
|
||||
$endCellRow += $rows;
|
||||
}
|
||||
|
||||
if (($endCellRow <= 0) || ($endCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::stringFromColumnIndex($endCellColumn);
|
||||
|
||||
$cellAddress = $startCellColumn.$startCellRow;
|
||||
if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) {
|
||||
$cellAddress .= ':'.$endCellColumn.$endCellRow;
|
||||
}
|
||||
|
||||
if ($sheetName !== null) {
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CHOOSE
|
||||
*
|
||||
* Uses lookup_value to return a value from the list of value arguments.
|
||||
* Use CHOOSE to select one of up to 254 values based on the lookup_value.
|
||||
*
|
||||
* Excel Function:
|
||||
* =CHOOSE(index_num, value1, [value2], ...)
|
||||
*
|
||||
* @param index_num Specifies which value argument is selected.
|
||||
* Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number
|
||||
* between 1 and 254.
|
||||
* @param value1... Value1 is required, subsequent values are optional.
|
||||
* Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on
|
||||
* index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or
|
||||
* text.
|
||||
* @return mixed The selected value
|
||||
*/
|
||||
public static function CHOOSE()
|
||||
{
|
||||
$chooseArgs = func_get_args();
|
||||
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
|
||||
$entryCount = count($chooseArgs) - 1;
|
||||
|
||||
if (is_array($chosenEntry)) {
|
||||
$chosenEntry = array_shift($chosenEntry);
|
||||
}
|
||||
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
|
||||
--$chosenEntry;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$chosenEntry = floor($chosenEntry);
|
||||
if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_array($chooseArgs[$chosenEntry])) {
|
||||
return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
|
||||
} else {
|
||||
return $chooseArgs[$chosenEntry];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MATCH
|
||||
*
|
||||
* The MATCH function searches for a specified item in a range of cells
|
||||
*
|
||||
* Excel Function:
|
||||
* =MATCH(lookup_value, lookup_array, [match_type])
|
||||
*
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
|
||||
* @return integer The relative position of the found item
|
||||
*/
|
||||
public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
|
||||
{
|
||||
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type);
|
||||
// MATCH is not case sensitive
|
||||
$lookup_value = strtolower($lookup_value);
|
||||
|
||||
// lookup_value type has to be number, text, or logical values
|
||||
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// match_type is 0, 1 or -1
|
||||
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should not be empty
|
||||
$lookupArraySize = count($lookup_array);
|
||||
if ($lookupArraySize <= 0) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
foreach ($lookup_array as $i => $lookupArrayValue) {
|
||||
// check the type of the value
|
||||
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
// convert strings to lowercase for case-insensitive testing
|
||||
if (is_string($lookupArrayValue)) {
|
||||
$lookup_array[$i] = strtolower($lookupArrayValue);
|
||||
}
|
||||
if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) {
|
||||
$lookup_array = array_slice($lookup_array, 0, $i-1);
|
||||
}
|
||||
}
|
||||
|
||||
// if match_type is 1 or -1, the list has to be ordered
|
||||
if ($match_type == 1) {
|
||||
asort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
} elseif ($match_type == -1) {
|
||||
arsort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
}
|
||||
|
||||
// **
|
||||
// find the match
|
||||
// **
|
||||
foreach ($lookup_array as $i => $lookupArrayValue) {
|
||||
if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) {
|
||||
// exact match
|
||||
return ++$i;
|
||||
} elseif (($match_type == -1) && ($lookupArrayValue <= $lookup_value)) {
|
||||
$i = array_search($i, $keySet);
|
||||
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
|
||||
if ($i < 1) {
|
||||
// 1st cell was already smaller than the lookup_value
|
||||
break;
|
||||
} else {
|
||||
// the previous cell was the match
|
||||
return $keySet[$i-1]+1;
|
||||
}
|
||||
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
|
||||
$i = array_search($i, $keySet);
|
||||
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
|
||||
if ($i < 1) {
|
||||
// 1st cell was already bigger than the lookup_value
|
||||
break;
|
||||
} else {
|
||||
// the previous cell was the match
|
||||
return $keySet[$i-1]+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unsuccessful in finding a match, return #N/A error value
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INDEX
|
||||
*
|
||||
* Uses an index to choose a value from a reference or array
|
||||
*
|
||||
* Excel Function:
|
||||
* =INDEX(range_array, row_num, [column_num])
|
||||
*
|
||||
* @param range_array A range of cells or an array constant
|
||||
* @param row_num The row in array from which to return a value. If row_num is omitted, column_num is required.
|
||||
* @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required.
|
||||
* @return mixed the value of a specified cell or array of cells
|
||||
*/
|
||||
public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0)
|
||||
{
|
||||
if (($rowNum < 0) || ($columnNum < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (!is_array($arrayValues)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$rowKeys = array_keys($arrayValues);
|
||||
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
|
||||
|
||||
if ($columnNum > count($columnKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($columnNum == 0) {
|
||||
if ($rowNum == 0) {
|
||||
return $arrayValues;
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
$returnArray = array();
|
||||
foreach ($arrayValues as $arrayColumn) {
|
||||
if (is_array($arrayColumn)) {
|
||||
if (isset($arrayColumn[$rowNum])) {
|
||||
$returnArray[] = $arrayColumn[$rowNum];
|
||||
} else {
|
||||
return $arrayValues[$rowNum];
|
||||
}
|
||||
} else {
|
||||
return $arrayValues[$rowNum];
|
||||
}
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
$columnNum = $columnKeys[--$columnNum];
|
||||
if ($rowNum > count($rowKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($rowNum == 0) {
|
||||
return $arrayValues[$columnNum];
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
|
||||
return $arrayValues[$rowNum][$columnNum];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRANSPOSE
|
||||
*
|
||||
* @param array $matrixData A matrix of values
|
||||
* @return array
|
||||
*
|
||||
* Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix.
|
||||
*/
|
||||
public static function TRANSPOSE($matrixData)
|
||||
{
|
||||
$returnMatrix = array();
|
||||
if (!is_array($matrixData)) {
|
||||
$matrixData = array(array($matrixData));
|
||||
}
|
||||
|
||||
$column = 0;
|
||||
foreach ($matrixData as $matrixRow) {
|
||||
$row = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
$returnMatrix[$row][$column] = $matrixCell;
|
||||
++$row;
|
||||
}
|
||||
++$column;
|
||||
}
|
||||
return $returnMatrix;
|
||||
}
|
||||
|
||||
|
||||
private static function vlookupSort($a, $b)
|
||||
{
|
||||
reset($a);
|
||||
$firstColumn = key($a);
|
||||
if (($aLower = strtolower($a[$firstColumn])) == ($bLower = strtolower($b[$firstColumn]))) {
|
||||
return 0;
|
||||
}
|
||||
return ($aLower < $bLower) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* VLOOKUP
|
||||
* The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param index_number The column number in table_array from which the matching value must be returned. The first column is 1.
|
||||
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
|
||||
* @return mixed The value of the found cell
|
||||
*/
|
||||
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
|
||||
|
||||
// index_number must be greater than or equal to 1
|
||||
if ($index_number < 1) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
// index_number must be less than or equal to the number of columns in lookup_array
|
||||
if ((!is_array($lookup_array)) || (empty($lookup_array))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$columnKeys = array_keys($lookup_array[$firstRow]);
|
||||
$returnColumn = $columnKeys[--$index_number];
|
||||
$firstColumn = array_shift($columnKeys);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$not_exact_match) {
|
||||
uasort($lookup_array, array('self', 'vlookupSort'));
|
||||
}
|
||||
|
||||
$rowNumber = $rowValue = false;
|
||||
foreach ($lookup_array as $rowKey => $rowData) {
|
||||
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)))) {
|
||||
break;
|
||||
}
|
||||
$rowNumber = $rowKey;
|
||||
$rowValue = $rowData[$firstColumn];
|
||||
}
|
||||
|
||||
if ($rowNumber !== false) {
|
||||
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
|
||||
// if an exact match is required, we have what we need to return an appropriate response
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
} else {
|
||||
// otherwise return the appropriate value
|
||||
return $lookup_array[$rowNumber][$returnColumn];
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HLOOKUP
|
||||
* The HLOOKUP function searches for value in the top-most row of lookup_array and returns the value in the same column based on the index_number.
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param index_number The row number in table_array from which the matching value must be returned. The first row is 1.
|
||||
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
|
||||
* @return mixed The value of the found cell
|
||||
*/
|
||||
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
|
||||
|
||||
// index_number must be greater than or equal to 1
|
||||
if ($index_number < 1) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
// index_number must be less than or equal to the number of columns in lookup_array
|
||||
if ((!is_array($lookup_array)) || (empty($lookup_array))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$columnKeys = array_keys($lookup_array[$firstRow]);
|
||||
$firstkey = $f[0] - 1;
|
||||
$returnColumn = $firstkey + $index_number;
|
||||
$firstColumn = array_shift($f);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$not_exact_match) {
|
||||
$firstRowH = asort($lookup_array[$firstColumn]);
|
||||
}
|
||||
|
||||
$rowNumber = $rowValue = false;
|
||||
foreach ($lookup_array[$firstColumn] as $rowKey => $rowData) {
|
||||
if ((is_numeric($lookup_value) && is_numeric($rowData) && ($rowData > $lookup_value)) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData) && (strtolower($rowData) > strtolower($lookup_value)))) {
|
||||
break;
|
||||
}
|
||||
$rowNumber = $rowKey;
|
||||
$rowValue = $rowData;
|
||||
}
|
||||
|
||||
if ($rowNumber !== false) {
|
||||
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
|
||||
// if an exact match is required, we have what we need to return an appropriate response
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
} else {
|
||||
// otherwise return the appropriate value
|
||||
return $lookup_array[$returnColumn][$rowNumber];
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LOOKUP
|
||||
* The LOOKUP function searches for value either from a one-row or one-column range or from an array.
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_vector The range of cells being searched
|
||||
* @param result_vector The column from which the matching value must be returned
|
||||
* @return mixed The value of the found cell
|
||||
*/
|
||||
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
|
||||
if (!is_array($lookup_vector)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
$lookupRows = count($lookup_vector);
|
||||
$l = array_keys($lookup_vector);
|
||||
$l = array_shift($l);
|
||||
$lookupColumns = count($lookup_vector[$l]);
|
||||
if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) {
|
||||
$lookup_vector = self::TRANSPOSE($lookup_vector);
|
||||
$lookupRows = count($lookup_vector);
|
||||
$l = array_keys($lookup_vector);
|
||||
$lookupColumns = count($lookup_vector[array_shift($l)]);
|
||||
}
|
||||
|
||||
if (is_null($result_vector)) {
|
||||
$result_vector = $lookup_vector;
|
||||
}
|
||||
$resultRows = count($result_vector);
|
||||
$l = array_keys($result_vector);
|
||||
$l = array_shift($l);
|
||||
$resultColumns = count($result_vector[$l]);
|
||||
if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) {
|
||||
$result_vector = self::TRANSPOSE($result_vector);
|
||||
$resultRows = count($result_vector);
|
||||
$r = array_keys($result_vector);
|
||||
$resultColumns = count($result_vector[array_shift($r)]);
|
||||
}
|
||||
|
||||
if ($lookupRows == 2) {
|
||||
$result_vector = array_pop($lookup_vector);
|
||||
$lookup_vector = array_shift($lookup_vector);
|
||||
}
|
||||
if ($lookupColumns != 2) {
|
||||
foreach ($lookup_vector as &$value) {
|
||||
if (is_array($value)) {
|
||||
$k = array_keys($value);
|
||||
$key1 = $key2 = array_shift($k);
|
||||
$key2++;
|
||||
$dataValue1 = $value[$key1];
|
||||
} else {
|
||||
$key1 = 0;
|
||||
$key2 = 1;
|
||||
$dataValue1 = $value;
|
||||
}
|
||||
$dataValue2 = array_shift($result_vector);
|
||||
if (is_array($dataValue2)) {
|
||||
$dataValue2 = array_shift($dataValue2);
|
||||
}
|
||||
$value = array($key1 => $dataValue1, $key2 => $dataValue2);
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
return self::VLOOKUP($lookup_value, $lookup_vector, 2);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user