| - Nieuw wachtwoord DBOIS De Beleidsonderzoekers - | -||||||||
-
|
-
diff --git a/app/Commands/Down.php b/app/Commands/Down.php new file mode 100644 index 0000000..0573ce9 --- /dev/null +++ b/app/Commands/Down.php @@ -0,0 +1,60 @@ + 'IP address(es) to whitelist (comma-separated or use multiple --allow)', + '--message' => 'Custom message for the maintenance page', + ]; + + public function run(array $params) + { + $allowedIps = []; + + // Get allowed IPs from command line + if (CLI::getOption('allow')) { + $allow = CLI::getOption('allow'); + if (is_array($allow)) { + foreach ($allow as $ip) { + $allowedIps = array_merge($allowedIps, array_map('trim', explode(',', $ip))); + } + } else { + $allowedIps = array_map('trim', explode(',', $allow)); + } + } + + // Get custom message + $message = CLI::getOption('message') ?: ''; + + // Create maintenance data + $data = [ + 'time' => date('Y-m-d H:i:s'), + 'allowed' => array_values(array_filter($allowedIps)), + 'message' => $message, + ]; + + $filePath = WRITEPATH . 'down'; + + if (file_put_contents($filePath, json_encode($data, JSON_PRETTY_PRINT))) { + CLI::write('Application is now in maintenance mode.', 'yellow'); + + if (! empty($allowedIps)) { + CLI::write('Whitelisted IPs: ' . implode(', ', $allowedIps), 'green'); + } + } else { + CLI::error('Failed to enable maintenance mode. Check writable directory permissions.'); + return 1; + } + + return 0; + } +} diff --git a/app/Commands/Up.php b/app/Commands/Up.php new file mode 100644 index 0000000..bfbf805 --- /dev/null +++ b/app/Commands/Up.php @@ -0,0 +1,33 @@ + + +
+ + ++ Vragen? Neem contact op via info@pensare.nl +
+Directory access is forbidden.
- - - diff --git a/application/config/autoload.php b/application/config/autoload.php deleted file mode 100755 index 8a7a9e0..0000000 --- a/application/config/autoload.php +++ /dev/null @@ -1,135 +0,0 @@ - 'ua'); -*/ -$autoload['libraries'] = array('database', 'session'); - -/* -| ------------------------------------------------------------------- -| Auto-load Drivers -| ------------------------------------------------------------------- -| These classes are located in system/libraries/ or in your -| application/libraries/ directory, but are also placed inside their -| own subdirectory and they extend the CI_Driver_Library class. They -| offer multiple interchangeable driver options. -| -| Prototype: -| -| $autoload['drivers'] = array('cache'); -| -| You can also supply an alternative property name to be assigned in -| the controller: -| -| $autoload['drivers'] = array('cache' => 'cch'); -| -*/ -$autoload['drivers'] = array(); - -/* -| ------------------------------------------------------------------- -| Auto-load Helper Files -| ------------------------------------------------------------------- -| Prototype: -| -| $autoload['helper'] = array('url', 'file'); -*/ -$autoload['helper'] = array('common'); - -/* -| ------------------------------------------------------------------- -| Auto-load Config files -| ------------------------------------------------------------------- -| Prototype: -| -| $autoload['config'] = array('config1', 'config2'); -| -| NOTE: This item is intended for use ONLY if you have created custom -| config files. Otherwise, leave it blank. -| -*/ -$autoload['config'] = array(); - -/* -| ------------------------------------------------------------------- -| Auto-load Language files -| ------------------------------------------------------------------- -| Prototype: -| -| $autoload['language'] = array('lang1', 'lang2'); -| -| NOTE: Do not include the "_lang" part of your file. For example -| "codeigniter_lang.php" would be referenced as array('codeigniter'); -| -*/ -$autoload['language'] = array(); - -/* -| ------------------------------------------------------------------- -| Auto-load Models -| ------------------------------------------------------------------- -| Prototype: -| -| $autoload['model'] = array('first_model', 'second_model'); -| -| You can also supply an alternative model name to be assigned -| in the controller: -| -| $autoload['model'] = array('first_model' => 'first'); -*/ -$autoload['model'] = ['beheer/User_model', ]; diff --git a/application/config/config.php b/application/config/config.php deleted file mode 100755 index 08c1f49..0000000 --- a/application/config/config.php +++ /dev/null @@ -1,523 +0,0 @@ -]+$/i -| -| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!! -| -*/ -$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; - -/* -|-------------------------------------------------------------------------- -| Enable Query Strings -|-------------------------------------------------------------------------- -| -| By default CodeIgniter uses search-engine friendly segment based URLs: -| example.com/who/what/where/ -| -| You can optionally enable standard query string based URLs: -| example.com?who=me&what=something&where=here -| -| Options are: TRUE or FALSE (boolean) -| -| The other items let you set the query string 'words' that will -| invoke your controllers and its functions: -| example.com/index.php?c=controller&m=function -| -| Please note that some of the helpers won't work as expected when -| this feature is enabled, since CodeIgniter is designed primarily to -| use segment based URLs. -| -*/ -$config['enable_query_strings'] = FALSE; -$config['controller_trigger'] = 'c'; -$config['function_trigger'] = 'm'; -$config['directory_trigger'] = 'd'; - -/* -|-------------------------------------------------------------------------- -| Allow $_GET array -|-------------------------------------------------------------------------- -| -| By default CodeIgniter enables access to the $_GET array. If for some -| reason you would like to disable it, set 'allow_get_array' to FALSE. -| -| WARNING: This feature is DEPRECATED and currently available only -| for backwards compatibility purposes! -| -*/ -$config['allow_get_array'] = TRUE; - -/* -|-------------------------------------------------------------------------- -| Error Logging Threshold -|-------------------------------------------------------------------------- -| -| You can enable error logging by setting a threshold over zero. The -| threshold determines what gets logged. Threshold options are: -| -| 0 = Disables logging, Error logging TURNED OFF -| 1 = Error Messages (including PHP errors) -| 2 = Debug Messages -| 3 = Informational Messages -| 4 = All Messages -| -| You can also pass an array with threshold levels to show individual error types -| -| array(2) = Debug Messages, without Error Messages -| -| For a live site you'll usually only enable Errors (1) to be logged otherwise -| your log files will fill up very fast. -| -*/ -$config['log_threshold'] = 1; - -/* -|-------------------------------------------------------------------------- -| Error Logging Directory Path -|-------------------------------------------------------------------------- -| -| Leave this BLANK unless you would like to set something other than the default -| application/logs/ directory. Use a full server path with trailing slash. -| -*/ -$config['log_path'] = ''; - -/* -|-------------------------------------------------------------------------- -| Log File Extension -|-------------------------------------------------------------------------- -| -| The default filename extension for log files. The default 'php' allows for -| protecting the log files via basic scripting, when they are to be stored -| under a publicly accessible directory. -| -| Note: Leaving it blank will default to 'php'. -| -*/ -$config['log_file_extension'] = ''; - -/* -|-------------------------------------------------------------------------- -| Log File Permissions -|-------------------------------------------------------------------------- -| -| The file system permissions to be applied on newly created log files. -| -| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal -| integer notation (i.e. 0700, 0644, etc.) -*/ -$config['log_file_permissions'] = 0644; - -/* -|-------------------------------------------------------------------------- -| Date Format for Logs -|-------------------------------------------------------------------------- -| -| Each item that is logged has an associated date. You can use PHP date -| codes to set your own date formatting -| -*/ -$config['log_date_format'] = 'Y-m-d H:i:s'; - -/* -|-------------------------------------------------------------------------- -| Error Views Directory Path -|-------------------------------------------------------------------------- -| -| Leave this BLANK unless you would like to set something other than the default -| application/views/errors/ directory. Use a full server path with trailing slash. -| -*/ -$config['error_views_path'] = ''; - -/* -|-------------------------------------------------------------------------- -| Cache Directory Path -|-------------------------------------------------------------------------- -| -| Leave this BLANK unless you would like to set something other than the default -| application/cache/ directory. Use a full server path with trailing slash. -| -*/ -$config['cache_path'] = ''; - -/* -|-------------------------------------------------------------------------- -| Cache Include Query String -|-------------------------------------------------------------------------- -| -| Whether to take the URL query string into consideration when generating -| output cache files. Valid options are: -| -| FALSE = Disabled -| TRUE = Enabled, take all query parameters into account. -| Please be aware that this may result in numerous cache -| files generated for the same page over and over again. -| array('q') = Enabled, but only take into account the specified list -| of query parameters. -| -*/ -$config['cache_query_string'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Encryption Key -|-------------------------------------------------------------------------- -| -| If you use the Encryption class, you must set an encryption key. -| See the user guide for more info. -| -| https://codeigniter.com/user_guide/libraries/encryption.html -| -*/ -$config['encryption_key'] = ''; - -/* -|-------------------------------------------------------------------------- -| Session Variables -|-------------------------------------------------------------------------- -| -| 'sess_driver' -| -| The storage driver to use: files, database, redis, memcached -| -| 'sess_cookie_name' -| -| The session cookie name, must contain only [0-9a-z_-] characters -| -| 'sess_expiration' -| -| The number of SECONDS you want the session to last. -| Setting to 0 (zero) means expire when the browser is closed. -| -| 'sess_save_path' -| -| The location to save sessions to, driver dependent. -| -| For the 'files' driver, it's a path to a writable directory. -| WARNING: Only absolute paths are supported! -| -| For the 'database' driver, it's a table name. -| Please read up the manual for the format with other session drivers. -| -| IMPORTANT: You are REQUIRED to set a valid save path! -| -| 'sess_match_ip' -| -| Whether to match the user's IP address when reading the session data. -| -| WARNING: If you're using the database driver, don't forget to update -| your session table's PRIMARY KEY when changing this setting. -| -| 'sess_time_to_update' -| -| How many seconds between CI regenerating the session ID. -| -| 'sess_regenerate_destroy' -| -| Whether to destroy session data associated with the old session ID -| when auto-regenerating the session ID. When set to FALSE, the data -| will be later deleted by the garbage collector. -| -| Other session cookie settings are shared with the rest of the application, -| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here. -| -*/ -$config['sess_driver'] = 'database'; -$config['sess_cookie_name'] = 'ci_session'; -$config['sess_expiration'] = 7200; -$config['sess_save_path'] = 'ci_sessions'; -$config['sess_match_ip'] = FALSE; -$config['sess_time_to_update'] = 300; -$config['sess_regenerate_destroy'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Cookie Related Variables -|-------------------------------------------------------------------------- -| -| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions -| 'cookie_domain' = Set to .your-domain.com for site-wide cookies -| 'cookie_path' = Typically will be a forward slash -| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists. -| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript) -| -| Note: These settings (with the exception of 'cookie_prefix' and -| 'cookie_httponly') will also affect sessions. -| -*/ -$config['cookie_prefix'] = ''; -$config['cookie_domain'] = ''; -$config['cookie_path'] = '/'; -$config['cookie_secure'] = FALSE; -$config['cookie_httponly'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Standardize newlines -|-------------------------------------------------------------------------- -| -| Determines whether to standardize newline characters in input data, -| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value. -| -| WARNING: This feature is DEPRECATED and currently available only -| for backwards compatibility purposes! -| -*/ -$config['standardize_newlines'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Global XSS Filtering -|-------------------------------------------------------------------------- -| -| Determines whether the XSS filter is always active when GET, POST or -| COOKIE data is encountered -| -| WARNING: This feature is DEPRECATED and currently available only -| for backwards compatibility purposes! -| -*/ -$config['global_xss_filtering'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Cross Site Request Forgery -|-------------------------------------------------------------------------- -| Enables a CSRF cookie token to be set. When set to TRUE, token will be -| checked on a submitted form. If you are accepting user data, it is strongly -| recommended CSRF protection be enabled. -| -| 'csrf_token_name' = The token name -| 'csrf_cookie_name' = The cookie name -| 'csrf_expire' = The number in seconds the token should expire. -| 'csrf_regenerate' = Regenerate token on every submission -| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks -*/ -$config['csrf_protection'] = FALSE; -$config['csrf_token_name'] = 'csrf_test_name'; -$config['csrf_cookie_name'] = 'csrf_cookie_name'; -$config['csrf_expire'] = 7200; -$config['csrf_regenerate'] = TRUE; -$config['csrf_exclude_uris'] = []; - -/* -|-------------------------------------------------------------------------- -| Output Compression -|-------------------------------------------------------------------------- -| -| Enables Gzip output compression for faster page loads. When enabled, -| the output class will test whether your server supports Gzip. -| Even if it does, however, not all browsers support compression -| so enable only if you are reasonably sure your visitors can handle it. -| -| Only used if zlib.output_compression is turned off in your php.ini. -| Please do not use it together with httpd-level output compression. -| -| VERY IMPORTANT: If you are getting a blank page when compression is enabled it -| means you are prematurely outputting something to your browser. It could -| even be a line of whitespace at the end of one of your scripts. For -| compression to work, nothing can be sent before the output buffer is called -| by the output class. Do not 'echo' any values with compression enabled. -| -*/ -$config['compress_output'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Master Time Reference -|-------------------------------------------------------------------------- -| -| Options are 'local' or any PHP supported timezone. This preference tells -| the system whether to use your server's local time as the master 'now' -| reference, or convert it to the configured one timezone. See the 'date -| helper' page of the user guide for information regarding date handling. -| -*/ -$config['time_reference'] = 'local'; - -/* -|-------------------------------------------------------------------------- -| Rewrite PHP Short Tags -|-------------------------------------------------------------------------- -| -| If your PHP installation does not have short tag support enabled CI -| can rewrite the tags on-the-fly, enabling you to utilize that syntax -| in your view files. Options are TRUE or FALSE (boolean) -| -| Note: You need to have eval() enabled for this to work. -| -*/ -$config['rewrite_short_tags'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| Reverse Proxy IPs -|-------------------------------------------------------------------------- -| -| If your server is behind a reverse proxy, you must whitelist the proxy -| IP addresses from which CodeIgniter should trust headers such as -| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify -| the visitor's IP address. -| -| You can use both an array or a comma-separated list of proxy addresses, -| as well as specifying whole subnets. Here are a few examples: -| -| Comma-separated: '10.0.1.200,192.168.5.0/24' -| Array: array('10.0.1.200', '192.168.5.0/24') -*/ -$config['proxy_ips'] = ''; diff --git a/application/config/constants.php b/application/config/constants.php deleted file mode 100755 index 18d3b4b..0000000 --- a/application/config/constants.php +++ /dev/null @@ -1,85 +0,0 @@ -db->last_query() and profiling of DB queries. -| When you run a query, with this setting set to TRUE (default), -| CodeIgniter will store the SQL statement for debugging purposes. -| However, this may cause high memory usage, especially if you run -| a lot of SQL queries ... disable this to avoid that problem. -| -| The $active_group variable lets you choose which connection group to -| make active. By default there is only one group (the 'default' group). -| -| The $query_builder variables lets you determine whether or not to load -| the query builder class. -*/ -$active_group = 'default'; -$query_builder = TRUE; - -$db['default'] = array( - 'dsn' => '', - 'hostname' => $_ENV['DB_HOST'], - 'username' => $_ENV['DB_USER'], - 'password' => $_ENV['DB_PASS'], - 'database' => $_ENV['DB_NAME'], - 'dbdriver' => 'mysqli', - 'dbprefix' => '', - 'pconnect' => FALSE, - 'db_debug' => (ENVIRONMENT !== 'production'), - 'cache_on' => FALSE, - 'cachedir' => '', - 'char_set' => 'utf8', - 'dbcollat' => 'utf8_general_ci', - 'swap_pre' => '', - 'encrypt' => FALSE, - 'compress' => FALSE, - 'stricton' => FALSE, - 'failover' => array(), - 'save_queries' => TRUE -); diff --git a/application/config/doctypes.php b/application/config/doctypes.php deleted file mode 100755 index 59a7991..0000000 --- a/application/config/doctypes.php +++ /dev/null @@ -1,24 +0,0 @@ - '', - 'xhtml1-strict' => '', - 'xhtml1-trans' => '', - 'xhtml1-frame' => '', - 'xhtml-basic11' => '', - 'html5' => '', - 'html4-strict' => '', - 'html4-trans' => '', - 'html4-frame' => '', - 'mathml1' => '', - 'mathml2' => '', - 'svg10' => '', - 'svg11' => '', - 'svg11-basic' => '', - 'svg11-tiny' => '', - 'xhtml-math-svg-xh' => '', - 'xhtml-math-svg-sh' => '', - 'xhtml-rdfa-1' => '', - 'xhtml-rdfa-2' => '' -); diff --git a/application/config/email.php b/application/config/email.php deleted file mode 100644 index baa6940..0000000 --- a/application/config/email.php +++ /dev/null @@ -1,27 +0,0 @@ - 'ae', - '/ö|œ/' => 'oe', - '/ü/' => 'ue', - '/Ä/' => 'Ae', - '/Ü/' => 'Ue', - '/Ö/' => 'Oe', - '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A', - '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a', - '/Б/' => 'B', - '/б/' => 'b', - '/Ç|Ć|Ĉ|Ċ|Č/' => 'C', - '/ç|ć|ĉ|ċ|č/' => 'c', - '/Д/' => 'D', - '/д/' => 'd', - '/Ð|Ď|Đ|Δ/' => 'Dj', - '/ð|ď|đ|δ/' => 'dj', - '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E', - '/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e', - '/Ф/' => 'F', - '/ф/' => 'f', - '/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G', - '/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g', - '/Ĥ|Ħ/' => 'H', - '/ĥ|ħ/' => 'h', - '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I', - '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i', - '/Ĵ/' => 'J', - '/ĵ/' => 'j', - '/Ķ|Κ|К/' => 'K', - '/ķ|κ|к/' => 'k', - '/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L', - '/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l', - '/М/' => 'M', - '/м/' => 'm', - '/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N', - '/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n', - '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O', - '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o', - '/П/' => 'P', - '/п/' => 'p', - '/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R', - '/ŕ|ŗ|ř|ρ|р/' => 'r', - '/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S', - '/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's', - '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T', - '/ț|ţ|ť|ŧ|т/' => 't', - '/Þ|þ/' => 'th', - '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U', - '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u', - '/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', - '/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y', - '/В/' => 'V', - '/в/' => 'v', - '/Ŵ/' => 'W', - '/ŵ/' => 'w', - '/Ź|Ż|Ž|Ζ|З/' => 'Z', - '/ź|ż|ž|ζ|з/' => 'z', - '/Æ|Ǽ/' => 'AE', - '/ß/' => 'ss', - '/IJ/' => 'IJ', - '/ij/' => 'ij', - '/Œ/' => 'OE', - '/ƒ/' => 'f', - '/ξ/' => 'ks', - '/π/' => 'p', - '/β/' => 'v', - '/μ/' => 'm', - '/ψ/' => 'ps', - '/Ё/' => 'Yo', - '/ё/' => 'yo', - '/Є/' => 'Ye', - '/є/' => 'ye', - '/Ї/' => 'Yi', - '/Ж/' => 'Zh', - '/ж/' => 'zh', - '/Х/' => 'Kh', - '/х/' => 'kh', - '/Ц/' => 'Ts', - '/ц/' => 'ts', - '/Ч/' => 'Ch', - '/ч/' => 'ch', - '/Ш/' => 'Sh', - '/ш/' => 'sh', - '/Щ/' => 'Shch', - '/щ/' => 'shch', - '/Ъ|ъ|Ь|ь/' => '', - '/Ю/' => 'Yu', - '/ю/' => 'yu', - '/Я/' => 'Ya', - '/я/' => 'ya' -); diff --git a/application/config/hooks.php b/application/config/hooks.php deleted file mode 100755 index c291608..0000000 --- a/application/config/hooks.php +++ /dev/null @@ -1,23 +0,0 @@ - 'EloquentHook', - 'function' => 'bootEloquent', - 'filename' => 'EloquentHook.php', - 'filepath' => 'hooks' -]; - - - diff --git a/application/config/index.html b/application/config/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/config/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/config/memcached.php b/application/config/memcached.php deleted file mode 100755 index 5c23b39..0000000 --- a/application/config/memcached.php +++ /dev/null @@ -1,19 +0,0 @@ - array( - 'hostname' => '127.0.0.1', - 'port' => '11211', - 'weight' => '1', - ), -); diff --git a/application/config/migration.php b/application/config/migration.php deleted file mode 100755 index 4b585a6..0000000 --- a/application/config/migration.php +++ /dev/null @@ -1,84 +0,0 @@ -migration->current() this is the version that schema will -| be upgraded / downgraded to. -| -*/ -$config['migration_version'] = 0; - -/* -|-------------------------------------------------------------------------- -| Migrations Path -|-------------------------------------------------------------------------- -| -| Path to your migrations folder. -| Typically, it will be within your application path. -| Also, writing permission is required within the migrations path. -| -*/ -$config['migration_path'] = APPPATH.'migrations/'; diff --git a/application/config/mimes.php b/application/config/mimes.php deleted file mode 100755 index 0176533..0000000 --- a/application/config/mimes.php +++ /dev/null @@ -1,183 +0,0 @@ - array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'), - 'cpt' => 'application/mac-compactpro', - 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'), - 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'), - 'dms' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'exe' => array('application/octet-stream', 'application/x-msdownload'), - 'class' => 'application/octet-stream', - 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'), - 'so' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'), - 'ai' => array('application/pdf', 'application/postscript'), - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'), - 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'), - 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'), - 'wbxml' => 'application/wbxml', - 'wmlc' => 'application/wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'gz' => 'application/x-gzip', - 'gzip' => 'application/x-gzip', - 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'), - 'php4' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'js' => array('application/x-javascript', 'text/plain'), - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'), - 'z' => 'application/x-compress', - 'xhtml' => 'application/xhtml+xml', - 'xht' => 'application/xhtml+xml', - 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'), - 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'), - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mpga' => 'audio/mpeg', - 'mp2' => 'audio/mpeg', - 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'), - 'aif' => array('audio/x-aiff', 'audio/aiff'), - 'aiff' => array('audio/x-aiff', 'audio/aiff'), - 'aifc' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'rv' => 'video/vnd.rn-realvideo', - 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'), - 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'), - 'gif' => 'image/gif', - 'jpeg' => array('image/jpeg', 'image/pjpeg'), - 'jpg' => array('image/jpeg', 'image/pjpeg'), - 'jpe' => array('image/jpeg', 'image/pjpeg'), - 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'), - 'png' => array('image/png', 'image/x-png'), - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'css' => array('text/css', 'text/plain'), - 'html' => array('text/html', 'text/plain'), - 'htm' => array('text/html', 'text/plain'), - 'shtml' => array('text/html', 'text/plain'), - 'txt' => 'text/plain', - 'text' => 'text/plain', - 'log' => array('text/plain', 'text/x-log'), - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'xml' => array('application/xml', 'text/xml', 'text/plain'), - 'xsl' => array('application/xml', 'text/xsl', 'text/xml'), - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'), - 'movie' => 'video/x-sgi-movie', - 'doc' => array('application/msword', 'application/vnd.ms-office'), - 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'), - 'dot' => array('application/msword', 'application/vnd.ms-office'), - 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'), - 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'), - 'word' => array('application/msword', 'application/octet-stream'), - 'xl' => 'application/excel', - 'eml' => 'message/rfc822', - 'json' => array('application/json', 'text/json'), - 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'), - 'p10' => array('application/x-pkcs10', 'application/pkcs10'), - 'p12' => 'application/x-pkcs12', - 'p7a' => 'application/x-pkcs7-signature', - 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), - 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'), - 'crl' => array('application/pkix-crl', 'application/pkcs-crl'), - 'der' => 'application/x-x509-ca-cert', - 'kdb' => 'application/octet-stream', - 'pgp' => 'application/pgp', - 'gpg' => 'application/gpg-keys', - 'sst' => 'application/octet-stream', - 'csr' => 'application/octet-stream', - 'rsa' => 'application/x-pkcs7', - 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'), - '3g2' => 'video/3gpp2', - '3gp' => array('video/3gp', 'video/3gpp'), - 'mp4' => 'video/mp4', - 'm4a' => 'audio/x-m4a', - 'f4v' => array('video/mp4', 'video/x-f4v'), - 'flv' => 'video/x-flv', - 'webm' => 'video/webm', - 'aac' => 'audio/x-acc', - 'm4u' => 'application/vnd.mpegurl', - 'm3u' => 'text/plain', - 'xspf' => 'application/xspf+xml', - 'vlc' => 'application/videolan', - 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'), - 'au' => 'audio/x-au', - 'ac3' => 'audio/ac3', - 'flac' => 'audio/x-flac', - 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'), - 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'), - 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'), - 'ics' => 'text/calendar', - 'ical' => 'text/calendar', - 'zsh' => 'text/x-scriptzsh', - '7zip' => array('application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'), - 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'), - 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'), - 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'), - 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'), - 'vcf' => 'text/x-vcard', - 'srt' => array('text/srt', 'text/plain'), - 'vtt' => array('text/vtt', 'text/plain'), - 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'), - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'otf' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'odm' => 'application/vnd.oasis.opendocument.text-master', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web' -); diff --git a/application/config/profiler.php b/application/config/profiler.php deleted file mode 100755 index 3db22e3..0000000 --- a/application/config/profiler.php +++ /dev/null @@ -1,14 +0,0 @@ - my_controller/index -| my-controller/my-method -> my_controller/my_method -*/ -$route['default_controller'] = 'main'; -$route['404_override'] = ''; -$route['translate_uri_dashes'] = FALSE; diff --git a/application/config/smileys.php b/application/config/smileys.php deleted file mode 100755 index abf9a89..0000000 --- a/application/config/smileys.php +++ /dev/null @@ -1,64 +0,0 @@ - array('grin.gif', '19', '19', 'grin'), - ':lol:' => array('lol.gif', '19', '19', 'LOL'), - ':cheese:' => array('cheese.gif', '19', '19', 'cheese'), - ':)' => array('smile.gif', '19', '19', 'smile'), - ';-)' => array('wink.gif', '19', '19', 'wink'), - ';)' => array('wink.gif', '19', '19', 'wink'), - ':smirk:' => array('smirk.gif', '19', '19', 'smirk'), - ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'), - ':-S' => array('confused.gif', '19', '19', 'confused'), - ':wow:' => array('surprise.gif', '19', '19', 'surprised'), - ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'), - ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'), - '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'), - ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'), - ':P' => array('raspberry.gif', '19', '19', 'raspberry'), - ':blank:' => array('blank.gif', '19', '19', 'blank stare'), - ':long:' => array('longface.gif', '19', '19', 'long face'), - ':ohh:' => array('ohh.gif', '19', '19', 'ohh'), - ':grrr:' => array('grrr.gif', '19', '19', 'grrr'), - ':gulp:' => array('gulp.gif', '19', '19', 'gulp'), - '8-/' => array('ohoh.gif', '19', '19', 'oh oh'), - ':down:' => array('downer.gif', '19', '19', 'downer'), - ':red:' => array('embarrassed.gif', '19', '19', 'red face'), - ':sick:' => array('sick.gif', '19', '19', 'sick'), - ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'), - ':-/' => array('hmm.gif', '19', '19', 'hmmm'), - '>:(' => array('mad.gif', '19', '19', 'mad'), - ':mad:' => array('mad.gif', '19', '19', 'mad'), - '>:-(' => array('angry.gif', '19', '19', 'angry'), - ':angry:' => array('angry.gif', '19', '19', 'angry'), - ':zip:' => array('zip.gif', '19', '19', 'zipper'), - ':kiss:' => array('kiss.gif', '19', '19', 'kiss'), - ':ahhh:' => array('shock.gif', '19', '19', 'shock'), - ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'), - ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'), - ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'), - ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'), - ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'), - ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'), - ':vampire:' => array('vampire.gif', '19', '19', 'vampire'), - ':snake:' => array('snake.gif', '19', '19', 'snake'), - ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'), - ':question:' => array('question.gif', '19', '19', 'question') - -); diff --git a/application/config/user_agents.php b/application/config/user_agents.php deleted file mode 100755 index 798086b..0000000 --- a/application/config/user_agents.php +++ /dev/null @@ -1,214 +0,0 @@ - 'Windows 10', - 'windows nt 6.3' => 'Windows 8.1', - 'windows nt 6.2' => 'Windows 8', - 'windows nt 6.1' => 'Windows 7', - 'windows nt 6.0' => 'Windows Vista', - 'windows nt 5.2' => 'Windows 2003', - 'windows nt 5.1' => 'Windows XP', - 'windows nt 5.0' => 'Windows 2000', - 'windows nt 4.0' => 'Windows NT 4.0', - 'winnt4.0' => 'Windows NT 4.0', - 'winnt 4.0' => 'Windows NT', - 'winnt' => 'Windows NT', - 'windows 98' => 'Windows 98', - 'win98' => 'Windows 98', - 'windows 95' => 'Windows 95', - 'win95' => 'Windows 95', - 'windows phone' => 'Windows Phone', - 'windows' => 'Unknown Windows OS', - 'android' => 'Android', - 'blackberry' => 'BlackBerry', - 'iphone' => 'iOS', - 'ipad' => 'iOS', - 'ipod' => 'iOS', - 'os x' => 'Mac OS X', - 'ppc mac' => 'Power PC Mac', - 'freebsd' => 'FreeBSD', - 'ppc' => 'Macintosh', - 'linux' => 'Linux', - 'debian' => 'Debian', - 'sunos' => 'Sun Solaris', - 'beos' => 'BeOS', - 'apachebench' => 'ApacheBench', - 'aix' => 'AIX', - 'irix' => 'Irix', - 'osf' => 'DEC OSF', - 'hp-ux' => 'HP-UX', - 'netbsd' => 'NetBSD', - 'bsdi' => 'BSDi', - 'openbsd' => 'OpenBSD', - 'gnu' => 'GNU/Linux', - 'unix' => 'Unknown Unix OS', - 'symbian' => 'Symbian OS' -); - - -// The order of this array should NOT be changed. Many browsers return -// multiple browser types so we want to identify the sub-type first. -$browsers = array( - 'OPR' => 'Opera', - 'Flock' => 'Flock', - 'Edge' => 'Spartan', - 'Chrome' => 'Chrome', - // Opera 10+ always reports Opera/9.80 and appends Version/Directory access is forbidden.
- - - diff --git a/application/controllers/projects/CommentsController.php b/application/controllers/projects/CommentsController.php deleted file mode 100644 index 64cb8e6..0000000 --- a/application/controllers/projects/CommentsController.php +++ /dev/null @@ -1,61 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function index() - { - - } - - public function getComments( $foreignID, $tablename ) - { - $comments = Comment::getComments( $foreignID, $tablename ); - - $this->json( $comments ); - } - - public function getComment( $commentID ) - { - $comment = Comment::find( $commentID ); - - $comment->comment = base64_decode( $comment->comment ); - - $this->json( $comment ); - } - - public function addComment( $foreignID, $tablename ) - { - $commentID = Comment::addComment( $foreignID, $tablename ); - - $this->json( $commentID ); - } - - public function saveComment( $commentID ) - { - $comment = $this->input->post( 'comment' ); - - $comment = base64_encode( $comment ); - - Comment::whereId( $commentID )->update( ['comment' => $comment] ); - } - -} \ No newline at end of file diff --git a/application/controllers/projects/DocumentsController.php b/application/controllers/projects/DocumentsController.php deleted file mode 100644 index ae77cab..0000000 --- a/application/controllers/projects/DocumentsController.php +++ /dev/null @@ -1,51 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function getDocuments( $foreignID ) - { - $documents = Document::getDocuments( $foreignID ); - - $this->json( $documents ); - } - - public function downloadDocument( $documentID ) - { - $this->load->helper( 'download' ); - - $document = Document::find( $documentID ); - - $data = file_get_contents( MYROOTPATH . 'documents/' . $document->storagename ); - - force_download( $document->originalname, $data ); - } - - public function removeDocument( $documentID ) - { - $document = Document::find( $documentID ); - - unlink( MYROOTPATH . 'documents/' . $document->storagename ); - - Document::whereId( $documentID )->delete(); - } - -} \ No newline at end of file diff --git a/application/controllers/projects/EmployeeHoursController.php b/application/controllers/projects/EmployeeHoursController.php deleted file mode 100644 index c382fba..0000000 --- a/application/controllers/projects/EmployeeHoursController.php +++ /dev/null @@ -1,103 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function getEmployeehours( $month, $year, $employeeID ) - { - $sql = EmployeehoursMonthly::fire( $month, $year, $employeeID ); - - $query = $this->db->query( $sql ); - - $result = $query->result(); - - $this->json( $result ); - } - - public function getHourtypes() - { - $hourtypes = Hourtype::all(); - - $this->json( $hourtypes ); - } - - public function saveEmployeehour() - { - //TODO: validatie inbouwen - $data = $this->input->post(); - - $employeehourID = $data['id']; - $hourType = $data['hourType']; - $projectID = $data['project_id']; - unset( $data['id'] ); - unset( $data['hourType'] ); - unset( $data['project_id'] ); - if ( $hourType == 'OFFERS' ) $data['offer_id'] = $projectID; - - $data['hourdate'] = date2mysql( $data['hourdate'] ); - - if ( $hourType == 'PROJECTS' ) - { - $projectemployee = Projectemployee::select( 'id' ) - ->whereUserId( $data['employee_id'] ) - ->whereprojectId( $projectID ) - ->first(); - $data['projectemployee_id'] = $projectemployee->id; - unset( $data['employee_id'] ); - - $data['hourtype_id'] = $data['hourtype_id'] - 8; - - $employeehourID = Projecthour::saveProjecthour( $data ); - } - elseif ( $hourType == 'OFFERS' ) - { - $data['projectemployee_id'] = $data['employee_id']; - unset( $data['employee_id'] ); - $data['hourtype_id'] = $data['hourtype_id'] - 8; - - $employeehourID = Projecthour::saveProjecthour( $data ); - } - else - { - $employeehourID = Employeehour::saveEmployeehour( $data ); - } - - $this->json( ['employeehourID' => $employeehourID] ); - } - - public function removeEmployeehour( $employeehourID, $hourType ) - { - //TODO:check op delete - if ( $hourType == 'OVERHEAD' ) - { - Employeehour::whereId( $employeehourID )->delete(); - } - else - { - Projecthour::whereId( $employeehourID )->delete(); - } - - - $this->json( ['result' => TRUE] ); - } - -} diff --git a/application/controllers/projects/OffersController.php b/application/controllers/projects/OffersController.php deleted file mode 100644 index df5f73f..0000000 --- a/application/controllers/projects/OffersController.php +++ /dev/null @@ -1,96 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function index() - { - - } - - public function getAllOffers() - { - $projectID = $this->clean_input( 'projectID' ); - $archive = $this->clean_input( 'archive' ); - $search = $this->clean_input( 'search' ); - $order = $this->clean_input( 'order' ); - $direction = $this->clean_input( 'direction' ); - - $offers = Offer::getAllOffers( $projectID, $archive, $search, $order, $direction ); - - $this->json( $offers ); - } - - public function getOffersWithoutProject() - { - $offersWithoutProject = Offer::getOffersWithoutProject(); - - $this->json( $offersWithoutProject); - } - - public function saveOffer() - { - $offerValidation = new OfferValidation(); - - if ( ! $offerValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $offerValidation->getErrorMessages()] ); - - $offer = $this->input->post(); - - $offerID = $offer['id']; - unset( $offer['id'] ); - - $offerID = Offer::saveOffer( $offerID, $offer ); - - $createProject = $this->checkCreateproject( $offerID ); - - $this->json( ['success' => TRUE, 'offerID' => $offerID, 'createProject' => $createProject] ); - } - - public function archiveOffer( $offerID, $status ) - { - Offer::whereId( $offerID )->update( ['archive' => $status] ); - } - - public function removeOffer( $offerID ) - { - $removeOffer = new RemoveOffer( $offerID ); - - if ( $removeOffer->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] ); - - Offer::removeOffer( $offerID ); - - $this->json( ['result' => TRUE] ); - } - - private function checkCreateproject( $offerID ) - { - $offer = Offer::find( $offerID ); - - if ( is_int( $offer->project_id ) ) return FALSE; - if ( is_null( $offer->accepteddate ) ) return FALSE; - - return TRUE; - } - -} \ No newline at end of file diff --git a/application/controllers/projects/ProjectsController.php b/application/controllers/projects/ProjectsController.php deleted file mode 100644 index 1356caf..0000000 --- a/application/controllers/projects/ProjectsController.php +++ /dev/null @@ -1,374 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function index() - { - - } - - public function getAllProjects() - { - $archive = $this->clean_input( 'archive' ); - $search = $this->clean_input( 'search' ); - $order = $this->clean_input( 'order' ); - $direction = $this->clean_input( 'direction' ); - - $projects = Project::getAllProjects( $archive, $search, $order, $direction ); - - $this->json( $projects ); - } - - public function getProject( $projectID ) - { - $project = Project::getProject( $projectID ); - - $project->invoiceDetails = - $this->Invoices_model->getOutstandingPerProject( $project->id ); - - $project->hourTotals = - Projecthour::getTotalHoursPerProject( $project->id ); - - $this->json( $project ); - } - - public function getAvailableEmployees( $projectID ) - { - $availableEmployees = - Projectemployee::getAvailableEmployees( $projectID ); - - $this->json( $availableEmployees ); - } - - public function addProject() - { - $projectID = Project::createProject(); - - $this->json( $projectID ); - } - - public function creatProjectFromOffer( $offerID ) - { - $offer = Offer::find( $offerID ); - - $offernumber = $offer->offernumber; - - $projectnumber = 'P' . substr( $offernumber, 1 ); - - $data = [ - 'projectnumber' => $projectnumber, - 'projectname' => $offer->offername, - 'projectleader_id' => $offer->offerleader_id, - 'startdate' => $offer->accepteddate, - 'customer_id' => $offer->customer_id - ]; - - $project = Project::create( $data ); - - Offer::whereId( $offerID )->update( ['project_id' => $project->id] ); - - Projectemployee::firstOrCreateProjectemployee( $offer->offerleader_id, $project->id ); - - $offerteHours = Employeehour::whereOfferId( $offerID )->get(); - foreach ( $offerteHours as $offerteHour ) - { - $projectemployee = - Projectemployee::firstOrCreateProjectemployee( $offerteHour->employee_id, $project->id ); - - $data = [ - 'projectemployee_id' => $projectemployee->id, - 'hourtype_id' => 10, - 'hourdate' => $offerteHour->hourdate, - 'hours' => $offerteHour->hours - ]; - - Projecthour::create( $data ); - - Employeehour::whereId( $offerteHour->id )->delete(); - } - - $this->json( ['success' => TRUE, 'projectnumber' => $projectnumber] ); - } - - public function addProjectEmployee( $projectID ) - { - Projectemployee::createProjectEmployee( $projectID ); - } - - public function saveProject() - { - $projectValidation = new ProjectValidation(); - - if ( ! $projectValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] ); - - $project = $this->input->post(); - - $projectID = $project['id']; - unset( $project['id'] ); - - $project['startdate'] = date2mysql( $project['startdate'] ); - $project['enddate'] = date2mysql( $project['enddate'] ); - - $projectID = Project::saveProject( $projectID, $project ); - - Offer::syncProjectname( $projectID ); - - $this->json( ['success' => TRUE, 'projectID' => $projectID] ); - } - - public function saveProjectemployee() - { - $projectemployeeValidation = new ProjectemployeeValidation(); - - if ( ! $projectemployeeValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $projectemployeeValidation->getErrorMessages()] ); - - $projectemployee = $this->input->post(); - - $projectemployeeID = $projectemployee['id']; - unset( $projectemployee['id'] ); - - Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee ); - - $this->json( ['success' => TRUE] ); - } - - public function saveInvoice() - { - $invoiceValidation = new InvoiceValidation(); - - if ( ! $invoiceValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] ); - - $invoice = $this->input->post(); - - $invoiceID = $invoice['id']; - unset( $invoice['id'] ); - - $invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] ); - $invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] ); - $invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] ?? '' ); - $invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] ?? '' ); - - $invoiceID = Invoice::saveInvoice( $invoiceID, $invoice ); - - $this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] ); - } - - public function savePayment() - { - $paymentValidation = new PaymentValidation(); - - if ( ! $paymentValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $paymentValidation->getErrorMessages()] ); - - $payment = $this->input->post(); - - $paymentID = $payment['id']; - unset( $payment['id'] ); - - $payment['paymentdate'] = date2mysql( $payment['paymentdate'] ); - $payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] ?? '' ); - - $paymentID = Payment::savePayment( $paymentID, $payment ); - - $this->json( ['success' => TRUE, 'paymentID' => $paymentID] ); - } - - public function saveProjectcost() - { - $projectcostValidation = new ProjectcostValidation(); - - if ( ! $projectcostValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] ); - - $projectcost = $this->input->post(); - - $projectcostID = $projectcost['id']; - unset( $projectcost['id'] ); - - $projectcost['date'] = date2mysql( $projectcost['date'] ); - - $projectcostID = Projectcost::saveProjectcost( $projectcostID, $projectcost ); - - $this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] ); - } - - public function saveProjecthour() - { - $projecthourValidation = new ProjecthourValidation(); - - if ( ! $projecthourValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $projecthourValidation->getErrorMessages()] ); - - $projecthour = $this->input->post(); - - $projecthourID = $projecthour['id']; - unset( $projecthour['id'] ); - - $projecthour['hourdate'] = date2mysql( $projecthour['hourdate'] ); - - $paymentID = Projecthour::saveProjecthour( $projecthourID, $projecthour ); - - $this->json( ['success' => TRUE, 'projecthourID' => $paymentID] ); - } - - public function saveForecast() - { - $forecastValidation = new ForecastValidation(); - - if ( ! $forecastValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] ); - - $forecast = $this->input->post(); - - $forecastID = $forecast['id']; - unset( $forecast['id'] ); - - $forecastID = Forecast::saveForecast( $forecastID, $forecast ); - - $this->json( ['success' => TRUE, 'forecastID' => $forecastID] ); - } - - public function saveReservation() - { - $reservationValidation = new ReservationValidation(); - - if ( ! $reservationValidation->getValidationResult() ) - return $this->json( [ - 'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] ); - - $reservation = $this->input->post(); - - $reservationID = $reservation['id']; - unset( $reservation['id'] ); - - $reservationID = Reservation::saveReservation( $reservationID, $reservation ); - - $this->json( ['success' => TRUE, 'reservationID' => $reservationID] ); - } - - public function archiveProject( $projectID, $status ) - { - Project::whereId( $projectID )->update( ['archive' => $status] ); - } - - public function removeProjectemployee( $projectemployeeID ) - { - $removeProjectemployee = new RemoveProjectemployee( $projectemployeeID ); - - if ( $removeProjectemployee->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] ); - - Projectemployee::removeProjectemployee( $projectemployeeID ); - - $this->json( ['result' => TRUE] ); - } - - public function removeInvoice( $invoiceID ) - { - $removeInvoice = new RemoveInvoice( $invoiceID ); - - if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] ); - - Invoice::whereId( $invoiceID )->delete(); - - return $this->json( ['result' => TRUE] ); - } - - public function removeIncomingInvoice( $invoiceID ) - { -// $removeInvoice = new RemoveInvoice( $invoiceID ); -// -// if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] ); - - Projectcost::whereId( $invoiceID )->delete(); - - return $this->json( ['result' => TRUE] ); - } - - public function removePayment( $paymentID ) - { - $removePayment = new RemovePayment( $paymentID ); - - if ( $removePayment->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] ); - - Payment::removePayment( $paymentID ); - - $this->json( ['result' => TRUE] ); - } - - public function removeProjecthour( $projecthourID ) - { - $removeProjecthour = new RemoveProjecthour( $projecthourID ); - - if ( $removeProjecthour->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] ); - - Projecthour::removeProjecthour( $projecthourID ); - - $this->json( ['result' => TRUE] ); - } - - public function removeForecast( $forecastID ) - { - $removeForecast = new RemoveForecast( $forecastID ); - - if ( $removeForecast->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] ); - - Forecast::removeForecast( $forecastID ); - - $this->json( ['result' => TRUE] ); - } - - public function removeReservation( $reservationID ) - { - $removeReservation = new RemoveReservation( $reservationID ); - - if ( $removeReservation->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] ); - - Reservation::removeReservation( $reservationID ); - - $this->json( ['result' => TRUE] ); - } - - public function removeProject( $projectID ) - { - $removeProject = new RemoveProject( $projectID ); - - if ( $removeProject->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] ); - - Project::removeProject( $projectID ); - - $this->json( ['result' => TRUE] ); - } - -} - - diff --git a/application/controllers/reports/ReportsController.php b/application/controllers/reports/ReportsController.php deleted file mode 100644 index 2a27228..0000000 --- a/application/controllers/reports/ReportsController.php +++ /dev/null @@ -1,91 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function index() - { - - } - - public function recapProjects( $archive ) - { - $field = $this->input->post('field'); - $direction = $this->input->post('direction'); - - $recapprojects = new Recapprojects( $archive, $field, $direction ); - - $projects = $recapprojects->getProjects(); - - - $this->json( $projects ); - } - - public function getMonthlyEmployeeHoursPerProject( $employeeID, $year ) - { - $monthlyhours = Projecthour::getMonthlyEmployeeHoursPerProject( $employeeID, $year ); - - $this->json( $monthlyhours ); - } - - public function getMonthlyEmployeehours( $month, $year ) - { - $sql = QEmployeeHours::fire( $month, $year ); - - $query = $this->db->query( $sql ); - - $result = $query->result(); - - foreach ( $result as $user ) - { - $user->targethours = Employeetarget::getTargetHoursPerEmployee( $user->user_id, $year, $month ); - } - - $this->json( $result ); - } - - public function getInvoiceOverview( $year, $orderType, $orderDirection, $archive ) - { - $invoices = new Invoices( $year, $orderType, $orderDirection, $archive ); - - $invoiceReport = $invoices->getInvoiceReport(); - - $this->json( $invoiceReport ); - } - - public function createInvoicesSpreadsheet( $year, $orderType, $orderDirection, $archive ) - { - $invoices = new Invoices( $year, $orderType, $orderDirection, $archive ); - - $invoiceReport = $invoices->getInvoiceReport(); - - new InvoiceSpreadsheet( $invoiceReport ); - } - - public function saveCurrentFinnacialYear( $projectID ) - { - $amount = $this->input->post( 'amount' ); - - Project::whereId( $projectID )->update( ['current_financial_year' => $amount] ); - } - -} diff --git a/application/controllers/reports/ReportsdefaultController.php b/application/controllers/reports/ReportsdefaultController.php deleted file mode 100644 index 11c3386..0000000 --- a/application/controllers/reports/ReportsdefaultController.php +++ /dev/null @@ -1,38 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function index() - { - - } - - public function getUsedYears() - { - $years = Projecthour::getUsedYears(); - - $this->json( $years ); - } - - -} \ No newline at end of file diff --git a/application/controllers/reports/ReservationsController.php b/application/controllers/reports/ReservationsController.php deleted file mode 100644 index f2e8598..0000000 --- a/application/controllers/reports/ReservationsController.php +++ /dev/null @@ -1,64 +0,0 @@ -db->query( $sql ); - - $results = $query->result(); - - foreach ( $results as $result ) - { - if ( ! isset( $projects[ $result->projectID ] ) ) - { - $projects[ $result->projectID ] = [ - 'projectnumber' => $result->projectnumber, - 'projectname' => $result->projectname, - 'costs' => 0, - 'reservation' => 0, - 'payed' => 0, - 'fromreservation' => 0, - 'saldo' => 0, - 'saldoToPay' => 0, - 'other_revenue' => 0, - 'customers' => [] - ]; - } - - $projects[ $result->projectID ]['reservation'] += $result->reservation; - $projects[ $result->projectID ]['costs'] += $result->costs; - $projects[ $result->projectID ]['payed'] += $result->payed; - $projects[ $result->projectID ]['fromreservation'] += $result->fromreservation; - $projects[ $result->projectID ]['saldo'] += $result->saldo; - $projects[ $result->projectID ]['saldoToPay'] += $result->saldoToPay; - $projects[ $result->projectID ]['other_revenue'] = $result->other_revenue; - - $projects[ $result->projectID ]['externals'][] = [ - 'external' => $result->contactperson, - 'reservation' => $result->reservation, - 'costs' => $result->costs, - 'payed' => $result->payed, - 'saldo' => $result->saldo, - 'fromreservation' => $result->fromreservation, - 'saldoToPay' => $result->saldoToPay - ]; - } - - $this->json( $projects ); - } - -} diff --git a/application/controllers/utils/DownloadDB.php b/application/controllers/utils/DownloadDB.php deleted file mode 100644 index cfce956..0000000 --- a/application/controllers/utils/DownloadDB.php +++ /dev/null @@ -1,41 +0,0 @@ -load->dbutil(); - - $filename = "backupDBOIS_" . date( 'YmdHis' ); - - $prefs = [ - 'tables' => [], // Array of tables to backup. - 'ignore' => [], // List of tables to omit from the backup - 'format' => '', // gzip, zip, txt - 'filename' => NULL, // File name - NEEDED ONLY WITH ZIP FILES - 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file - 'add_insert' => TRUE, // Whether to add INSERT data to backup file - 'newline' => "\n" // Newline character used in backup file - ]; - - $backup = $this->dbutil->backup( $prefs ); - -// Load the download helper and send the file to your desktop - $this->load->helper( 'download' ); - force_download( $filename . '.sql', $backup ); - } - -} \ No newline at end of file diff --git a/application/controllers/utils/FileUpload.php b/application/controllers/utils/FileUpload.php deleted file mode 100644 index 54962f9..0000000 --- a/application/controllers/utils/FileUpload.php +++ /dev/null @@ -1,75 +0,0 @@ -load->model( $models ); - $this->load->library( $libraries ); - } - - public function upload( $foreignID ) - { - $config['upload_path'] = MYROOTPATH . 'documents/temp'; - $config['allowed_types'] = '*'; - $config['remove_spaces'] = FALSE; - - $this->load->library( 'upload', $config ); - - if ( ! $this->upload->do_upload( 'userfile' ) ) - { - $error = ['error' => $this->upload->display_errors()]; - - $this->json( $error ); - } - else - { - $data = ['upload_data' => $this->upload->data()]; - - $this->setStoragename(); - - $this->persistDocument( $data['upload_data'], $foreignID ); - - $this->renameDocument( $data['upload_data']['full_path'] ); - } - } - - private function setStoragename() - { - $this->load->helper( 'string' ); - $this->storagename = sha1( random_string( 'alnum', 16 ) ); - } - - private function persistDocument( $data, $foreignID ) - { - $file = [ - 'storagename' => $this->storagename, - 'originalname' => $data['file_name'], - 'user_id' => USERID, - 'uploaddate' => date( 'Y-m-d H:i:s' ), - 'foreign_id' => $foreignID - ]; - - Document::create( $file ); - } - - private function renameDocument( $original ) - { - rename( $original, MYROOTPATH . 'documents/' . $this->storagename ); - } -} \ No newline at end of file diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php deleted file mode 100644 index 5bb8398..0000000 --- a/application/core/MY_Controller.php +++ /dev/null @@ -1,79 +0,0 @@ -version = '1.00.81'; - - $this->load->library( 'beheer/session/RetrieveUserSession' ); - - $this->handle(); - } - - private function handle() - { - $this->garbageCiSessions(); - - $this->setSecureSite(); - - $this->retrieveusersession->handle(); - - $this->user = $this->User_model->get( USERID ); - } - - public function garbageCiSessions() - { - $number = random_int(0, 100); - - if( $number != 17 ) return; - - $this->db->query( "DELETE FROM ci_sessions WHERE TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(timestamp), NOW()) > 60" ); - } - - public function setSecureSite() - { - if ( getenv( 'ENVIRONMENT' ) != 'production' ) return; - - if ( ! isset( $_SERVER["HTTPS"] ) || $_SERVER["HTTPS"] != "on" ) - { - header( "Location: " . getenv( 'APP_URL' ) ); - - exit; - } - } - - function clean_input( $post ) - { - $value = $this->input->input_stream( $post, TRUE ); - - $denulledValue = str_replace( 'null', '', $value ?? '' ); - - return $denulledValue; - } - - public function json( $data ) - { - $this->output - ->set_content_type( 'application/json' ) - ->set_output( json_encode( $data ) ); - } - - public function unAuthorized() - { - - } - -} diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php deleted file mode 100644 index 545fd4c..0000000 --- a/application/core/MY_Model.php +++ /dev/null @@ -1,400 +0,0 @@ -filepictures = array("", "images/word.png", "images/excel.png", "images/pdf.png", "images/other.png", "images/text.png"); - } - - function get($where = FALSE, $fieldname = FALSE, $row = FALSE) - { - if( $fieldname ) $row = TRUE; - - if ( ! is_array( $where ) && $where ) - { - $this->db->where( array('T1.id' => $where) ); - $row = TRUE; - } - elseif ( $where ) - { - $this->db->where( $where ); - } - - - if ( $fieldname ) $this->db->select( $fieldname ); - - $query = $this->db->get( $this->tablename . ' AS T1' ); - - if ( $query->num_rows() == 0 ) return FALSE; - - if ( $row ) - { - $row = $query->row(); - - if ( $fieldname ) - { - return $row->$fieldname; - } - else - { - return $row; - } - } - else - { - return $query->result(); - } - } - - function get_record_by_id($id, $fieldname = FALSE, $row = TRUE) - { - $query = $this->db->get_where( $this->tablename, array('id' => $id) ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - elseif ( $row ) - { - $row = $query->row(); - if ( $fieldname ) - { - return $row->$fieldname; - } - else - { - return $row; - } - } - else - { - return $query->result(); - } - } - - function get_fieldvalue($where, $fieldname) - { - $query = $this->db->get_where( $this->tablename, $where ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - $row = $query->row(); - - return $row->$fieldname; - } - } - - function get_records_where($where = FALSE, $row = FALSE, $order = FALSE, $sort = 'asc') - { - if ( $order ) $this->db->order_by( $order, $sort ); - - if ( $where ) $this->db->where( $where ); - - $query = $this->db->get( $this->tablename ); - - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - if ( $row ) - { - return $query->row(); - } - else - { - return $query->result(); - } - } - } - - function check_for_record($where = FALSE) - { - if ( $where ) $this->db->where( $where ); - $query = $this->db->get( $this->tablename, $where ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - return TRUE; - } - } - - function get_query_result() - { - $query = $this->db->query( $this->sql ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - return $query->result(); - } - } - - function get_query_row($fieldname = FALSE) - { - $query = $this->db->query( $this->sql ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - if ( $fieldname ) - { - $row = $query->row(); - - return $row->$fieldname; - } - else - { - return $query->row(); - } - } - } - - function check_query_record() - { - $query = $this->db->query( $this->sql ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - else - { - return TRUE; - } - } - - function get_query($where = FALSE, $row = FALSE) - { - if ( $where ) $this->db->where( $where ); - - $query = $this->db->get( $this->tablename ); - if ( $query->num_rows() == 0 ) - { - return FALSE; - } - elseif ( $row ) - { - return $query->row(); - } - else - { - return $query->result(); - } - } - - function get_minmax_field($where, $field, $max) - { - if ( $max ) - { - $this->db->select_max( $field, 'minimaxi' ); - } - else - { - $this->db->select_min( $field, 'minimaxi' ); - } - if ( $where ) - { - $query = $this->db->get_where( $this->tablename, $where ); - } - else - { - $query = $this->db->get( $this->tablename ); - } - $row = $query->row(); - if ( is_null( $row->minimaxi ) ) - { - return FALSE; - } - else - { - return $row->minimaxi; - } - } - - function get_result_count($where = FALSE) - { - if ( $where ) $this->db->where( $where ); - $this->db->from( $this->tablename . ' AS T1' ); - - return $this->db->count_all_results(); - } - - function get_query_count() - { - $query = $this->db->query( $this->sql ); - - return $query->num_rows(); - } - - function insert_record($data) - { - $data['creation_date'] = date( 'Y-m-d G:i:s' ); - $data['created_by'] = ''; - $data['last_update_date'] = date( 'Y-m-d G:i:s' ); - $data['last_updated_by'] = ''; - $this->db->insert( $this->tablename, $data ); - - $newID = $this->db->insert_id(); - - $this->createActivity( $newID, 'INSERT' ); - - return $newID; - } - - /** - * Called from CLI. no activity recorded here - * @param array $data - * @return integer The inserted id - */ - function insert_record_cli($data) - { - $data['creation_date'] = date( 'Y-m-d G:i:s' ); - $data['created_by'] = 'SYNCER'; - $data['last_update_date'] = date( 'Y-m-d G:i:s' ); - $data['last_updated_by'] = 'SYNCER'; - $this->db->insert( $this->tablename, $data ); - - $newID = $this->db->insert_id(); - - return $newID; - } - - function update_record($data, $id) - { - $data['last_update_date'] = date( 'Y-m-d G:i:s' ); - $data['last_updated_by'] = ''; - $this->db->update( $this->tablename, $data, 'id = ' . $id ); - } - - function update_record_where($data, $where) - { - $records = $this->get($where); - - if( ! $records ) return; - - foreach( $records as $record) - { - $this->update_record($data, $record->id); - } -// $data['last_update_date'] = date( 'Y-m-d G:i:s' ); -// $data['last_updated_by'] = $this->username; -// -// $this->db->update( $this->tablename, $data, $where ); - } - - /** - * Used when script is called from CLI, so no user - * No logging to activitylog here - * @param array $data - * @param integer $id - */ - function update_record_cli($data, $id) - { - $data['last_update_date'] = date( 'Y-m-d G:i:s' ); - $data['last_updated_by'] = 'SYNCER'; - $this->db->update( $this->tablename, $data, 'id = ' . $id ); - } - - /** - * save_record insert or update a record - * - * @param array $data cpntains the data that needs to be inserted or udated - * @param int $id id of the update record, if FALSE the record is being inserted - * - * @return int if an insert returns the newly created id of the record, else returns the id of the updated record - */ - function save($data, $id) - { - if ( ! $id ) - { - $id = $this->insert_record( $data ); - } - else - { - $this->update_record( $data, $id ); - } - - return $id; - } - - function delete_record($id) - { - $this->createActivity( $id, 'DELETE' ); - - $this->db->delete( $this->tablename, array('id' => $id) ); - } - - function delete_record_where($where) - { - $records = $this->get($where); - - if( ! $records ) return; - - foreach( $records as $record) - { - $this->delete_record($record->id); - } - //$this->db->delete( $this->tablename, $where ); - } - - function sanitise_postinput($post, $notinclude) - { - foreach ( $post as $key => $value ) - { - if ( ! in_array( $key, $notinclude ) ) $data[] = array($key => $value); - } - } - - function createActivity($id, $activityType) - { - return; - if( ! isset( $this->logActivity ) || ! $this->logActivity ) return; - $oldData = $this->get( $id ); - - if ( $oldData ) $oldData = serialize( $oldData ); - - $data = array( - 'table' => $this->tablename, - 'table_id' => $id, - 'username' => '', - 'olddata' => $oldData, - 'activitytype' => $activityType, - 'activitytime' => date( 'Y-m-d H:i:s' ), - 'activityip' => $this->input->ip_address() - ); - - $this->db->insert( 'activitylogs', $data ); - } - - function clean_input($post){ - return str_replace('null', '', $this->db->escape_str($this->input->post($post) ?? '', TRUE)); - } -} - - diff --git a/application/core/index.html b/application/core/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/core/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php deleted file mode 100644 index ad0c071..0000000 --- a/application/helpers/common_helper.php +++ /dev/null @@ -1,365 +0,0 @@ -n(s+)/m", "] => ", $output ); - $output = '' . $label . ' => ' . $output . ''; - - // Output - if ( $echo == TRUE ) - { - echo $output; - } - else - { - return $output; - } - } -} - -if ( ! function_exists( 'dump_exit' ) ) -{ - function dump_exit( $var, $label = 'Dump', $echo = TRUE ) - { - dump( $var, $label, $echo ); - exit; - } -} - - -function mysql2text( $message ) -{ - $regeleinden = ['\r\n', '\r', '\n']; - $message = str_replace( $regeleinden, chr( 13 ), $message ?? '' ); - $message = stripslashes( $message ); - - return ( $message ); -} - -function mysql2html( $message ) -{ - $regeleinden = ['\r\n', '\r', '\n']; - $message = str_replace( $regeleinden, "
Directory access is forbidden.
- - - diff --git a/application/hooks/EloquentHook.php b/application/hooks/EloquentHook.php deleted file mode 100644 index 431771a..0000000 --- a/application/hooks/EloquentHook.php +++ /dev/null @@ -1,60 +0,0 @@ -instance =& get_instance(); - } - - /** - * Loads database - */ - private function loadDatabase() { - $this->instance->load->database(); - } - - /** - * Returns the instance of the db - * @return object - */ - private function getDB() { - return $this->instance->db; - } - - public function bootEloquent() { - - $this->setInstance(); - - $this->loadDatabase(); - - $config = $this->getDB(); - - $capsule = new Capsule; - - $capsule->addConnection([ - 'driver' => 'mysql', - 'host' => $config->hostname, - 'database' => $config->database, - 'username' => $config->username, - 'password' => $config->password, - 'charset' => $config->char_set, - 'collation' => $config->dbcollat, - 'prefix' => $config->dbprefix, - ]); - - $capsule->setAsGlobal(); - $capsule->bootEloquent(); - } - -} \ No newline at end of file diff --git a/application/hooks/index.html b/application/hooks/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/hooks/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/index.html b/application/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/language/english/index.html b/application/language/english/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/language/english/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/language/index.html b/application/language/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/language/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/libraries/TwoFactorAuth.php b/application/libraries/TwoFactorAuth.php deleted file mode 100644 index ef07690..0000000 --- a/application/libraries/TwoFactorAuth.php +++ /dev/null @@ -1,193 +0,0 @@ -ci =& get_instance(); - } - - /** - * Generate a new secret key for TOTP - * @return string Base32 encoded secret - */ - public function generateSecret($length = 16) - { - $secret = ''; - $validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; // Base32 alphabet - - for ($i = 0; $i < $length; $i++) { - $secret .= $validChars[random_int(0, 31)]; - } - - return $secret; - } - - /** - * Generate QR code URL for Google Authenticator - * @param string $secret The user's TOTP secret - * @param string $username The username - * @param string $issuer The application name - * @return string QR code URL - */ - public function getQRCodeUrl($secret, $username, $issuer = 'DBOIS') - { - $encodedIssuer = rawurlencode($issuer); - $encodedUsername = rawurlencode($username); - - $otpauthUrl = "otpauth://totp/{$encodedIssuer}:{$encodedUsername}?secret={$secret}&issuer={$encodedIssuer}"; - - // Using Google Charts API for QR code generation - return "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=" . urlencode($otpauthUrl); - } - - /** - * Verify a TOTP code - * @param string $secret The user's secret - * @param string $code The code to verify - * @param int $discrepancy Time window (default 1 = +/- 30 seconds) - * @return bool True if code is valid - */ - public function verifyCode($secret, $code, $discrepancy = 1) - { - $currentTimeSlice = floor(time() / $this->period); - - for ($i = -$discrepancy; $i <= $discrepancy; $i++) { - $calculatedCode = $this->getCode($secret, $currentTimeSlice + $i); - if ($this->timingSafeEquals($calculatedCode, $code)) { - return true; - } - } - - return false; - } - - /** - * Generate TOTP code for a given time slice - * @param string $secret The secret key - * @param int $timeSlice The time slice (defaults to current) - * @return string The generated code - */ - public function getCode($secret, $timeSlice = null) - { - if ($timeSlice === null) { - $timeSlice = floor(time() / $this->period); - } - - $secretKey = $this->base32Decode($secret); - - // Pack time into binary string - $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice); - - // Hash with secret - $hash = hash_hmac('sha1', $time, $secretKey, true); - - // Use last 4 bits as offset - $offset = ord(substr($hash, -1)) & 0x0F; - - // Get 4 bytes from offset - $hashPart = substr($hash, $offset, 4); - - // Unpack binary value - $value = unpack('N', $hashPart); - $value = $value[1]; - - // Only 32 bits - $value = $value & 0x7FFFFFFF; - - // Get the required digits - $modulo = pow(10, $this->codeLength); - - return str_pad($value % $modulo, $this->codeLength, '0', STR_PAD_LEFT); - } - - /** - * Decode Base32 string - * @param string $secret Base32 encoded string - * @return string Binary string - */ - protected function base32Decode($secret) - { - if (empty($secret)) { - return ''; - } - - $base32chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; - $base32charsFlipped = array_flip(str_split($base32chars)); - - $paddingCharCount = substr_count($secret, '='); - $allowedValues = array(6, 4, 3, 1, 0); - - if (!in_array($paddingCharCount, $allowedValues)) { - return false; - } - - for ($i = 0; $i < 4; $i++) { - if ($paddingCharCount == $allowedValues[$i] && - substr($secret, -($allowedValues[$i])) != str_repeat('=', $allowedValues[$i])) { - return false; - } - } - - $secret = str_replace('=', '', $secret); - $secret = str_split($secret); - $binaryString = ''; - - for ($i = 0; $i < count($secret); $i = $i + 8) { - $x = ''; - if (!in_array($secret[$i], $base32charsFlipped)) { - return false; - } - - for ($j = 0; $j < 8; $j++) { - $x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); - } - - $eightBits = str_split($x, 8); - - for ($z = 0; $z < count($eightBits); $z++) { - $binaryString .= (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : ''; - } - } - - return $binaryString; - } - - /** - * Timing-safe string comparison - * @param string $safeString Known string - * @param string $userString User provided string - * @return bool True if strings match - */ - protected function timingSafeEquals($safeString, $userString) - { - if (function_exists('hash_equals')) { - return hash_equals($safeString, $userString); - } - - $safeLen = strlen($safeString); - $userLen = strlen($userString); - - if ($userLen != $safeLen) { - return false; - } - - $result = 0; - - for ($i = 0; $i < $userLen; $i++) { - $result |= (ord($safeString[$i]) ^ ord($userString[$i])); - } - - return $result === 0; - } -} diff --git a/application/libraries/beheer/customer/RemoveCustomer.php b/application/libraries/beheer/customer/RemoveCustomer.php deleted file mode 100644 index 1fd17f4..0000000 --- a/application/libraries/beheer/customer/RemoveCustomer.php +++ /dev/null @@ -1,36 +0,0 @@ -setCustomerID( $userID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setCustomerID( $customerID ) - { - $this->customerID = $customerID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/beheer/externals/RemoveExternal.php b/application/libraries/beheer/externals/RemoveExternal.php deleted file mode 100644 index 88dd9fd..0000000 --- a/application/libraries/beheer/externals/RemoveExternal.php +++ /dev/null @@ -1,36 +0,0 @@ -setExternalID( $userID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setExternalID( $externalID ) - { - $this->externalID = $externalID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/beheer/session/CreateUserSession.php b/application/libraries/beheer/session/CreateUserSession.php deleted file mode 100644 index 9766b7f..0000000 --- a/application/libraries/beheer/session/CreateUserSession.php +++ /dev/null @@ -1,47 +0,0 @@ -ci =& get_instance(); - } - - public function handle( $user ) - { - $this->setUser( $user ); - - $this->setSessionArray(); - - $this->createSession(); - } - - private function setUser( $user ) - { - $this->user = $user; - } - - private function setSessionArray() - { - $this->sessionArray = [ - 'userID' => $this->user->id, - 'role' => $this->user->role - ]; - } - - private function createSession() - { - $this->ci->session->set_userdata( $this->sessionArray ); - } - -} \ No newline at end of file diff --git a/application/libraries/beheer/session/RetrieveUserSession.php b/application/libraries/beheer/session/RetrieveUserSession.php deleted file mode 100644 index 3750d01..0000000 --- a/application/libraries/beheer/session/RetrieveUserSession.php +++ /dev/null @@ -1,41 +0,0 @@ -ci =& get_instance(); - } - - public function handle() - { - $this->setUserID(); - - $this->setRole(); - - $this->setAuthenticated(); - } - - private function setUserID() - { - define( 'USERID', $this->ci->session->userID ); - } - - private function setRole() - { - define( 'ROLE', $this->ci->session->role ); - } - - private function setAuthenticated() - { - define( 'AUTHENTICATED', USERID ? TRUE : FALSE ); - } -} \ No newline at end of file diff --git a/application/libraries/beheer/twofactor/SendOtpEmail.php b/application/libraries/beheer/twofactor/SendOtpEmail.php deleted file mode 100644 index 0466962..0000000 --- a/application/libraries/beheer/twofactor/SendOtpEmail.php +++ /dev/null @@ -1,108 +0,0 @@ -ci =& get_instance(); - $this->user = $user; - - $this->ci->load->library('email'); - $this->ci->load->model('beheer/UserOtp_model'); - - $this->handle(); - } - - /** - * Get the result of the email send operation - * @return bool True if email was sent successfully - */ - public function getSendResult() - { - return $this->sendResult; - } - - /** - * Get the generated OTP code (for testing purposes) - * @return string The OTP code - */ - public function getOtpCode() - { - return $this->otpCode; - } - - /** - * Main handler for OTP email process - */ - private function handle() - { - $this->generateOTP(); - $this->sendOTPEmail(); - } - - /** - * Generate a new OTP code - */ - private function generateOTP() - { - // Generate OTP valid for 10 minutes - $this->otpCode = $this->ci->UserOtp_model->generateOTP($this->user->id, 10); - } - - /** - * Send the OTP code via email - */ - private function sendOTPEmail() - { - // Build email configuration directly from environment variables - $config = [ - 'protocol' => $_ENV['PROTOCOL'] ?? getenv('PROTOCOL') ?: 'mail', - 'smtp_host' => $_ENV['SMTP_HOST'] ?? getenv('SMTP_HOST') ?: '', - 'smtp_user' => $_ENV['SMTP_USER'] ?? getenv('SMTP_USER') ?: '', - 'smtp_pass' => $_ENV['SMTP_PASS'] ?? getenv('SMTP_PASS') ?: '', - 'smtp_port' => $_ENV['SMTP_PORT'] ?? getenv('SMTP_PORT') ?: 25, - 'smtp_crypto' => 'tls', - 'smtp_timeout' => 30, - 'charset' => 'iso-8859-1', - 'mailtype' => 'html', - 'newline' => "\r\n", - 'crlf' => "\r\n", - 'wordwrap' => TRUE, - 'validate' => TRUE - ]; - - // Re-initialize email library with config - $this->ci->email->initialize($config); - - $data = [ - 'username' => $this->user->username, - 'firstname' => $this->user->firstname, - 'middlename' => $this->user->middlename, - 'lastname' => $this->user->lastname, - 'otp_code' => $this->otpCode - ]; - - $html = $this->ci->load->view('emails/twofactor_otp_email', ['user' => $data], true); - - $this->ci->email->from('noreply@dbois.nl', 'DBOIS'); - $this->ci->email->to($this->user->email); - $this->ci->email->subject('DBOIS Tweefactorauthenticatie - Verificatiecode'); - $this->ci->email->message($html); - - $this->sendResult = $this->ci->email->send(); - - if (!$this->sendResult) { - log_message('error', 'Failed to send 2FA OTP email to ' . $this->user->email . ': ' . $this->ci->email->print_debugger()); - } - } -} diff --git a/application/libraries/beheer/user/CreateUser.php b/application/libraries/beheer/user/CreateUser.php deleted file mode 100644 index f215e4d..0000000 --- a/application/libraries/beheer/user/CreateUser.php +++ /dev/null @@ -1,16 +0,0 @@ -handle(); - } - - public function getPassword() - { - return $this->password; - } - - public function getSalt() - { - return $this->salt; - } - - public function getSaltedPassword() - { - return $this->saltedPassword; - } - - public function setPassword( $password ) - { - $this->password = $password; - } - - public function setSalt( $salt ) - { - $this->salt = $salt; - } - - private function handle() - { - $this->checkPassword(); - - $this->checkSalt(); - - $this->setSaltedPassword(); - } - - private function checkPassword() - { - if ( ! $this->password ) $this->createPassword(); - - if ( strlen( $this->password ) < 6 ) return; - } - - private function checkSalt() - { - if ( ! $this->salt ) $this->createSalt(); - } - - private function createPassword() - { - $pass = $this->getRandomString( 8 ); - - $this->password = $pass; - } - - private function createSalt() - { - $salt = $this->getRandomString( 18 ); - - $this->salt = sha1($salt); - } - - private function setSaltedPassword() - { - $this->saltedPassword = User::getSaltedPassword( $this->password, $this->salt); - } - - private function getRandomString( $length = 8 ) - { - $rand = ''; - $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; - $alphaLength = strlen( $alphabet ) - 1; //put the length -1 in cache - for ( $i = 0; $i < $length; $i ++ ) - { - $n = rand( 0, $alphaLength ); - $rand .= $alphabet[ $n ]; - } - - return $rand; - } -} diff --git a/application/libraries/beheer/user/RemoveUser.php b/application/libraries/beheer/user/RemoveUser.php deleted file mode 100644 index eb04c3b..0000000 --- a/application/libraries/beheer/user/RemoveUser.php +++ /dev/null @@ -1,36 +0,0 @@ -setUserID($userID); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setUserID( $userID ) - { - $this->userID = $userID; - } - - private function handle() - { - //$this->checkIfUserHasProjects(); - } - -} \ No newline at end of file diff --git a/application/libraries/beheer/user/RequestPassword.php b/application/libraries/beheer/user/RequestPassword.php deleted file mode 100644 index b8a5c47..0000000 --- a/application/libraries/beheer/user/RequestPassword.php +++ /dev/null @@ -1,104 +0,0 @@ -ci =& get_instance(); - - $this->user = $user; - - $this->ci->load->library( 'email' ); - - $this->handle(); - } - - public function getSendResult() - { - return $this->sendResult; - } - - private function handle() - { - $this->createPassword(); - - $this->setPassword(); - - $this->setSalt(); - - $this->setSaltedPassword(); - - $this->persistNewpassword(); - - $this->sendNewPassword(); - } - - private function createPassword() - { - $this->passwordRecipe = new PasswordRecipe(); - } - - private function setPassword() - { - $this->password = $this->passwordRecipe->getPassword(); - } - - private function setSalt() - { - $this->salt = $this->passwordRecipe->getsalt(); - } - - private function setSaltedPassword() - { - $this->saltedPassword = $this->passwordRecipe->getSaltedPassword(); - } - - private function persistNewPassword() - { - $data = [ - 'password' => $this->saltedPassword, - 'salt' => $this->salt - ]; - - User::whereId( $this->user->id )->update( $data ); - } - - private function sendNewPassword() - { - $data = [ - 'username' => $this->user->username, - 'firstname' => $this->user->firstname, - 'middlename' => $this->user->middlename, - 'lastname' => $this->user->lastname, - 'password' => $this->password - ]; - - $html = $this->ci->load->view( 'emails/requestpassword_email', ['user'=>$data], true ); - - $this->ci->email->from( 'noreply@dbois.nl', 'DBOIS' ); - $this->ci->email->to( $this->user->email ); - $this->ci->email->subject( 'Nieuw wachtwoord DBOIS' ); - $this->ci->email->message( $html ); - $this->ci->email->set_mailtype("html"); - $this->ci->email->set_newline("\r\n"); - - $this->sendResult = $this->ci->email->send(); - - if( ! $this->sendResult ) log_message( 'error', json_encode($this->ci->email->print_debugger())); - } - -} \ No newline at end of file diff --git a/application/libraries/beheer/user/UserCreation.php b/application/libraries/beheer/user/UserCreation.php deleted file mode 100644 index c700fb9..0000000 --- a/application/libraries/beheer/user/UserCreation.php +++ /dev/null @@ -1,72 +0,0 @@ -setUser( $user ); - - $this->handle(); - } - - public function getUser() - { - return $this->user; - } - - public function getPassword() - { - return $this->password; - } - - private function setUser( $user ) - { - $this->user = $user; - } - - private function handle() - { - $this->passWordRecipe = new PasswordRecipe(); - - $this->setPassword(); - - $this->setSalt(); - - $this->setSaltedPassword(); - - $this->enrichUser(); - } - - private function setPassword() - { - $this->password = $this->passWordRecipe->getPassword(); - } - - private function setSalt() - { - $this->salt = $this->passWordRecipe->getSalt(); - } - - private function setSaltedPassword() - { - $this->saltedPassword = $this->passWordRecipe->getSaltedPassword(); - } - - private function enrichUser() - { - $this->user['password'] = $this->saltedPassword; - $this->user['salt'] = $this->salt; - } -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveInvoice.php b/application/libraries/deletions/RemoveInvoice.php deleted file mode 100644 index c217630..0000000 --- a/application/libraries/deletions/RemoveInvoice.php +++ /dev/null @@ -1,53 +0,0 @@ -setInvoiceID( $invoiceID ); - - $this->handle(); - } - - public function getRemoveAllowed() - { - return $this->removeAllowed; - } - - private function setInvoiceID( $invoiceID ) - { - $this->invoiceID = $invoiceID; - } - - private function handle() - { - $this->setPayment(); - - $this->setRemoveAllowed(); - } - - private function setPayment() - { - $payments = Payment::whereInvoiceId( $this->invoiceID ); - - $this->payments = $payments->count() == 0 ? TRUE : FALSE; - } - - private function setRemoveAllowed() - { - if ( $this->payments === FALSE ) return $this->removeAllowed = FALSE; - - $this->removeAllowed = TRUE; - } - -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveInvoices.php b/application/libraries/deletions/RemoveInvoices.php deleted file mode 100644 index afc9629..0000000 --- a/application/libraries/deletions/RemoveInvoices.php +++ /dev/null @@ -1,46 +0,0 @@ -setInvoiceID($invoiceID); - - $this->handle(); - } - - private function setInvoiceID( $invoiceID ) - { - $this->invoiceID = $invoiceID; - } - - private function handle() - { - $this->setPayments(); - - $this->setRemoveAllowed(); - } - - private function setPayments() - { - $payments = Payment::whereInvoiceId($this->invoiceID); - - $this->payments = $payments->count() == 0 ? TRUE : FALSE; - } - - private function setRemoveAllowed() - { - $this->removeAllowed = $this->payments; - } - -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveOffer.php b/application/libraries/deletions/RemoveOffer.php deleted file mode 100644 index 3d74389..0000000 --- a/application/libraries/deletions/RemoveOffer.php +++ /dev/null @@ -1,52 +0,0 @@ -setOfferID($offerID); - - $this->handle(); - } - - public function getRemoveAllowed() - { - return $this->removeAllowed; - } - - private function setOfferID( $offerID ) - { - $this->offerID = $offerID; - } - - private function handle() - { - $this->setProject(); - - $this->setRemoveAllowed(); - } - - private function setProject() - { - $offer = Offer::Find($this->offerID); - - $this->project = is_null($offer->project_id) ? TRUE : FALSE; - } - - private function setRemoveAllowed() - { - if( $this->project === FALSE ) return $this->removeAllowed = FALSE; - - $this->removeAllowed = TRUE; - } -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveProject.php b/application/libraries/deletions/RemoveProject.php deleted file mode 100644 index c47dd1a..0000000 --- a/application/libraries/deletions/RemoveProject.php +++ /dev/null @@ -1,97 +0,0 @@ -setProjectID( $projectID ); - - $this->handle(); - } - - public function getRemoveAllowed() - { - return $this->removeAllowed; - } - - private function setProjectID( $projectID ) - { - $this->projectID = $projectID; - } - - private function handle() - { - $this->setForecast(); - - $this->setInvoices(); - - $this->setProjectemployees(); - - $this->setReservations(); - - $this->setRemoveAllowed(); - - $this->setProjectCosts(); - } - - private function setForecast() - { - $forecast = Forecast::whereProjectId( $this->projectID ); - - $this->forecast = $forecast->count() == 0 ? TRUE : FALSE; - } - - private function setInvoices() - { - $invoices = Invoice::whereProjectId( $this->projectID ); - - $this->invoices = $invoices->count() == 0 ? TRUE : FALSE; - } - - private function setProjectemployees( ) - { - $setProjectemployees = Projectemployee::whereProjectId($this->projectID); - - $this->projectemployees = $setProjectemployees->count() == 0 ? TRUE : FALSE; - } - - private function setReservations( ) - { - $reservations = Reservation::whereProjectId($this->projectID); - - $this->reservations = $reservations->count() == 0 ? TRUE : FALSE; - } - - private function setProjectcosts( ) - { - $projectcosts = Projectcost::whereProjectId($this->projectID); - - $this->projectcosts = $projectcosts->count() == 0 ? TRUE : FALSE; - } - - private function setRemoveAllowed() - { - if( $this->forecast === false ) return $this->removeAllowed = FALSE; - if( $this->invoices === false ) return $this->removeAllowed = FALSE; - if( $this->projectemployees === false ) return $this->removeAllowed = FALSE; - if( $this->reservations === false ) return $this->removeAllowed = FALSE; - if( $this->projectcosts === false ) return $this->removeAllowed = FALSE; - - $this->removeAllowed = TRUE; - } - -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveProjectemployee.php b/application/libraries/deletions/RemoveProjectemployee.php deleted file mode 100644 index 9c8e56e..0000000 --- a/application/libraries/deletions/RemoveProjectemployee.php +++ /dev/null @@ -1,53 +0,0 @@ -setProjectemployeeID( $projectemployeeID ); - - $this->handle(); - } - - public function getRemoveAllowed() - { - return $this->removeAllowed; - } - - private function setProjectemployeeID( $projectemployeeID ) - { - $this->projectemployeeID = $projectemployeeID; - } - - private function handle() - { - $this->setProjectHours(); - - $this->setRemoveAllowed(); - } - - private function setProjecthours() - { - $projecthours = Projecthour::whereProjectemployeeId($this->projectemployeeID); - - $this->projecthours = $projecthours->count() == 0 ?TRUE : FALSE; - } - - private function setRemoveAllowed() - { - if( $this->projecthours === false ) return $this->removeAllowed = FALSE; - - $this->removeAllowed = TRUE; - } - -} \ No newline at end of file diff --git a/application/libraries/deletions/RemoveVat.php b/application/libraries/deletions/RemoveVat.php deleted file mode 100644 index a36e38e..0000000 --- a/application/libraries/deletions/RemoveVat.php +++ /dev/null @@ -1,65 +0,0 @@ -setVatID( $vatID ); - - $this->handle(); - } - - public function getRemoveAllowed() - { - return $this->removeAllowed; - } - - private function setVatID( $vatID ) - { - $this->vatID = $vatID; - } - - private function handle() - { - $this->setProject(); - - $this->setInvoices(); - - $this->setRemoveAllowed(); - } - - private function setProject() - { - $projects = Project::whereVatId( $this->vatID ); - - $this->projects = $projects->count() == 0 ? TRUE : FALSE; - } - - private function setInvoices() - { - $invoices = Invoice::whereVatId( $this->vatID ); - - $this->invoices = $invoices->count() == 0 ? TRUE : FALSE; - } - - private function setRemoveAllowed() - { - if ( $this->projects === FALSE ) return $this->removeAllowed = FALSE; - - if ( $this->invoices === FALSE ) return $this->removeAllowed = FALSE; - - $this->removeAllowed = TRUE; - } - -} \ No newline at end of file diff --git a/application/libraries/index.html b/application/libraries/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/libraries/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/libraries/projects/RemoveForecast.php b/application/libraries/projects/RemoveForecast.php deleted file mode 100644 index 70f8f3b..0000000 --- a/application/libraries/projects/RemoveForecast.php +++ /dev/null @@ -1,36 +0,0 @@ -setForecastID( $forecastID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setForecastID( $forecastID ) - { - $this->forecastID = $forecastID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/projects/RemovePayment.php b/application/libraries/projects/RemovePayment.php deleted file mode 100644 index 918d742..0000000 --- a/application/libraries/projects/RemovePayment.php +++ /dev/null @@ -1,36 +0,0 @@ -setPaymentID( $paymentID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setPaymentID( $paymentID ) - { - $this->paymentID = $paymentID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/projects/RemoveProjecthour.php b/application/libraries/projects/RemoveProjecthour.php deleted file mode 100644 index 37a4f4f..0000000 --- a/application/libraries/projects/RemoveProjecthour.php +++ /dev/null @@ -1,36 +0,0 @@ -setProjecthourID( $projecthourID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setProjecthourID( $projecthourID ) - { - $this->projecthourID = $projecthourID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/projects/RemoveReservation.php b/application/libraries/projects/RemoveReservation.php deleted file mode 100644 index de13dca..0000000 --- a/application/libraries/projects/RemoveReservation.php +++ /dev/null @@ -1,36 +0,0 @@ -setReservationID( $reservationID ); - - $this->handle(); - } - - public function getAllowDelete() - { - return $this->allowDelete; - } - - private function setReservationID( $reservationID ) - { - $this->reservationID = $reservationID; - } - - private function handle() - { - - } - -} \ No newline at end of file diff --git a/application/libraries/reports/Recapprojects.php b/application/libraries/reports/Recapprojects.php deleted file mode 100644 index 6366cc5..0000000 --- a/application/libraries/reports/Recapprojects.php +++ /dev/null @@ -1,285 +0,0 @@ -ci =& get_instance(); - - $this->archive = $archive; - $this->field = $field; - $this->direction = $direction; - - $this->ci->load->Model( 'projects/Invoices_model' ); - - $this->handle(); - } - - public function getProjects() - { - return $this->projects; - } - - private function handle() - { - $this->setProjects(); - - $this->setUniqueEmployees(); - - $this->loopProjects(); - - $this->setInvoicedYears(); - - $this->loopProjectsForInvoicedYears(); - } - - private function setProjects() - { - $this->projects = Project::getActiveProjects( - $this->archive, $this->field, $this->direction )->toArray(); - } - - private function setUniqueEmployees() - { - $this->uniqueEmployees = - Projectemployee::getUniqueEmployeesWithActivity(); - } - - private function loopProjects() - { - $this->index = 0; - foreach ( $this->projects as $this->project ) - { - $this->projectTotals = 0; - - $this->setProjectEmployeeDetails(); - - $this->loopUniqueEmployees(); - - $this->setBudget(); - - $this->setProjectCosts(); - - $this->setBudgetAvailable(); - - $this->setSaldo(); - - $this->setInvoiced(); - - $this->setWorkInProgress(); - - $this->setCurrentFinancialYear(); - - $this->index ++; - } - } - - private function setProjectEmployeeDetails() - { - $this->projectEmployeeDetails = - Projectemployee::getProjectemployeeDetailsPerProject( $this->project['id'] ); - } - - private function loopUniqueEmployees() - { - foreach ( $this->uniqueEmployees as $this->uniqueEmployee ) - { - $this->setProjectEmployeeDetail(); - - $this->setEmployeeBudget(); - - $this->setEmployeeHours(); - - $this->setEmployeeDetails(); - - $this->setProjectTotals(); - } - } - - private function setProjectEmployeeDetail() - { - foreach ( $this->projectEmployeeDetails as $this->projectEmployeeDetail ) - { - if ( $this->uniqueEmployee->id == $this->projectEmployeeDetail->id ) return; - } - - $this->projectEmployeeDetail = FALSE; - } - - private function setEmployeeBudget() - { - if( property_exists($this, 'uniqueEmployee') ) return $this->employeeBudget = 0; - - if( is_null($this->projectEmployeeDetail)) return $this->employeeBudget = 0; - - $this->employeeBudget = - is_null( $this->projectEmployeeDetail['budget'] ) ? 0 : $this->projectEmployeeDetail['budget']; - } - - private function setEmployeeHours() - { - $this->employeeHours = - $this->projectEmployeeDetail ? $this->projectEmployeeDetail->hours : 0; - } - - private function setEmployeeDetails() - { - $this->projects[ $this->index ]['employees'][] = [ - 'id' => $this->uniqueEmployee->id, - 'fullname' => $this->uniqueEmployee->fullname, - 'hours' => $this->employeeHours, - 'revenues' => $this->projectEmployeeDetail ? $this->projectEmployeeDetail->revenues : 0, - 'budget' => $this->employeeBudget, - 'availableHours' => $this->employeeBudget - $this->employeeHours - ]; - } - - private function setProjectTotals() - { - if ( ! isset( $this->projects[ $this->index ]['projectHours'] ) ) - $this->projects[ $this->index ]['projectHours'] = 0; - if ( ! isset( $this->projects[ $this->index ]['projectEuros'] ) ) - $this->projects[ $this->index ]['projectEuros'] = 0; - if ( ! isset( $this->projects[ $this->index ]['hoursAvailable'] ) ) - $this->projects[ $this->index ]['hoursAvailable'] = 0; - - $this->projects[ $this->index ]['projectHours'] += - $this->projectEmployeeDetail ? $this->projectEmployeeDetail->hours : 0; - $this->projects[ $this->index ]['projectEuros'] += - $this->projectEmployeeDetail ? $this->projectEmployeeDetail->revenues : 0; - $this->projects[ $this->index ]['hoursAvailable'] += - $this->employeeBudget - $this->employeeHours; - } - - private function setBudget() - { - $this->projects[ $this->index ]['budget'] = - round( ( $this->projects[ $this->index ]['own_revenue'] + $this->projects[ $this->index ]['other_revenue'] ), 0 ); - } - - private function setProjectCosts() - { - $this->projects[ $this->index ]['projectcosts'] = - Projectcost::getCostsPerPerProject( $this->projects[ $this->index ]['id'] ); - } - - private function setBudgetAvailable() - { - $this->projects[ $this->index ]['budgetAvailable'] = - $this->projects[ $this->index ]['budget'] - $this->projects[ $this->index ]['projectcosts']; - } - - private function setSaldo() - { - $this->projects[ $this->index ]['saldo'] = - $this->projects[ $this->index ]['budgetAvailable'] - $this->projects[ $this->index ]['projectEuros']; - } - - private function setInvoiced() - { - $invoiced = - $this->ci->Invoices_model->getInvoicedPerYearPerProject( $this->projects[ $this->index ]['id'] ); - - foreach ( $invoiced ? $invoiced : [] as $invoice ) - { - $this->projects[ $this->index ]['invoiced'][] = [ - 'year' => $invoice->invoiceyear, - 'invoiced' => $invoice->invoiced - ]; - - $this->setTotalInvoiced( $invoice->invoiced ); - } - - if ( ! isset( $this->projects[ $this->index ]['invoiced'] ) ) - { - $this->projects[ $this->index ]['invoiced'] = []; - $this->projects[ $this->index ]['totalInvoiced'] = 0; - } - } - - private function setTotalInvoiced( $invoiced ) - { - if ( ! isset( $this->projects[ $this->index ]['totalInvoiced'] ) ) - $this->projects[ $this->index ]['totalInvoiced'] = 0; - - $this->projects[ $this->index ]['totalInvoiced'] += $invoiced; - } - - private function setWorkInProgress() - { - $this->projects[ $this->index ]['workInProgress'] = - $this->projects[ $this->index ]['projectEuros'] + - $this->projects[ $this->index ]['projectcosts'] - - $this->projects[ $this->index ]['totalInvoiced']; - - if ( $this->projects[ $this->index ]['workInProgress'] < 0 ) - $this->projects[ $this->index ]['workInProgress'] = 0; - } - - private function setCurrentFinancialYear() - { - $this->currentFinancialYear = $this->project['current_financial_year']; - } - - private function setInvoicedYears() - { - foreach ( $this->projects as $this->project ) - { - foreach ( $this->project['invoiced'] as $year ) - { - if ( in_array( $year['year'], $this->invoicedYears ) ) continue; - - array_push( $this->invoicedYears, $year['year'] ); - } - } - } - - private function loopProjectsForInvoicedYears() - { - $this->index = 0; - - foreach ( $this->projects as $this->project ) - { - foreach ( $this->invoicedYears as $invoiceYear ) - { - $hasYear = FALSE; - foreach ( $this->project['invoiced'] as $year ) - { - if ( $invoiceYear == $year['year'] ) $hasYear = TRUE; - } - - if ( ! $hasYear ) $this->projects[ $this->index ]['invoiced'][] = [ - 'year' => $invoiceYear, - 'invoiced' => 0 - ]; - } - usort( $this->projects[ $this->index ]['invoiced'], function ( $a, $b ) { - return $a['year'] - $b['year']; - } ); - $this->index ++; - } - } -} diff --git a/application/libraries/reports/invoice/Excel/InvoiceForecastSheet.php b/application/libraries/reports/invoice/Excel/InvoiceForecastSheet.php deleted file mode 100644 index 97cc44c..0000000 --- a/application/libraries/reports/invoice/Excel/InvoiceForecastSheet.php +++ /dev/null @@ -1,75 +0,0 @@ - 'project', - 'B' => 'klant', - 'C' => 'Nog te factureren incl. btw', - 'D' => 'Nog te factureren incl. btw lopend boekjaar incl. btw', - 'E' => 'Nog te factureren na lopend boekjaar inc. btw', - 'F' => 'Nog te prognotiseren inc. btw' - ]; - - private $invoiceForecast; - private $sheet; - private $row; - - public function __construct( $invoiceForecast, $sheet ) - { - $this->invoiceForecast = $invoiceForecast; - $this->sheet = $sheet; - - $this->handle(); - } - - private function handle() - { - $this->setHeader(); - - $this->setBody(); - - $this->setTotals(); - } - - private function setHeader() - { - foreach ( self::HEADERS as $cell => $header ) - { - $this->sheet->setCellValue( $cell . '1', $header ); - $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); - } - } - - private function setBody() - { - $this->row = 2; - foreach ( $this->invoiceForecast AS $project ) - { - $this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] ); - $this->sheet->setCellValue( 'B' . $this->row, $project['customer'] ); - $this->sheet->setCellValue( 'C' . $this->row, str_replace( '.', '', $project['needInvoice'] ?? '' ) ); - $this->sheet->setCellValue( 'D' . $this->row, str_replace( '.', '', $project['forecastThisYear'] ?? '' ) ); - $this->sheet->setCellValue( 'E' . $this->row, str_replace( '.', '', $project['forecastOtherYears'] ?? '' ) ); - $this->sheet->setCellValue( 'F' . $this->row, str_replace( '.', '', $project['forecastRemaining'] ?? '' ) ); - - $this->row ++; - } - } - - private function setTotals() - { - $lastRow = $this->row - 1; - $this->sheet->setCellValue( 'C' . $this->row, '=SUM(C2:C' . $lastRow . ')' ); - $this->sheet->setCellValue( 'D' . $this->row, '=SUM(D2:D' . $lastRow . ')' ); - $this->sheet->setCellValue( 'E' . $this->row, '=SUM(E2:E' . $lastRow . ')' ); - $this->sheet->setCellValue( 'F' . $this->row, '=SUM(F2:F' . $lastRow . ')' ); - } - -} diff --git a/application/libraries/reports/invoice/Excel/InvoiceOverviewSheet.php b/application/libraries/reports/invoice/Excel/InvoiceOverviewSheet.php deleted file mode 100644 index 704a69a..0000000 --- a/application/libraries/reports/invoice/Excel/InvoiceOverviewSheet.php +++ /dev/null @@ -1,80 +0,0 @@ - 'project', - 'B' => 'klant', - 'C' => 'Totaal te factureren excl. btw', - 'D' => 'Totaal te factureren incl. btw', - 'E' => 'Gefactureerd overige jaren incl. btw', - 'F' => 'Gefactureerd lopende boekjaar incl. btw', - 'G' => 'Gefactureerd totaal incl. btw', - 'H' => 'Nog te factureren incl. btw' - ]; - - private $invoiceOverview; - private $sheet; - private $row; - - public function __construct( $invoiceOverview, $sheet ) - { - $this->invoiceOverview = $invoiceOverview; - $this->sheet = $sheet; - - $this->handle(); - } - - private function handle() - { - $this->setHeader(); - - $this->setBody(); - - $this->setTotals(); - } - - private function setHeader() - { - foreach ( self::HEADERS as $cell => $header ) - { - $this->sheet->setCellValue( $cell . '1', $header ); - $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); - } - } - - private function setBody() - { - $this->row = 2; - foreach ( $this->invoiceOverview AS $project ) - { - $this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] ); - $this->sheet->setCellValue( 'B' . $this->row, $project['customer'] ); - $this->sheet->setCellValue( 'C' . $this->row, str_replace( '.', '', $project['totalToInvoicingExcl'] ?? '' ) ); - $this->sheet->setCellValue( 'D' . $this->row, str_replace( '.', '', $project['totalToInvoicingIncl'] ?? '' ) ); - $this->sheet->setCellValue( 'E' . $this->row, str_replace( '.', '', $project['totalInvoicedOtherYears'] ?? '' ) ); - $this->sheet->setCellValue( 'F' . $this->row, str_replace( '.', '', $project['totalInvoicedThisYear'] ?? '' ) ); - $this->sheet->setCellValue( 'G' . $this->row, str_replace( '.', '', $project['invoicesTotal'] ?? '' ) ); - $this->sheet->setCellValue( 'H' . $this->row, str_replace( '.', '', $project['needInvoice'] ?? '' ) ); - - $this->row ++; - } - } - - private function setTotals() - { - $lastRow = $this->row - 1; - $this->sheet->setCellValue( 'C' . $this->row, '=SUM(C2:C' . $lastRow . ')' ); - $this->sheet->setCellValue( 'D' . $this->row, '=SUM(D2:D' . $lastRow . ')' ); - $this->sheet->setCellValue( 'E' . $this->row, '=SUM(E2:E' . $lastRow . ')' ); - $this->sheet->setCellValue( 'F' . $this->row, '=SUM(F2:F' . $lastRow . ')' ); - $this->sheet->setCellValue( 'G' . $this->row, '=SUM(G2:G' . $lastRow . ')' ); - $this->sheet->setCellValue( 'H' . $this->row, '=SUM(H2:H' . $lastRow . ')' ); - } -} diff --git a/application/libraries/reports/invoice/Excel/InvoiceSpreadsheet.php b/application/libraries/reports/invoice/Excel/InvoiceSpreadsheet.php deleted file mode 100644 index 4adf92d..0000000 --- a/application/libraries/reports/invoice/Excel/InvoiceSpreadsheet.php +++ /dev/null @@ -1,136 +0,0 @@ -ci =& get_instance(); - - $this->invoiceReport = $invoiceReport; - - $this->ci->load->helper( 'download' ); - - $this->handle(); - } - - private function handle() - { - $this->setSpreadsheet(); - - $this->setInvoiceOverviewSheet(); - - $this->setInvoiceForecast(); - - $this->setMonthForecast(); - - $this->setMonthPayment(); - - $this->setInvoiced(); - - $this->setFilename(); - - $this->setFullPathname(); - - $this->createFile(); - - $this->downloadSpreadsheet(); - } - - private function setSpreadsheet() - { - $this->spreadsheet = new Spreadsheet(); - } - - private function setInvoiceOverviewSheet() - { - $invoiceSheet = new Worksheet( $this->spreadsheet, 'Facturen' ); - - $this->invoiceSheet = - $this->spreadsheet->addSheet( $invoiceSheet ); - - new InvoiceOverviewSheet( $this->invoiceReport['invoiceOverview'], $this->invoiceSheet ); - } - - private function setInvoiceForecast() - { - $invoiceSheet = new Worksheet( $this->spreadsheet, 'prognose' ); - - $this->invoiceSheet = - $this->spreadsheet->addSheet( $invoiceSheet ); - - new InvoiceForecastSheet( $this->invoiceReport['forecasts'], $this->invoiceSheet ); - } - - private function setMonthForecast() - { - $invoiceSheet = new Worksheet( $this->spreadsheet, 'maandprognose' ); - - $this->invoiceSheet = - $this->spreadsheet->addSheet( $invoiceSheet ); - - new MonthForecastSheet( $this->invoiceReport['monthForecasts'], $this->invoiceSheet ); - } - - private function setMonthPayment() - { - $invoiceSheet = new Worksheet( $this->spreadsheet, 'maand betalingen' ); - - $this->invoiceSheet = - $this->spreadsheet->addSheet( $invoiceSheet ); - - new MonthPaymentSheet( $this->invoiceReport['monthPayments'], $this->invoiceSheet ); - } - - private function setInvoiced() - { - $invoiceSheet = new Worksheet( $this->spreadsheet, 'verstuurde facturen' ); - - $this->invoiceSheet = - $this->spreadsheet->addSheet( $invoiceSheet ); - - new InvoicedSheet( $this->invoiceReport['invoiced'], $this->invoiceSheet ); - } - - private function setFilename() - { - $this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx'; - } - - private function setFullPathname() - { - $this->fullpathname = MYROOTPATH . 'documents/spreadsheets/' . $this->filename; - } - - private function createFile() - { - $writer = new Xlsx( $this->spreadsheet ); - - $writer->save( $this->fullpathname ); - } - - private function downloadSpreadsheet() - { - $data = file_get_contents( $this->fullpathname ); - - force_download( $this->filename, $data ); - } - - -} diff --git a/application/libraries/reports/invoice/Excel/InvoicedSheet.php b/application/libraries/reports/invoice/Excel/InvoicedSheet.php deleted file mode 100644 index d0de687..0000000 --- a/application/libraries/reports/invoice/Excel/InvoicedSheet.php +++ /dev/null @@ -1,67 +0,0 @@ - 'factuurnummer', - 'B' => 'project', - 'C' => 'klant', - 'D' => 'factuurdatum', - 'E' => 'exc btw', - 'F' => 'btw', - 'G' => 'incl btw' - ]; - - private $invoiced; - private $sheet; - private $row; - - public function __construct( $invoiced, $sheet ) - { - $this->invoiced = $invoiced; - $this->sheet = $sheet; - - $this->handle(); - } - - private function handle() - { - $this->setHeader(); - - $this->setBody(); - } - - private function setHeader() - { - foreach ( self::HEADERS as $cell => $header ) - { - $this->sheet->setCellValue( $cell . '1', $header ); - $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); - } - } - - private function setBody() - { - $this->row = 2; - foreach ( $this->invoiced AS $invoice ) - { - $vat = ROUND($invoice->invoiceamount * 0.21, 2); - $this->sheet->setCellValue( 'A' . $this->row, $invoice->invoicenumber ); - $this->sheet->setCellValue( 'B' . $this->row, ($invoice->projectnumber . ' ' . $invoice['projectname'])); - $this->sheet->setCellValue( 'C' . $this->row, $invoice->name ); - $this->sheet->setCellValue( 'D' . $this->row, $invoice->invoicenumber ); - $this->sheet->setCellValue( 'E' . $this->row, $invoice->invoiceamount ); - $this->sheet->setCellValue( 'F' . $this->row, $vat ); - $this->sheet->setCellValue( 'G' . $this->row, $invoice->invoiceamount + $vat ); - - $this->row ++; - } - } - -} diff --git a/application/libraries/reports/invoice/Excel/MonthForecastSheet.php b/application/libraries/reports/invoice/Excel/MonthForecastSheet.php deleted file mode 100644 index 6b38844..0000000 --- a/application/libraries/reports/invoice/Excel/MonthForecastSheet.php +++ /dev/null @@ -1,101 +0,0 @@ - 'project', - 'B' => 'klant', - 'C' => 'Nog te factureren incl. btw', - 'D' => 'januari', - 'E' => 'februari', - 'F' => 'maart', - 'G' => 'april', - 'H' => 'mei', - 'I' => 'juni', - 'J' => 'juli', - 'K' => 'augustus', - 'L' => 'september', - 'M' => 'oktober', - 'N' => 'november', - 'O' => 'december', - 'P' => 'Nog te factureren na lopend boekjaar inc. btw', - 'Q' => 'Nog te prognotiseren inc. btw' - ]; - - const MONTH_COLUMNS = ['D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O']; - - private $invoiceForecast; - private $sheet; - private $row; - - public function __construct( $invoiceForecast, $sheet ) - { - $this->invoiceForecast = $invoiceForecast; - $this->sheet = $sheet; - - $this->handle(); - } - - private function handle() - { - $this->setHeader(); - - $this->setBody(); - - $this->setTotals(); - } - - private function setHeader() - { - foreach ( self::HEADERS as $cell => $header ) - { - $this->sheet->setCellValue( $cell . '1', $header ); - $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); - } - } - - private function setBody() - { - $this->row = 2; - foreach ( $this->invoiceForecast AS $project ) - { - $this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] ); - $this->sheet->setCellValue( 'B' . $this->row, $project['customer'] ); - $this->sheet->setCellValue( 'C' . $this->row, str_replace( '.', '', $project['needInvoice'] ?? '' ) ); - - $columnCount = 0; - foreach ( $project['forecastMonths'] as $month ) - { - $column = self::MONTH_COLUMNS[ $columnCount ]; - $forecast = $month['forecastamount']; - $this->sheet->setCellValue( $column . $this->row, $forecast ); - $columnCount ++; - } - - $this->sheet->setCellValue( 'P' . $this->row, str_replace( '.', '', $project['forecastOtherYears'] ?? '' ) ); - $this->sheet->setCellValue( 'Q' . $this->row, str_replace( '.', '', $project['forecastRemaining'] ?? '' ) ); - - $this->row ++; - } - } - - private function setTotals() - { - $lastRow = $this->row - 1; - $this->sheet->setCellValue( 'C' . $this->row, '=SUM(C2:C' . $lastRow . ')' ); - $this->sheet->setCellValue( 'D' . $this->row, '=SUM(D2:D' . $lastRow . ')' ); - foreach ( self::MONTH_COLUMNS as $column ) - { - $this->sheet->setCellValue( $column . $this->row, '=SUM(' . $column . '2:' . $column . $lastRow . ')' ); - } - $this->sheet->setCellValue( 'P' . $this->row, '=SUM(P2:P' . $lastRow . ')' ); - $this->sheet->setCellValue( 'Q' . $this->row, '=SUM(Q2:Q' . $lastRow . ')' ); - } - -} diff --git a/application/libraries/reports/invoice/Excel/MonthPaymentSheet.php b/application/libraries/reports/invoice/Excel/MonthPaymentSheet.php deleted file mode 100644 index d51bd0d..0000000 --- a/application/libraries/reports/invoice/Excel/MonthPaymentSheet.php +++ /dev/null @@ -1,95 +0,0 @@ - 'project', - 'B' => 'klant', - 'C' => 'januari', - 'D' => 'februari', - 'E' => 'maart', - 'F' => 'april', - 'G' => 'mei', - 'H' => 'juni', - 'I' => 'juli', - 'J' => 'augustus', - 'K' => 'september', - 'L' => 'oktober', - 'M' => 'november', - 'N' => 'december', - 'O' => 'Totaal betaald lopend boekjaar inc. btw' - ]; - - const MONTH_COLUMNS = ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']; - - private $invoiceForecast; - private $sheet; - private $row; - - public function __construct( $invoiceForecast, $sheet ) - { - $this->invoiceForecast = $invoiceForecast; - $this->sheet = $sheet; - - $this->handle(); - } - - private function handle() - { - $this->setHeader(); - - $this->setBody(); - - $this->setTotals(); - } - - private function setHeader() - { - foreach ( self::HEADERS as $cell => $header ) - { - $this->sheet->setCellValue( $cell . '1', $header ); - $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); - } - } - - private function setBody() - { - $this->row = 2; - foreach ( $this->invoiceForecast AS $project ) - { - $this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] ); - $this->sheet->setCellValue( 'B' . $this->row, $project['customer'] ); - - $columnCount = 0; - foreach ( $project['monthPayments'] as $month ) - { - $column = self::MONTH_COLUMNS[ $columnCount ]; - $forecast = $month['paymentamount']; - $this->sheet->setCellValue( $column . $this->row, $forecast ); - $columnCount ++; - } - - $formula = '=SUM(C'.$this->row.':N'.$this->row.')'; - $this->sheet->setCellValue( 'O' . $this->row, $formula); - - $this->row ++; - } - } - - private function setTotals() - { - $lastRow = $this->row - 1; - foreach ( self::MONTH_COLUMNS as $column ) - { - $this->sheet->setCellValue( $column . $this->row, '=SUM(' . $column . '2:' . $column . $lastRow . ')' ); - } - $this->sheet->setCellValue( 'O' . $this->row, '=SUM(O2:O' . $lastRow . ')' ); - } - -} \ No newline at end of file diff --git a/application/libraries/reports/invoice/InvoiceForecast.php b/application/libraries/reports/invoice/InvoiceForecast.php deleted file mode 100644 index 9a0a9f6..0000000 --- a/application/libraries/reports/invoice/InvoiceForecast.php +++ /dev/null @@ -1,125 +0,0 @@ -project = $project; - $this->needInvoice = $needInvoice; - $this->year = $year; - - $this->handle(); - } - - public function getProjectDetails() - { - return $this->projectDetails; - } - - public function getNeedInvoice() - { - return $this->needInvoice; - } - - public function getForecastOtherYear() - { - return $this->forecastOtherYears; - } - - public function getForecastRemaining() - { - return $this->forecastRemaining; - } - - private function handle() - { - $this->setCurrentyear(); - - $this->setProjectname(); - - $this->setCustomer(); - - $this->loopForecasts(); - - $this->setForecastRemaining(); - - $this->setProjectDetails(); - } - - private function setCurrentyear() - { - $this->currentYear = date( 'Y' ); - } - - private function setProjectname() - { - $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')'; - } - - private function setCustomer() - { - $this->customer = $this->project->customer->name; - } - - private function loopForecasts() - { - if ( is_null( $this->project->forecasts ) ) return $this->forecastThisYear = 0; - - foreach ( $this->project->forecasts as $this->forecast ) - { - $this->setForecastThisYear(); - - $this->setForecastOtherYears(); - } - } - - private function setForecastThisYear() - { - if ( $this->forecast->year == $this->year ) - $this->forecastThisYear += $this->forecast->forecastamount; - } - - private function setForecastOtherYears() - { - if ( $this->forecast->year != $this->year ) - $this->forecastOtherYears += $this->forecast->forecastamount; - } - - private function setForecastRemaining() - { - $this->forecastRemaining = - $this->needInvoice - $this->forecastThisYear - $this->forecastOtherYears; - } - - private function setProjectDetails() - { - $this->projectDetails = [ - 'projectnumber' => $this->project->projectnumber, - 'projectname' => $this->projectname, - 'customer' => $this->customer, - 'needInvoice' => number_format( $this->needInvoice, 0, ',', '.' ), - 'forecastThisYear' => number_format( $this->forecastThisYear, 0, ',', '.' ), - 'forecastOtherYears' => number_format( $this->forecastOtherYears, 0, ',', '.' ), - 'forecastRemaining' => number_format( $this->forecastRemaining, 0, ',', '.' ), - ]; - } - -} diff --git a/application/libraries/reports/invoice/InvoiceOverview.php b/application/libraries/reports/invoice/InvoiceOverview.php deleted file mode 100644 index f806a08..0000000 --- a/application/libraries/reports/invoice/InvoiceOverview.php +++ /dev/null @@ -1,151 +0,0 @@ -project = $project; - - $this->year = $year; - - $this->handle(); - } - - public function getProjectDetails() - { - return $this->projectDetails; - } - - public function getNeedinvoice() - { - return $this->needInvoice; - } - - private function handle() - { - $this->setProjectnumber(); - - $this->setProjectname(); - - $this->setCustomer(); - - $this->setTotalToInvoicingExcl(); - - $this->setTotalToInvoicingIncl(); - - $this->setTotalInvoicedOtherYears(); - - $this->setTotalInvoicedThisYear(); - - $this->setPaymentPerProject(); - - $this->setInvoicesTotal(); - - $this->setInvoicesToPay(); - - $this->setNeedInvoice(); - - $this->setProjectDetails(); - } - - private function setProjectnumber() - { - $this->projectnumber = $this->project->projectnumber; - } - - private function setProjectname() - { - $this->projectname = $this->project->projectname; - } - - private function setCustomer() - { - $this->customer = $this->project->customer->name; - } - - private function setTotalToInvoicingExcl() - { - $offer = $this->project->offer; - - $this->totalToInvoicingExcl = - $offer->own_revenue + $offer->other_revenue + $offer->costs; - } - - private function setTotalToInvoicingIncl() - { - $this->totalToInvoicingIncl = - $this->totalToInvoicingExcl * ( 1 + ( $this->project->vat->vatrate / 100 ) ); - } - - private function setTotalInvoicedOtherYears() - { - $this->totalInvoicedOtherYears = - Invoice::invoicePerYear( $this->project->id, $this->year, FALSE ); - } - - private function setTotalInvoicedThisYear() - { - $this->totalInvoicedThisYear = - Invoice::invoicePerYear( $this->project->id, $this->year, TRUE ); - } - - private function setPaymentPerProject() - { - $this->projectPayment = Payment::getPaymentPerProject( $this->project->id ); - } - - private function setInvoicesTotal() - { - $this->invoicesTotal = - $this->totalInvoicedOtherYears + $this->totalInvoicedThisYear; - } - - private function setInvoicesToPay() - { - $this->invoicesToPay = $this->invoicesTotal - $this->projectPayment; - } - - private function setNeedInvoice() - { - $this->needInvoice = - $this->totalToInvoicingIncl - $this->invoicesTotal; - } - - private function setProjectDetails() - { - $this->projectDetails = [ - 'projectnumber' => $this->projectnumber, - 'projectname' => $this->projectname, - 'customer' => $this->customer, - 'totalToInvoicingExcl' => number_format( $this->totalToInvoicingExcl ?? 0, 0, ',', '.' ), - 'totalToInvoicingIncl' => number_format( $this->totalToInvoicingIncl ?? 0, 0, ',', '.' ), - 'totalInvoicedOtherYears' => number_format( $this->totalInvoicedOtherYears ?? 0, 0, ',', '.' ), - 'totalInvoicedThisYear' => number_format( $this->totalInvoicedThisYear ?? 0, 0, ',', '.' ), - 'invoicesTotal' => number_format( $this->invoicesTotal ?? 0, 0, ',', '.' ), - 'projectPayment' => number_format( $this->projectPayment ?? 0, 0, ',', '.' ), - 'invoiceToPay' => number_format( $this->invoicesToPay ?? 0, 0, ',', '.' ), - 'needInvoice' => number_format( $this->needInvoice ?? 0, 0, ',', '.' ) - ]; - } -} diff --git a/application/libraries/reports/invoice/Invoices.php b/application/libraries/reports/invoice/Invoices.php deleted file mode 100644 index 9740376..0000000 --- a/application/libraries/reports/invoice/Invoices.php +++ /dev/null @@ -1,133 +0,0 @@ -year = $year; - $this->orderType = $orderType; - $this->orderDirection = $orderDirection; - $this->archive = $archive; - - $this->handle(); - } - - public function getInvoiceReport() - { - return $this->invoiceReport; - } - - private function handle() - { - $this->setProjects(); - - $this->loopProjects(); - - //only projects with payments also archived projects - $this->setMonthPayments(); - - $this->setInvoicedyears(); - - $this->setInvoiced(); - - $this->setInvoiceReport(); - } - - private function setProjects() - { - $this->projects = - Project::getProjectsForReport( $this->orderType, $this->orderDirection, $this->archive ); - } - - private function loopProjects() - { - foreach ( $this->projects as $this->project ) - { - $this->setInvoiceOverview(); - - $this->setInvoiceForecasts(); - - $this->setMonthForecasts(); - } - } - - private function setInvoiceOverview() - { - $this->invoiceOverview = new InvoiceOverview( $this->project, $this->year ); - - $this->invoiceOverviews[] = $this->invoiceOverview->getProjectDetails(); - } - - private function setInvoiceForecasts() - { - $this->invoiceForecast = - new InvoiceForecast( $this->project, $this->invoiceOverview->getNeedinvoice(), $this->year ); - - $this->invoiceForecasts[] = $this->invoiceForecast->getProjectDetails(); - } - - public function setMonthForecasts() - { - $this->monthForecast = - new MonthForecast( $this->invoiceForecast, $this->project, $this->year ); - - $this->monthForecasts[] = $this->monthForecast->getProjectDetails(); - } - - public function setMonthPayments() - { - $monthPayment = new MonthPayments( - $this->year, $this->orderType, $this->orderDirection ); - - $this->monthPayments = $monthPayment->getProjectDetails(); - } - - private function setInvoiced() - { - $this->invoiced = Invoice::getInvoiced( $this->year, $this->orderType, $this->orderDirection ); - } - - private function setInvoicedYears() - { - $this->invoicedYears = Invoice::selectRaw( 'DATE_FORMAT(invoicedate, "%Y") AS years' ) - ->distinct() - ->orderBy( 'invoicedate' ) - ->pluck( 'years' ); - } - - private function setInvoiceReport() - { - $this->invoiceReport = [ - 'invoiceOverview' => $this->invoiceOverviews, - 'forecasts' => $this->invoiceForecasts, - 'monthForecasts' => $this->monthForecasts, - 'monthPayments' => $this->monthPayments, - 'invoicedYears' => $this->invoicedYears, - 'invoiced' => $this->invoiced - ]; - } -} diff --git a/application/libraries/reports/invoice/MonthForecast.php b/application/libraries/reports/invoice/MonthForecast.php deleted file mode 100644 index c2fb537..0000000 --- a/application/libraries/reports/invoice/MonthForecast.php +++ /dev/null @@ -1,92 +0,0 @@ -project = $project; - $this->invoiceForecast = $invoiceForecast; - $this->year = $year; - - $this->handle(); - } - - public function getProjectDetails() - { - return $this->projectDetails; - } - - private function handle() - { - $this->setProjectname(); - - $this->setCustomer(); - - $this->setInitialsForecastMonths(); - - $this->loopForecasts(); - - $this->setProjectDetails(); - } - - private function setProjectname() - { - $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')'; - } - - private function setCustomer() - { - $this->customer = $this->project->customer->name; - } - - private function setInitialsForecastMonths() - { - for ( $i = 0; $i < 12; $i ++ ) - { - $this->forecastMonths[ $i ] = ['forecastamount' => 0]; - } - } - - private function loopForecasts() - { - foreach ( $this->project->forecasts as $this->forecast ) - { - $this->setMonthForecast(); - } - } - - private function setMonthForecast() - { - if ( $this->forecast->year == $this->year ) - $this->forecastMonths[ $this->forecast->month_id ]['forecastamount'] += $this->forecast->forecastamount; - } - - private function setProjectDetails() - { - $this->projectDetails = [ - 'projectnumber' => $this->project->projectnumber, - 'projectname' => $this->projectname, - 'customer' => $this->customer, - 'needInvoice' => number_format( $this->invoiceForecast->getNeedInvoice(), 0, ',', '.' ), - 'forecastOtherYears' => number_format( $this->invoiceForecast->getForecastOtherYear(), 0, ',', '.' ), - 'forecastRemaining' => number_format( $this->invoiceForecast->getForecastRemaining(), 0, ',', '.' ), - 'forecastMonths' => $this->forecastMonths - ]; - } - -} diff --git a/application/libraries/reports/invoice/MonthPayments.php b/application/libraries/reports/invoice/MonthPayments.php deleted file mode 100644 index 0508e8f..0000000 --- a/application/libraries/reports/invoice/MonthPayments.php +++ /dev/null @@ -1,128 +0,0 @@ -year = $year; - $this->orderType = $orderType; - $this->orderDirection = $orderDirection; - - $this->handle(); - } - - public function getProjectDetails() - { - return $this->projectDetails; - } - - private function handle() - { - $this->setProjectsWithPayments(); - - $this->loopProjectsWithPayments(); - } - - private function setProjectsWithPayments() - { - $projectsArray = Payment::getProjectsWithPayments( $this->year ); - - $this->projectsWithPayments = - Project::getProjectsForReport( - $this->orderType, $this->orderDirection, FALSE, $projectsArray ); - } - - private function loopProjectsWithPayments() - { - foreach ( $this->projectsWithPayments as $this->project ) - { - $this->setProjectname(); - - $this->setCustomer(); - - $this->setInitialsMonthPayments(); - - $this->loopPayments(); - - $this->setProjectDetails(); - } - } - - private function setProjectname() - { - $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')'; - } - - private function setCustomer() - { - $this->customer = $this->project->customer->name; - } - - private function setInitialsMonthPayments() - { - for ( $i = 1; $i <= 12; $i ++ ) - { - $this->monthPayments[ $i ] = ['paymentamount' => 0]; - } - } - - private function loopPayments() - { - $this->totalProjectPayments = 0; - foreach ( $this->project->invoices as $invoice ) - { - foreach ( $invoice->payments as $this->payment ) - { - $this->setMonthPayments(); - - $this->setTotalProjectPayments(); - } - } - } - - private function setMonthPayments() - { - $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) ); - $paymentMonth = date( 'n', strtotime( $this->payment->paymentdate ) ); - - if ( $paymentYear == $this->year ) - $this->monthPayments[ $paymentMonth ]['paymentamount'] += $this->payment->paymentamount; - } - - private function setTotalProjectPayments() - { - $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) ); - - if ( $paymentYear == $this->year ) - $this->totalProjectPayments += $this->payment->paymentamount; - } - - private function setProjectDetails() - { - $this->projectDetails[] = [ - 'projectnumber' => $this->project->projectnumber, - 'projectname' => $this->projectname, - 'customer' => $this->customer, - 'monthPayments' => $this->monthPayments, - 'totalProjectPayments' => number_format( $this->totalProjectPayments, 0, ',', '.' ) - ]; - } -} diff --git a/application/libraries/validation/Validation.php b/application/libraries/validation/Validation.php deleted file mode 100644 index bbe8571..0000000 --- a/application/libraries/validation/Validation.php +++ /dev/null @@ -1,224 +0,0 @@ -ci =& get_instance(); - } - - public function validate( $fieldValue, $validationField = FALSE ) - { - $this->setValidationField( $validationField ); - - $this->setFieldValue( $fieldValue ); - - $this->handle(); - } - - public function setValidationField( $validationfield ) - { - $this->validationField = $validationfield; - } - - public function getErrorMessages() - { - return $this->errorMessages; - } - - public function getValidationResult() - { - return $this->validationResult; - } - - private function handle() - { - $this->setValidations(); - - $this->checkValidations(); - - $this->setValidationResult(); - } - - private function setValidations() - { - $this->validations = explode( '|', $this->validationField['validations'] ); - } - - private function setFieldValue( $fieldValue ) - { - $this->fieldValue = $fieldValue; - } - - private function setValidationResult() - { - if ( count( $this->errorMessages ) == 0 ) return $this->validationResult = TRUE; - - $this->validationResult = FALSE; - } - - private function checkValidations() - { - foreach ( $this->validations as $this->validation ) - { - if ( $this->validation == 'required' ) $this->checkRequired(); - if ( $this->validation == 'alpha' ) $this->checkAlfa(); - if ( $this->validation == 'alphaNumeric' ) $this->checkAlfanumeric(); - if ( $this->validation == 'alphaNumericSpaces' ) $this->checkAlphaNumericSpaces(); - if ( $this->validation == 'alphaDash' ) $this->checkAlphaDash(); - if ( $this->validation == 'numeric' ) $this->checkNumeric(); - if ( $this->validation == 'integer' ) $this->checkInteger(); - if ( $this->validation == 'decimal' ) $this->checkDecimal(); - if ( $this->validation == 'email' ) $this->checkEmail(); - if ( $this->validation == 'unique' ) $this->checkUnique(); - if( $this->validation == 'date' ) $this->checkdate(); - if ( substr( $this->validation, 0, 9 ) == 'minlength' ) $this->checkMinlength(); - if ( substr( $this->validation, 0, 9 ) == 'maxlength' ) $this->checkMaxlength(); - if ( substr( $this->validation, 0, 8 ) == 'minvalue' ) $this->checkMinvalue(); - if ( substr( $this->validation, 0, 8 ) == 'maxvalue' ) $this->checkMaxvalue(); - } - } - - public function checkRequired() - { - if ( ! $this->fieldValue || empty( $this->fieldValue ) || strlen( $this->fieldValue ) == 0 ) - $this->errorMessages[] = 'veld is verplicht'; - } - - public function checkAlfa() - { - $value = ctype_alpha( $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen letters toegestaan'; - } - - public function checkAlfaNumeric() - { - $value = ctype_alnum( (string) $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen letters en cijfers toegestaan'; - - return $value; - } - - public function checkAlphaNumericSpaces() - { - $value = (bool) preg_match( '/^[A-Z0-9 ]+$/i', $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen letters, cijfers en spaties toegestaan'; - } - - public function checkAlphaDash() - { - $value = (bool) preg_match( '/^[a-z0-9_-]+$/i', $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen letters, cijfers en streepjes toegestaan'; - } - - public function checkNumeric() - { - $value = (bool) preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen getallen toegestaan'; - } - - public function checkInteger() - { - $value = (bool) preg_match( '/^[\-+]?[0-9]+$/', $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen gehele getallen toegestaan'; - } - - public function checkDecimal() - { - $value = is_numeric( $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'alleen getallen toegestaan'; - } - - public function checkEmail() - { - if ( ! $this->fieldValue || empty( $this->fieldValue ) || strlen( $this->fieldValue ) == 0 ) return; - - $value = (bool) filter_var( $this->fieldValue, FILTER_VALIDATE_EMAIL ); - - if ( ! $value ) $this->errorMessages[] = 'ongeldig emailadres'; - } - - public function checkUnique() - { - $recordID = $this->ci->input->post( 'id' ); - - $model = $this->validationField['model']; - $field = $this->validationField['field']; - - $value = $this->ci - ->$model - ->checkUnique( $recordID, $field, $this->fieldValue ); - - if ( ! $value ) $this->errorMessages[] = 'invoer moet uniek zijn'; - } - - public function checkDate() - { - if( empty($this->fieldValue) ) return; - - $dateParts = explode('-', $this->fieldValue); - - if( count($dateParts) != 3) $dateParts = explode('/', $this->fieldValue); - - if( count($dateParts) != 3) - return $this->errorMessages[] = 'invoer is geen datum'; - - if( ! checkdate($dateParts[1], $dateParts[0], $dateParts[2] )) - $this->errorMessages[] = 'invoer is geen datum'; - } - - private function checkMinlength() - { - $length = explode( '-', $this->validation ); - - if ( strlen( $this->fieldValue ) < $length[1] ) - $this->errorMessages[] = 'moet minimaal uit ' . $length[1] . ' karakters bestaan'; - } - - private function checkMaxlength() - { - $length = explode( $this->validation, '-' ); - - if ( strlen( $this->fieldValue ) > $length[1] ) - $this->errorMessages[] = 'mag maximaal uit ' . $length[1] . ' karakters bestaan'; - } - - private function checkMinValue() - { - $value = explode( $this->validation, '-' ); - - if( $this->fieldValue < $value[1]) - $this->errorMessages[] = 'moet minimaal ' . $value[1] . ' zijn'; - } - - private function checkMaxValue() - { - $value = explode( $this->validation, '-' ); - - if( $this->fieldValue > $value[1]) - $this->errorMessages[] = 'mag maximaal ' . $value[1] . ' zijn'; - } - - -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/BaseValidation.php b/application/libraries/validation/inputValidations/BaseValidation.php deleted file mode 100644 index 0b8cba2..0000000 --- a/application/libraries/validation/inputValidations/BaseValidation.php +++ /dev/null @@ -1,91 +0,0 @@ -ci =& get_instance(); - - $this->validateInput(); - } - - public function getValidationResult() - { - return $this->validationResult; - } - - public function validateInput() - { - $this->loopFields(); - } - - public function getErrorMessages( ) - { - return $this->errorMessages; - } - - private function loopFields() - { - foreach ( $this->validationFields as $this->key => $this->validationField ) - { - $this->validation = new Validation(); - - $this->setInputfield(); - - $this->validateFieldvalue(); - - $this->setFieldname(); - - $this->setValidationResult(); - - $this->setErrorMesagges(); - } - } - - private function setInputfield() - { - $this->fieldValue = $this->ci->input->post( $this->key ); - } - - private function validateFieldvalue() - { - $this->validation->validate( $this->fieldValue, $this->validationField ); - } - - private function setFieldname() - { - $this->fieldname = $this->validationField['fieldname']; - } - - private function setErrorMesagges() - { - $this->errorMessages[ $this->fieldname ] = $this->validation->getErrorMessages(); - } - - private function setValidationResult() - { - if( $this->validationResult === FALSE ) return; - - $this->validationResult = $this->validation->getValidationResult(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/CustomerValidation.php b/application/libraries/validation/inputValidations/CustomerValidation.php deleted file mode 100644 index a3fd305..0000000 --- a/application/libraries/validation/inputValidations/CustomerValidation.php +++ /dev/null @@ -1,32 +0,0 @@ - [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'name' - ], - 'email' => [ - 'validations' => 'email', - 'fieldname' => 'email' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/EmployeeTargetValidation.php b/application/libraries/validation/inputValidations/EmployeeTargetValidation.php deleted file mode 100644 index cdff06f..0000000 --- a/application/libraries/validation/inputValidations/EmployeeTargetValidation.php +++ /dev/null @@ -1,40 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'gebruiker' - ], - 'startmonth' => [ - 'validations' => 'integer', - 'fieldname' => 'startmaand' - ], - 'startyear' => [ - 'validations' => 'required|integer', - 'fieldname' => 'startjaar' - ], - 'target' =>[ - 'validations' => 'integer', - 'fieldname' => 'uren target' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ExternalValidation.php b/application/libraries/validation/inputValidations/ExternalValidation.php deleted file mode 100644 index 9c29b90..0000000 --- a/application/libraries/validation/inputValidations/ExternalValidation.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'contact' - ], - 'email' => [ - 'validations' => 'email', - 'fieldname' => 'email' - ], - 'rate' => [ - 'validations' => 'numeric', - 'fieldname' => 'tarief' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ForecastValidation.php b/application/libraries/validation/inputValidations/ForecastValidation.php deleted file mode 100644 index b70f9dc..0000000 --- a/application/libraries/validation/inputValidations/ForecastValidation.php +++ /dev/null @@ -1,40 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'project' - ], - 'year' => [ - 'validations' => 'integer', - 'fieldname' => 'jaar' - ], - 'month_id' => [ - 'validations' => 'integer', - 'fieldname' => 'maand' - ], - 'forecastamount' => [ - 'validations' => 'number', - 'fieldname' => 'bedrag' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/InvoiceValidation.php b/application/libraries/validation/inputValidations/InvoiceValidation.php deleted file mode 100644 index 3bb1ba8..0000000 --- a/application/libraries/validation/inputValidations/InvoiceValidation.php +++ /dev/null @@ -1,44 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'project' - ], - 'invoicedate' => [ - 'validations' => 'date', - 'fieldname' => 'factuurdatum' - ], - 'forecastdate' => [ - 'validations' => 'date', - 'fieldname' => 'prognosedatum' - ], - 'invoiceamount' => [ - 'validations' => 'number', - 'fieldname' => 'factuurbedrag' - ], - 'forecastamount' => [ - 'validations' => 'number', - 'fieldname' => 'prognosebedrag' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/LoginValidation.php b/application/libraries/validation/inputValidations/LoginValidation.php deleted file mode 100644 index c9f1c76..0000000 --- a/application/libraries/validation/inputValidations/LoginValidation.php +++ /dev/null @@ -1,28 +0,0 @@ - [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'gebruikersnaam' - ], - 'password' => [ - 'validations' => 'required', - 'fieldname' => 'wachtwoord' - ] - ]; - - public function __construct() - { - parent::__construct(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/OfferValidation.php b/application/libraries/validation/inputValidations/OfferValidation.php deleted file mode 100644 index ac730a2..0000000 --- a/application/libraries/validation/inputValidations/OfferValidation.php +++ /dev/null @@ -1,44 +0,0 @@ - [ - 'validations' => 'required|numeric', - 'fieldname' => 'klant' - ], - 'startdate' => [ - 'validations' => 'required|date', - 'fieldname' => 'offertedatum' - ], - 'acceptdate' => [ - 'validations' => 'date', - 'fieldname' => 'acceptatiedatum' - ], - 'rejectdate' => [ - 'validations' => 'date', - 'fieldname' => 'afwijsdatum' - ], - 'acceptance_chance' => [ - 'validations' => 'numeric', - 'fieldname' => 'afwijsdatum|minvalue-0|maxvalue-100' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/OrganisationValidation.php b/application/libraries/validation/inputValidations/OrganisationValidation.php deleted file mode 100644 index 1002d32..0000000 --- a/application/libraries/validation/inputValidations/OrganisationValidation.php +++ /dev/null @@ -1,47 +0,0 @@ - [ - 'validations' => 'required|alphaNumeric', - 'fieldname' => 'brinnummer' - ], - 'naam' => [ - 'validations' => 'required', - 'fieldname' => 'Organisatienaam' - ], - 'naamkort' => [ - 'validations' => 'required', - 'fieldname' => 'Organisatienaam (kort)' - ], - 'vestiging' => [ - 'validations' => 'required|alphaNumeric|unique', - 'fieldname' => 'vestigingsnummer', - 'model' => 'organisations_model', - 'field' => 'vestiging' - ], - 'email' => [ - 'validations' => 'email', - 'fieldname' => 'email' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } - -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/PasswordRequestValidation.php b/application/libraries/validation/inputValidations/PasswordRequestValidation.php deleted file mode 100644 index 5e82827..0000000 --- a/application/libraries/validation/inputValidations/PasswordRequestValidation.php +++ /dev/null @@ -1,28 +0,0 @@ - [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'gebruikersnaam' - ], - 'email' => [ - 'validations' => 'required|email', - 'fieldname' => 'email' - ] - ]; - - public function __construct() - { - parent::__construct(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/PaymentValidation.php b/application/libraries/validation/inputValidations/PaymentValidation.php deleted file mode 100644 index bce826f..0000000 --- a/application/libraries/validation/inputValidations/PaymentValidation.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'factuur' - ], - 'paymentdate' => [ - 'validations' => 'date', - 'fieldname' => 'betaaldatum' - ], - 'paymentamount' => [ - 'validations' => 'number', - 'fieldname' => 'bedrag' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ProjectValidation.php b/application/libraries/validation/inputValidations/ProjectValidation.php deleted file mode 100644 index ffd7d83..0000000 --- a/application/libraries/validation/inputValidations/ProjectValidation.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'klant' - ], - 'startdate' => [ - 'validations' => 'required|date', - 'fieldname' => 'start project' - ], - 'enddate' => [ - 'validations' => 'date', - 'fieldname' => 'eind project' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ProjectcostValidation.php b/application/libraries/validation/inputValidations/ProjectcostValidation.php deleted file mode 100644 index 791c619..0000000 --- a/application/libraries/validation/inputValidations/ProjectcostValidation.php +++ /dev/null @@ -1,44 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'project' - ], - 'external_id' => [ - 'validations' => 'required|integer', - 'fieldname' => 'externe' - ], - 'date' => [ - 'validations' => 'date', - 'fieldname' => 'datum' - ], - 'costs' => [ - 'validations' => 'number', - 'fieldname' => 'kosten' - ], - 'payed' => [ - 'validations' => 'number', - 'fieldname' => 'betaald' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ProjectemployeeValidation.php b/application/libraries/validation/inputValidations/ProjectemployeeValidation.php deleted file mode 100644 index f4e65b2..0000000 --- a/application/libraries/validation/inputValidations/ProjectemployeeValidation.php +++ /dev/null @@ -1,43 +0,0 @@ - [ - 'validations' => 'integer', - 'fieldname' => 'klant' - ], - 'startdate' => [ - 'validations' => 'date', - 'fieldname' => 'start project' - ], - 'enddate' => [ - 'validations' => 'date', - 'fieldname' => 'eind project' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - - $this->handleSpecificValidations(); - } - - protected function handleSpecificValidations() - { - - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ProjecthourValidation.php b/application/libraries/validation/inputValidations/ProjecthourValidation.php deleted file mode 100644 index 3d0f6bd..0000000 --- a/application/libraries/validation/inputValidations/ProjecthourValidation.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'projectmedewerker' - ], - 'hourdate' => [ - 'validations' => 'date', - 'fieldname' => 'datum' - ], - 'hours' => [ - 'validations' => 'number', - 'fieldname' => 'uren' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ReservationValidation.php b/application/libraries/validation/inputValidations/ReservationValidation.php deleted file mode 100644 index c029a43..0000000 --- a/application/libraries/validation/inputValidations/ReservationValidation.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - 'validations' => 'required|integer', - 'fieldname' => 'project' - ], - 'external_id' =>[ - 'validations' => 'required|integer', - 'fieldname' => 'onderaannemer' - ], - 'reservationamount' => [ - 'validations' => 'number', - 'fieldname' => 'bedrag' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/UserValidation.php b/application/libraries/validation/inputValidations/UserValidation.php deleted file mode 100644 index 52d99e0..0000000 --- a/application/libraries/validation/inputValidations/UserValidation.php +++ /dev/null @@ -1,48 +0,0 @@ - [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'firstname' - ], - 'lastname' => [ - 'validations' => 'required|alphaNumericSpaces', - 'fieldname' => 'lastname' - ], - 'email' => [ - 'validations' => 'required|email|unique', - 'fieldname' => 'email', - 'model' => 'User_model', - 'field' => 'email' - ], - 'username' => [ - 'validations' => 'required|alphanumeric|minlength-4|unique', - 'fieldname' => 'username', - 'model' => 'User_model', - 'field' => 'username' - ], - 'hourlyrate' =>[ - 'validations' => 'decimal', - 'fieldname' => 'uurtarief' - ] - ]; - - public function __construct() - { - parent::__construct(); - - $this->ci =& get_instance(); - } -} \ No newline at end of file diff --git a/application/logs/index.html b/application/logs/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/logs/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/migrations/001_add_two_factor_authentication.sql b/application/migrations/001_add_two_factor_authentication.sql deleted file mode 100644 index 58b12de..0000000 --- a/application/migrations/001_add_two_factor_authentication.sql +++ /dev/null @@ -1,26 +0,0 @@ --- Migration: Add Two-Factor Authentication Support --- Description: Adds 2FA columns to users table and creates table for email OTP codes --- Date: 2025-10-17 - --- Add 2FA columns to users table -ALTER TABLE `users` -ADD COLUMN `two_factor_enabled` VARCHAR(1) NOT NULL DEFAULT 'F' COMMENT 'T=enabled, F=disabled' AFTER `role`, -ADD COLUMN `two_factor_method` VARCHAR(20) NULL DEFAULT NULL COMMENT 'email or authenticator' AFTER `two_factor_enabled`, -ADD COLUMN `two_factor_secret` VARCHAR(255) NULL DEFAULT NULL COMMENT 'TOTP secret for Google Authenticator' AFTER `two_factor_method`; - --- Create table for email OTP codes -CREATE TABLE `user_otp_codes` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `user_id` INT(11) UNSIGNED NOT NULL, - `otp_code` VARCHAR(6) NOT NULL, - `expires_at` TIMESTAMP NOT NULL, - `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `used` VARCHAR(1) NOT NULL DEFAULT 'F' COMMENT 'T=used, F=not used', - PRIMARY KEY (`id`), - KEY `idx_user_id` (`user_id`), - KEY `idx_expires_at` (`expires_at`), - CONSTRAINT `fk_otp_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- Create index for faster lookups -CREATE INDEX `idx_users_two_factor` ON `users` (`two_factor_enabled`, `two_factor_method`); diff --git a/application/models/beheer/Customer_model.php b/application/models/beheer/Customer_model.php deleted file mode 100644 index 4ca6450..0000000 --- a/application/models/beheer/Customer_model.php +++ /dev/null @@ -1,18 +0,0 @@ - $userId, - 'otp_code' => $otpCode, - 'expires_at' => $expiresAt, - 'used' => 'F' - ]; - - // Use direct insert since this table doesn't have audit columns - $this->db->insert($this->tablename, $data); - - return $otpCode; - } - - /** - * Verify an OTP code for a user - * @param int $userId User ID - * @param string $otpCode The OTP code to verify - * @return bool True if valid, false otherwise - */ - public function verifyOTP($userId, $otpCode) - { - // Get the most recent unused OTP for this user - $sql = " - SELECT * FROM {$this->tablename} - WHERE user_id = ? - AND otp_code = ? - AND used = 'F' - AND expires_at > NOW() - ORDER BY created_at DESC - LIMIT 1 - "; - - $query = $this->db->query($sql, [$userId, $otpCode]); - - if ($query->num_rows() == 0) { - return false; - } - - $result = $query->row(); - - // Mark OTP as used (use direct update since this table doesn't have audit columns) - $this->db->where('id', $result->id); - $this->db->update($this->tablename, ['used' => 'T']); - - return true; - } - - /** - * Clean up expired OTP codes - * @return int Number of deleted records - */ - public function cleanupExpiredOTPs() - { - $this->sql = "DELETE FROM {$this->tablename} WHERE expires_at < NOW() OR used = 'T'"; - $this->db->query($this->sql); - - return $this->db->affected_rows(); - } - - /** - * Delete all OTP codes for a user - * @param int $userId User ID - */ - public function deleteUserOTPs($userId) - { - $this->db->where('user_id', $userId); - $this->db->delete($this->tablename); - } -} diff --git a/application/models/beheer/User_model.php b/application/models/beheer/User_model.php deleted file mode 100644 index bcc3ca4..0000000 --- a/application/models/beheer/User_model.php +++ /dev/null @@ -1,41 +0,0 @@ -get( [ - 'UCASE(username)' => strtoupper( $username )], FALSE, TRUE); - - return $user; - } - - public function checkUnique($recordID, $field, $fieldValue) - { - $this->sql = " - SELECT * - FROM users - WHERE ucase( {$field} ) = '".strtoupper($fieldValue)."' - AND id != {$recordID} "; - - $result = $this->get_query_row(); - - if( ! $result ) return TRUE; - - return FALSE; - } - -} \ No newline at end of file diff --git a/application/models/eloquent/BaseModel.php b/application/models/eloquent/BaseModel.php deleted file mode 100644 index 807689d..0000000 --- a/application/models/eloquent/BaseModel.php +++ /dev/null @@ -1,59 +0,0 @@ -created_by = $user->username; - $model->updated_by = $user->username; - } - } ); - static::updating( function ( $model ) { - static::$oldValue = json_encode($model->original); - - if ( AUTHENTICATED ) - { - $user = User::find(USERID); - $model->updated_by = $user->username; - } - } ); - - } -} \ No newline at end of file diff --git a/application/models/eloquent/Comment.php b/application/models/eloquent/Comment.php deleted file mode 100644 index f608412..0000000 --- a/application/models/eloquent/Comment.php +++ /dev/null @@ -1,52 +0,0 @@ -belongsTo( 'User' ); - } - - public static function getComments( $foreignID, $tablename ) - { - $comments = Comment::orderBy( 'comment_date', 'desc' ) - ->with( [ - 'user' => function ( $q ) { - $q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" ); - }] ) - ->whereForeignId( $foreignID ) - ->whereForeignTable( $tablename ) - ->get(); - - foreach ( $comments as $comment ) - { - $comment->comment = base64_decode( $comment->comment ); - } - - return $comments; - } - - public static function addComment( $foreignID, $tablename ) - { - $data = [ - 'foreign_id' => $foreignID, - 'foreign_table' => $tablename, - 'user_id' => USERID, - 'comment_date' => date( 'Y-m-d H:i:s' ) - ]; - - $comment = Comment::create( $data ); - - return $comment['id']; - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/Customer.php b/application/models/eloquent/Customer.php deleted file mode 100644 index 6fbeab1..0000000 --- a/application/models/eloquent/Customer.php +++ /dev/null @@ -1,48 +0,0 @@ -whereArchive( 'F' ); - - $customers = $customers->get(); - - return $customers; - } - - public static function saveCustomer( $customerID, $customer ) - { - $customer = (array)$customer; - - if( $customerID == 0) - { - $customer = Customer::create($customer); - $customerID = $customer['id']; - } - else - { - Customer::whereId($customerID)->update($customer); - } - - return $customerID; - } - - public static function removeCustomer($customerID) - { - Customer::whereId($customerID)->delete(); - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/Document.php b/application/models/eloquent/Document.php deleted file mode 100644 index 5339564..0000000 --- a/application/models/eloquent/Document.php +++ /dev/null @@ -1,32 +0,0 @@ -belongsTo( 'User' ); - } - - public static function getDocuments( $foreignID) - { - $documents = Document::orderBy( 'uploaddate', 'desc' ) - ->with( [ - 'user' => function ( $q ) { - $q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" ); - }] ) - ->whereForeignId( $foreignID ) - ->get(); - - return $documents; - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/Employeehour.php b/application/models/eloquent/Employeehour.php deleted file mode 100644 index a78c509..0000000 --- a/application/models/eloquent/Employeehour.php +++ /dev/null @@ -1,60 +0,0 @@ -belongsTo( 'User', 'employee_id' ); - } - - public function hourtype() - { - return $this->belongsTo( 'Hourtype' ); - } - - public static function getEmployeehours( $month, $year ) - { - $employeehours = Employeehour::whereRaw( "MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" ) - ->with( [ - 'user' => function ( $q ) { - $q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ); - }] ) - ->with( 'hourtype' ); - - $projecthours = Employeehour::whereRaw("MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" )->with( [ - 'user' => function ( $q ) { - $q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ); - }] ) - ->with( 'hourtype' ); - - $results = $employeehours->union($projecthours)->get(); - - return $results; - } - - public static function saveEmployeehour( $data ) - { - $record = Employeehour::whereUuid( $data['uuid'])->first(); - if ( ! $record ) - { - $employeehour = Employeehour::create( $data ); - $employeehourID = $employeehour->id; - } - else - { - Employeehour::whereUuid( $data['uuid'] )->update( $data ); - $employeehourID = FALSE; - } - - return $employeehourID; - } -} diff --git a/application/models/eloquent/Employeetarget.php b/application/models/eloquent/Employeetarget.php deleted file mode 100644 index b507a61..0000000 --- a/application/models/eloquent/Employeetarget.php +++ /dev/null @@ -1,64 +0,0 @@ -belongsTo( 'User' ); - } - - public static function saveTarget( $targetID, $target ) - { - $target = (array) $target; - - if ( $targetID == 0 ) - { - $target = self::create( $target ); - $targetID = $target['id']; - } - else - { - self::whereId( $targetID )->update( $target ); - } - - return $targetID; - } - - public static function getTargetHoursPerEmployee( $employeeID, $year, $monthID ) - { - $months = $monthID == 0 ? [1,2,3,4,5,6,7,8,9,10,11,12] : [$monthID]; - - $targetHours = 0; - - foreach($months as $month) - { - $targetHours += self::getCurrentMonthTarget( $employeeID, $year, $month); - } - - return $targetHours; - } - - public static function getCurrentMonthTarget( $employeeID, $year, $month ) - { - $monthTarget = Self::whereUserId($employeeID) - ->where('startyear', '<=', $year) - ->where('startmonth', '<=', $month) - ->orderBy('startyear', 'DESC') - ->orderBy('startmonth', 'DESC'); - - if( $monthTarget->count() == 0 ) return 0; - - $monthtarget = $monthTarget->first(); - - return $monthtarget->target; - } - -} \ No newline at end of file diff --git a/application/models/eloquent/External.php b/application/models/eloquent/External.php deleted file mode 100644 index d5ed07e..0000000 --- a/application/models/eloquent/External.php +++ /dev/null @@ -1,53 +0,0 @@ -hasMany( 'Reservation' ); - } - - public static function getAllExternals( $archive ) - { - $externals = External::orderBy( 'name' ); - - if ( $archive == 'F' ) $externals = $externals->whereArchive( 'F' ); - - $externals = $externals->get(); - - return $externals; - } - - public static function saveExternal( $externalID, $external ) - { - $external = (array) $external; - - if ( $externalID == 0 ) - { - $external = External::create( $external ); - $externalID = $external['id']; - } - else - { - External::whereId( $externalID )->update( $external ); - } - - return $externalID; - } - - public static function removeExternal( $externalID ) - { - External::whereId( $externalID )->delete(); - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/Forecast.php b/application/models/eloquent/Forecast.php deleted file mode 100644 index ec3e733..0000000 --- a/application/models/eloquent/Forecast.php +++ /dev/null @@ -1,38 +0,0 @@ -belongsTo( 'Project' ); - } - - public static function saveForecast( $forecastID, $forecast ) - { - $forecast = (array) $forecast; - - if ( $forecastID == 0 ) - { - $forecast = self::create( $forecast ); - $forecastID = $forecast['id']; - } - else - { - self::whereId( $forecastID )->update( $forecast ); - } - - return $forecastID; - } - - public static function removeForecast( $forecastID ) - { - Forecast::whereId( $forecastID )->delete(); - } - -} \ No newline at end of file diff --git a/application/models/eloquent/Hourtype.php b/application/models/eloquent/Hourtype.php deleted file mode 100644 index 7f45af2..0000000 --- a/application/models/eloquent/Hourtype.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany( 'Employeehour' ); - } -} \ No newline at end of file diff --git a/application/models/eloquent/Invoice.php b/application/models/eloquent/Invoice.php deleted file mode 100644 index d4c6b1c..0000000 --- a/application/models/eloquent/Invoice.php +++ /dev/null @@ -1,77 +0,0 @@ -belongsTo( 'Project' ); - } - - public function payments() - { - return $this->hasMany( 'Payment' ); - } - - public function vat() - { - return $this->belongsTo( 'Vat' ); - } - - public static function invoicePerYear( $projectID, $year, $thatYear = TRUE ) - { - $invoices = Invoice::selectRAW( 'SUM(invoiceamount * ( 1 +(vatrate / 100))) AS invoicetotal' ) - ->join( 'vats', 'vats.id', '=', 'invoices.vat_id' ) - ->whereProjectId( $projectID ); - - if ( $thatYear ) - { - $invoices = $invoices->whereRaw( "YEAR(invoicedate) = {$year}" ); - } - else - { - $invoices = $invoices->whereRaw( "YEAR(invoicedate) != {$year}" ); - } - - if ( $invoices->count() == 0 ) return 0; - - $invoices = $invoices->first(); - - return $invoices->invoicetotal; - } - - public static function saveInvoice( $invoiceID, $invoice ) - { - $invoice = (array) $invoice; - - if ( $invoiceID == 0 ) - { - $invoice = Invoice::create( $invoice ); - $invoiceID = $invoice['id']; - } - else - { - Invoice::whereId( $invoiceID )->update( $invoice ); - } - - return $invoiceID; - } - - public static function getInvoiced( $year, $orderType='invoicedate', $orderDirection='DESC' ) - { - $invoiced = Invoice::selectRaw('invoicenumber, PRJ.projectname, projectnumber, CUS.name, invoicedate, CUS.name, ROUND(invoiceamount, 0) AS invoiceamount') - ->join('projects AS PRJ', 'PRJ.id', '=', 'invoices.project_id') - ->join('customers AS CUS', 'CUS.id', '=', 'PRJ.customer_id') - ->whereRaw("DATE_FORMAT(invoicedate, '%Y') = {$year}") - ->orderBy($orderType, $orderDirection) - ->get(); - - return $invoiced; - } -} diff --git a/application/models/eloquent/Offer.php b/application/models/eloquent/Offer.php deleted file mode 100644 index fe1b1ef..0000000 --- a/application/models/eloquent/Offer.php +++ /dev/null @@ -1,100 +0,0 @@ -hasMany( 'Payment' ); - } - - public function project() - { - return $this->belongsTo( 'Project' ); - } - - public function customer() - { - return $this->belongsTo( 'Customer' ); - } - - public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction ) - { - $offers = Offer::selectRAW( 'offers.*' ) - ->join( 'customers AS CUS', 'CUS.id', '=', 'offers.customer_id' ) - ->with( 'customer' ) - ->with( 'project' ) - ->where( 'offernumber', 'LIKE', "%{$search}%" ) - ->orderBy( $order, $direction ); - - if ( $projectID ) $offers = $offers->whereProjectId( $projectID ); - - if ( $archive == 'F' ) $offers = $offers->where( 'offers.archive', '=', 'F' ); - - $offers = $offers->get(); - - return $offers; - } - - public static function getOffersWithoutProject() - { - $offersWithoutProject = Offer::selectRAW('offers.*, CONCAT(offernumber, " ", offername) AS fulloffer') - ->orderBy( 'startdate' ) -// ->whereNull('rejectdate') -// ->whereNull('project_id') - ->whereArchive( 'F' ) - ->get(); - - return $offersWithoutProject; - } - - public static function saveOffer( $offerID, $offer ) - { - $offer = (array) $offer; - - $offer['startdate'] = date2mysql( $offer['startdate'] ); - $offer['accepteddate'] = date2mysql( $offer['accepteddate'] ); - $offer['rejectdate'] = date2mysql( $offer['rejectdate'] ); - $offer['deadline'] = date2mysql( $offer['deadline'] ); - - if ( $offerID == 0 ) - { - $offer = Offer::create( $offer ); - - $offerID = $offer['id']; - } - else - { - Offer::whereId( $offerID )->update( $offer ); - - $offer = self::find( $offerID ); - - if ( ! is_null( $offer->project_id ) ) Project::syncOffername( $offer ); - } - - return $offerID; - } - - public static function syncProjectname( $projectID ) - { - $project = Project::find( $projectID ); - - $offer = self::find( $projectID ); - - $offer->offername = $project->projectname; - $offer->save(); - } - - public static function removeOffer( $offerID ) - { - Offer::whereId( $offerID )->delete(); - } -} diff --git a/application/models/eloquent/Page.php b/application/models/eloquent/Page.php deleted file mode 100644 index d0e6fbf..0000000 --- a/application/models/eloquent/Page.php +++ /dev/null @@ -1,62 +0,0 @@ -hasMany( 'Page' ); - } - - - public static function getPages( $user ) - { - $pages = Page::whereRaw( "id = page_id AND ((SELECT {$user->role} & pagelevel) != 0 OR pagelevel = 0)" ) - ->with( [ - 'subpages' => function ( $q ) use ( $user ) { - $q->whereRaw( - "id != page_id AND ((SELECT {$user->role} & pagelevel) != 0 OR pagelevel = 0)" ) - ->orderBy( 'pageorder' ); - }] ) - ->orderBy( 'pageorder' ) - ->get(); - - return $pages; - } - - public static function getAppPages( $user ) - { - $appPages = Page::select( 'id', 'pageurl' ) - ->whereAppPage( 'T' ) - ->whereRaw( - "((SELECT {$user->role} & pagelevel) != 0 OR pagelevel = 0)" ) - ->get(); - - return $appPages; - } - - public static function getPageAccessByRoleLevel( $roleLevel ) - { - $rolePages = self::selectRaw( " - id, - {$roleLevel} AS rolelevel, - IF(id = page_id, 'MAIN', 'SUB') AS typepage, - pagename, - IF((SELECT {$roleLevel} & pagelevel ) = 0, 'F', 'T') AS pageaccess" ) - ->orderByRaw( "page_id, IF(id = page_id, 0, 1)" ) - ->get(); - - return $rolePages; - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/Payment.php b/application/models/eloquent/Payment.php deleted file mode 100644 index c5f7a96..0000000 --- a/application/models/eloquent/Payment.php +++ /dev/null @@ -1,112 +0,0 @@ -belongsTo( 'Invoice' ); - } - - public static function getPaymentPerProject( $projectID ) - { - $projectPayment = self::selectRAW( 'id, invoice_id, SUM(paymentamount) as payment' ) - ->whereHas( 'invoice', function ( $q ) use ( $projectID ) { - $q->whereProjectId( $projectID ); - } ) - ->first(); - - if ( ! $projectPayment ) return 0; - - return $projectPayment->payment; - } - - public static function getPaymentsPerCustomerMonth( $year ) - { - $projects = self::selectRaw( 'PRJ.id, projectname, CUS.name, SUM(paymentamount) AS totalProjectPayments' ) - ->join( 'invoices AS INV', 'INV.id', '=', 'payments.invoice_id' ) - ->join( 'projects AS PRJ', 'PRJ.id', '=', 'INV.project_id' ) - ->join( 'customers AS CUS', 'CUS.id', '=', 'PRJ.customer_id' ) - ->groupBy( 'PRJ.id' ) - ->whereRaw( 'DATE_FORMAT(paymentdate, "%Y") = ' . $year ) - ->get() - ->toArray(); - - for ( $x = 0; $x < count( $projects ); $x ++ ) - { - $projects[ $x ]['monthPayments'] = []; - $monthPayments = self::getMonthPaymentPerProject( $projects[ $x ]['id'], $year ); - for ( $i = 1; $i <= 12; $i ++ ) - { - $projects[ $x ]['monthPayment'][ $i ] = 0; - foreach ( $monthPayments as $monthPayment ) - { - if ( $monthPayment->month == $i ) - $projects[ $x ]['monthPayment'][ $i ] = $monthPayment->paymentamount; - } - } - } - - return $projects; - } - - public static function getMonthPaymentPerProject( $projectID, $year ) - { - return self::selectRaw( 'SUM(paymentamount) AS paymentamount, DATE_FORMAT(paymentdate, "%m") AS month' ) - ->join( 'invoices AS INV', 'INV.id', '=', 'payments.invoice_id' ) - ->whereRaw( 'DATE_FORMAT(paymentdate, "%Y") = ' . $year ) - ->whereProjectId( $projectID ) - ->groupBy( \DB::raw( 'DATE_FORMAT(paymentdate, "%m")' ) ) - ->get(); - } - - public static function getProjectsWithPayments( $year ) - { - $projects = self::selectRaw( 'INV.project_id' ) - ->distinct() - ->join( 'invoices AS INV', 'INV.id', '=', 'payments.invoice_id' ) - ->whereRaw( 'DATE_FORMAT(paymentdate, "%Y") = "' . $year . '"' ) - ->pluck( 'project_id' ); - - return $projects->toArray(); - } - - public static function getPaymentInYear( $year ) - { - $payments = self::selectRAW( 'SUM(paymentamount) AS totalpayment' ) - ->whereRaw( "DATE_FORMAT(paymentdate, '%Y') = '{$year}'" ) - ->first(); - - return $payments->totalpayment; - } - - public static function savePayment( $paymentID, $payment ) - { - $payment = (array) $payment; - - if ( $paymentID == 0 ) - { - $payment = Payment::create( $payment ); - $paymentID = $payment['id']; - } - else - { - Payment::whereId( $paymentID )->update( $payment ); - } - - return $paymentID; - } - - public static function removePayment( $paymentID ) - { - Payment::whereId( $paymentID )->delete(); - } - -} diff --git a/application/models/eloquent/Project.php b/application/models/eloquent/Project.php deleted file mode 100644 index 4191a51..0000000 --- a/application/models/eloquent/Project.php +++ /dev/null @@ -1,197 +0,0 @@ -hasMany( 'Offer' ); - } - - public function offer() - { - return $this->hasOne( 'Offer' ); - } - - public function projectemployees() - { - return $this->hasMany( 'Projectemployee' ); - } - - public function projectcosts() - { - return $this->hasMany( 'Projectcost' ); - } - - public function invoices() - { - return $this->hasMany( 'Invoice' ); - } - - public function forecasts() - { - return $this->hasMany( 'Forecast' ); - } - - public function reservations() - { - return $this->hasMany( 'Reservation' ); - } - - public function vat() - { - return $this->belongsTo( 'Vat' ); - } - - public function projectleader() - { - return $this->belongsTo( 'User', 'projectleader_id' ); - } - - public function customer() - { - return $this->belongsTo( 'Customer' ); - } - - public static function getAllProjects( $archive, $search, $order, $direction ) - { - $projects = Project::getBaseProject(); - - $projects = $projects->selectRaw( 'projects.*' ) - ->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' ) - ->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' ) - ->where( 'projects.projectnumber', 'LIKE', "%{$search}%" ) - ->orderBy( $order, $direction ); - - if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' ); - - $projects = $projects->get(); - - return $projects; - } - - public static function getProject( $projectID ) - { - $project = Project::getBaseProject(); - - $project = $project->whereId( $projectID ) -// ->whereArchive( 'F' ) - ->first(); - - return $project; - } - - public static function removeProject( $projectID ) - { - Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] ); - - Project::whereId( $projectID )->delete(); - } - - public static function getActiveProjects( $archive = 'T', $sortField = FALSE, $direction = FALSE ) - { - $projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year, - projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" ) - ->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' ) - ->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' ) - ->groupBy( 'projects.id' ) - ->groupBy( 'OFF.own_revenue' ) - ->groupBy( 'OFF.other_revenue' ); - - if ( $sortField ) $projects = $projects->orderBy( $sortField, $direction ); - - if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' ); - - $projects = $projects->get(); - - return $projects; - } - - public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F', $projectsArray = FALSE ) - { - $projects = self::getBaseProject(); - - if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' ); - - if ( is_array( $projectsArray ) ) $projects = $projects->whereIn( 'id', $projectsArray ); - - $projects = $projects->orderBy( $orderType, $orderDirection )->get(); - - return $projects; - } - - public static function getBaseProject() - { - $project = Project::with( [ - 'projectleader' => function ( $q ) { - $q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ); - }] ) - ->with( 'offer' ) - ->with( [ - 'projectemployees.user' => function ( $q ) { - $q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ); - }] ) - ->with( 'vat' ) - ->with( ['forecasts'] ) - ->with( ['reservations'] ) - ->with( 'projectemployees.projecthours' ) - ->with( 'projectcosts.external' ) - ->with( 'invoices.payments' ) - ->with( 'invoices.vat' ) - ->with( 'vat' ) - ->with( 'customer' ); - - return $project; - } - - public static function createProject() - { - $data = ['startdate' => date( 'Y-m-d' )]; - - $project = Project::create( $data ); - - return $project->id; - } - - public static function saveProject( $projectID, $project ) - { - $project = (array) $project; - - if ( $projectID == 0 ) - { - $project = Project::create( $project ); - $projectID = $project['id'];; - } - else - { - Project::whereId( $projectID )->update( $project ); - } - - return $projectID; - } - - public static function syncOffername( $offer ) - { - self::whereId( $offer->project_id ) - ->update( ['projectname' => $offer->offername] ); - } - - public static function getProjectsWithExternalCosts( $projects ) - { - $projectCosts = self::selectRAW( 'projects.id, OFF.costs' ) - ->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' ) - ->whereNotIn( 'projects.id', $projects ) - ->where( 'OFF.costs', '>', 0 ) - ->get(); - - return $projectCosts; - } -} diff --git a/application/models/eloquent/Projectcost.php b/application/models/eloquent/Projectcost.php deleted file mode 100644 index 29d959d..0000000 --- a/application/models/eloquent/Projectcost.php +++ /dev/null @@ -1,47 +0,0 @@ -belongsTo( 'Project' ); - } - - public function external() - { - return $this->belongsTo( 'External' ); - } - - public static function saveProjectcost( $projectID, $project ) - { - $project = (array) $project; - - if ( $projectID == 0 ) - { - $project = Self::create( $project ); - $projectID = $project['id']; - } - else - { - Self::whereId( $projectID )->update( $project ); - } - - return $projectID; - } - - public static function getCostsPerPerProject( $projectID ) - { - $projectCosts = Projectcost::selectraw( 'ROUND(COALESCE(SUM(costs), 0), 0) AS costs') - ->whereProjectId($projectID) - ->first(); - - return $projectCosts->costs; - } - -} \ No newline at end of file diff --git a/application/models/eloquent/Projectemployee.php b/application/models/eloquent/Projectemployee.php deleted file mode 100644 index 0dfb76e..0000000 --- a/application/models/eloquent/Projectemployee.php +++ /dev/null @@ -1,119 +0,0 @@ -belongsTo( 'Project' ); - } - - public function user() - { - return $this->belongsTo( 'User' ); - } - - public function projecthours() - { - return $this->hasMany( 'Projecthour' ); - } - - public static function getAvailableEmployees( $projectID ) - { - $currentEmployees = Self::whereProjectId( $projectID ) - ->pluck( 'user_id' ); - - $availableEmployees = User::selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ) - ->whereNotIn( 'id', $currentEmployees ) - ->whereArchive( 'F' ) - ->get(); - - return $availableEmployees; - } - - public static function getUniqueProjectEmployees() - { - $projectemployees = Projectemployee::selectRaw( "USR.id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ) - ->distinct() - ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' ) - ->get(); - - return $projectemployees; - } - - public static function getUniqueEmployeesWithActivity( $archive = 'F' ) - { - $projectemployees = Projectemployee::selectRaw( "USR.id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ) - ->distinct() - ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' ) - ->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'USR.id' ) - ->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' ); - - if ( $archive == 'F' ) $projectemployees = $projectemployees->where( 'PRJ.archive', '=', 'F' ); - - $projectemployees = $projectemployees->get(); - - return $projectemployees; - } - - public static function getProjectemployeeDetailsPerProject( $projectID ) - { - $details = Projectemployee::selectRaw( ' - USR.id, budget, project_id, ROUND(SUM(hours), 0) AS hours, ROUND(SUM(hours * tarif), 0) AS revenues, projectemployees.id AS projectemployeeID' ) - ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' ) - ->join( 'projecthours AS PRH', 'PRH.projectemployee_id', '=', 'projectemployees.id' ) - ->where( 'projectemployees.project_id', '=', $projectID ) - ->where( 'PRH.hourtype_id', '=', 1 ) -// ->where( 'budget', '!=', 0 ) - ->groupBy( 'projectemployees.id' ) - ->havingRaw( 'ROUND(SUM(hours), 0) > 0' ); - $details = $details->get(); - - return $details; - } - - public static function firstOrCreateProjectemployee( $userID, $projectID ) - { - $projectemployee = self::whereUserId( $userID )->whereProjectId( $projectID ); - - if ( $projectemployee->count() > 0 ) return $projectemployee->first(); - - $user = User::find( $userID ); - - $tarif = $user ? $user->hourlyrate : 0; - - $projectemployee = Projectemployee::create( [ - 'project_id' => $projectID, - 'user_id' => $userID, - 'tarif' => $tarif - ] ); - - return $projectemployee; - } - - public static function createProjectEmployee( $projectID ) - { - $projectemployee = Projectemployee::create( [ - 'project_id' => $projectID - ] ); - - return $projectemployee->id; - } - - public static function saveProjectemployee( $projectemployeeID, $projectemployee ) - { - Projectemployee::whereId( $projectemployeeID ) - ->update( $projectemployee ); - } - - public static function removeProjectemployee( $projectemployeeID ) - { - Projectemployee::whereId( $projectemployeeID )->delete(); - } - -} diff --git a/application/models/eloquent/Projecthour.php b/application/models/eloquent/Projecthour.php deleted file mode 100644 index f039859..0000000 --- a/application/models/eloquent/Projecthour.php +++ /dev/null @@ -1,83 +0,0 @@ -belongsTo( 'Projectemployee' ); - } - - public static function getUsedYears() - { - $years = Projecthour::selectRaw( "YEAR(hourdate) AS year" ) - ->distinct() - ->orderByRaw( 'YEAR( hourdate )' ) - ->get(); - - return $years; - } - - public static function getMonthlyEmployeeHoursPerProject( $employeeID, $year ) - { - $projectHours = ProjecthoursPerEmployeePerMonth::fire( $employeeID, $year ); - - return $projectHours; - } - - public static function recapProjects() - { - $recaps = QRecapProjects::fire(); - - return $recaps; - } - - public static function saveProjecthour( $projecthour ) - { - $projecthour = (array) $projecthour; - $record = Projecthour::whereUuid( $projecthour['uuid'] )->first(); - - if ( ! $record ) - { - $projecthour = Projecthour::create( $projecthour ); - $projecthourID = $projecthour['id']; - } - else - { - Projecthour::whereUuid( $projecthour['uuid'] )->update( $projecthour ); - $projecthourID = FALSE; - } - - return $projecthourID; - } - - public static function removeProjecthour( $projecthourID ) - { - Projecthour::whereId( $projecthourID )->delete(); - } - - public static function getTotalHoursPerProject( $projectID ) - { - $totalProjecthours = - self::selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, - SUM(IF(hourtype_id = 1, hours, 0)) AS declarable, - SUM(IF(hourtype_id = 1, hours * tarif, 0)) AS revenues, - SUM(IF(hourtype_id != 1, hours, 0)) AS nondeclarable" ) - ->join( 'projectemployees AS PRE', 'PRE.id', '=', 'projecthours.projectemployee_id' ) - ->join( 'users AS USR', 'USR.id', '=', 'PRE.user_id' ) - ->groupBy( 'USR.id' ) - ->where( 'PRE.project_id', '=', $projectID ) - ->get(); - - return $totalProjecthours; - } - - -} diff --git a/application/models/eloquent/Reservation.php b/application/models/eloquent/Reservation.php deleted file mode 100644 index 9fa3481..0000000 --- a/application/models/eloquent/Reservation.php +++ /dev/null @@ -1,43 +0,0 @@ -belongsTo( 'Project' ); - } - - public function external() - { - return $this->belongsTo( 'External' ); - } - - public static function saveReservation( $reservationID, $reservation ) - { - $reservation = (array) $reservation; - - if ( $reservationID == 0 ) - { - $reservation = self::create( $reservation ); - $reservationID = $reservation['id']; - } - else - { - self::whereId( $reservationID )->update( $reservation ); - } - - return $reservationID; - } - - public static function removeReservation( $reservationID ) - { - Reservation::whereId( $reservationID )->delete(); - } - -} \ No newline at end of file diff --git a/application/models/eloquent/Role.php b/application/models/eloquent/Role.php deleted file mode 100644 index b75fcc5..0000000 --- a/application/models/eloquent/Role.php +++ /dev/null @@ -1,63 +0,0 @@ -hasOne( 'User', 'role', 'rolelevel' ); - } - - public static function getAllRoles( $archive ) - { - $roleHierarchy = Role::getUserroleHierachy(); - - $roles = Role::orderBy( 'rolehierarchy' ) - ->where( 'rolehierarchy', '>=', $roleHierarchy ); - - if ( $archive == 'F' ) $roles = $roles->whereArchive( 'F' ); - - $roles = $roles->get(); - - return $roles; - } - - public static function getUserroleHierachy() - { - $userrole = User::getUserRoleHierarchy(); - - if( $userrole == 0 ) return 0; - - $roleHierarchy = Role::whereRolelevel($userrole) - ->first() - ->rolehierarchy; - - return $roleHierarchy; - } - - public static function getPagesAccessByRole() - { - $roles = self::all(); - - $pageroles=[]; - foreach ( $roles as $role ) - { - $pageroles[ $role->id ]['rolelevel'] = $role->rolelevel; - $pageroles[ $role->id ]['rolename'] = $role->rolename; - - $pageroles[ $role->id ]['pagesAccess'] = - Page::getPageAccessByRoleLevel( $role->rolelevel ); - } - - return $pageroles; - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/User.php b/application/models/eloquent/User.php deleted file mode 100644 index 29ab410..0000000 --- a/application/models/eloquent/User.php +++ /dev/null @@ -1,154 +0,0 @@ -hasMany( 'Projectemployee' ); - } - - public function employeetargets() - { - return $this->hasMany( 'Employeetarget' ); - } - - public function projectemployee() - { - return $this->hasOne( 'Projectemployee' ); - } - - public function role() - { - return $this->belongsTo( 'Role', 'level', 'rolelevel' ); - } - - public static function getAllUsers( $archive ) - { - $users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" ) - ->orderBy( 'lastname' ); - - if ( $archive == 'F' ) $users = $users->whereArchive( 'F' ); - - $users = $users->get(); - - return $users; - } - - public static function getUserRoleHierarchy() - { - $userrole = User::find( USERID )->role; - - return $userrole; - } - - public static function getUserWithprojects() - { - $usersWithProjects = - User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" ) - ->with( [ - 'projectemployees.project' => function ( $q ) { - $q->whereArchive( 'F' ); - }] ) - ->get(); - - return $usersWithProjects; - } - - public static function getUserActiveProjects( $userID ) - { - $usersActiveProjects = - User::selectRaw( "PRJ.id AS projectID, projectname, projectnumber, CONCAT(projectnumber, '-', projectname) AS projectFull" ) - ->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'users.id' ) - ->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' ) - ->where( 'PRJ.archive', '=', 'F' ) - ->where( 'users.id', '=', $userID ) - ->orderBy('projectnumber') - ->get(); - - return $usersActiveProjects; - } - - public static function checkUsername( $username ) - { - $username = strtoupper( $username ); - - $user = User::whereRaw( "UCASE(username) = {$username}" ); - - if ( $user->count() == 0 ) return FALSE; - - return TRUE; - } - - public static function saveUser( $userID, $user ) - { - $user = (array) $user; - - if ( $userID == 0 ) - { - $user = User::create( $user ); - $userID = $user['id']; - } - else - { - User::whereId( $userID )->update( $user ); - } - - return $userID; - } - - public static function removeUser( $userID ) - { - User::whereId( $userID )->delete(); - } - - public static function getUniqueProjectUsers() - { - //TODO: date range - $projectusers = User::selectRaw( " - users.id, - CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, - SUBSTR(MD5(users.id), 1, 6) AS slug" ) - ->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' ) - ->with( [ - 'projectemployee.project' => function ( $q ) { - $q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" ); - }] ) - ->distinct() - ->get(); - - return $projectusers; - } - - public static function getSaltedPassword( $password, $salt ) - { - $saltedpassword = sha1( sha1( $password ) . $salt ); - - return $saltedpassword; - } - - public static function generateSalt() - { - $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; - $alphaLength = strlen( $alphabet ) - 1; - $randomString = ''; - - for ( $i = 0; $i < 18; $i++ ) - { - $n = rand( 0, $alphaLength ); - $randomString .= $alphabet[ $n ]; - } - - return sha1( $randomString ); - } - - -} diff --git a/application/models/eloquent/Vat.php b/application/models/eloquent/Vat.php deleted file mode 100644 index 57340af..0000000 --- a/application/models/eloquent/Vat.php +++ /dev/null @@ -1,39 +0,0 @@ -hasMany( 'Invoice' ); - } - - public static function getVats( $archive ) - { - if ( $archive == 'F' ) - { - $vats = vat::whereArchive( 'F' )->get(); - } - else - { - $vats = Vat::get(); - } - - return $vats; - } - - public static function getCurrentVat() - { - $currentVat = Vat::whereActive('T')->whereArchive('F')->first(); - - if( ! $currentVat) return 0; - - return $currentVat->vatrate; - } - -} \ No newline at end of file diff --git a/application/models/eloquent/queries/EmployeehoursMonthly.php b/application/models/eloquent/queries/EmployeehoursMonthly.php deleted file mode 100644 index 3dc1fa9..0000000 --- a/application/models/eloquent/queries/EmployeehoursMonthly.php +++ /dev/null @@ -1,85 +0,0 @@ -join( 'projectemployees AS PEM', 'PEM.id', '=', 'projecthours.projectemployee_id' ) - ->join( 'projects AS PRJ', 'PRJ.id', '=', 'PEM.project_id' ) - ->where( 'PEM.user_id', '=', $employeeID ) - ->where( 'projecthours.hourtype_id', '=', 1) - ->groupBy('PRJ.id') - ->groupBy('PEM.tarif') - ->groupBy('PRJ.projectname') - ->get(); - - return $projectHours; - } - - -} \ No newline at end of file diff --git a/application/models/eloquent/queries/QEmployeeHours.php b/application/models/eloquent/queries/QEmployeeHours.php deleted file mode 100644 index afd9d2a..0000000 --- a/application/models/eloquent/queries/QEmployeeHours.php +++ /dev/null @@ -1,80 +0,0 @@ -= MONTH(NOW()) -1, forecastamount, 0), 0)) AS currentforecast, - SUM(IF(year > {$year}, forecastamount, 0)) AS otherforecast - FROM forecasts - GROUP BY project_id - ) AS Q3 - ON PRJ.id = Q3.project_id - GROUP BY PRJ.projectnumber, PRJ.projectname "; - - return $sql; - } -} \ No newline at end of file diff --git a/application/models/eloquent/queries/ReservationTotals.php b/application/models/eloquent/queries/ReservationTotals.php deleted file mode 100644 index d5b9edb..0000000 --- a/application/models/eloquent/queries/ReservationTotals.php +++ /dev/null @@ -1,69 +0,0 @@ - 0 - AND PRJ.archive = 'F'"; - - return $sql; - } - -} diff --git a/application/models/index.html b/application/models/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/models/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/models/projects/Invoices_model.php b/application/models/projects/Invoices_model.php deleted file mode 100644 index 7d08cd2..0000000 --- a/application/models/projects/Invoices_model.php +++ /dev/null @@ -1,117 +0,0 @@ -sql = " - SELECT ROUND(COALESCE(SUM(invoiceamount), 0),0) AS invoiced, YEAR(invoicedate) AS invoiceyear - FROM invoices - WHERE project_id = {$projectID} - GROUP BY YEAR(invoicedate) - ORDER BY YEAR(invoicedate) "; - - $invoiced = $this->get_query_result(); - - return $invoiced; - } - - public function getOutstandingPerProject( $projectID ) - { - $this->sql = " - SELECT (own_revenue + other_revenue + OFF.costs) AS totalrevenue, - ROUND(SUM(INV.invoiceamount * ((100 + vatrate) / 100)), 0) AS totalinvoiced, - ( - SELECT SUM(paymentamount) PAYMENTAMOUNT - FROM payments PAY - JOIN invoices INV - ON INV.id = PAY.invoice_id - WHERE INV.project_id = {$projectID} - ) AS payed, - PRJ.archive - FROM invoices INV - JOIN projects PRJ - ON PRJ.id = INV.project_id - JOIN ( - SELECT vatrate, id - FROM vats - WHERE active = 'T' - AND archive = 'F' - ) VTS - ON VTS.id = INV.vat_id - JOIN offers OFF - ON PRJ.id = OFF.project_id - WHERE PRJ.id = {$projectID} "; - - $invoiceDetails = $this->get_query_row(); - - return $invoiceDetails; - } - - public function getTotalsOutstandingPerProject($archive = TRUE) - { - $this->sql = " - SELECT - PRJ.id, - projectnumber, - projectname, - SUM(invoiced) AS invoiced, - SUM(payment) AS payment, - revenues, - costs, - COALESCE(payedcosts, 0) AS payedcosts - FROM ( - SELECT - project_id, - ROUND(SUM(invoiceamount * (1 + (vatrate / 100))), 0) AS invoiced, - payment - FROM - invoices INV - JOIN vats VAT ON VAT.id = INV.vat_id - LEFT JOIN ( - SELECT - ROUND(COALESCE(SUM(paymentamount), 0), 0) AS payment, - invoice_id - FROM - payments - GROUP BY - invoice_id) AS Q1 ON INV.id = Q1.invoice_id - GROUP BY - INV.id) Q2 - JOIN projects PRJ ON PRJ.id = Q2.project_id - JOIN ( - SELECT - ROUND((own_revenue + other_revenue + costs) * (1 + (vatrate / 100)), 0) revenues, - ROUND(costs * (1 + (vatrate / 100)), 0) costs, - OFF.project_id - FROM - offers OFF - JOIN projects PRJ ON PRJ.id = OFF.project_id - JOIN vats VAT ON VAT.id = PRJ.vat_id) Q3 ON Q3.project_id = PRJ.id - LEFT JOIN ( - SELECT - SUM(costs) AS payedcosts, - project_id - FROM - projectcosts - GROUP BY - project_id) Q4 ON Q4.project_id = PRJ.id "; - if( $archive == FALSE ) $this->sql .= "WHERE PRJ.archive = 'F' "; - - $this->sql .= " - GROUP BY - PRJ.id "; - - $outstandings = $this->get_query_result(); - - return $outstandings; - } -} diff --git a/application/models/projects/Offer_model.php b/application/models/projects/Offer_model.php deleted file mode 100644 index 42e6a90..0000000 --- a/application/models/projects/Offer_model.php +++ /dev/null @@ -1,18 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/views/emails/requestpassword_email.php b/application/views/emails/requestpassword_email.php deleted file mode 100644 index a141a26..0000000 --- a/application/views/emails/requestpassword_email.php +++ /dev/null @@ -1,366 +0,0 @@ - - - - - -| - |
-
-
|
- - |
| - |
-
-
|
- - |
| - |
-
-
|
- - |
Directory access is forbidden.
- - - diff --git a/application/views/errors/html/error_404.php b/application/views/errors/html/error_404.php deleted file mode 100755 index 756ea9d..0000000 --- a/application/views/errors/html/error_404.php +++ /dev/null @@ -1,64 +0,0 @@ - - - - -Type:
-Message:
-Filename: getFile(); ?>
-Line Number: getLine(); ?>
- - - -Backtrace:
- getTrace() as $error): ?> - - - -
- File:
- Line:
- Function:
-
Severity:
-Message:
-Filename:
-Line Number:
- - - -Backtrace:
- - - - -
- File:
- Line:
- Function:
-
Directory access is forbidden.
- - - diff --git a/application/views/errors/index.html b/application/views/errors/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/views/errors/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/views/index.html b/application/views/index.html deleted file mode 100755 index b702fbc..0000000 --- a/application/views/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/views/main_view.old b/application/views/main_view.old deleted file mode 100644 index b8de45f..0000000 --- a/application/views/main_view.old +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - -