Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37299ac1a8 | ||
|
|
f614e0ebf0 | ||
|
|
66ced28bad | ||
|
|
22a371eef9 | ||
|
|
143961cf3f | ||
|
|
aae74a8cc9 | ||
|
|
3c89cb277c | ||
|
|
48619a086c | ||
|
|
ace8020028 | ||
|
|
acf281371b | ||
|
|
39820b84e0 | ||
|
|
5656910eab | ||
|
|
0594d84ed1 | ||
|
|
fbd77cedf7 | ||
|
|
045e85f3ad | ||
|
|
f6d5202ad5 | ||
|
|
31bb455d6f | ||
|
|
301ea64832 | ||
|
|
6fd9ba20c8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
/.buildpath
|
||||
/.project
|
||||
/.idea
|
||||
build
|
||||
|
||||
75
build.xml
75
build.xml
@@ -8,14 +8,15 @@
|
||||
<property name="env.appname" value="icehrm"/>
|
||||
<property name="env.Version" value="dev"/>
|
||||
<property name="installpath" value="/var/www/apps.gamonoid.com/icehrm-open-core"/>
|
||||
<property name="installLocalpath" value="/Applications/XAMPP/xamppfiles/htdocs/icehrm-open-core"/>
|
||||
|
||||
|
||||
<target name="build"
|
||||
depends="prepare,lint,phpunit,copyapp,release,install"
|
||||
depends="prepare,lint,copyapp,release,install"
|
||||
description=""/>
|
||||
|
||||
<target name="buildlocal"
|
||||
depends="prepare,copyapp"
|
||||
<target name="buildlocal"
|
||||
depends="prepare,copyapp,installLocal"
|
||||
description=""/>
|
||||
|
||||
<target name="clean"
|
||||
@@ -37,6 +38,7 @@
|
||||
depends="clean"
|
||||
description="Prepare for build">
|
||||
<mkdir dir="${basedir}/build/api"/>
|
||||
<mkdir dir="${basedir}/build/api"/>
|
||||
<mkdir dir="${basedir}/build/coverage"/>
|
||||
<mkdir dir="${basedir}/build/logs"/>
|
||||
<mkdir dir="${basedir}/build/pdepend"/>
|
||||
@@ -47,29 +49,6 @@
|
||||
<mkdir dir="${basedir}/build/release/data/${env.appname}_${env.Version}"/>
|
||||
<mkdir dir="${basedir}/src/lib"/>
|
||||
|
||||
<copy todir="${basedir}/src/lib" overwrite="true">
|
||||
<fileset dir="${basedir}/lib">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${basedir}/src" overwrite="true">
|
||||
<fileset dir="${basedir}/core-ext">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${basedir}/src">
|
||||
<fileset dir="${basedir}/ext">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${basedir}/src">
|
||||
<fileset dir="${basedir}/tp">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<property name="prepare.done" value="true"/>
|
||||
</target>
|
||||
@@ -204,7 +183,6 @@
|
||||
|
||||
|
||||
<target name="copyapp"
|
||||
depends=""
|
||||
description="Copy generated files to QA app">
|
||||
|
||||
<delete includeemptydirs="true">
|
||||
@@ -213,12 +191,30 @@
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<copy todir="${destination}">
|
||||
<copy todir="${destination}" overwrite="true">
|
||||
<fileset dir="${origin}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${destination}/lib" overwrite="true">
|
||||
<fileset dir="${basedir}/lib">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${destination}" overwrite="true">
|
||||
<fileset dir="${basedir}/core-ext">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${destination}" overwrite="true">
|
||||
<fileset dir="${basedir}/ext">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="install"
|
||||
@@ -233,8 +229,8 @@
|
||||
|
||||
<mkdir dir="${installpath}"/>
|
||||
|
||||
<copy todir="${installpath}">
|
||||
<fileset dir="${origin}">
|
||||
<copy todir="${installpath}" overwrite="true">
|
||||
<fileset dir="${destination}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
@@ -246,6 +242,25 @@
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="installLocal"
|
||||
depends="copyapp"
|
||||
description="">
|
||||
|
||||
<delete includeemptydirs="true" failonerror="false">
|
||||
<fileset dir="${installLocalpath}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<mkdir dir="${installLocalpath}"/>
|
||||
|
||||
<copy todir="${installLocalpath}">
|
||||
<fileset dir="${destination}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="release"
|
||||
depends="copyapp"
|
||||
description="Create a release">
|
||||
|
||||
82
core-ext/classes/LDAPManager.php
Normal file
82
core-ext/classes/LDAPManager.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class LDAPManager {
|
||||
|
||||
private static $me = null;
|
||||
|
||||
private function __construct(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getInstance(){
|
||||
if(empty(self::$me)){
|
||||
self::$me = new LDAPManager();
|
||||
}
|
||||
|
||||
return self::$me;
|
||||
}
|
||||
|
||||
public function checkLDAPLogin($user, $password){
|
||||
$ldap_host = SettingsManager::getInstance()->getSetting("LDAP: Server");
|
||||
$ldap_port = SettingsManager::getInstance()->getSetting("LDAP: Port");
|
||||
$ldap_dn = SettingsManager::getInstance()->getSetting("LDAP: Root DN");
|
||||
|
||||
$managerDN = SettingsManager::getInstance()->getSetting("LDAP: Manager DN");
|
||||
$managerPassword = SettingsManager::getInstance()->getSetting("LDAP: Manager Password");
|
||||
|
||||
// connect to active directory
|
||||
if(empty($ldap_port)){
|
||||
$ldap_port = 389;
|
||||
}
|
||||
|
||||
$ldap = ldap_connect($ldap_host, intval($ldap_port));
|
||||
|
||||
if(!$ldap){
|
||||
return new IceResponse(IceResponse::ERROR,"Could not connect to LDAP Server");
|
||||
}
|
||||
|
||||
LogManager::getInstance()->debug("LDAP Connect Result:".print_r($ldap,true));
|
||||
|
||||
if(SettingsManager::getInstance()->getSetting("LDAP: Version 3") == "1"){
|
||||
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
}
|
||||
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
// verify user and password
|
||||
$bind = @ldap_bind($ldap, $managerDN, $managerPassword);
|
||||
|
||||
LogManager::getInstance()->debug("LDAP Manager Bind:".print_r($bind,true));
|
||||
|
||||
if($bind) {
|
||||
|
||||
$userFilterStr = SettingsManager::getInstance()->getSetting("LDAP: User Filter");
|
||||
|
||||
$filter = str_replace("{}", $user, $userFilterStr); //"(uid=" . $user . ")";
|
||||
$result = ldap_search($ldap, $ldap_dn, $filter);
|
||||
LogManager::getInstance()->debug("LDAP Search Result:".print_r($result,true));
|
||||
if(!$result){
|
||||
exit("Unable to search LDAP server");
|
||||
}
|
||||
$entries = ldap_get_entries($ldap, $result);
|
||||
LogManager::getInstance()->debug("LDAP Search Entries:".print_r($entries,true));
|
||||
|
||||
if(empty($entries) || !isset($entries[0]) || !isset($entries[0]['dn'])){
|
||||
return new IceResponse(IceResponse::ERROR,"Invalid user");
|
||||
}
|
||||
|
||||
$bind = @ldap_bind($ldap,$entries[0]['dn'], $password);
|
||||
ldap_unbind($ldap);
|
||||
|
||||
if($bind){
|
||||
return new IceResponse(IceResponse::SUCCESS, $entries[0]);
|
||||
}else{
|
||||
return new IceResponse(IceResponse::ERROR,"Invalid user");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
return new IceResponse(IceResponse::ERROR,"Invalid manager user");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
<?php
|
||||
//Nothing here
|
||||
?>
|
||||
@@ -9,9 +9,9 @@ define('HOME_LINK_ADMIN', CLIENT_BASE_URL."?g=admin&n=dashboard&m=admin_Admin");
|
||||
define('HOME_LINK_OTHERS', CLIENT_BASE_URL."?g=modules&n=dashboard&m=module_Personal_Information");
|
||||
|
||||
//Version
|
||||
define('VERSION', '15.2.OS');
|
||||
define('CACHE_VALUE', '15.2.OS');
|
||||
define('VERSION_DATE', '12/03/2016');
|
||||
define('VERSION', '16.1.OS');
|
||||
define('CACHE_VALUE', '16.1.OS');
|
||||
define('VERSION_DATE', '02/05/2016');
|
||||
|
||||
if(!defined('CONTACT_EMAIL')){define('CONTACT_EMAIL','icehrm@gamonoid.com');}
|
||||
if(!defined('KEY_PREFIX')){define('KEY_PREFIX','IceHrm');}
|
||||
|
||||
27
core-ext/doc/ldap-config.txt
Normal file
27
core-ext/doc/ldap-config.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
Before using please install php5-ldap module
|
||||
sudo apt-get install php5-ldap
|
||||
|
||||
For using php ldap on windows please refer
|
||||
http://stackoverflow.com/questions/16864306/fatal-error-call-to-undefined-function-ldap-connect
|
||||
|
||||
|
||||
The user "admin" will always login with local db username and password (even LDAP is enabled)
|
||||
|
||||
Use following config to test LDAP connection with following test LDAP server
|
||||
http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
|
||||
|
||||
Change configs as follows under System->Settings
|
||||
|
||||
LDAP: Enabled = Yes
|
||||
LDAP: Server = ldap.forumsys.com
|
||||
LDAP: Port = 389
|
||||
LDAP: Root DN = dc=example,dc=com
|
||||
LDAP: Manager DN = cn=read-only-admin,dc=example,dc=com
|
||||
LDAP: Manager Password = password
|
||||
LDAP: Version 3 = Yes
|
||||
LDAP: User Filter = uid={}
|
||||
|
||||
Then create a user with username "riemann" under System->Users
|
||||
|
||||
Logout and try login with riemann/password
|
||||
|
||||
2
core-ext/login.com.inc.php
Normal file
2
core-ext/login.com.inc.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
//Nothing here
|
||||
@@ -3,17 +3,65 @@ define('CLIENT_PATH',dirname(__FILE__));
|
||||
include ("config.base.php");
|
||||
include ("include.common.php");
|
||||
include("server.includes.inc.php");
|
||||
|
||||
error_log(print_r($_REQUEST,true));
|
||||
|
||||
if(empty($user)){
|
||||
|
||||
if(!isset($_REQUEST['f']) && isset($_COOKIE['icehrmLF']) && @$_REQUEST['login'] != 'no' && !isset($_REQUEST['username'])){
|
||||
$tempUser = new User();
|
||||
$tempUser->Load("login_hash = ?",array($_COOKIE['icehrmLF']));
|
||||
|
||||
if(!empty($tempUser->id) &&
|
||||
sha1($tempUser->email."_".$tempUser->password) == $_COOKIE['icehrmLF']){
|
||||
|
||||
$_REQUEST['username'] = $tempUser->username;
|
||||
$_REQUEST['password'] = $tempUser->password;
|
||||
$_REQUEST['hashedPwd'] = $tempUser->password;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_REQUEST['username']) && !empty($_REQUEST['password'])){
|
||||
|
||||
$suser = null;
|
||||
$ssoUserLoaded = false;
|
||||
|
||||
if(empty($suser)){
|
||||
if($_REQUEST['username'] != "admin") {
|
||||
LogManager::getInstance()->debug("LDAP: Enabled :" . SettingsManager::getInstance()->getSetting("LDAP: Enabled"));
|
||||
if (SettingsManager::getInstance()->getSetting("LDAP: Enabled") == "1") {
|
||||
$ldapResp = LDAPManager::getInstance()->checkLDAPLogin($_REQUEST['username'], $_REQUEST['password']);
|
||||
LogManager::getInstance()->debug("LDAP Response :" . print_r($ldapResp, true));
|
||||
LogManager::getInstance()->debug("LDAP Response Status :" . $ldapResp->getStatus());
|
||||
if ($ldapResp->getStatus() == IceResponse::ERROR) {
|
||||
header("Location:" . CLIENT_BASE_URL . "login.php?f=1");
|
||||
exit();
|
||||
} else {
|
||||
$suser = new User();
|
||||
$suser->Load("(username = ? or email = ?) and password = ?",array($_REQUEST['username'],$_REQUEST['username'],md5($_REQUEST['password'])));
|
||||
$suser->Load("username = ?", array($_REQUEST['username']));
|
||||
LogManager::getInstance()->debug("LDAP Response :[".$_REQUEST['username']."]" . print_r($suser, true));
|
||||
if (empty($suser)) {
|
||||
header("Location:" . CLIENT_BASE_URL . "login.php?f=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
if($suser->password == md5($_REQUEST['password']) || $ssoUserLoaded){
|
||||
$ssoUserLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isset($_REQUEST['hashedPwd'])){
|
||||
$_REQUEST['hashedPwd'] = md5($_REQUEST['password']);
|
||||
}
|
||||
|
||||
include 'login.com.inc.php';
|
||||
|
||||
if(empty($suser)){
|
||||
$suser = new User();
|
||||
$suser->Load("(username = ? or email = ?) and password = ?",array($_REQUEST['username'],$_REQUEST['username'],$_REQUEST['hashedPwd']));
|
||||
}
|
||||
|
||||
if($suser->password == $_REQUEST['hashedPwd'] || $ssoUserLoaded){
|
||||
$user = $suser;
|
||||
SessionUtils::saveSessionObject('user', $user);
|
||||
$suser->last_login = date("Y-m-d H:i:s");
|
||||
@@ -24,12 +72,29 @@ if(empty($user)){
|
||||
BaseService::getInstance()->audit(IceConstants::AUDIT_AUTHENTICATION, "User Login");
|
||||
}
|
||||
|
||||
if(!$ssoUserLoaded && isset($_REQUEST['remember'])){
|
||||
//Add cookie
|
||||
$suser->login_hash = sha1($suser->email."_".$suser->password);
|
||||
$suser->Save();
|
||||
|
||||
setcookie('icehrmLF',$suser->login_hash);
|
||||
}
|
||||
|
||||
if(!isset($_REQUEST['remember'])){
|
||||
setcookie('icehrmLF');
|
||||
}
|
||||
|
||||
$redirectUrl = SessionUtils::getSessionObject('loginRedirect');
|
||||
if(!empty($redirectUrl)){
|
||||
header("Location:".$redirectUrl);
|
||||
}else{
|
||||
if($user->user_level == "Admin"){
|
||||
if(SessionUtils::getSessionObject('account_locked') == "1"){
|
||||
header("Location:".CLIENT_BASE_URL."?g=admin&n=billing&m=admin_System");
|
||||
}else{
|
||||
header("Location:".HOME_LINK_ADMIN);
|
||||
}
|
||||
|
||||
}else{
|
||||
if(empty($user->default_module)){
|
||||
header("Location:".HOME_LINK_OTHERS);
|
||||
@@ -39,12 +104,13 @@ if(empty($user)){
|
||||
if($defaultModule->mod_group == "user"){
|
||||
$defaultModule->mod_group = "modules";
|
||||
}
|
||||
$homeLink = CLIENT_BASE_URL."?g=".$defaultModule->mod_group."&n=".$defaultModule->name.
|
||||
$homeLink = CLIENT_BASE_URL."?g=".$defaultModule->mod_group."&&n=".$defaultModule->name.
|
||||
"&m=".$defaultModule->mod_group."_".str_replace(" ","_",$defaultModule->menu);
|
||||
header("Location:".$homeLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
header("Location:".CLIENT_BASE_URL."login.php?f=1");
|
||||
}
|
||||
@@ -70,23 +136,21 @@ if(empty($user)){
|
||||
}
|
||||
|
||||
$tuser = SessionUtils::getSessionObject('user');
|
||||
//check user
|
||||
|
||||
$logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?=APP_NAME?> Login v<?=VERSION?> © http://icehrm.com</title>
|
||||
<title><?=APP_NAME?> Login</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="A Powerful But Simple Way to Manage Your Company and People. http://icehrm.com">
|
||||
<meta name="author" content="http://gamonoid.com">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="<?=BASE_URL?>bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.js"></script>
|
||||
<script type="text/javascript" src="<?=BASE_URL?>js/jquery-1.8.1.js"></script>
|
||||
<script src="<?=BASE_URL?>bootstrap/js/bootstrap.js"></script>
|
||||
<script src="<?=BASE_URL?>js/jquery.placeholder.js"></script>
|
||||
<script src="<?=BASE_URL?>js/jquery.dataTables.js"></script>
|
||||
@@ -98,7 +162,7 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<script src="<?=BASE_URL?>js/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style type="text/css">
|
||||
@@ -154,25 +218,9 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div itemscope itemtype="http://schema.org/WebApplication" style="display: none;">
|
||||
<span itemprop="name">IceHrm Pro</span> -
|
||||
<body>
|
||||
|
||||
REQUIRES <span itemprop="operatingSystem">Windows, OSX, Linux</span>
|
||||
<link itemprop="applicationCategory" href="http://icehrm.com"/>
|
||||
|
||||
RATING:
|
||||
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
|
||||
<span itemprop="ratingValue">4.5</span> (
|
||||
<span itemprop="ratingCount">12</span> ratings )
|
||||
</div>
|
||||
|
||||
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
Price: $<span itemprop="price">199.99</span>
|
||||
<meta itemprop="priceCurrency" content="USD" />
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
@@ -181,9 +229,9 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
ga('create', '<?=BaseService::getInstance()->getGAKey()?>', 'gamonoid.com');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
var key = "";
|
||||
<?php if(isset($_REQUEST['key'])){?>
|
||||
key = '<?=$_REQUEST['key']?>';
|
||||
@@ -253,11 +301,14 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
}
|
||||
|
||||
function submitLogin(){
|
||||
try{
|
||||
localStorage.clear();
|
||||
}catch(e){}
|
||||
$("#loginForm").submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="container">
|
||||
</script>
|
||||
<div class="container">
|
||||
<?php if(defined('DEMO_MODE')){?>
|
||||
<div class="content" style="top: 30px;
|
||||
position: absolute;
|
||||
@@ -292,6 +343,11 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
<input class="span2" type="password" id="password" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<div class="checkbox">
|
||||
<label><input id="remember" name="remember" type="checkbox" value="remember" checked>Remember me</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(isset($_REQUEST['f'])){?>
|
||||
<div class="clearfix alert alert-error" style="font-size:11px;width:147px;margin-bottom: 5px;">
|
||||
Login failed
|
||||
@@ -309,11 +365,10 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
</fieldset>
|
||||
<div class="clearfix">
|
||||
<a href="" onclick="showForgotPassword();return false;" style="float:left;margin-top: 10px;">Forgot password</a>
|
||||
<!--
|
||||
<a href="<?=TWITTER_URL?>" target="_blank" style="float:right;"><img src="<?=BASE_URL?>images/32x32-Circle-53-TW.png"/></a>
|
||||
<a href="<?=FB_URL?>" target="_blank" style="float:right;margin-right: 7px;"><img src="<?=BASE_URL?>images/32x32-Circle-54-FB.png"/></a>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<span style="font-size:9px;">© <a href="http://icehrm.com" target="_blank">IceHrm - v<?=VERSION?></a> Developed by <a href="http://gamonoid.com" target="_blank">Gamonoid (Pvt) Ltd.</a></span>
|
||||
-->
|
||||
</div>
|
||||
</form>
|
||||
<form id="requestPasswordChangeForm" style="display:none;" action="">
|
||||
@@ -349,6 +404,6 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /container -->
|
||||
</div> <!-- /container -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -61,6 +61,10 @@ class ICEHRM_Record extends ADOdb_Active_Record{
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function postProcessGetElement($obj){
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function getDefaultAccessLevel(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- Delete Modal -->
|
||||
<div class="modal fade" id="deleteModel" tabindex="-1" role="dialog" aria-labelledby="deleteModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 id="deleteModelLabel" style="font-size: 17px;"></h3>
|
||||
@@ -13,15 +13,15 @@
|
||||
<button class="btn" onclick="modJs.cancelDelete();">Cancel</button>
|
||||
<button class="btn btn-primary" onclick="modJs.confirmDelete();">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Delete Modal -->
|
||||
|
||||
<!-- Message Modal -->
|
||||
<div class="modal fade" id="messageModel" tabindex="-1" role="dialog" aria-labelledby="messageModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 id="messageModelLabel" style="font-size: 17px;"></h3>
|
||||
@@ -32,23 +32,23 @@
|
||||
<div class="modal-footer">
|
||||
<button class="btn" onclick="modJs.closeMessage();">Ok</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Message Modal -->
|
||||
|
||||
<!-- Plain Message Modal -->
|
||||
<div class="modal fade" id="plainMessageModel" tabindex="-1" role="dialog" aria-labelledby="plainMessageModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="border-bottom:none;/*background-color: #3c8dbc;*/">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top:-10px;"><li class="fa fa-times"/></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p id="plainMessageModelBody"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Plain Message Modal -->
|
||||
|
||||
@@ -89,8 +89,8 @@
|
||||
|
||||
<!-- Upload Modal -->
|
||||
<div class="modal fade" id="uploadModel" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 id="uploadModelLabel" style="font-size: 17px;"></h3>
|
||||
@@ -101,15 +101,15 @@
|
||||
<div class="modal-footer">
|
||||
<button class="btn" onclick="$('#uploadModel').modal('hide');">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Upload Modal -->
|
||||
|
||||
<!-- Message Modal -->
|
||||
<div class="modal fade" id="verifyModel" tabindex="-1" role="dialog" aria-labelledby="verifyModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 id="verifyModelLabel" style="font-size: 17px;"></h3>
|
||||
@@ -144,7 +144,7 @@
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Message Modal -->
|
||||
@@ -183,4 +183,4 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,19 @@
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE FUNCTION generate_fname () RETURNS varchar(255)
|
||||
BEGIN
|
||||
RETURN ELT(FLOOR(1 + (RAND() * (100-1))), "James","Mary","John","Patricia","Robert","Linda","Michael","Barbara","William","Elizabeth","David","Jennifer","Richard","Maria","Charles","Susan","Joseph","Margaret","Thomas","Dorothy","Christopher","Lisa","Daniel","Nancy","Paul","Karen","Mark","Betty","Donald","Helen","George","Sandra","Kenneth","Donna","Steven","Carol","Edward","Ruth","Brian","Sharon","Ronald","Michelle","Anthony","Laura","Kevin","Sarah","Jason","Kimberly","Matthew","Deborah","Gary","Jessica","Timothy","Shirley","Jose","Cynthia","Larry","Angela","Jeffrey","Melissa","Frank","Brenda","Scott","Amy","Eric","Anna","Stephen","Rebecca","Andrew","Virginia","Raymond","Kathleen","Gregory","Pamela","Joshua","Martha","Jerry","Debra","Dennis","Amanda","Walter","Stephanie","Patrick","Carolyn","Peter","Christine","Harold","Marie","Douglas","Janet","Henry","Catherine","Carl","Frances","Arthur","Ann","Ryan","Joyce","Roger","Diane");
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE FUNCTION generate_lname () RETURNS varchar(255)
|
||||
BEGIN
|
||||
RETURN ELT(FLOOR(1 + (RAND() * (100-1))), "Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Jackson","White","Harris","Martin","Thompson","Garcia","Martinez","Robinson","Clark","Rodriguez","Lewis","Lee","Walker","Hall","Allen","Young","Hernandez","King","Wright","Lopez","Hill","Scott","Green","Adams","Baker","Gonzalez","Nelson","Carter","Mitchell","Perez","Roberts","Turner","Phillips","Campbell","Parker","Evans","Edwards","Collins","Stewart","Sanchez","Morris","Rogers","Reed","Cook","Morgan","Bell","Murphy","Bailey","Rivera","Cooper","Richardson","Cox","Howard","Ward","Torres","Peterson","Gray","Ramirez","James","Watson","Brooks","Kelly","Sanders","Price","Bennett","Wood","Barnes","Ross","Henderson","Coleman","Jenkins","Perry","Powell","Long","Patterson","Hughes","Flores","Washington","Butler","Simmons","Foster","Gonzales","Bryant","Alexander","Russell","Griffin","Diaz","Hayes");
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO `CompanyStructures` (`id`, `title`, `description`, `address`, `type`, `country`, `parent`) VALUES
|
||||
(4, 'Development Center', 'Development Center', 'PO Box 001002\nSample Road, Sample Town', 'Regional Office', 'SG', 1),
|
||||
@@ -10,11 +24,23 @@ INSERT INTO `CompanyStructures` (`id`, `title`, `description`, `address`, `type`
|
||||
(9, 'Administration & HR', 'Administration and Human Resource', '', 'Department', 'SG', 4);
|
||||
|
||||
|
||||
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) VALUES
|
||||
(2, 'EMP002', 'Lala', 'Nadila ', 'Lamees', 175, '1984-03-12 18:30:00', 'Female', 'Single', '', '4594567WE3', '4595567WE3', '349-066-YUO', '2012-03-01', 1, 8, 2, 'W001', 'Green War Rd, 00123', '', 'Istanbul', 'TR', NULL, '909066', '+960112345', '+960112345', '+960112345', 'icehrm+manager@web-stalk.com', 'icehrm+manager@web-stalk.com', '2011-03-07 18:30:00', '2012-02-14 18:30:00', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(3, 'EMP003', 'Sofia', '', 'O''Sullivan', 4, '1975-08-28 18:30:00', 'Female', 'Married', '', '768-20-4394', '768-20-4394', '', NULL, 3, 10, 2, '', '2792 Trails End Road', 'Fort Lauderdale', 'Fort Lauderdale', 'US', 12, '33308', '954-388-3340', '954-388-3340', '954-388-3340', 'icehrm+user1@web-stalk.com', 'icehrm+user1@web-stalk.com', '2010-02-08 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(4, 'EMP004', 'Taylor', '', 'Holmes', 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`,`indirect_supervisors`) VALUES
|
||||
(2, 'EMP002', 'Lala', 'Nadila ', 'Lamees', 175, '1984-03-12 18:30:00', 'Female', 'Single', '', '4594567WE3', '4595567WE3', '349-066-YUO', '2012-03-01', 1, 8, 2, 'W001', 'Green War Rd, 00123', '', 'Istanbul', 'TR', NULL, '909066', '+960112345', '+960112345', '+960112345', 'icehrm+manager@web-stalk.com', 'icehrm+manager@web-stalk.com', '2011-03-07 18:30:00', '2012-02-14 18:30:00', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL),
|
||||
(3, 'EMP003', 'Sofia', '', 'O''Sullivan', 4, '1975-08-28 18:30:00', 'Female', 'Married', '', '768-20-4394', '768-20-4394', '', NULL, 3, 10, 2, '', '2792 Trails End Road', 'Fort Lauderdale', 'Fort Lauderdale', 'US', 12, '33308', '954-388-3340', '954-388-3340', '954-388-3340', 'icehrm+user1@web-stalk.com', 'icehrm+user1@web-stalk.com', '2010-02-08 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,'[\"1\"]'),
|
||||
(4, 'EMP004', 'Taylor', '', 'Holmes', 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL);
|
||||
|
||||
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) VALUES
|
||||
(5, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(6, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(7, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(8, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(9, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(10, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(11, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(12, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(13, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(14, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
(15, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
INSERT INTO `EmergencyContacts` (`id`, `employee`, `name`, `relationship`, `home_phone`, `work_phone`, `mobile_phone`) VALUES
|
||||
@@ -36,9 +62,6 @@ INSERT INTO `EmployeeDependents` (`id`, `employee`, `name`, `relationship`, `dob
|
||||
(2, 1, 'Mica Singroo', 'Other', '2000-06-13', '');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO `EmployeeEducations` (`id`, `education_id`, `employee`, `institute`, `date_start`, `date_end`) VALUES
|
||||
(1, 1, 1, 'National University of Turky', '2004-02-03', '2006-06-13'),
|
||||
(2, 1, 2, 'MIT', '1995-02-21', '1999-10-12');
|
||||
@@ -56,12 +79,38 @@ INSERT INTO `EmployeeProjects` (`id`, `employee`, `project`, `date_start`, `date
|
||||
(5, 2, 3, '2013-02-24', '0000-00-00', 'Current', '');
|
||||
|
||||
|
||||
INSERT INTO `EmployeeSalary` (`employee`, `component`,`amount`, `details`) VALUES
|
||||
(1, 1,'50000.00', ''),
|
||||
(1, 2,'20000.00', ''),
|
||||
(1, 3,'30000.00', ''),
|
||||
(1, 4,'2000.00', ''),
|
||||
|
||||
INSERT INTO `EmployeeSalary` (`id`, `employee`, `component`, `pay_frequency`, `currency`, `amount`, `details`) VALUES
|
||||
(1, 1, 1, 'Monthly', 131, '2700.00', ''),
|
||||
(2, 2, 2, 'Monthly', 151, '12000.00', ''),
|
||||
(3, 2, 3, 'Monthly', 131, '5000.00', '');
|
||||
(2, 1,'90500.00', ''),
|
||||
(2, 2,'40000.00', ''),
|
||||
(2, 3,'50000.00', ''),
|
||||
|
||||
(3, 1,'131409.00', ''),
|
||||
(3, 2,'143471.00', ''),
|
||||
(3, 3,'50000.00', ''),
|
||||
(3, 4,'30000.00', ''),
|
||||
|
||||
(4, 5,'1432.00', ''),
|
||||
(4, 6,'2100.00', ''),
|
||||
|
||||
(5, 5,'1200.00', ''),
|
||||
(5, 6,'1500.00', ''),
|
||||
(5, 7,'2000.00', ''),
|
||||
|
||||
(5, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(6, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(7, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(8, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(9, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(10, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(11, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(12, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(13, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
|
||||
(14, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), '');
|
||||
|
||||
INSERT INTO `EmployeeSkills` (`id`, `skill_id`, `employee`, `details`) VALUES
|
||||
(1, 9, 1, 'Creating web sites'),
|
||||
@@ -69,10 +118,37 @@ INSERT INTO `EmployeeSkills` (`id`, `skill_id`, `employee`, `details`) VALUES
|
||||
|
||||
|
||||
|
||||
INSERT INTO `Users` (`id`, `username`, `email`, `password`, `employee`, `user_level`, `last_login`, `last_update`, `created`) VALUES
|
||||
(2, 'manager', 'icehrm+manager@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 2, 'Manager', '2013-01-03 02:47:37', '2013-01-03 02:47:37', '2013-01-03 02:47:37'),
|
||||
(3, 'user1', 'icehrm+user1@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 3, 'Employee', '2013-01-03 02:48:32', '2013-01-03 02:48:32', '2013-01-03 02:48:32'),
|
||||
(4, 'user2', 'icehrm+user2@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 4, 'Employee', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55');
|
||||
|
||||
INSERT INTO `LeaveRules` (`id`, `leave_type`, `job_title`, `employment_status`, `employee`, `supervisor_leave_assign`, `employee_can_apply`, `apply_beyond_current`, `leave_accrue`, `carried_forward`, `default_per_year`) VALUES
|
||||
(1, 1, 11, NULL, NULL, 'No', 'Yes', 'Yes', 'No', 'No', 25),
|
||||
(2, 2, NULL, NULL, 2, 'No', 'Yes', 'Yes', 'No', 'No', 10);
|
||||
|
||||
|
||||
|
||||
INSERT INTO `Users` (`id`, `username`, `email`, `password`, `employee`,`default_module`, `user_level`,`user_roles`, `last_login`, `last_update`, `created`) VALUES
|
||||
(2, 'manager', 'icehrm+manager@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 2,NULL, 'Manager','', '2013-01-03 02:47:37', '2013-01-03 02:47:37', '2013-01-03 02:47:37'),
|
||||
(3, 'user1', 'icehrm+user1@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 3,NULL, 'Employee','', '2013-01-03 02:48:32', '2013-01-03 02:48:32', '2013-01-03 02:48:32'),
|
||||
(4, 'user2', 'icehrm+user2@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 4,NULL, 'Employee','', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55'),
|
||||
(5, 'user3', 'icehrm+user3@web-stalk.com', '4048bb914a704a0728549a26b92d8550', NULL,NULL, 'Other','["1"]', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55');
|
||||
|
||||
INSERT INTO `Job` VALUES
|
||||
(1,'Software Engineer','More than 375,000 users world-wide rely on our software for their daily business as it makes creating graphical presentations so much easier, faster and more enjoyable. Among our customers are many renowned consulting companies and large international corporations.','More than 375,000 users world-wide rely on our software for their daily business as it makes creating graphical presentations so much easier, faster and more enjoyable. Among our customers are many renowned consulting companies and large international corporations.\n\nWe follow our own strategy and do not have to make compromises with regard to code quality and beauty, because think-cell is profitable and has no outside investors. We are flourishing without program managers, meetings, and marketing-driven deadlines. Our code quality is extraordinarily high because we only release software when it is ready. We are willing to do the leg work of developing sophisticated algorithms and refining our user interface, which makes working with think-cell’s software so satisfying.','Challenging C++ coding with high personal responsibility\nWork with a competent and creative team in a modern loft office in Berlin\nFamily-friendly working hours, no deadlines\nAbove-average salary (we offer our developers EUR 120,000 annually after one year of employment)\nFree supply of drinks, fruits, sweets and snacks\nFlat hierarchies and plenty of room for your ideas\nA full-time company nanny who is available for free when children are sick, or when you just feel like spending an evening out','[\"Health plan\",\"Paid vacations\"]',226,2,NULL,'JC001',1,NULL,7,14,9,151,'Yes',3500,5500,'job, engineer','Active','0000-00-00 00:00:00',NULL,'Text Only',1),
|
||||
(2,'QA Senior Test Automation Engineer','As a QA Senior Test Automation Engineer at Rocket you will help us launch the most successful startup companies around the world.','As a QA Senior Test Automation Engineer at Rocket you will help us launch the most successful startup companies around the world.','Responsibilities:\n\nAutomated testing of web and mobile applications\nDevelop automated scenarios/scripts using Cucumber (for web applications) and Calabash (for mobile applications)\nOptimize existing test cases to get more stability and efficiency\nRun automated functional tests as well as performance and load tests\nAnalyze automated test results and report bugs to responsible employees\nSupport the test automation team during the whole development process (starting from the analysis of requirements up to the integration of automated test cases into the CI system (Jenkins)\n\n\nRequirements:\n\nSeveral years of experience as a Test Automation Engineer ( 5+ years )\nExperience with automated solutions such as Cucumber/Calabash, Gherkin, Selenium or similar tools/frameworks\nExperience with Ruby, Python, PHP, JAVA or similar programming languages\nExperience with source code controls like SVN, GIT, CVS\nFamiliarity with Continuous Integration and Delivery\nExperience in Agile Methodologies like Scrum and Kanban or extreme programming\nFluency in speaking & writing English skills\nISTQB certification\n Technology stack we use:\n\nTools: GitHub, Jira, Confluence, Bamboo, Jenkins, Testlink\nScrum, Kanban\nCucumber, Calabash, Capybara, JMeter','[\"Life insurance\"]',80,3,NULL,'JC002',3,NULL,5,14,6,151,'Yes',4000,4500,'','Active','0000-00-00 00:00:00',NULL,'Text Only',1),
|
||||
(3,'Online Editor','Online Editors required for a reputed news agency','Online Editors required for a reputed news agency','','[]',129,NULL,NULL,'J0003',1,NULL,7,23,9,103,'No',0,0,'','Active','0001-01-01 00:00:00','attachment_BI5XQCYFxZO12W1447383181684','Image and Full Text',1);
|
||||
|
||||
INSERT INTO `Candidates` VALUES
|
||||
(1,'Jhon','Doe',4,NULL,'Male',NULL,NULL,NULL,'New York','US',NULL,NULL,'icehrm+jhon@web-stalk.com','+1 455565656',NULL,'Software Engineer','cv_rYwHphV7xD5dOe1444302569136',NULL,NULL,NULL,'','','','','','',NULL,NULL,NULL,NULL,NULL,NULL,'2015-10-08 16:59:20','2015-10-08 16:59:20',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'663fd20d1859344585f678a0f87b23522b8f9fce8c67c5290a609ce342b81442',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
|
||||
INSERT INTO `Files` VALUES
|
||||
(6,'attachment_BI5XQCYFxZO12W1447383181684','attachment_BI5XQCYFxZO12W1447383181684.png',1,'Job');
|
||||
|
||||
|
||||
INSERT INTO `EmployeeDocuments` (`id`,`employee`, `document`, `date_added`, `valid_until`, `status`, `details`, `attachment`, `expire_notification_last`) VALUES
|
||||
(1, 1, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 30 DAY), 'Active', '', NULL, -1),
|
||||
(2, 1, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 7 DAY), 'Active', '', NULL, -1),
|
||||
(3, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 1 DAY), 'Active', '', NULL, -1);
|
||||
|
||||
|
||||
|
||||
INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES
|
||||
(1, FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 30 DAY))) + FLOOR(28800 + (RAND() * 3600)),'%Y-%m-%d %T'), FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 30 DAY))) + FLOOR(57600 + (RAND() * 21600)),'%Y-%m-%d %T'), ''),
|
||||
@@ -116,7 +192,95 @@ INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES
|
||||
(3, FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))) + FLOOR(28800 + (RAND() * 3600)),'%Y-%m-%d %T'), FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))) + FLOOR(57600 + (RAND() * 21600)),'%Y-%m-%d %T'), '');
|
||||
|
||||
|
||||
INSERT INTO `Payroll` VALUES
|
||||
(1,'2016-03',4,1,1,'[\"5\",\"8\",\"9\",\"10\",\"6\",\"7\",\"4\",\"3\",\"2\",\"1\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\"]','2016-03-01','2016-03-31','Draft'),
|
||||
(2,'2016-03-Weekly',2,1,2,'[\"1\",\"2\",\"3\"]','2016-03-01','2016-03-31','Draft');
|
||||
|
||||
INSERT INTO `PayrollColumns` VALUES
|
||||
(5,'Basic Salary',NULL,'[\"1\"]','[]','[]','[]',5,'No','Yes','0.00',NULL,NULL),
|
||||
(6,'Fixed Allowance',NULL,'[\"2\"]','[]','[]','[]',6,'No','Yes','0.00',NULL,NULL),
|
||||
(7,'Gross Pay',NULL,'[]','[]','[\"5\",\"6\"]','[]',7,'No','Yes','0.00',NULL,NULL),
|
||||
(8,'EPF Employee Contribution',NULL,'[]','[\"1\"]','[]','[]',8,'No','Yes','0.00',NULL,NULL),
|
||||
(9,'EPF Employer Contribution',NULL,'[]','[\"2\"]','[]','[]',9,'No','Yes','0.00',NULL,NULL),
|
||||
(10,'ETF Employee Contribution',NULL,'[]','[\"3\"]','[]','[]',10,'No','Yes','0.00',NULL,NULL),
|
||||
(11,'Total EPF 20%',NULL,'[]','[]','[\"8\",\"9\"]','[]',11,'No','Yes','0.00',NULL,NULL),
|
||||
(12,'Total for PAYE',NULL,'[]','[]','[\"7\"]','[]',12,'No','Yes','0.00',NULL,NULL),
|
||||
(13,'PAYE Tax',NULL,'[]','[\"4\"]','[]','[]',13,'No','Yes','0.00',NULL,NULL),
|
||||
(14,'Stamp Duty',NULL,'[]','[\"5\"]','[]','[]',14,'No','Yes','0.00',NULL,NULL),
|
||||
(15,'Total Deductions',NULL,'[]','[]','[\"8\",\"13\",\"14\"]','[]',15,'No','Yes','0.00',NULL,NULL),
|
||||
(16,'Salary to Bank',NULL,'[]','[]','[\"7\"]','[\"15\"]',16,'No','Yes','0.00',NULL,NULL);
|
||||
|
||||
|
||||
INSERT INTO `DeductionGroup` VALUES
|
||||
(1,'Sri Lanka Payroll Calculation',''),
|
||||
(2,'Singapore Payroll Calculation','');
|
||||
|
||||
INSERT INTO `Deductions` VALUES
|
||||
(1,'EPF Employee Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.08\",\"id\":\"rangeAmounts_1\"}]',1),
|
||||
(2,'EPF Employer Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.12\",\"id\":\"rangeAmounts_1\"}]',1),
|
||||
(3,'ETF Employee Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.03\",\"id\":\"rangeAmounts_1\"}]',1),
|
||||
(4,'PAYE Tax','[]','[]',12,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"62500\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"62500\",\"upperCondition\":\"lte\",\"upperLimit\":\"104167\",\"amount\":\"X*0.04 - 2500\",\"id\":\"rangeAmounts_2\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"104167\",\"upperCondition\":\"lte\",\"upperLimit\":\"145833\",\"amount\":\"X*0.08 - 6667\",\"id\":\"rangeAmounts_3\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"145833\",\"upperCondition\":\"lte\",\"upperLimit\":\"187500\",\"amount\":\"X*0.12-12500\",\"id\":\"rangeAmounts_4\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"187500\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.16 - 20000\",\"id\":\"rangeAmounts_5\"}]',1),
|
||||
(5,'Stamp Duty','[]','[]',12,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"25000\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"25000\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"25\",\"id\":\"rangeAmounts_2\"}]',1);
|
||||
|
||||
INSERT INTO `PayrollEmployees` VALUES
|
||||
(1,1,4,151,'[]','[]',1),
|
||||
(2,2,4,151,'[]','[]',1),
|
||||
(3,3,4,151,'[]','[]',1),
|
||||
(4,4,2,151,'[]','[]',1),
|
||||
(5,5,2,151,'[]','[]',1),
|
||||
(6,6,4,151,'[]','[]',1),
|
||||
(7,7,4,151,'[]','[]',1),
|
||||
(8,8,4,151,'[]','[]',1),
|
||||
(9,9,4,151,'[]','[]',1),
|
||||
(10,10,4,151,'[]','[]',1);
|
||||
|
||||
INSERT INTO `EmployeeLeaves` VALUES
|
||||
(1,1,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Test Reason 1','Pending',''),
|
||||
(2,1,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),'Test Reason 2','Approved',''),
|
||||
(3,2,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Test Reason 3','Approved',''),
|
||||
|
||||
(4,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(5,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(6,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(7,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(8,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(9,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(10,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(11,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(12,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(13,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(14,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(15,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(16,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(17,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
|
||||
(18,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),'Test Reason 22','Pending','');
|
||||
|
||||
INSERT INTO `EmployeeLeaveDays` VALUES
|
||||
(1,1,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(2,1,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),'Half Day - Morning'),
|
||||
(3,2,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Half Day - Morning'),
|
||||
|
||||
(4,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),'3 Hours - Morning'),
|
||||
(5,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(6,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(7,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(8,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(9,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(10,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(11,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(12,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(13,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(14,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(15,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(16,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(17,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),'Full Day'),
|
||||
(18,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),'Full Day');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('Instance : ID', '0847429146712c108e23c435e8f93b4d', '',''),
|
||||
('Instance: Key', 'UQHEYBx9H1eNR66nhNCNCz1WCDDhkjtx1OuJbO3ZQMt+8tfSGvuOH/YEHntRajY=', '','');
|
||||
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
|
||||
@@ -125,11 +289,3 @@ INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +99,12 @@ create table `Nationality` (
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
CREATE TABLE `PayFrequency` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(200) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
create table `Employees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee_id` varchar(50) default null,
|
||||
@@ -106,7 +112,7 @@ create table `Employees` (
|
||||
`middle_name` varchar(100) default null,
|
||||
`last_name` varchar(100) default null,
|
||||
`nationality` bigint(20) default null,
|
||||
`birthday` DATETIME default '0000-00-00 00:00:00',
|
||||
`birthday` date default '0000-00-00',
|
||||
`gender` enum('Male','Female') default NULL,
|
||||
`marital_status` enum('Married','Single','Divorced','Widowed','Other') default NULL,
|
||||
`ssn_num` varchar(100) default NULL,
|
||||
@@ -129,9 +135,10 @@ create table `Employees` (
|
||||
`work_phone` varchar(50) default null,
|
||||
`work_email` varchar(100) default null,
|
||||
`private_email` varchar(100) default null,
|
||||
`joined_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`confirmation_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`joined_date` date default '0000-00-00',
|
||||
`confirmation_date` date default '0000-00-00',
|
||||
`supervisor` bigint(20) default null,
|
||||
`indirect_supervisors` varchar(250) default null,
|
||||
`department` bigint(20) default null,
|
||||
`custom1` varchar(250) default null,
|
||||
`custom2` varchar(250) default null,
|
||||
@@ -143,7 +150,7 @@ create table `Employees` (
|
||||
`custom8` varchar(250) default null,
|
||||
`custom9` varchar(250) default null,
|
||||
`custom10` varchar(250) default null,
|
||||
`termination_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`termination_date` date default '0000-00-00',
|
||||
`notes` text default null,
|
||||
`status` enum('Active','Terminated') default 'Active',
|
||||
`ethnicity` bigint(20) default null,
|
||||
@@ -161,6 +168,7 @@ create table `Employees` (
|
||||
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `ArchivedEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`ref_id` bigint(20) NOT NULL,
|
||||
@@ -202,12 +210,16 @@ create table `Users` (
|
||||
`last_login` timestamp default '0000-00-00 00:00:00',
|
||||
`last_update` timestamp default '0000-00-00 00:00:00',
|
||||
`created` timestamp default '0000-00-00 00:00:00',
|
||||
`login_hash` varchar(64) default null,
|
||||
CONSTRAINT `Fk_User_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
unique key `username` (`username`)
|
||||
unique key `username` (`username`),
|
||||
INDEX login_hash_index (`login_hash`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
create table `EmployeeSkills` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`skill_id` bigint(20) NULL,
|
||||
@@ -284,6 +296,134 @@ create table `EmployeeDependents` (
|
||||
|
||||
|
||||
|
||||
create table `LeaveTypes` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`supervisor_leave_assign` enum('Yes','No') default 'Yes',
|
||||
`employee_can_apply` enum('Yes','No') default 'Yes',
|
||||
`apply_beyond_current` enum('Yes','No') default 'Yes',
|
||||
`leave_accrue` enum('No','Yes') default 'No',
|
||||
`carried_forward` enum('No','Yes') default 'No',
|
||||
`default_per_year` decimal(10,3) NOT NULL,
|
||||
`carried_forward_percentage` int(11) NULL default 0,
|
||||
`carried_forward_leave_availability` int(11) NULL default 365,
|
||||
`propotionate_on_joined_date` enum('No','Yes') default 'No',
|
||||
`send_notification_emails` enum('Yes','No') default 'Yes',
|
||||
`leave_group` bigint(20) NULL,
|
||||
`leave_color` varchar(10) NULL,
|
||||
`max_carried_forward_amount` int(11) NULL default 0,
|
||||
primary key (`id`),
|
||||
unique key (`name`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeaveRules` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`job_title` bigint(20) NULL,
|
||||
`employment_status` bigint(20) NULL,
|
||||
`employee` bigint(20) NULL,
|
||||
`supervisor_leave_assign` enum('Yes','No') default 'Yes',
|
||||
`employee_can_apply` enum('Yes','No') default 'Yes',
|
||||
`apply_beyond_current` enum('Yes','No') default 'Yes',
|
||||
`leave_accrue` enum('No','Yes') default 'No',
|
||||
`carried_forward` enum('No','Yes') default 'No',
|
||||
`default_per_year` decimal(10,3) NOT NULL,
|
||||
`carried_forward_percentage` int(11) NULL default 0,
|
||||
`carried_forward_leave_availability` int(11) NULL default 365,
|
||||
`propotionate_on_joined_date` enum('No','Yes') default 'No',
|
||||
`leave_group` bigint(20) NULL,
|
||||
`max_carried_forward_amount` int(11) NULL default 0,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `LeaveGroups` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`created` timestamp NULL default '0000-00-00 00:00:00',
|
||||
`updated` timestamp NULL default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeaveGroupEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`leave_group` bigint(20) NOT NULL,
|
||||
`created` timestamp NULL default '0000-00-00 00:00:00',
|
||||
`updated` timestamp NULL default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_LeaveGroupEmployees_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_LeaveGroupEmployees_LeaveGroups` FOREIGN KEY (`leave_group`) REFERENCES `LeaveGroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
unique key `LeaveGroupEmployees_employee` (`employee`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeavePeriods` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`date_start` date default '0000-00-00',
|
||||
`date_end` date default '0000-00-00',
|
||||
`status` enum('Active','Inactive') default 'Inactive',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `WorkDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`status` enum('Full Day','Half Day','Non-working Day') default 'Full Day',
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key `workdays_name_country` (`name`,`country`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `HoliDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`dateh` date default '0000-00-00',
|
||||
`status` enum('Full Day','Half Day') default 'Full Day',
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key `holidays_dateh_country` (`dateh`,`country`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaves` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`leave_period` bigint(20) NOT NULL,
|
||||
`date_start` date default '0000-00-00',
|
||||
`date_end` date default '0000-00-00',
|
||||
`details` text default null,
|
||||
`status` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`attachment` varchar(100) NULL,
|
||||
CONSTRAINT `Fk_EmployeeLeaves_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeLeaves_LeaveTypes` FOREIGN KEY (`leave_type`) REFERENCES `LeaveTypes` (`id`),
|
||||
CONSTRAINT `Fk_EmployeeLeaves_LeavePeriods` FOREIGN KEY (`leave_period`) REFERENCES `LeavePeriods` (`id`),
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaveLog` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee_leave` bigint(20) NOT NULL,
|
||||
`user_id` bigint(20) NULL,
|
||||
`data` varchar(500) NOT NULL,
|
||||
`status_from` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`status_to` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`created` timestamp default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_EmployeeLeaveLog_EmployeeLeaves` FOREIGN KEY (`employee_leave`) REFERENCES `EmployeeLeaves` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeLeaveLog_Users` FOREIGN KEY (`user_id`) REFERENCES `Users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaveDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee_leave` bigint(20) NOT NULL,
|
||||
`leave_date` date default '0000-00-00',
|
||||
`leave_type` enum('Full Day','Half Day - Morning','Half Day - Afternoon','1 Hour - Morning','2 Hours - Morning','3 Hours - Morning','1 Hour - Afternoon','2 Hours - Afternoon','3 Hours - Afternoon') NOT NULL,
|
||||
CONSTRAINT `Fk_EmployeeLeaveDays_EmployeeLeaves` FOREIGN KEY (`employee_leave`) REFERENCES `EmployeeLeaves` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Files` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
@@ -365,8 +505,52 @@ create table `EmployeeTimeEntry` (
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Documents` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`expire_notification` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_month` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_week` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_day` enum('Yes','No') default 'Yes',
|
||||
`sign` enum('Yes','No') default 'Yes',
|
||||
`sign_label` VARCHAR(500) default null,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `EmployeeDocuments` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`document` bigint(20) NULL,
|
||||
`date_added` date NOT NULL,
|
||||
`valid_until` date NOT NULL,
|
||||
`status` enum('Active','Inactive','Draft') default 'Active',
|
||||
`details` text default null,
|
||||
`attachment` varchar(100) NULL,
|
||||
`signature` text default null,
|
||||
`expire_notification_last` int(4) NULL,
|
||||
CONSTRAINT `Fk_EmployeeDocuments_Documents` FOREIGN KEY (`document`) REFERENCES `Documents` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeDocuments_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
KEY `KEY_EmployeeDocuments_valid_until` (`valid_until`),
|
||||
KEY `KEY_EmployeeDocuments_valid_until_status` (`valid_until`,`status`,`expire_notification_last`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `CompanyDocuments` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`valid_until` date NOT NULL,
|
||||
`status` enum('Active','Inactive','Draft') default 'Active',
|
||||
`notify_employees` enum('Yes','No') default 'Yes',
|
||||
`attachment` varchar(100) NULL,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `CompanyLoans` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
@@ -496,6 +680,56 @@ create table `Notifications` (
|
||||
KEY `toUser_status_time` (`toUser`,`status`,`time`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Courses` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(300) NOT NULL,
|
||||
`name` varchar(300) NOT NULL,
|
||||
`description` text default null,
|
||||
`coordinator` bigint(20) NULL,
|
||||
`trainer` varchar(300) NULL,
|
||||
`trainer_info` text default null,
|
||||
`paymentType` enum('Company Sponsored','Paid by Employee') default 'Company Sponsored',
|
||||
`currency` varchar(3) null,
|
||||
`cost` decimal(12,2) DEFAULT 0.00,
|
||||
`status` enum('Active','Inactive') default 'Active',
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_Courses_Employees` FOREIGN KEY (`coordinator`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `TrainingSessions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(300) NOT NULL,
|
||||
`course` bigint(20) NOT NULL,
|
||||
`description` text default null,
|
||||
`scheduled` datetime default '0000-00-00 00:00:00',
|
||||
`dueDate` datetime default '0000-00-00 00:00:00',
|
||||
`deliveryMethod` enum('Classroom','Self Study','Online') default 'Classroom',
|
||||
`deliveryLocation` varchar(500) NULL,
|
||||
`status` enum('Pending','Approved','Completed','Cancelled') default 'Pending',
|
||||
`attendanceType` enum('Sign Up','Assign') default 'Sign Up',
|
||||
`attachment` varchar(300) NULL,
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
`requireProof` enum('Yes','No') default 'Yes',
|
||||
CONSTRAINT `Fk_TrainingSessions_Courses` FOREIGN KEY (`course`) REFERENCES `Courses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `EmployeeTrainingSessions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`trainingSession` bigint(20) NULL,
|
||||
`feedBack` varchar(1500) NULL,
|
||||
`status` enum('Scheduled','Attended','Not-Attended','Completed') default 'Scheduled',
|
||||
`proof` varchar(300) NULL,
|
||||
CONSTRAINT `Fk_EmployeeTrainingSessions_TrainingSessions` FOREIGN KEY (`trainingSession`) REFERENCES `TrainingSessions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeTrainingSessions_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `ImmigrationDocuments` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
@@ -648,67 +882,284 @@ create table `EmployeeSalary` (
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `DeductionGroup` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(100) NOT NULL,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Deductions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`contributor` enum('Employee','Employer') default NULL,
|
||||
`type` enum('Fixed','Percentage') default NULL,
|
||||
`percentage_type` enum('On Component','On Component Type') default NULL,
|
||||
`componentType` bigint(20) NULL,
|
||||
`component` bigint(20) NULL,
|
||||
`componentType` varchar(250) NULL,
|
||||
`component` varchar(250) NULL,
|
||||
`payrollColumn` int(11) DEFAULT NULL,
|
||||
`rangeAmounts` text default null,
|
||||
`country` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_Deductions_Country` FOREIGN KEY (`country`) REFERENCES `Country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
`deduction_group` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_Deductions_DeductionGroup` FOREIGN KEY (`deduction_group`) REFERENCES `DeductionGroup` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Tax` (
|
||||
|
||||
|
||||
|
||||
create table `PayrollEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`contributor` enum('Employee','Employer') default NULL,
|
||||
`type` enum('Fixed','Percentage') default NULL,
|
||||
`percentage_type` enum('On Component','On Component Type') default NULL,
|
||||
`componentType` bigint(20) NULL,
|
||||
`component` bigint(20) NULL,
|
||||
`rangeAmounts` text default null,
|
||||
`country` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_Tax_Country` FOREIGN KEY (`country`) REFERENCES `Country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`pay_frequency` int(11) default null,
|
||||
`currency` bigint(20) NULL,
|
||||
`deduction_exemptions` varchar(250) default null,
|
||||
`deduction_allowed` varchar(250) default null,
|
||||
`deduction_group` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_PayrollEmployee_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_PayrollEmployees_DeductionGroup` FOREIGN KEY (`deduction_group`) REFERENCES `DeductionGroup` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
unique key `PayrollEmployees_employee` (`employee`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `TaxRules` (
|
||||
CREATE TABLE `PayrollColumnTemplates` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`apply` enum('Yes','No') default 'Yes',
|
||||
`application_type` enum('All','Condition - OR','Condition - AND') default 'All',
|
||||
`tax` bigint(20) NOT NULL,
|
||||
`job_title` bigint(20) NULL,
|
||||
`ethnicity` bigint(20) NULL,
|
||||
`nationality` bigint(20) NULL,
|
||||
`immigration_status` bigint(20) NULL,
|
||||
`pay_grade` bigint(20) NULL,
|
||||
`country` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_TaxRules_Tax` FOREIGN KEY (`tax`) REFERENCES `Tax` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_TaxRules_Country` FOREIGN KEY (`country`) REFERENCES `Country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
`columns` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
create table `DeductionRules` (
|
||||
create table `Payroll` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`apply` enum('Yes','No') default 'Yes',
|
||||
`application_type` enum('All','Condition - OR','Condition - AND') default 'All',
|
||||
`deduction` bigint(20) NOT NULL,
|
||||
`job_title` bigint(20) NULL,
|
||||
`ethnicity` bigint(20) NULL,
|
||||
`nationality` bigint(20) NULL,
|
||||
`immigration_status` bigint(20) NULL,
|
||||
`pay_grade` bigint(20) NULL,
|
||||
`country` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_DeductionRules_Deductions` FOREIGN KEY (`deduction`) REFERENCES `Deductions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_DeductionRules_Country` FOREIGN KEY (`country`) REFERENCES `Country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
`name` varchar(200) NULL,
|
||||
`pay_period` bigint(20) NOT NULL,
|
||||
`department` bigint(20) NOT NULL,
|
||||
`column_template` bigint(20) NOT NULL,
|
||||
`columns` varchar(500) DEFAULT NULL,
|
||||
`date_start` DATE NULL default '0000-00-00',
|
||||
`date_end` DATE NULL default '0000-00-00',
|
||||
`status` enum('Draft','Completed','Processing') default 'Draft',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `PayrollData` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`payroll` bigint(20) NOT NULL,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`payroll_item` int(11) NOT NULL,
|
||||
`amount` varchar(25) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `PayrollDataUniqueKey` (`payroll`,`employee`,`payroll_item`),
|
||||
CONSTRAINT `Fk_PayrollData_Payroll` FOREIGN KEY (`payroll`) REFERENCES `Payroll` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `PayrollColumns` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
`calculation_hook` varchar(200) DEFAULT NULL,
|
||||
`salary_components` varchar(500) DEFAULT NULL,
|
||||
`deductions` varchar(500) DEFAULT NULL,
|
||||
`add_columns` varchar(500) DEFAULT NULL,
|
||||
`sub_columns` varchar(500) DEFAULT NULL,
|
||||
`colorder` int(11) DEFAULT NULL,
|
||||
`editable` enum('Yes','No') default 'Yes',
|
||||
`enabled` enum('Yes','No') default 'Yes',
|
||||
`default_value` varchar(25) DEFAULT NULL,
|
||||
`calculation_columns` varchar(500) DEFAULT NULL,
|
||||
`calculation_function` varchar(100) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
create table `EmployementType` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Industry` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `ExperienceLevel` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `JobFunction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EducationLevel` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Benifits` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Tags` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Job` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`shortDescription` text DEFAULT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`requirements` text DEFAULT NULL,
|
||||
`benefits` text DEFAULT NULL,
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
`company` bigint(20) DEFAULT NULL,
|
||||
`department` VARCHAR(100) NULL,
|
||||
`code` VARCHAR(20) NULL,
|
||||
`employementType` bigint(20) DEFAULT NULL,
|
||||
`industry` bigint(20) DEFAULT NULL,
|
||||
`experienceLevel` bigint(20) DEFAULT NULL,
|
||||
`jobFunction` bigint(20) DEFAULT NULL,
|
||||
`educationLevel` bigint(20) DEFAULT NULL,
|
||||
`currency` bigint(20) DEFAULT NULL,
|
||||
`showSalary` enum('Yes','No') default NULL,
|
||||
`salaryMin` bigint(20) DEFAULT NULL,
|
||||
`salaryMax` bigint(20) DEFAULT NULL,
|
||||
`keywords` text DEFAULT NULL,
|
||||
`status` enum('Active','On hold','Closed') default NULL,
|
||||
`closingDate` DATETIME default '0000-00-00 00:00:00',
|
||||
`attachment` varchar(100) NULL,
|
||||
`display` varchar(200) NOT NULL,
|
||||
`postedBy` bigint(20) DEFAULT NULL,
|
||||
INDEX `Job_status` (`status`),
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Candidates` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`first_name` varchar(100) default '' not null,
|
||||
`last_name` varchar(100) default '' not null,
|
||||
`nationality` bigint(20) default null,
|
||||
`birthday` DATETIME default '0000-00-00 00:00:00',
|
||||
`gender` enum('Male','Female') default NULL,
|
||||
`marital_status` enum('Married','Single','Divorced','Widowed','Other') default NULL,
|
||||
`address1` varchar(100) default '',
|
||||
`address2` varchar(100) default '',
|
||||
`city` varchar(150) default '',
|
||||
`country` char(2) default null,
|
||||
`province` bigint(20) default null,
|
||||
`postal_code` varchar(20) default null,
|
||||
`email` varchar(200) default null,
|
||||
`home_phone` varchar(50) default null,
|
||||
`mobile_phone` varchar(50) default null,
|
||||
`cv_title` varchar(200) default '' not null,
|
||||
`cv` varchar(150) NULL,
|
||||
`cvtext` text NULL,
|
||||
`industry` text DEFAULT NULL,
|
||||
`profileImage` varchar(150) NULL,
|
||||
`head_line` text DEFAULT NULL,
|
||||
`objective` text DEFAULT NULL,
|
||||
`work_history` text DEFAULT NULL,
|
||||
`education` text DEFAULT NULL,
|
||||
`skills` text DEFAULT NULL,
|
||||
`referees` text DEFAULT NULL,
|
||||
`linkedInUrl` varchar(500) DEFAULT NULL,
|
||||
`linkedInData` text DEFAULT NULL,
|
||||
`totalYearsOfExperience` int(11) default null,
|
||||
`totalMonthsOfExperience` int(11) default null,
|
||||
`htmlCVData` longtext DEFAULT NULL,
|
||||
`generatedCVFile` varchar(150) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`expectedSalary` int(11) default null,
|
||||
`preferedPositions` text default null,
|
||||
`preferedJobtype` varchar(60) default null,
|
||||
`preferedCountries` text default null,
|
||||
`tags` text default null,
|
||||
`notes` text default null,
|
||||
`calls` text default null,
|
||||
`age` int(11) default null,
|
||||
`hash` varchar(100) DEFAULT NULL,
|
||||
`linkedInProfileLink` varchar(250) DEFAULT NULL,
|
||||
`linkedInProfileId` varchar(50) DEFAULT NULL,
|
||||
`facebookProfileLink` varchar(250) DEFAULT NULL,
|
||||
`facebookProfileId` varchar(50) DEFAULT NULL,
|
||||
`twitterProfileLink` varchar(250) DEFAULT NULL,
|
||||
`twitterProfileId` varchar(50) DEFAULT NULL,
|
||||
`googleProfileLink` varchar(250) DEFAULT NULL,
|
||||
`googleProfileId` varchar(50) DEFAULT NULL,
|
||||
primary key (`id`)
|
||||
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Applications` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`referredByEmail` varchar(200) DEFAULT NULL,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key (`job`,`candidate`),
|
||||
CONSTRAINT `Fk_Applications_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Applications_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Interviews` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`level` varchar(100) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`scheduled` DATETIME default '0000-00-00 00:00:00',
|
||||
`location` varchar(500) DEFAULT NULL,
|
||||
`mapId` bigint(20) NULL,
|
||||
`status` varchar(100) default null,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
CONSTRAINT `Fk_Interviews_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Interviews_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Calls` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`phone` varchar(20) default null,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`status` varchar(100) default null,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
CONSTRAINT `Fk_Calls_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Calls_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `LeaveStartingBalance` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`employee` bigint(20) NULL,
|
||||
`leave_period` bigint(20) NOT NULL,
|
||||
`amount` decimal(10,3) NOT NULL,
|
||||
`note` text DEFAULT NULL,
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Crons` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
@@ -788,3 +1239,21 @@ create table `Timezones` (
|
||||
`details` varchar(255) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeDataHistory` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`type` varchar(100) not null,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`field` varchar(100) not null,
|
||||
`old_value` varchar(500) default null,
|
||||
`new_value` varchar(500) default null,
|
||||
`description` varchar(800) default null,
|
||||
`user` bigint(20) NULL,
|
||||
`updated` timestamp default '0000-00-00 00:00:00',
|
||||
`created` timestamp default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_EmployeeDataHistory_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeDataHistory_Users` FOREIGN KEY (`user`) REFERENCES `Users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
839
core-ext/scripts/upgrade_v15.2.OS_to_v16.0.OS.sql
Normal file
839
core-ext/scripts/upgrade_v15.2.OS_to_v16.0.OS.sql
Normal file
@@ -0,0 +1,839 @@
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
|
||||
('Employee Details Report', 'This report list all employee details and you can filter employees by department, employment status or job title', '[\r\n[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "employment_status", {"label":"Employment Status","type":"select2","remote-source":["EmploymentStatus","id","name"],"allow-null":true}],\r\n[ "job_title", {"label":"Job Title","type":"select2","remote-source":["JobTitle","id","name"],"allow-null":true}]\r\n]', 'Select id, employee_id as ''Employee ID'',\r\nconcat(`first_name`,'' '',`middle_name`,'' '', `last_name`) as ''Name'',\r\n(SELECT name from Nationality where id = nationality) as ''Nationality'',\r\nbirthday as ''Birthday'',\r\ngender as ''Gender'',\r\nmarital_status as ''Marital Status'',\r\nssn_num as ''SSN Number'',\r\nnic_num as ''NIC Number'',\r\nother_id as ''Other IDs'',\r\ndriving_license as ''Driving License Number'',\r\n(SELECT name from EmploymentStatus where id = employment_status) as ''Employment Status'',\r\n(SELECT name from JobTitles where id = job_title) as ''Job Title'',\r\n(SELECT name from PayGrades where id = pay_grade) as ''Pay Grade'',\r\nwork_station_id as ''Work Station ID'',\r\naddress1 as ''Address 1'',\r\naddress2 as ''Address 2'',\r\ncity as ''City'',\r\n(SELECT name from Country where code = country) as ''Country'',\r\n(SELECT name from Province where id = province) as ''Province'',\r\npostal_code as ''Postal Code'',\r\nhome_phone as ''Home Phone'',\r\nmobile_phone as ''Mobile Phone'',\r\nwork_phone as ''Work Phone'',\r\nwork_email as ''Work Email'',\r\nprivate_email as ''Private Email'',\r\njoined_date as ''Joined Date'',\r\nconfirmation_date as ''Confirmation Date'',\r\n(SELECT title from CompanyStructures where id = department) as ''Department'',\r\n(SELECT concat(`first_name`,'' '',`middle_name`,'' '', `last_name`,'' [Employee ID:'',`employee_id`,'']'') from Employees e1 where e1.id = e.supervisor) as ''Supervisor'' \r\nFROM Employees e _where_', '["department","employment_status","job_title"]', 'Query', 'Employee Information'),
|
||||
('Employee Time Entry Report', 'This report list all employee time entries by employee, date range and project', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "project", {"label":"Project","type":"select","allow-null":true,"remote-source":["Project","id","name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'EmployeeTimesheetReport', '["employee","date_start","date_end","status"]', 'Class','Time Management'),
|
||||
('Employee Attendance Report', 'This report list all employee attendance entries by employee and date range', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'EmployeeAttendanceReport', '["employee","date_start","date_end"]', 'Class','Time Management'),
|
||||
('Employee Time Tracking Report', 'This report list employee working hours and attendance details for each day for a given period ', '[\r\n[ "employee", {"label":"Employee","type":"select2","allow-null":false,"remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'EmployeeTimeTrackReport', '["employee","date_start","date_end"]', 'Class','Time Management');
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
|
||||
('Active Employee Report', 'This report list employees who are currently active based on joined date and termination date ',
|
||||
'[\r\n[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}]\r\n]',
|
||||
'ActiveEmployeeReport',
|
||||
'["department"]', 'Class','Employee Information');
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`, `report_group`) VALUES
|
||||
('New Hires Employee Report', 'This report list employees who are joined between given two dates ',
|
||||
'[[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]',
|
||||
'NewHiresEmployeeReport',
|
||||
'["department","date_start","date_end"]', 'Class','Employee Information');
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`, `report_group`) VALUES
|
||||
('Terminated Employee Report', 'This report list employees who are terminated between given two dates ',
|
||||
'[[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]',
|
||||
'TerminatedEmployeeReport',
|
||||
'["department","date_start","date_end"]', 'Class','Employee Information');
|
||||
|
||||
|
||||
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
|
||||
('Employee Time Sheet Report', 'This report list all employee time sheets by employee and date range', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}],\r\n[ "status", {"label":"Status","allow-null":true,"null-label":"All Status","type":"select","source":[["Approved","Approved"],["Pending","Pending"],["Rejected","Rejected"]]}]\r\n]', 'EmployeeTimeSheetData', '["employee","date_start","date_end","status"]', 'Class','Time Management');
|
||||
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('LDAP: Enabled', '0', '','["value", {"label":"Value","type":"select","source":[["0","No"],["1","Yes"]]}]'),
|
||||
('LDAP: Server', '', 'LDAP Server IP or DNS',''),
|
||||
('LDAP: Port', '389', 'LDAP Server Port',''),
|
||||
('LDAP: Root DN', '', 'e.g: dc=mycompany,dc=net',''),
|
||||
('LDAP: Manager DN', '', 'e.g: cn=admin,dc=mycompany,dc=net',''),
|
||||
('LDAP: Manager Password', '', 'Password of the manager user',''),
|
||||
('LDAP: Version 3', '1', 'Are you using LDAP v3','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]'),
|
||||
('LDAP: User Filter', '', 'e.g: uid={}, we will replace {} with actual username provided by the user at the time of login','');
|
||||
|
||||
|
||||
|
||||
|
||||
/* v15.0.PRO to v16.0.PRO */
|
||||
|
||||
ALTER TABLE `Users` ADD COLUMN `login_hash` varchar(64) default null;
|
||||
ALTER TABLE `Users` ADD INDEX login_hash_index (`login_hash`);
|
||||
|
||||
INSERT INTO `ImmigrationStatus` VALUES
|
||||
(1,'Citizen'),
|
||||
(2,'Permanent Resident'),
|
||||
(3,'Work Permit Holder'),
|
||||
(4,'Dependant Pass Holder');
|
||||
|
||||
INSERT INTO `Ethnicity` VALUES
|
||||
(1,'White American'),
|
||||
(2,'Black or African American'),
|
||||
(3,'Native American'),
|
||||
(4,'Alaska Native'),
|
||||
(5,'Asian American'),
|
||||
(6,'Native Hawaiian'),
|
||||
(7,'Pacific Islander');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('Attendance: Overtime Calculation Class', 'BasicOvertimeCalculator', 'Set the method used to calculate overtime','["value", {"label":"Value","type":"select","source":[["BasicOvertimeCalculator","BasicOvertimeCalculator"],["CaliforniaOvertimeCalculator","CaliforniaOvertimeCalculator"]]}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('Attendance: Work Week Start Day', '0', 'Set the starting day of the work week','["value", {"label":"Value","type":"select","source":[["0","Sunday"],["1","Monday"],["2","Tuesday"],["3","Wednesday"],["4","Thursday"],["5","Friday"],["6","Saturday"]]}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('System: Reset Module Names', '1', 'Select this to reset module names in Database','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('Attendance: Overtime Start Hour', '8', 'Overtime calculation will start after an employee work this number of hours per day, 0 to indicate no overtime', ''),
|
||||
('Attendance: Double time Start Hour', '12', 'Double time calculation will start after an employee work this number of hours per day, 0 to indicate no double time', ''),
|
||||
('Api: REST Api Enabled', '1', '','["value", {"label":"Value","type":"select","source":[["0","No"],["1","Yes"]]}]'),
|
||||
('Api: REST Api Token', 'Click on edit icon', '','["value", {"label":"Value","type":"placeholder"}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('System: Allowed Countries', '0', 'Only these countries will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["Country","id","name"]}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('System: Allowed Currencies', '0', 'Only these currencies will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["CurrencyType","id","code+name"]}]');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('System: Allowed Nationality', '', 'Only these nationalities will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["Nationality","id","name"]}]');
|
||||
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
|
||||
('Overtime Report', 'This report list all employee attendance entries by employee with overtime calculations', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'OvertimeReport', '["employee","date_start","date_end"]', 'Class','Time Management');
|
||||
|
||||
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
|
||||
('Overtime Summary Report', 'This report list all employee attendance entries by employee with overtime calculation summary', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'OvertimeSummaryReport', '["employee","date_start","date_end"]', 'Class','Time Management');
|
||||
|
||||
create table `EmployeeDataHistory` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`type` varchar(100) not null,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`field` varchar(100) not null,
|
||||
`old_value` varchar(500) default null,
|
||||
`new_value` varchar(500) default null,
|
||||
`description` varchar(800) default null,
|
||||
`user` bigint(20) NULL,
|
||||
`updated` timestamp default '0000-00-00 00:00:00',
|
||||
`created` timestamp default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_EmployeeDataHistory_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeDataHistory_Users` FOREIGN KEY (`user`) REFERENCES `Users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
Alter table `Employees` modify column `joined_date` date default '0000-00-00';
|
||||
Alter table `Employees` modify column `confirmation_date` date default '0000-00-00';
|
||||
Alter table `Employees` modify column `termination_date` date default '0000-00-00';
|
||||
Alter table `Employees` modify column `birthday` date default '0000-00-00';
|
||||
|
||||
|
||||
REPLACE INTO `FieldNameMappings` (`type`, `name`, `textOrig`, `textMapped`, `display`) VALUES
|
||||
('Employee', 'indirect_supervisors', 'Indirect Supervisors', 'Indirect Supervisors', 'Form');
|
||||
|
||||
Update Crons set time = (FLOOR( 1 + RAND( ) *58 )), type = 'Hourly' where name = 'Document Expire Alert';
|
||||
|
||||
CREATE TABLE `PayFrequency` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(200) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
INSERT INTO `PayFrequency` VALUES
|
||||
(1,'Bi Weekly'),
|
||||
(2,'Weekly'),
|
||||
(3,'Semi Monthly'),
|
||||
(4,'Monthly'),
|
||||
(5,'Yearly');
|
||||
|
||||
|
||||
CREATE TABLE `PayrollColumnTemplates` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
`columns` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
create table `Payroll` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(200) NULL,
|
||||
`pay_period` bigint(20) NOT NULL,
|
||||
`department` bigint(20) NOT NULL,
|
||||
`column_template` bigint(20) NOT NULL,
|
||||
`columns` varchar(500) DEFAULT NULL,
|
||||
`date_start` DATE NULL default '0000-00-00',
|
||||
`date_end` DATE NULL default '0000-00-00',
|
||||
`status` enum('Draft','Completed','Processing') default 'Draft',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `PayrollData` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`payroll` bigint(20) NOT NULL,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`payroll_item` int(11) NOT NULL,
|
||||
`amount` varchar(25) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `PayrollDataUniqueKey` (`payroll`,`employee`,`payroll_item`),
|
||||
CONSTRAINT `Fk_PayrollData_Payroll` FOREIGN KEY (`payroll`) REFERENCES `Payroll` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `PayrollColumns` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
`calculation_hook` varchar(200) DEFAULT NULL,
|
||||
`salary_components` varchar(500) DEFAULT NULL,
|
||||
`deductions` varchar(500) DEFAULT NULL,
|
||||
`add_columns` varchar(500) DEFAULT NULL,
|
||||
`sub_columns` varchar(500) DEFAULT NULL,
|
||||
`colorder` int(11) DEFAULT NULL,
|
||||
`editable` enum('Yes','No') default 'Yes',
|
||||
`enabled` enum('Yes','No') default 'Yes',
|
||||
`default_value` varchar(25) DEFAULT NULL,
|
||||
`calculation_columns` varchar(500) DEFAULT NULL,
|
||||
`calculation_function` varchar(100) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB default charset=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO `PayrollColumns` (`id`,`name`,`calculation_hook`,`salary_components`,`deductions`,`add_columns`,`sub_columns`,`editable`) VALUES
|
||||
(1,'Total Hours','AttendanceUtil_getTimeWorkedHours','','','','','No'),
|
||||
(2,'Regular Hours','AttendanceUtil_getRegularWorkedHours','','','','','No'),
|
||||
(3,'Overtime Hours','AttendanceUtil_getOverTimeWorkedHours','','','','','No'),
|
||||
(4,'Leave Hours','LeaveUtil_getLeaveHours','','','','','No');
|
||||
|
||||
create table `PayrollEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`pay_frequency` int(11) default null,
|
||||
`currency` bigint(20) NULL,
|
||||
`deduction_exemptions` varchar(250) default null,
|
||||
`deduction_allowed` varchar(250) default null,
|
||||
CONSTRAINT `Fk_PayrollEmployee_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
unique key `PayrollEmployees_employee` (`employee`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `DeductionGroup` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(100) NOT NULL,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
drop table `DeductionRules`;
|
||||
drop table `Deductions`;
|
||||
|
||||
create table `Deductions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`componentType` varchar(250) NULL,
|
||||
`component` varchar(250) NULL,
|
||||
`payrollColumn` int(11) DEFAULT NULL,
|
||||
`rangeAmounts` text default null,
|
||||
`deduction_group` bigint(20) NULL,
|
||||
CONSTRAINT `Fk_Deductions_DeductionGroup` FOREIGN KEY (`deduction_group`) REFERENCES `DeductionGroup` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Update Reports set parameters = '[\r\n[ "department", {"label":"Department (Company)","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}],\r\n[ "status", {"label":"Leave Status","type":"select","source":[["NULL","All Statuses"],["Approved","Approved"],["Pending","Pending"],["Rejected","Rejected"],["Cancellation Requested","Cancellation Requested"],["Cancelled","Cancelled"]]}]\r\n]' where name = "Employee Leaves Report";
|
||||
|
||||
|
||||
Delete from `Settings` where name = 'System: Default Country';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
create table `LeaveTypes` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`supervisor_leave_assign` enum('Yes','No') default 'Yes',
|
||||
`employee_can_apply` enum('Yes','No') default 'Yes',
|
||||
`apply_beyond_current` enum('Yes','No') default 'Yes',
|
||||
`leave_accrue` enum('No','Yes') default 'No',
|
||||
`carried_forward` enum('No','Yes') default 'No',
|
||||
`default_per_year` decimal(10,3) NOT NULL,
|
||||
`carried_forward_percentage` int(11) NULL default 0,
|
||||
`carried_forward_leave_availability` int(11) NULL default 365,
|
||||
`propotionate_on_joined_date` enum('No','Yes') default 'No',
|
||||
`send_notification_emails` enum('Yes','No') default 'Yes',
|
||||
`leave_group` bigint(20) NULL,
|
||||
`leave_color` varchar(10) NULL,
|
||||
`max_carried_forward_amount` int(11) NULL default 0,
|
||||
primary key (`id`),
|
||||
unique key (`name`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeaveRules` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`job_title` bigint(20) NULL,
|
||||
`employment_status` bigint(20) NULL,
|
||||
`employee` bigint(20) NULL,
|
||||
`supervisor_leave_assign` enum('Yes','No') default 'Yes',
|
||||
`employee_can_apply` enum('Yes','No') default 'Yes',
|
||||
`apply_beyond_current` enum('Yes','No') default 'Yes',
|
||||
`leave_accrue` enum('No','Yes') default 'No',
|
||||
`carried_forward` enum('No','Yes') default 'No',
|
||||
`default_per_year` decimal(10,3) NOT NULL,
|
||||
`carried_forward_percentage` int(11) NULL default 0,
|
||||
`carried_forward_leave_availability` int(11) NULL default 365,
|
||||
`propotionate_on_joined_date` enum('No','Yes') default 'No',
|
||||
`leave_group` bigint(20) NULL,
|
||||
`max_carried_forward_amount` int(11) NULL default 0,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `LeaveGroups` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`created` timestamp NULL default '0000-00-00 00:00:00',
|
||||
`updated` timestamp NULL default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeaveGroupEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`leave_group` bigint(20) NOT NULL,
|
||||
`created` timestamp NULL default '0000-00-00 00:00:00',
|
||||
`updated` timestamp NULL default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_LeaveGroupEmployees_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_LeaveGroupEmployees_LeaveGroups` FOREIGN KEY (`leave_group`) REFERENCES `LeaveGroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
unique key `LeaveGroupEmployees_employee` (`employee`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `LeavePeriods` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`date_start` date default '0000-00-00',
|
||||
`date_end` date default '0000-00-00',
|
||||
`status` enum('Active','Inactive') default 'Inactive',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `WorkDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`status` enum('Full Day','Half Day','Non-working Day') default 'Full Day',
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key `workdays_name_country` (`name`,`country`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `HoliDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`dateh` date default '0000-00-00',
|
||||
`status` enum('Full Day','Half Day') default 'Full Day',
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key `holidays_dateh_country` (`dateh`,`country`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaves` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`leave_period` bigint(20) NOT NULL,
|
||||
`date_start` date default '0000-00-00',
|
||||
`date_end` date default '0000-00-00',
|
||||
`details` text default null,
|
||||
`status` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`attachment` varchar(100) NULL,
|
||||
CONSTRAINT `Fk_EmployeeLeaves_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeLeaves_LeaveTypes` FOREIGN KEY (`leave_type`) REFERENCES `LeaveTypes` (`id`),
|
||||
CONSTRAINT `Fk_EmployeeLeaves_LeavePeriods` FOREIGN KEY (`leave_period`) REFERENCES `LeavePeriods` (`id`),
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaveLog` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee_leave` bigint(20) NOT NULL,
|
||||
`user_id` bigint(20) NULL,
|
||||
`data` varchar(500) NOT NULL,
|
||||
`status_from` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`status_to` enum('Approved','Pending','Rejected','Cancellation Requested','Cancelled') default 'Pending',
|
||||
`created` timestamp default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_EmployeeLeaveLog_EmployeeLeaves` FOREIGN KEY (`employee_leave`) REFERENCES `EmployeeLeaves` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeLeaveLog_Users` FOREIGN KEY (`user_id`) REFERENCES `Users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EmployeeLeaveDays` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee_leave` bigint(20) NOT NULL,
|
||||
`leave_date` date default '0000-00-00',
|
||||
`leave_type` enum('Full Day','Half Day - Morning','Half Day - Afternoon','1 Hour - Morning','2 Hours - Morning','3 Hours - Morning','1 Hour - Afternoon','2 Hours - Afternoon','3 Hours - Afternoon') NOT NULL,
|
||||
CONSTRAINT `Fk_EmployeeLeaveDays_EmployeeLeaves` FOREIGN KEY (`employee_leave`) REFERENCES `EmployeeLeaves` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Documents` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`expire_notification` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_month` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_week` enum('Yes','No') default 'Yes',
|
||||
`expire_notification_day` enum('Yes','No') default 'Yes',
|
||||
`sign` enum('Yes','No') default 'Yes',
|
||||
`sign_label` VARCHAR(500) default null,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `EmployeeDocuments` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`document` bigint(20) NULL,
|
||||
`date_added` date NOT NULL,
|
||||
`valid_until` date NOT NULL,
|
||||
`status` enum('Active','Inactive','Draft') default 'Active',
|
||||
`details` text default null,
|
||||
`attachment` varchar(100) NULL,
|
||||
`signature` text default null,
|
||||
`expire_notification_last` int(4) NULL,
|
||||
CONSTRAINT `Fk_EmployeeDocuments_Documents` FOREIGN KEY (`document`) REFERENCES `Documents` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeDocuments_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`),
|
||||
KEY `KEY_EmployeeDocuments_valid_until` (`valid_until`),
|
||||
KEY `KEY_EmployeeDocuments_valid_until_status` (`valid_until`,`status`,`expire_notification_last`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `CompanyDocuments` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`details` text default null,
|
||||
`valid_until` date NOT NULL,
|
||||
`status` enum('Active','Inactive','Draft') default 'Active',
|
||||
`notify_employees` enum('Yes','No') default 'Yes',
|
||||
`attachment` varchar(100) NULL,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Courses` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(300) NOT NULL,
|
||||
`name` varchar(300) NOT NULL,
|
||||
`description` text default null,
|
||||
`coordinator` bigint(20) NULL,
|
||||
`trainer` varchar(300) NULL,
|
||||
`trainer_info` text default null,
|
||||
`paymentType` enum('Company Sponsored','Paid by Employee') default 'Company Sponsored',
|
||||
`currency` varchar(3) null,
|
||||
`cost` decimal(12,2) DEFAULT 0.00,
|
||||
`status` enum('Active','Inactive') default 'Active',
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
CONSTRAINT `Fk_Courses_Employees` FOREIGN KEY (`coordinator`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `TrainingSessions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(300) NOT NULL,
|
||||
`course` bigint(20) NOT NULL,
|
||||
`description` text default null,
|
||||
`scheduled` datetime default '0000-00-00 00:00:00',
|
||||
`dueDate` datetime default '0000-00-00 00:00:00',
|
||||
`deliveryMethod` enum('Classroom','Self Study','Online') default 'Classroom',
|
||||
`deliveryLocation` varchar(500) NULL,
|
||||
`status` enum('Pending','Approved','Completed','Cancelled') default 'Pending',
|
||||
`attendanceType` enum('Sign Up','Assign') default 'Sign Up',
|
||||
`attachment` varchar(300) NULL,
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
`requireProof` enum('Yes','No') default 'Yes',
|
||||
CONSTRAINT `Fk_TrainingSessions_Courses` FOREIGN KEY (`course`) REFERENCES `Courses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `EmployeeTrainingSessions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`employee` bigint(20) NOT NULL,
|
||||
`trainingSession` bigint(20) NULL,
|
||||
`feedBack` varchar(1500) NULL,
|
||||
`status` enum('Scheduled','Attended','Not-Attended','Completed') default 'Scheduled',
|
||||
`proof` varchar(300) NULL,
|
||||
CONSTRAINT `Fk_EmployeeTrainingSessions_TrainingSessions` FOREIGN KEY (`trainingSession`) REFERENCES `TrainingSessions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_EmployeeTrainingSessions_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
create table `LeaveStartingBalance` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`leave_type` bigint(20) NOT NULL,
|
||||
`employee` bigint(20) NULL,
|
||||
`leave_period` bigint(20) NOT NULL,
|
||||
`amount` decimal(10,3) NOT NULL,
|
||||
`note` text DEFAULT NULL,
|
||||
`created` datetime default '0000-00-00 00:00:00',
|
||||
`updated` datetime default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
/* Sync with Default Schema */
|
||||
|
||||
create table `EmployementType` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Industry` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `ExperienceLevel` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `JobFunction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `EducationLevel` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Benifits` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Tags` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(250) not null default '',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Job` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`shortDescription` text DEFAULT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`requirements` text DEFAULT NULL,
|
||||
`benefits` text DEFAULT NULL,
|
||||
`country` bigint(20) DEFAULT NULL,
|
||||
`company` bigint(20) DEFAULT NULL,
|
||||
`department` VARCHAR(100) NULL,
|
||||
`code` VARCHAR(20) NULL,
|
||||
`employementType` bigint(20) DEFAULT NULL,
|
||||
`industry` bigint(20) DEFAULT NULL,
|
||||
`experienceLevel` bigint(20) DEFAULT NULL,
|
||||
`jobFunction` bigint(20) DEFAULT NULL,
|
||||
`educationLevel` bigint(20) DEFAULT NULL,
|
||||
`currency` bigint(20) DEFAULT NULL,
|
||||
`showSalary` enum('Yes','No') default NULL,
|
||||
`salaryMin` bigint(20) DEFAULT NULL,
|
||||
`salaryMax` bigint(20) DEFAULT NULL,
|
||||
`keywords` text DEFAULT NULL,
|
||||
`status` enum('Active','On hold','Closed') default NULL,
|
||||
`closingDate` DATETIME default '0000-00-00 00:00:00',
|
||||
`attachment` varchar(100) NULL,
|
||||
`display` varchar(200) NOT NULL,
|
||||
`postedBy` bigint(20) DEFAULT NULL,
|
||||
INDEX `Job_status` (`status`),
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Candidates` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`first_name` varchar(100) default '' not null,
|
||||
`last_name` varchar(100) default '' not null,
|
||||
`nationality` bigint(20) default null,
|
||||
`birthday` DATETIME default '0000-00-00 00:00:00',
|
||||
`gender` enum('Male','Female') default NULL,
|
||||
`marital_status` enum('Married','Single','Divorced','Widowed','Other') default NULL,
|
||||
`address1` varchar(100) default '',
|
||||
`address2` varchar(100) default '',
|
||||
`city` varchar(150) default '',
|
||||
`country` char(2) default null,
|
||||
`province` bigint(20) default null,
|
||||
`postal_code` varchar(20) default null,
|
||||
`email` varchar(200) default null,
|
||||
`home_phone` varchar(50) default null,
|
||||
`mobile_phone` varchar(50) default null,
|
||||
`cv_title` varchar(200) default '' not null,
|
||||
`cv` varchar(150) NULL,
|
||||
`cvtext` text NULL,
|
||||
`industry` text DEFAULT NULL,
|
||||
`profileImage` varchar(150) NULL,
|
||||
`head_line` text DEFAULT NULL,
|
||||
`objective` text DEFAULT NULL,
|
||||
`work_history` text DEFAULT NULL,
|
||||
`education` text DEFAULT NULL,
|
||||
`skills` text DEFAULT NULL,
|
||||
`referees` text DEFAULT NULL,
|
||||
`linkedInUrl` varchar(500) DEFAULT NULL,
|
||||
`linkedInData` text DEFAULT NULL,
|
||||
`totalYearsOfExperience` int(11) default null,
|
||||
`totalMonthsOfExperience` int(11) default null,
|
||||
`htmlCVData` longtext DEFAULT NULL,
|
||||
`generatedCVFile` varchar(150) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`expectedSalary` int(11) default null,
|
||||
`preferedPositions` text default null,
|
||||
`preferedJobtype` varchar(60) default null,
|
||||
`preferedCountries` text default null,
|
||||
`tags` text default null,
|
||||
`notes` text default null,
|
||||
`calls` text default null,
|
||||
`age` int(11) default null,
|
||||
`hash` varchar(100) DEFAULT NULL,
|
||||
`linkedInProfileLink` varchar(250) DEFAULT NULL,
|
||||
`linkedInProfileId` varchar(50) DEFAULT NULL,
|
||||
`facebookProfileLink` varchar(250) DEFAULT NULL,
|
||||
`facebookProfileId` varchar(50) DEFAULT NULL,
|
||||
`twitterProfileLink` varchar(250) DEFAULT NULL,
|
||||
`twitterProfileId` varchar(50) DEFAULT NULL,
|
||||
`googleProfileLink` varchar(250) DEFAULT NULL,
|
||||
`googleProfileId` varchar(50) DEFAULT NULL,
|
||||
primary key (`id`)
|
||||
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Applications` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`referredByEmail` varchar(200) DEFAULT NULL,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
unique key (`job`,`candidate`),
|
||||
CONSTRAINT `Fk_Applications_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Applications_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
create table `Interviews` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`level` varchar(100) DEFAULT NULL,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`scheduled` DATETIME default '0000-00-00 00:00:00',
|
||||
`location` varchar(500) DEFAULT NULL,
|
||||
`mapId` bigint(20) NULL,
|
||||
`status` varchar(100) default null,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
CONSTRAINT `Fk_Interviews_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Interviews_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `Calls` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job` bigint(20) NOT NULL,
|
||||
`candidate` bigint(20) DEFAULT NULL,
|
||||
`phone` varchar(20) default null,
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
`status` varchar(100) default null,
|
||||
`notes` text DEFAULT NULL,
|
||||
primary key (`id`),
|
||||
CONSTRAINT `Fk_Calls_Job` FOREIGN KEY (`job`) REFERENCES `Job` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `Fk_Calls_Candidates` FOREIGN KEY (`candidate`) REFERENCES `Candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Add Missing Master Data */
|
||||
|
||||
INSERT INTO `WorkDays` (`id`, `name`, `status`, `country`) VALUES
|
||||
(1, 'Monday', 'Full Day',NULL),
|
||||
(2, 'Tuesday', 'Full Day',NULL),
|
||||
(3, 'Wednesday', 'Full Day',NULL),
|
||||
(4, 'Thursday', 'Full Day',NULL),
|
||||
(5, 'Friday', 'Full Day',NULL),
|
||||
(6, 'Saturday', 'Non-working Day',NULL),
|
||||
(7, 'Sunday', 'Non-working Day',NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('System: Reset Module Names', '1', 'Select this to reset module names in Database','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]'),
|
||||
('Leave: Share Calendar to Whole Company', '1', '','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]'),
|
||||
('Leave: CC Emails', '', 'Every email sent though leave module will be CC to these comma seperated list of emails addresses',''),
|
||||
('Leave: BCC Emails', '', 'Every email sent though leave module will be BCC to these comma seperated list of emails addresses',''),
|
||||
('Api: REST Api Enabled', '1', '','["value", {"label":"Value","type":"select","source":[["0","No"],["1","Yes"]]}]'),
|
||||
('Api: REST Api Token', 'Click on edit icon', '','["value", {"label":"Value","type":"placeholder"}]');
|
||||
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('LDAP: Enabled', '0', '','["value", {"label":"Value","type":"select","source":[["0","No"],["1","Yes"]]}]'),
|
||||
('LDAP: Server', '', 'LDAP Server IP or DNS',''),
|
||||
('LDAP: Port', '389', 'LDAP Server Port',''),
|
||||
('LDAP: Root DN', '', 'e.g: dc=mycompany,dc=net',''),
|
||||
('LDAP: Manager DN', '', 'e.g: cn=admin,dc=mycompany,dc=net',''),
|
||||
('LDAP: Manager Password', '', 'Password of the manager user',''),
|
||||
('LDAP: Version 3', '1', 'Are you using LDAP v3','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]'),
|
||||
('LDAP: User Filter', '', 'e.g: uid={}, we will replace {} with actual username provided by the user at the time of login','');
|
||||
|
||||
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
|
||||
('Leave: Allow Indirect Admins to Approve', '0', 'Allow indirect admins to approve leave requests','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]');
|
||||
|
||||
|
||||
REPLACE INTO `Documents` (`id`, `name`, `details`, `expire_notification`, `expire_notification_month`, `expire_notification_week`, `expire_notification_day`,`sign`,`created`, `updated`) VALUES
|
||||
(1, 'ID Copy', 'Your ID copy','Yes','Yes','Yes','Yes','No',NOW(), NOW()),
|
||||
(2, 'Degree Certificate', 'Degree Certificate','Yes','Yes','Yes','Yes','Yes',NOW(), NOW()),
|
||||
(3, 'Driving License', 'Driving License','Yes','Yes','Yes','Yes','Yes',NOW(), NOW());
|
||||
|
||||
REPLACE INTO `HoliDays` (`id`, `name`, `dateh`, `status`) VALUES
|
||||
(1, 'New Year''s Day', '2015-01-01', 'Full Day'),
|
||||
(2, 'Christmas Day', '2015-12-25', 'Full Day');
|
||||
|
||||
REPLACE INTO `LeavePeriods` (`id`, `name`, `date_start`, `date_end`, `status`) VALUES
|
||||
(3, 'Year 2015', '2015-01-01', '2015-12-31', 'Active'),
|
||||
(4, 'Year 2016', '2016-01-01', '2016-12-31', 'Active'),
|
||||
(5, 'Year 2017', '2017-01-01', '2017-12-31', 'Active');
|
||||
|
||||
REPLACE INTO `LeaveTypes` (`id`, `name`, `supervisor_leave_assign`, `employee_can_apply`, `apply_beyond_current`, `leave_accrue`, `carried_forward`, `default_per_year`) VALUES
|
||||
(1, 'Annual leave', 'No', 'Yes', 'No', 'No', 'No', 14),
|
||||
(2, 'Casual leave', 'Yes', 'Yes', 'No', 'No', 'No', 7),
|
||||
(3, 'Medical leave', 'Yes', 'Yes', 'Yes', 'No', 'No', 7);
|
||||
|
||||
REPLACE INTO `Courses` (`id`,`code`, `name`, `description`, `coordinator`, `trainer`, `trainer_info`, `paymentType`, `currency`, `cost`, `status`, `created`, `updated`) VALUES
|
||||
(1,'C0001', 'Info Marketing', 'Learn how to Create and Outsource Info Marketing Products', 1, 'Tim Jhon', 'Tim Jhon has a background in business management and has been working with small business to establish their online presence','Company Sponsored','USD','55','Active',now(), now()),
|
||||
(2,'C0002', 'People Management', 'Learn how to Manage People', 1, 'Tim Jhon', 'Tim Jhon has a background in business management and has been working with small business to establish their online presence','Company Sponsored','USD','59','Active',now(), now());
|
||||
|
||||
REPLACE INTO `EmployementType` (`name`) VALUES
|
||||
('Full-time'),
|
||||
('Part-time'),
|
||||
('Contract'),
|
||||
('Temporary'),
|
||||
('Other');
|
||||
|
||||
REPLACE INTO `Benifits` (`name`) VALUES
|
||||
('Retirement plan'),
|
||||
('Health plan'),
|
||||
('Life insurance'),
|
||||
('Paid vacations');
|
||||
|
||||
|
||||
|
||||
REPLACE INTO `ExperienceLevel` (`name`) VALUES
|
||||
('Not Applicable'),
|
||||
('Internship'),
|
||||
('Entry level'),
|
||||
('Associate'),
|
||||
('Mid-Senior level'),
|
||||
('Director'),
|
||||
('Executive');
|
||||
|
||||
REPLACE INTO `JobFunction` (`name`) VALUES
|
||||
('Accounting/Auditing'),
|
||||
('Administrative'),
|
||||
('Advertising'),
|
||||
('Business Analyst'),
|
||||
('Financial Analyst'),
|
||||
('Data Analyst'),
|
||||
('Art/Creative'),
|
||||
('Business Development'),
|
||||
('Consulting'),
|
||||
('Customer Service'),
|
||||
('Distribution'),
|
||||
('Design'),
|
||||
('Education'),
|
||||
('Engineering'),
|
||||
('Finance'),
|
||||
('General Business'),
|
||||
('Health Care Provider'),
|
||||
('Human Resources'),
|
||||
('Information Technology'),
|
||||
('Legal'),
|
||||
('Management'),
|
||||
('Manufacturing'),
|
||||
('Marketing'),
|
||||
('Other'),
|
||||
('Public Relations'),
|
||||
('Purchasing'),
|
||||
('Product Management'),
|
||||
('Project Management'),
|
||||
('Production'),
|
||||
('Quality Assurance'),
|
||||
('Research'),
|
||||
('Sales'),
|
||||
('Science'),
|
||||
('Strategy/Planning'),
|
||||
('Supply Chain'),
|
||||
('Training'),
|
||||
('Writing/Editing');
|
||||
|
||||
|
||||
REPLACE INTO `EducationLevel` (`name`) VALUES
|
||||
('Unspecified'),
|
||||
('High School or equivalent'),
|
||||
('Certification'),
|
||||
('Vocational'),
|
||||
('Associate Degree'),
|
||||
('Bachelor\'s Degree'),
|
||||
('Master\'s Degree'),
|
||||
('Doctorate'),
|
||||
('Professional'),
|
||||
('Some College Coursework Completed'),
|
||||
('Vocational - HS Diploma'),
|
||||
('Vocational - Degree'),
|
||||
('Some High School Coursework');
|
||||
|
||||
|
||||
REPLACE INTO `Crons` (`name`,`class`, `lastrun`, `frequency`, `time`, `type`, `status`) VALUES
|
||||
('Email Sender Task', 'EmailSenderTask', NULL, 1, 1, 'Minutely', 'Enabled'),
|
||||
('Document Expire Alert', 'DocumentExpiryNotificationTask', NULL, 1, (FLOOR( 1 + RAND( ) *58 )), 'Hourly', 'Enabled');
|
||||
|
||||
|
||||
REPLACE INTO `ExpensesPaymentMethods` (`name`) VALUES
|
||||
('Cash'),
|
||||
('Check'),
|
||||
('Credit Card'),
|
||||
('Debit Card');
|
||||
|
||||
|
||||
REPLACE INTO `ExpensesCategories` (`name`) VALUES
|
||||
('Auto - Gas'),
|
||||
('Auto - Insurance'),
|
||||
('Auto - Maintenance'),
|
||||
('Auto - Payment'),
|
||||
('Transportation'),
|
||||
('Bank Fees'),
|
||||
('Dining Out'),
|
||||
('Entertainment'),
|
||||
('Hotel / Motel'),
|
||||
('Insurance'),
|
||||
('Interest Charges'),
|
||||
('Loan Payment'),
|
||||
('Medical'),
|
||||
('Mileage'),
|
||||
('Rent'),
|
||||
('Rental Car'),
|
||||
('Utility');
|
||||
@@ -34,6 +34,12 @@ if (!class_exists('AttendanceAdminManager')) {
|
||||
UIManager::getInstance()->addQuickAccessMenuItem("Clocked In Employees","fa-clock-o",CLIENT_BASE_URL."?g=admin&n=attendance&m=admin_Employees#tabAttendanceStatus",array("Admin","Manager"));
|
||||
}
|
||||
|
||||
public function initCalculationHooks(){
|
||||
$this->addCalculationHook('AttendanceUtil_getTimeWorkedHours','Total Hours from Attendance','AttendanceUtil','getTimeWorkedHours');
|
||||
$this->addCalculationHook('AttendanceUtil_getRegularWorkedHours','Total Regular Hours from Attendance','AttendanceUtil','getRegularWorkedHours');
|
||||
$this->addCalculationHook('AttendanceUtil_getOverTimeWorkedHours','Total Overtime Hours from Attendance','AttendanceUtil','getOverTimeWorkedHours');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +219,39 @@ if (!class_exists('AttendanceStatus')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('AttendanceUtil')) {
|
||||
class AttendanceUtil{
|
||||
public function getAttendanceSummary($employeeId, $startDate, $endDate){
|
||||
$startTime = $startDate." 00:00:00";
|
||||
$endTime = $endDate." 23:59:59";
|
||||
$attendance = new Attendance();
|
||||
$atts = $attendance->Find("employee = ? and in_time >= ? and out_time <= ?",array($employeeId, $startTime, $endTime));
|
||||
|
||||
$atCalClassName = SettingsManager::getInstance()->getSetting('Attendance: Overtime Calculation Class');
|
||||
|
||||
$atCal = new $atCalClassName();
|
||||
$atSum = $atCal->getDataSeconds($atts, $startDate, true);
|
||||
|
||||
return $atSum;
|
||||
}
|
||||
|
||||
public function getTimeWorkedHours($employeeId, $startDate, $endDate){
|
||||
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
|
||||
return round(($atSum['t']/60)/60,2);
|
||||
}
|
||||
|
||||
public function getRegularWorkedHours($employeeId, $startDate, $endDate){
|
||||
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
|
||||
return round(($atSum['r']/60)/60,2);
|
||||
}
|
||||
|
||||
public function getOverTimeWorkedHours($employeeId, $startDate, $endDate){
|
||||
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
|
||||
return round(($atSum['o']/60)/60,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!class_exists('BasicOvertimeCalculator')) {
|
||||
|
||||
@@ -305,6 +344,18 @@ if (!class_exists('BasicOvertimeCalculator')) {
|
||||
|
||||
}
|
||||
|
||||
public function getDataSeconds($atts, $actualStartDate, $aggregate = false){
|
||||
$atSummary = $this->createAttendanceSummary($atts);
|
||||
$overtime = $this->calculateOvertime($this->removeAdditionalDays($atSummary, $actualStartDate));
|
||||
if($aggregate){
|
||||
$overtime = $this->aggregateData($overtime);
|
||||
return $overtime;
|
||||
}else{
|
||||
return $overtime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function convertToHours($overtime){
|
||||
|
||||
@@ -56,6 +56,37 @@ if (!class_exists('CompanyStructure')) {
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS,"");
|
||||
}
|
||||
|
||||
public static function getAllChildCompanyStructures($companyStructureId){
|
||||
$structures = array();
|
||||
$companyStructure = new CompanyStructure();
|
||||
$companyStructure->Load("id = ?",array($companyStructureId));
|
||||
|
||||
if($companyStructure->id != $companyStructureId || empty($companyStructure->id)){
|
||||
return new IceResponse(IceResponse::ERROR, array());
|
||||
}
|
||||
|
||||
self::getChildCompanyStructures($companyStructure, $structures);
|
||||
|
||||
$structures[$companyStructure->id] = $companyStructure;
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, array_values($structures));
|
||||
|
||||
}
|
||||
|
||||
private static function getChildCompanyStructures($companyStructure, &$structures){
|
||||
$child = new CompanyStructure();
|
||||
$children = $child->Find("parent = ?",array($companyStructure->id));
|
||||
if(!empty($children)){
|
||||
foreach($children as $c){
|
||||
if(isset($structures[$c->id])){
|
||||
continue;
|
||||
}
|
||||
$structures[$c->id] = $c;
|
||||
self::getChildCompanyStructures($c, $structures);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,21 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="iceannon">
|
||||
<div class="callout callout-danger lead" style="font-size: 14px;font-weight: bold;">
|
||||
<h4>Why not upgrade to IceHrm Pro Version</h4>
|
||||
<p>
|
||||
IceHrm Pro is the feature rich upgrade to IceHrm open source version. It comes with improved modules for
|
||||
employee management, leave management and number of other features over open source version.
|
||||
Hit this <a href="http://icehrm.com/#compare" class="btn btn-primary btn-xs target="_blank">link</a> to do a full one to one comparison.
|
||||
|
||||
Also you can learn more about IceHrm Pro <a href="http://blog.icehrm.com/docs/icehrm-pro/" class="btn btn-primary btn-xs" target="_blank">here</a>
|
||||
<br/>
|
||||
<br/>
|
||||
<a href="http://icehrm.com/modules.php" class="btn btn-success btm-xs" target="_blank"><i class="fa fa-checkout"></i> Buy IceHrm Pro</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
@@ -68,5 +82,17 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
|
||||
var modJs = modJsList['tabDashboard'];
|
||||
|
||||
$(document).ready(function() {
|
||||
try {
|
||||
$.ajax({
|
||||
url: "https://icehrm-public.s3.amazonaws.com/icehrmnews.html",
|
||||
success: function (result) {
|
||||
$('#iceannon').html(result);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
164
ext/admin/employees/api/EmployeesActionManager.php
Normal file
164
ext/admin/employees/api/EmployeesActionManager.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
class EmployeesActionManager extends SubActionManager{
|
||||
|
||||
public function terminateEmployee($req){
|
||||
$employee = new Employee();
|
||||
$employee->Load("id = ?",array($req->id));
|
||||
|
||||
if(empty($employee->id)){
|
||||
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
|
||||
}
|
||||
|
||||
$employee->termination_date = date('Y-m-d H:i:s');
|
||||
$employee->status = 'Terminated';
|
||||
|
||||
$ok = $employee->Save();
|
||||
if(!$ok){
|
||||
return new IceResponse(IceResponse::ERROR, "Error occured while terminating employee");
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, $employee);
|
||||
|
||||
//$user = BaseService::getInstance()->getUserFromProfileId($employee->id);
|
||||
}
|
||||
|
||||
public function activateEmployee($req){
|
||||
$employee = new Employee();
|
||||
$employee->Load("id = ?",array($req->id));
|
||||
|
||||
if(empty($employee->id)){
|
||||
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
|
||||
}
|
||||
|
||||
$employee->termination_date = NULL;
|
||||
$employee->status = 'Active';
|
||||
|
||||
$ok = $employee->Save();
|
||||
if(!$ok){
|
||||
return new IceResponse(IceResponse::ERROR, "Error occured while activating employee");
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, $employee);
|
||||
|
||||
//$user = BaseService::getInstance()->getUserFromProfileId($employee->id);
|
||||
}
|
||||
|
||||
public function deleteEmployee($req){
|
||||
|
||||
$employee = new Employee();
|
||||
$employee->Load("id = ?",array($req->id));
|
||||
|
||||
if(empty($employee->id)){
|
||||
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
|
||||
}
|
||||
|
||||
$archived = new ArchivedEmployee();
|
||||
$archived->ref_id = $employee->id;
|
||||
$archived->employee_id = $employee->employee_id;
|
||||
$archived->first_name = $employee->first_name;
|
||||
$archived->last_name = $employee->last_name;
|
||||
$archived->gender = $employee->gender;
|
||||
$archived->ssn_num = $employee->ssn_num;
|
||||
$archived->nic_num = $employee->nic_num;
|
||||
$archived->other_id = $employee->other_id;
|
||||
$archived->work_email = $employee->work_email;
|
||||
$archived->joined_date = $employee->joined_date;
|
||||
$archived->confirmation_date = $employee->confirmation_date;
|
||||
$archived->supervisor = $employee->supervisor;
|
||||
$archived->department = $employee->department;
|
||||
$archived->termination_date = $employee->termination_date;
|
||||
$archived->notes = $employee->notes;
|
||||
|
||||
//$archived = BaseService::getInstance()->cleanUpAdoDB($archived);
|
||||
|
||||
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
|
||||
|
||||
$employeeEnriched = BaseService::getInstance()->getElement('Employee',$employee->id,$mapping,true);
|
||||
$employeeEnriched = BaseService::getInstance()->cleanUpAdoDB($employeeEnriched);
|
||||
|
||||
$data = new stdClass();
|
||||
$data->enrichedEmployee = $employeeEnriched;
|
||||
|
||||
$data->timesheets = $this->getEmployeeData($employee->id, new EmployeeTimeSheet());
|
||||
$data->timesheetEntries = $this->getEmployeeData($employee->id, new EmployeeTimeEntry());
|
||||
$data->attendance = $this->getEmployeeData($employee->id, new Attendance());
|
||||
$data->documents = $this->getEmployeeData($employee->id, new EmployeeDocument());
|
||||
if(class_exists('EmployeeTrainingSession')){
|
||||
$data->trainingSessions = $this->getEmployeeData($employee->id, new EmployeeTrainingSession());
|
||||
}
|
||||
$data->travelRecords = $this->getEmployeeData($employee->id, new EmployeeTravelRecord());
|
||||
$data->qualificationSkills = $this->getEmployeeData($employee->id, new EmployeeSkill());
|
||||
$data->qualificationEducation = $this->getEmployeeData($employee->id, new EmployeeEducation());
|
||||
$data->qualificationCertifications = $this->getEmployeeData($employee->id, new EmployeeCertification());
|
||||
$data->qualificationLanguages = $this->getEmployeeData($employee->id, new EmployeeLanguage());
|
||||
$data->salary = $this->getEmployeeData($employee->id, new EmployeeSalary());
|
||||
$data->dependants = $this->getEmployeeData($employee->id, new EmployeeDependent());
|
||||
$data->emergencyContacts = $this->getEmployeeData($employee->id, new EmergencyContact());
|
||||
$data->projects = $this->getEmployeeData($employee->id, new EmployeeProject());
|
||||
$data->leaves = $this->getEmployeeData($employee->id, new EmployeeLeave());
|
||||
$data->leaveDays = $this->getEmployeeData($employee->id, new EmployeeLeaveDay());
|
||||
|
||||
$archived->data = json_encode($data, JSON_PRETTY_PRINT);
|
||||
|
||||
$ok = $archived->Save();
|
||||
if(!$ok){
|
||||
return new IceResponse(IceResponse::ERROR, "Error occured while archiving employee");
|
||||
}
|
||||
|
||||
$ok = $employee->Delete();
|
||||
if(!$ok){
|
||||
return new IceResponse(IceResponse::ERROR, "Error occured while deleting employee");
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, $archived);
|
||||
}
|
||||
|
||||
public function downloadArchivedEmployee($req){
|
||||
|
||||
|
||||
if($this->baseService->currentUser->user_level != 'Admin'){
|
||||
echo "Error: Permission denied";
|
||||
exit();
|
||||
}
|
||||
|
||||
$employee = new ArchivedEmployee();
|
||||
$employee->Load("id = ?",array($req->id));
|
||||
|
||||
if(empty($employee->id)){
|
||||
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
|
||||
}
|
||||
|
||||
$employee->data = json_decode($employee->data);
|
||||
$employee = $this->baseService->cleanUpAdoDB($employee);
|
||||
|
||||
$str = json_encode($employee, JSON_PRETTY_PRINT);
|
||||
|
||||
$filename = uniqid();
|
||||
$file = fopen("/tmp/".$filename,"w");
|
||||
fwrite($file,$str);
|
||||
fclose($file);
|
||||
|
||||
$downloadFileName = "employee_".$employee->id."_".str_replace(" ", "_", $employee->first_name)."_".str_replace(" ", "_", $employee->last_name).".txt";
|
||||
|
||||
header("Pragma: public"); // required
|
||||
header("Expires: 0");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: image/jpg");
|
||||
header('Content-Disposition: attachment; filename="'.$downloadFileName.'"');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: ".filesize("/tmp/".$filename));
|
||||
readfile("/tmp/".$filename);
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
private function getEmployeeData($id, $obj){
|
||||
$data = array();
|
||||
$objs = $obj->Find("employee = ?",array($id));
|
||||
foreach($objs as $entry){
|
||||
$data[] = BaseService::getInstance()->cleanUpAdoDB($entry);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,18 @@ if (!class_exists('EmployeesAdminManager')) {
|
||||
|
||||
}
|
||||
|
||||
public function setupRestEndPoints(){
|
||||
\NoahBuscher\Macaw\Macaw::get(REST_API_PATH.'employee/(:any)', function($pathParams) {
|
||||
$empRestEndPoint = new EmployeeRestEndPoint();
|
||||
$empRestEndPoint->process('get',$pathParams);
|
||||
});
|
||||
|
||||
\NoahBuscher\Macaw\Macaw::get(REST_API_PATH.'employees', function() {
|
||||
$empRestEndPoint = new EmployeesRestEndPoint();
|
||||
$empRestEndPoint->process('get',NULL);
|
||||
});
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings(){
|
||||
$this->addDatabaseErrorMapping('CONSTRAINT `Fk_User_Employee` FOREIGN KEY',"Can not delete Employee, please delete the User for this employee first.");
|
||||
$this->addDatabaseErrorMapping("Duplicate entry|for key 'employee'","A duplicate entry found");
|
||||
@@ -41,6 +53,43 @@ if (!class_exists('EmployeesAdminManager')) {
|
||||
if (!class_exists('Employee')) {
|
||||
class Employee extends ICEHRM_Record {
|
||||
|
||||
var $oldObj = null;
|
||||
var $oldObjOrig = null;
|
||||
var $historyUpdateList = array();
|
||||
var $historyFieldsToTrack = array(
|
||||
"employee_id"=>"employee_id",
|
||||
"first_name"=>"first_name",
|
||||
"middle_name"=>"middle_name",
|
||||
"last_name"=>"last_name",
|
||||
"nationality"=>"nationality_Name",
|
||||
"birthday"=>"birthday",
|
||||
"gender"=>"gender",
|
||||
"marital_status"=>"marital_status",
|
||||
"ssn_num"=>"ssn_num",
|
||||
"nic_num"=>"nic_num",
|
||||
"other_id"=>"other_id",
|
||||
"employment_status"=>"employment_status_Name",
|
||||
"job_title"=>"job_title_Name",
|
||||
"pay_grade"=>"pay_grade_Name",
|
||||
"work_station_id"=>"work_station_id",
|
||||
"address1"=>"address1",
|
||||
"address2"=>"address2",
|
||||
"city"=>"city_Name",
|
||||
"country"=>"country_Name",
|
||||
"province"=>"province_Name",
|
||||
"postal_code"=>"postal_code",
|
||||
"home_phone"=>"home_phone",
|
||||
"mobile_phone"=>"mobile_phone",
|
||||
"work_phone"=>"work_phone",
|
||||
"work_email"=>"work_email",
|
||||
"private_email"=>"private_email",
|
||||
"joined_date"=>"joined_date",
|
||||
"confirmation_date"=>"confirmation_date",
|
||||
"supervisor"=>"supervisor_Name",
|
||||
"indirect_supervisors"=>"indirect_supervisors",
|
||||
"department"=>"department_Name"
|
||||
);
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
@@ -61,10 +110,165 @@ if (!class_exists('Employee')) {
|
||||
return "id";
|
||||
}
|
||||
|
||||
|
||||
private function initHistory($obj){
|
||||
|
||||
$oldObjOrig = new Employee();
|
||||
$oldObjOrig->Load("id = ?",array($obj->id));
|
||||
$this->oldObjOrig = $oldObjOrig;
|
||||
|
||||
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
|
||||
|
||||
$this->oldObj = BaseService::getInstance()->getElement('Employee',$obj->id,$mapping,true);
|
||||
|
||||
}
|
||||
|
||||
private function saveHistory($obj){
|
||||
|
||||
$oldObj = $this->oldObj;
|
||||
$oldObjOrig = $this->oldObjOrig;
|
||||
|
||||
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
|
||||
|
||||
$objEnriched = BaseService::getInstance()->getElement('Employee',$obj->id,$mapping,true);
|
||||
|
||||
foreach($this->historyFieldsToTrack as $k => $v){
|
||||
|
||||
if(empty($oldObjOrig->$k) && $obj->$k = '[]'){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(empty($obj->$k) && $oldObjOrig->$k = '0000-00-00'){
|
||||
continue;
|
||||
}
|
||||
|
||||
if($oldObjOrig->$k != $obj->$k){
|
||||
|
||||
$enrichNewVal = '';
|
||||
$enrichOldVal = '';
|
||||
|
||||
if($k == 'indirect_supervisors'){
|
||||
if(!empty($obj->$k) && $obj->$k != '[]'){
|
||||
$newIndeirectSupervisorIds = json_decode($obj->$k);
|
||||
foreach($newIndeirectSupervisorIds as $id){
|
||||
$item = BaseService::getInstance()->getItemFromCache("Employee", $id);
|
||||
if($enrichNewVal != ""){
|
||||
$enrichNewVal .= ", ";
|
||||
}
|
||||
$enrichNewVal .= $item->first_name." ".$item->last_name;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($oldObjOrig->$k) && $oldObjOrig->$k != '[]'){
|
||||
$oldIndeirectSupervisorIds = json_decode($oldObjOrig->$k);
|
||||
foreach($oldIndeirectSupervisorIds as $id){
|
||||
$item = BaseService::getInstance()->getItemFromCache("Employee", $id);
|
||||
if($enrichOldVal != ""){
|
||||
$enrichOldVal .= ", ";
|
||||
}
|
||||
$enrichOldVal .= $item->first_name." ".$item->last_name;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$enrichOldVal = $oldObj->$v;
|
||||
$enrichNewVal = $objEnriched->$v;
|
||||
}
|
||||
|
||||
$this->historyUpdateList[] = array($obj->id,$k,$enrichOldVal,$enrichNewVal);
|
||||
}
|
||||
}
|
||||
|
||||
while(count($this->historyUpdateList)){
|
||||
$ele = array_pop($this->historyUpdateList);
|
||||
BaseService::getInstance()->addHistoryItem("Employee","Employee",$ele[0],$ele[1],$ele[2],$ele[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public function executePreSaveActions($obj){
|
||||
if(empty($obj->status)){
|
||||
$obj->status = 'Active';
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS,$obj);
|
||||
}
|
||||
|
||||
public function executePreUpdateActions($obj){
|
||||
$this->initHistory($obj);
|
||||
return new IceResponse(IceResponse::SUCCESS,$obj);
|
||||
}
|
||||
|
||||
public function executePostUpdateActions($obj){
|
||||
$this->saveHistory($obj);
|
||||
}
|
||||
|
||||
public function postProcessGetData($obj){
|
||||
$obj = FileService::getInstance()->updateSmallProfileImage($obj);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function getVirtualFields(){
|
||||
return array(
|
||||
"image"
|
||||
);
|
||||
}
|
||||
|
||||
public function getActiveEmployees(){
|
||||
$employee = new Employee();
|
||||
$list = $employee->Find("status = ?",array('Active'));
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getActiveSubordinateEmployees(){
|
||||
|
||||
$employee = new Employee();
|
||||
if(BaseService::getInstance()->currentUser->user_level != 'Admin'){
|
||||
$cemp = BaseService::getInstance()->getCurrentProfileId();
|
||||
$list = $employee->Find("status = ? and supervisor = ?",array('Active', $cemp));
|
||||
}else{
|
||||
$list = $employee->Find("status = ?",array('Active'));
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function cleanEmployeeData($obj){
|
||||
unset($obj->historyFieldsToTrack);
|
||||
unset($obj->historyUpdateList);
|
||||
unset($obj->oldObjOrig);
|
||||
unset($obj->oldObj);
|
||||
unset($obj->oldObj);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
var $_table = 'Employees';
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('ArchivedEmployee')) {
|
||||
class ArchivedEmployee extends ICEHRM_Record {
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getManagerAccess(){
|
||||
return array("get","element","save");
|
||||
}
|
||||
|
||||
public function getUserAccess(){
|
||||
return array("get");
|
||||
}
|
||||
|
||||
public function getUserOnlyMeAccess(){
|
||||
return array("element","save");
|
||||
}
|
||||
|
||||
public function getUserOnlyMeAccessField(){
|
||||
return "id";
|
||||
}
|
||||
|
||||
var $_table = 'ArchivedEmployees';
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('EmploymentStatus')) {
|
||||
class EmploymentStatus extends ICEHRM_Record {
|
||||
|
||||
@@ -84,3 +288,52 @@ if (!class_exists('EmploymentStatus')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!class_exists('EmployeeRestEndPoint')) {
|
||||
class EmployeeRestEndPoint extends RestEndPoint{
|
||||
public function get($parameter){
|
||||
if(empty($parameter)){
|
||||
return new IceResponse(IceResponse::ERROR, "Employee ID not provided");
|
||||
}
|
||||
|
||||
$accessTokenValidation = $this->validateAccessToken();
|
||||
if($accessTokenValidation->getStatus() == IceResponse::ERROR){
|
||||
return $accessTokenValidation;
|
||||
}
|
||||
|
||||
$mapping = '{"nationality":["Nationality","id","name"],"ethnicity":["Ethnicity","id","name"],"immigration_status":["ImmigrationStatus","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
|
||||
$employeeResp = BaseService::getInstance()->getElement('Employee',$parameter,$mapping,true);
|
||||
if($employeeResp->getStatus() == IceResponse::SUCCESS){
|
||||
$emp = $employeeResp->getObject();
|
||||
$emp = Employee::cleanEmployeeData($emp);
|
||||
return new IceResponse(IceResponse::SUCCESS,$emp);
|
||||
}
|
||||
return $employeeResp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('EmployeesRestEndPoint')) {
|
||||
class EmployeesRestEndPoint extends RestEndPoint{
|
||||
public function get($parameter){
|
||||
|
||||
$accessTokenValidation = $this->validateAccessToken();
|
||||
if($accessTokenValidation->getStatus() == IceResponse::ERROR){
|
||||
return $accessTokenValidation;
|
||||
}
|
||||
|
||||
$emp = new Employee();
|
||||
$emps = $emp->Find("1=1");
|
||||
$newEmps = array();
|
||||
foreach($emps as $emp){
|
||||
$newEmps[] = Employee::cleanEmployeeData($emp);
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS, $newEmps);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
248
ext/admin/employees/customTemplates/myDetails.html
Normal file
248
ext/admin/employees/customTemplates/myDetails.html
Normal file
@@ -0,0 +1,248 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-2">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-12" style="text-align: center;">
|
||||
<img id="profile_image__id_" src="" class="img-polaroid img-thumbnail" style="max-width: 140px;max-height: 140px;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-10">
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12"><h2 id="name"></h2></div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12">
|
||||
<p>
|
||||
<i class="fa fa-phone"></i> <span id="mobile_phone"></span>
|
||||
<i class="fa fa-envelope"></i> <span id="work_email"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-12" style="font-size:18px;border-bottom: 1px solid #DDD;margin-bottom: 10px;padding-bottom: 10px;">
|
||||
<button id="employeeProfileEditInfo" class="btn btn-small btn-success" onclick="modJs.edit(_id_);" style="margin-right:10px;"><i class="fa fa-edit"></i> Edit Info</button>
|
||||
<button id="employeeUploadProfileImage" onclick="showUploadDialog('profile_image__id_','Upload Profile Image','profile_image',_id_,'profile_image__id_','src','url','image');return false;" class="btn btn-small btn-primary" type="button" style="margin-right:10px;"><i class="fa fa-upload"></i> Upload Profile Image</button>
|
||||
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-small btn-warning" type="button" style="margin-right:10px;"><i class="fa fa-times"></i> Delete Profile Image</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid" style="border-top: 1px;">
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;font-size:13px;">#_label_employee_id_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employee_id"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_nic_num_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nic_num"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_ssn_num_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="ssn_num"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="nav nav-tabs" id="subModTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
<li class="active"><a id="tabBasic" href="#tabPageBasic">Basic Information</a></li>
|
||||
<li class=""><a id="tabQualifications" href="#tabPageQualifications">Qualifications</a></li>
|
||||
<li class=""><a id="tabDocuments" href="#tabPageDocuments">Documents</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tabPageBasic" style="border:1px solid #DDD;">
|
||||
<div class="row" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Personal Information</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_driving_license_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="driving_license"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_other_id_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="other_id"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_birthday_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="birthday"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_gender_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="gender"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_nationality_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nationality_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_marital_status_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="marital_status"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_joined_date_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="joined_date"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Contact Information</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_address1_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address1"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_address2_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address2"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_city_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="city"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_country_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="country_Name"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_postal_code_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="postal_code"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_home_phone_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="home_phone"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_work_phone_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_phone"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_private_email_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="private_email"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Job Details</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_job_title_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="job_title_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_employment_status_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employment_status_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_supervisor_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="supervisor_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Direct Reports</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="subordinates"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_department_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="department_Name"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal" id="adminUsersModel" tabindex="-1" role="dialog" aria-labelledby="messageModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 style="font-size: 17px;">Change User Password</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="adminUsersChangePwd">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<span class="label label-warning" id="adminUsersChangePwd_error" style="display:none;"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" id="field_newpwd">
|
||||
<label class="control-label" for="newpwd">New Password</label>
|
||||
<div class="controls">
|
||||
<input class="" type="password" id="newpwd" name="newpwd" value="" class="form-control"/>
|
||||
<span class="help-inline" id="help_newpwd"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" id="field_conpwd">
|
||||
<label class="control-label" for="conpwd">Confirm Password</label>
|
||||
<div class="controls">
|
||||
<input class="" type="password" id="conpwd" name="conpwd" value="" class="form-control"/>
|
||||
<span class="help-inline" id="help_conpwd"></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" onclick="modJs.changePasswordConfirm();">Change Password</button>
|
||||
<button class="btn" onclick="modJs.closeChangePassword();">Not Now</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- End tabPageBasic -->
|
||||
<div class="tab-pane" id="tabPageQualifications" style="border:1px solid #DDD;">
|
||||
<div class="row" style="margin-top:20px;">
|
||||
<div class="col-md-3">
|
||||
<div id="EmployeeSkillSubTab" class="" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div id="EmployeeEducationSubTab" class="" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div id="EmployeeCertificationSubTab" class="" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div id="EmployeeLanguageSubTab" class="" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- End tabPageQualifications -->
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageDocuments" style="border:1px solid #DDD;">
|
||||
<div class="row" style="margin-top:20px;">
|
||||
<div class="col-md-12">
|
||||
<div id="EmployeeDocumentSubTab" class="" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- End tabPageQualifications -->
|
||||
</div>
|
||||
</div><!-- End tab-content -->
|
||||
108
ext/admin/employees/db_update.sql
Normal file
108
ext/admin/employees/db_update.sql
Normal file
@@ -0,0 +1,108 @@
|
||||
ALTER TABLE Employees ADD COLUMN `status` enum('Active','Terminated') default 'Active';
|
||||
|
||||
create table `ArchivedEmployees` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`ref_id` bigint(20) NOT NULL,
|
||||
`employee_id` varchar(50) default null,
|
||||
`first_name` varchar(100) default '' not null,
|
||||
`last_name` varchar(100) default '' not null,
|
||||
`gender` enum('Male','Female') default NULL,
|
||||
`ssn_num` varchar(100) default '',
|
||||
`nic_num` varchar(100) default '',
|
||||
`other_id` varchar(100) default '',
|
||||
`work_email` varchar(100) default null,
|
||||
`joined_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`confirmation_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`supervisor` bigint(20) default null,
|
||||
`department` bigint(20) default null,
|
||||
`termination_date` DATETIME default '0000-00-00 00:00:00',
|
||||
`notes` text default null,
|
||||
`data` longtext default null,
|
||||
primary key (`id`)
|
||||
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
create table `FieldNameMappings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`type` varchar(20) NOT NULL,
|
||||
`name` varchar(20) NOT NULL,
|
||||
`textOrig` varchar(200) default null,
|
||||
`textMapped` varchar(200) default null,
|
||||
`display` enum('Form','Table and Form','Hidden') default 'Form',
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
INSERT INTO `FieldNameMappings` (`type`, `name`, `textOrig`, `textMapped`, `display`) VALUES
|
||||
('Employee', 'employee_id', 'Employee Number', 'Employee Number', 'Table and Form'),
|
||||
('Employee', 'first_name', 'First Name', 'First Name', 'Table and Form'),
|
||||
('Employee', 'middle_name', 'Middle Name', 'Middle Name', 'Form'),
|
||||
('Employee', 'last_name', 'Last Name', 'Last Name', 'Table and Form'),
|
||||
('Employee', 'nationality', 'Nationality', 'Nationality', 'Form'),
|
||||
('Employee', 'birthday', 'Date of Birth', 'Date of Birth', 'Form'),
|
||||
('Employee', 'gender', 'Gender', 'Gender', 'Form'),
|
||||
('Employee', 'marital_status', 'Marital Status', 'Marital Status', 'Form'),
|
||||
('Employee', 'ssn_num', 'SSN/NRIC', 'SSN/NRIC', 'Form'),
|
||||
('Employee', 'nic_num', 'NIC', 'NIC', 'Form'),
|
||||
('Employee', 'other_id', 'Other ID', 'Other ID', 'Form'),
|
||||
('Employee', 'driving_license', 'Driving License No', 'Driving License No', 'Form'),
|
||||
('Employee', 'employment_status', 'Employment Status', 'Employment Status', 'Form'),
|
||||
('Employee', 'job_title', 'Job Title', 'Job Title', 'Form'),
|
||||
('Employee', 'pay_grade', 'Pay Grade', 'Pay Grade', 'Form'),
|
||||
('Employee', 'work_station_id', 'Work Station Id', 'Work Station Id', 'Form'),
|
||||
('Employee', 'address1', 'Address Line 1', 'Address Line 1', 'Form'),
|
||||
('Employee', 'address2', 'Address Line 2', 'Address Line 2', 'Form'),
|
||||
('Employee', 'city', 'City', 'City', 'Form'),
|
||||
('Employee', 'country', 'Country', 'Country', 'Form'),
|
||||
('Employee', 'province', 'Province', 'Province', 'Form'),
|
||||
('Employee', 'postal_code', 'Postal/Zip Code', 'Postal/Zip Code', 'Form'),
|
||||
('Employee', 'home_phone', 'Home Phone', 'Home Phone', 'Form'),
|
||||
('Employee', 'mobile_phone', 'Mobile Phone', 'Mobile Phone', 'Table and Form'),
|
||||
('Employee', 'work_phone', 'Work Phone', 'Work Phone', 'Form'),
|
||||
('Employee', 'work_email', 'Work Email', 'Work Email', 'Form'),
|
||||
('Employee', 'private_email', 'Private Email', 'Private Email', 'Form'),
|
||||
('Employee', 'joined_date', 'Joined Date', 'Joined Date', 'Form'),
|
||||
('Employee', 'confirmation_date', 'Confirmation Date', 'Confirmation Date', 'Form'),
|
||||
('Employee', 'termination_date', 'Termination Date', 'Termination Date', 'Form'),
|
||||
('Employee', 'supervisor', 'Supervisor', 'Supervisor', 'Table and Form'),
|
||||
('Employee', 'department', 'Department', 'Department', 'Table and Form'),
|
||||
('Employee', 'notes', 'Notes', 'Notes', 'Form');
|
||||
|
||||
|
||||
create table `CustomFields` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`type` varchar(20) NOT NULL,
|
||||
`name` varchar(20) NOT NULL,
|
||||
`data` text default null,
|
||||
`display` enum('Form','Table and Form','Hidden') default 'Form',
|
||||
`created` DATETIME default '0000-00-00 00:00:00',
|
||||
`updated` DATETIME default '0000-00-00 00:00:00',
|
||||
primary key (`id`)
|
||||
) engine=innodb default charset=utf8;
|
||||
|
||||
|
||||
INSERT INTO `CustomFields` (`type`, `name`, `data`,`display`) VALUES
|
||||
('Employee', 'custom1', '', 'Hidden'),
|
||||
('Employee', 'custom2', '', 'Hidden'),
|
||||
('Employee', 'custom3', '', 'Hidden'),
|
||||
('Employee', 'custom4', '', 'Hidden'),
|
||||
('Employee', 'custom5', '', 'Hidden'),
|
||||
('Employee', 'custom6', '', 'Hidden'),
|
||||
('Employee', 'custom7', '', 'Hidden'),
|
||||
('Employee', 'custom8', '', 'Hidden'),
|
||||
('Employee', 'custom9', '', 'Hidden'),
|
||||
('Employee', 'custom10', '', 'Hidden');
|
||||
|
||||
|
||||
Alter table `Employees` MODIFY COLUMN `middle_name` varchar(100) default null;
|
||||
Alter table `Employees` MODIFY COLUMN `last_name` varchar(100) default null;
|
||||
Alter table `Employees` MODIFY COLUMN `ssn_num` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `nic_num` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `other_id` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `driving_license` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `work_station_id` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `address1` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `address2` varchar(100) default NULL;
|
||||
Alter table `Employees` MODIFY COLUMN `city` varchar(150) default NULL;
|
||||
@@ -4,10 +4,41 @@ $moduleName = 'employees';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
$fieldNameMap = BaseService::getInstance()->getFieldNameMappings("Employee");
|
||||
$customFields = BaseService::getInstance()->getCustomFields("Employee");
|
||||
?><div class="span9">
|
||||
|
||||
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
<?php if($user->user_level != "Admin"){
|
||||
?>
|
||||
<li class="active"><a id="tabEmployee" href="#tabPageEmployee">Employees (Direct Reports)</a></li>
|
||||
<?php }else{ ?>
|
||||
<li class="active"><a id="tabEmployee" href="#tabPageEmployee">Employees</a></li>
|
||||
<?php }?>
|
||||
|
||||
<?php if($user->user_level == "Admin"){
|
||||
?>
|
||||
<li><a id="tabEmployeeSkill" href="#tabPageEmployeeSkill">Skills</a></li>
|
||||
<li><a id="tabEmployeeEducation" href="#tabPageEmployeeEducation">Education</a></li>
|
||||
<li><a id="tabEmployeeCertification" href="#tabPageEmployeeCertification">Certifications</a></li>
|
||||
<li><a id="tabEmployeeLanguage" href="#tabPageEmployeeLanguage">Languages</a></li>
|
||||
<li><a id="tabEmployeeDependent" href="#tabPageEmployeeDependent">Dependents</a></li>
|
||||
<li><a id="tabEmergencyContact" href="#tabPageEmergencyContact">Emergency Contacts</a></li>
|
||||
<?php if (!class_exists('DocumentsAdminManager')) {?>
|
||||
<li><a id="tabEmployeeDocument" href="#tabPageEmployeeDocument">Documents</a></li>
|
||||
<?php } ?>
|
||||
<?php }?>
|
||||
<?php if($user->user_level == "Admin"){
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="#" id="terminatedEmployeeMenu" class="dropdown-toggle" data-toggle="dropdown" aria-controls="terminatedEmployeeMenu-contents">Suspended Employees <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="terminatedEmployeeMenu" id="terminatedEmployeeMenu-contents">
|
||||
<li><a id="tabTerminatedEmployee" href="#tabPageTerminatedEmployee">Temporarily Suspended Employees</a></li>
|
||||
<li><a id="tabArchivedEmployee" href="#tabPageArchivedEmployee">Terminated Employee Data</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
@@ -19,16 +50,161 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeSkill">
|
||||
<div id="EmployeeSkill" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeSkillForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeEducation">
|
||||
<div id="EmployeeEducation" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeEducationForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeCertification">
|
||||
<div id="EmployeeCertification" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeCertificationForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeLanguage">
|
||||
<div id="EmployeeLanguage" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeLanguageForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeDependent">
|
||||
<div id="EmployeeDependent" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeDependentForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmergencyContact">
|
||||
<div id="EmergencyContact" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmergencyContactForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="tabPageArchivedEmployee">
|
||||
<div id="ArchivedEmployee" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="ArchivedEmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageTerminatedEmployee">
|
||||
<div id="TerminatedEmployee" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="TerminatedEmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!class_exists('DocumentsAdminManager')) {?>
|
||||
<div class="tab-pane" id="tabPageEmployeeDocument">
|
||||
<div id="EmployeeDocument" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeDocumentForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
modJsList['tabEmployee'] = new EmployeeAdapter('Employee');
|
||||
<?php if($user->user_level != "Admin"){
|
||||
?>
|
||||
modJsList['tabEmployee'] = new EmployeeAdapter('Employee','Employee',{"status":"Active", "supervisor":"__myid__"});
|
||||
modJsList['tabEmployee'].setShowAddNew(false);
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
modJsList['tabEmployee'] = new EmployeeAdapter('Employee','Employee',{"status":"Active"});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
modJsList['tabEmployee'].setRemoteTable(true);
|
||||
modJsList['tabEmployee'].setFieldNameMap(<?=json_encode($fieldNameMap)?>);
|
||||
modJsList['tabEmployee'].setCustomFields(<?=json_encode($customFields)?>);
|
||||
|
||||
modJsList['tabEmployeeSkill'] = new EmployeeSkillAdapter('EmployeeSkill');
|
||||
modJsList['tabEmployeeSkill'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmployeeEducation'] = new EmployeeEducationAdapter('EmployeeEducation');
|
||||
modJsList['tabEmployeeEducation'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmployeeCertification'] = new EmployeeCertificationAdapter('EmployeeCertification');
|
||||
modJsList['tabEmployeeCertification'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmployeeLanguage'] = new EmployeeLanguageAdapter('EmployeeLanguage');
|
||||
modJsList['tabEmployeeLanguage'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmployeeDependent'] = new EmployeeDependentAdapter('EmployeeDependent');
|
||||
modJsList['tabEmployeeDependent'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmergencyContact'] = new EmergencyContactAdapter('EmergencyContact');
|
||||
modJsList['tabEmergencyContact'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabEmployeeImmigration'] = new EmployeeImmigrationAdapter('EmployeeImmigration');
|
||||
modJsList['tabEmployeeImmigration'].setRemoteTable(true);
|
||||
|
||||
modJsList['tabArchivedEmployee'] = new ArchivedEmployeeAdapter('ArchivedEmployee');
|
||||
modJsList['tabArchivedEmployee'].setRemoteTable(true);
|
||||
modJsList['tabArchivedEmployee'].setShowAddNew(false);
|
||||
|
||||
modJsList['tabTerminatedEmployee'] = new TerminatedEmployeeAdapter('Employee','TerminatedEmployee',{"status":"Terminated"});
|
||||
modJsList['tabTerminatedEmployee'].setRemoteTable(true);
|
||||
modJsList['tabTerminatedEmployee'].setShowAddNew(false);
|
||||
|
||||
<?php if (!class_exists('DocumentsAdminManager')) {?>
|
||||
modJsList['tabEmployeeDocument'] = new EmployeeDocumentAdapter('EmployeeDocument','EmployeeDocument');
|
||||
modJsList['tabTerminatedEmployee'].setRemoteTable(true);
|
||||
<?php } ?>
|
||||
|
||||
var modJs = modJsList['tabEmployee'];
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div class="modal" id="createUserModel" tabindex="-1" role="dialog" aria-labelledby="messageModelLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||
<h3 style="font-size: 17px;">Employee Saved Successfully</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Employee needs a User to login to IceHrm. Do you want to create a user for this employee now? <br/><br/>You can do this later through Users module if required.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" onclick="modJs.createUser();">Yes</button>
|
||||
<button class="btn" onclick="modJs.closeCreateUser();">No</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
File diff suppressed because it is too large
Load Diff
57
ext/admin/fieldnames/api/FieldnamesAdminManager.php
Normal file
57
ext/admin/fieldnames/api/FieldnamesAdminManager.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if (!class_exists('FieldnamesAdminManager')) {
|
||||
class FieldnamesAdminManager extends AbstractModuleManager{
|
||||
public function initializeUserClasses(){
|
||||
|
||||
}
|
||||
|
||||
public function initializeFieldMappings(){
|
||||
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings(){
|
||||
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions(){
|
||||
$this->addModelClass('FieldNameMapping');
|
||||
$this->addModelClass('CustomField');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('FieldNameMapping')) {
|
||||
class FieldNameMapping extends ICEHRM_Record {
|
||||
var $_table = 'FieldNameMappings';
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getUserAccess(){
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('CustomField')) {
|
||||
class CustomField extends ICEHRM_Record {
|
||||
var $_table = 'CustomFields';
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getUserAccess(){
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
}
|
||||
}
|
||||
62
ext/admin/fieldnames/index.php
Normal file
62
ext/admin/fieldnames/index.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
This file is part of Ice Framework.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
|
||||
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
|
||||
*/
|
||||
|
||||
$moduleName = 'fieldnames';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
?><div class="span9">
|
||||
|
||||
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
<li class="dropdown">
|
||||
<a href="#" id="settingsEmployeeMenu" class="dropdown-toggle" data-toggle="dropdown" aria-controls="settingsEmployeeMenu-contents">Employee Fields <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="settingsEmployeeMenu" id="settingsEmployeeMenu-contents">
|
||||
<li><a id="tabEmployeeFieldName" href="#tabPageEmployeeFieldName">Employee Field Name Mapping</a></li>
|
||||
<li><a id="tabEmployeeCustomField" href="#tabPageEmployeeCustomField">Employee Custom Fields</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tabPageEmployeeFieldName">
|
||||
<div id="EmployeeFieldName" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeFieldNameForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageEmployeeCustomField">
|
||||
<div id="EmployeeCustomField" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeCustomFieldForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
|
||||
modJsList['tabEmployeeFieldName'] = new FieldNameAdapter('FieldNameMapping','EmployeeFieldName',{"type":"Employee"});
|
||||
modJsList['tabEmployeeFieldName'].setRemoteTable(true);
|
||||
modJsList['tabEmployeeFieldName'].setShowAddNew(false);
|
||||
|
||||
modJsList['tabEmployeeCustomField'] = new CustomFieldAdapter('CustomField','EmployeeCustomField',{"type":"Employee"});
|
||||
modJsList['tabEmployeeCustomField'].setRemoteTable(true);
|
||||
modJsList['tabEmployeeCustomField'].setShowAddNew(false);
|
||||
|
||||
|
||||
var modJs = modJsList['tabEmployeeFieldName'];
|
||||
|
||||
</script>
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
86
ext/admin/fieldnames/lib.js
Normal file
86
ext/admin/fieldnames/lib.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Author: Thilina Hasantha
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* FieldNameAdapter
|
||||
*/
|
||||
|
||||
function FieldNameAdapter(endPoint,tab,filter,orderBy) {
|
||||
this.initAdapter(endPoint,tab,filter,orderBy);
|
||||
}
|
||||
|
||||
FieldNameAdapter.inherits(AdapterBase);
|
||||
|
||||
|
||||
|
||||
FieldNameAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"textOrig",
|
||||
"textMapped",
|
||||
"display"
|
||||
];
|
||||
});
|
||||
|
||||
FieldNameAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Name" },
|
||||
{ "sTitle": "Original Text"},
|
||||
{ "sTitle": "Mapped Text"},
|
||||
{ "sTitle": "Display Status"}
|
||||
];
|
||||
});
|
||||
|
||||
FieldNameAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "type", {"label":"Type","type":"placeholder","validation":""}],
|
||||
[ "name", {"label":"Name","type":"placeholder","validation":""}],
|
||||
[ "textOrig", {"label":"Original Text","type":"placeholder","validation":""}],
|
||||
[ "textMapped", {"label":"Mapped Text","type":"text","validation":""}],
|
||||
[ "display", {"label":"Display Status","type":"select","source":[["Form","Form"],["Table and Form","Table and Form"],["Hidden","Hidden"]]}]
|
||||
];
|
||||
});
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
function CustomFieldAdapter(endPoint,tab,filter,orderBy) {
|
||||
this.initAdapter(endPoint,tab,filter,orderBy);
|
||||
}
|
||||
|
||||
CustomFieldAdapter.inherits(AdapterBase);
|
||||
|
||||
|
||||
|
||||
CustomFieldAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"display"
|
||||
];
|
||||
});
|
||||
|
||||
CustomFieldAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Name" },
|
||||
{ "sTitle": "Display Status"}
|
||||
];
|
||||
});
|
||||
|
||||
CustomFieldAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "type", {"label":"Type","type":"placeholder","validation":""}],
|
||||
[ "name", {"label":"Name","type":"placeholder","validation":""}],
|
||||
[ "data", {"label":"Data","type":"textarea","validation":""}],
|
||||
[ "display", {"label":"Display Status","type":"select","source":[["Form","Form"],["Table and Form","Table and Form"],["Hidden","Hidden"]]}]
|
||||
];
|
||||
});
|
||||
|
||||
11
ext/admin/fieldnames/meta.json
Normal file
11
ext/admin/fieldnames/meta.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"label":"Field Names Setup",
|
||||
"menu":"System",
|
||||
"order":"7",
|
||||
"icon":"fa-sort-alpha-asc",
|
||||
"user_levels":["Admin"],
|
||||
|
||||
"permissions":
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,5 @@
|
||||
"Employees":"fa-users",
|
||||
"Reports":"fa-file-text",
|
||||
"System":"fa-cogs",
|
||||
"Salary Details":"fa-money"
|
||||
"Payroll":"fa-money"
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ if (!class_exists('MetadataAdminManager')) {
|
||||
$this->addModelClass('Nationality');
|
||||
$this->addModelClass('ImmigrationStatus');
|
||||
$this->addModelClass('Ethnicity');
|
||||
$this->addModelClass('CalculationHook');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,6 +43,20 @@ if (!class_exists('Country')) {
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
|
||||
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Countries');
|
||||
$allowedCountries = array();
|
||||
if(!empty($allowedCountriesStr)){
|
||||
$allowedCountries = json_decode($allowedCountriesStr,true);
|
||||
}
|
||||
|
||||
if(!empty($allowedCountries)){
|
||||
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
|
||||
}
|
||||
|
||||
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +94,20 @@ if (!class_exists('CurrencyType')) {
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
|
||||
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Currencies');
|
||||
$allowedCountries = array();
|
||||
if(!empty($allowedCountriesStr)){
|
||||
$allowedCountries = json_decode($allowedCountriesStr,true);
|
||||
}
|
||||
|
||||
if(!empty($allowedCountries)){
|
||||
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
|
||||
}
|
||||
|
||||
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +127,22 @@ if (!class_exists('Nationality')) {
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
|
||||
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Nationality');
|
||||
$allowedCountries = array();
|
||||
if(!empty($allowedCountriesStr)){
|
||||
$allowedCountries = json_decode($allowedCountriesStr,true);
|
||||
}
|
||||
|
||||
if(!empty($allowedCountries)){
|
||||
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
|
||||
}
|
||||
|
||||
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +184,32 @@ if (!class_exists('Ethnicity')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('CalculationHook')) {
|
||||
class CalculationHook extends ICEHRM_Record {
|
||||
var $_table = 'CalculationHooks';
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getUserAccess(){
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
|
||||
return BaseService::getInstance()->getCalculationHooks();
|
||||
}
|
||||
|
||||
function Load($where=null,$bindarr=false){
|
||||
return BaseService::getInstance()->getCalculationHook($bindarr[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ $moduleBuilder->addModuleOrGroup(new ModuleTab('Country','Country','Countries','
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('Province','Province','Provinces','ProvinceAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('CurrencyType','CurrencyType','Currency Types','CurrencyTypeAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('Nationality','Nationality','Nationality','NationalityAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('Nationality','Nationality','Nationality','NationalityAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('Ethnicity','Ethnicity','Ethnicity','EthnicityAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('ImmigrationStatus','ImmigrationStatus','Immigration Status','ImmigrationStatusAdapter','',''));
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
|
||||
modJsList['moduleModule'] = new ModuleAdapter('Module','Module');
|
||||
modJsList['moduleModule'].setShowAddNew(false);
|
||||
var modJs = modJsList['moduleModule'];
|
||||
modJsList['tabModule'] = new ModuleAdapter('Module','Module');
|
||||
modJsList['tabModule'].setShowAddNew(false);
|
||||
var modJs = modJsList['tabModule'];
|
||||
|
||||
</script>
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
@@ -58,7 +58,7 @@ ModuleAdapter.method('getActionButtonsHtml', function(id,data) {
|
||||
var nonEditableFields = {};
|
||||
nonEditableFields["admin_Company Structure"] = 1;
|
||||
nonEditableFields["admin_Employees"] = 1;
|
||||
nonEditableFields["admin_Jobs"] = 1;
|
||||
nonEditableFields["admin_Job Details Setup"] = 1;
|
||||
nonEditableFields["admin_Leaves"] = 1;
|
||||
nonEditableFields["admin_Manage Modules"] = 1;
|
||||
nonEditableFields["admin_Projects"] = 1;
|
||||
@@ -66,9 +66,10 @@ ModuleAdapter.method('getActionButtonsHtml', function(id,data) {
|
||||
nonEditableFields["admin_Settings"] = 1;
|
||||
nonEditableFields["admin_Users"] = 1;
|
||||
nonEditableFields["admin_Upgrade"] = 1;
|
||||
nonEditableFields["admin_Upgrade"] = 1;
|
||||
nonEditableFields["admin_Dashboard"] = 1;
|
||||
|
||||
nonEditableFields["user_Basic Information"] = 1;
|
||||
nonEditableFields["user_Dashboard"] = 1;
|
||||
|
||||
if(nonEditableFields[data[3]+"_"+data[1]] == 1){
|
||||
return "";
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"label":"Setup",
|
||||
"menu":"Salary Details",
|
||||
"order":"6",
|
||||
"icon":"fa-cogs",
|
||||
"user_levels":["Admin"],
|
||||
|
||||
"permissions":
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -33,31 +33,47 @@ from EmployeeLeaves lv";
|
||||
$employeeList = array();
|
||||
}
|
||||
|
||||
if($request['department'] != "NULL" && empty($employeeList)){
|
||||
$empTmp = new Employee();
|
||||
$empTemps = $empTmp->Find("department = ? and status = Active",array($request['department']));
|
||||
foreach($empTemps as $empTmp){
|
||||
$employeeList[] = $empTmp->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ? and status = ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?)) and status = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['status']
|
||||
);
|
||||
}else if(!empty($employeeList)){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else if(($request['status'] != "NULL" && !empty($request['status']))){
|
||||
$query = "where status = ? and date_start >= ? and date_end <= ?;";
|
||||
$query = "where status = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$params = array(
|
||||
$request['status'],
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else{
|
||||
$query = "where date_start >= ? and date_end <= ?;";
|
||||
$query = "where ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}
|
||||
|
||||
44
ext/admin/salary/LICENSE.txt
Normal file
44
ext/admin/salary/LICENSE.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
ICEHRM END USER LICENSE AGREEMENT
|
||||
NOTICE TO ALL USERS: BY PURCHASING THE MODULE, YOU (EITHER AN INDIVIDUAL OR A SINGLE ENTITY) CONSENT TO BE BOUND BY AND BECOME A PARTY TO THIS AGREEMENT.
|
||||
|
||||
All references to "Software" herein shall be deemed to include the software license with which you will be provided by Gamonoid Media Pvt Ltd, as part of the Software.
|
||||
|
||||
1. LICENSE GRANT. Subject to the payment of the applicable licence fees, and subject to the terms and conditions of this Agreement, ICEHRM hereby grants to you a non-exclusive, non-transferable right to use one copy of the specified version of the Software and the accompanying documentation (the "Documentation") for the term of this Agreement solely for your own internal business purposes. You may install one copy of the Software for production use.
|
||||
.
|
||||
2. USE. The Software is licensed as a single product; it may not be used on more than one ICEHRM Server at a time. The Software is "in use" on a Server when its installed on a Server. You shall not, nor permit any third party to copy (other than as expressly permitted herein). You shall not rent, lease or lend the Software to any other person, nor transfer or sub-licence your licence rights to any other person.
|
||||
|
||||
3. TERM. This Agreement is effective until terminated as set forth herein. This Agreement will terminate automatically if you fail to comply with any of the conditions, limitations or other requirements described herein. Upon any termination of this Agreement, you must immediately destroy all copies of the Software and the Documentation. You may terminate this Agreement at any point by destroying all copies of the Software and the Documentation.
|
||||
|
||||
4. SUPPORT. Gamonoid Media Pvt Ltd will provide you support according to the support agreement subscribed by the company.
|
||||
|
||||
5. OWNERSHIP RIGHTS. The Software is protected by copyright laws. ICEHRM and Gamonoid Media Pvt Ltd own and retain all right, title and interest in and to the Software, including all copyrights, patents, trademarks and other intellectual property rights therein. Your possession, installation, or use of the Software does not transfer to you any title to the intellectual property in the Software, and you will not acquire any rights to the Software except as expressly set forth in this Agreement.
|
||||
|
||||
6. LIMITED WARRANTY. You may not rent, lease, loan or resell the Software. You may not permit third parties to benefit from the use or functionality of the Software via a timesharing, service bureau or other arrangement, except to the extent such use is specified in the applicable list price or product packaging for the Software. You may not transfer any of the rights granted to you under this Agreement. You may not modify, or create derivative works based upon, the Software in whole or in part. You may not copy the Software or Documentation except as expressly permitted in Section 1 above. You may not remove any proprietary notices or labels on the Software. All rights not expressly set forth hereunder are reserved by ICEHRM. ICEHRM reserves the right to periodically conduct audits upon advance written notice to verify compliance with the terms of this Agreement.
|
||||
|
||||
7. WARRANTY and DISCLAIMER.
|
||||
|
||||
(i) Gamonoid Media Pvt Ltd. warrants that for 30 days from first download or installation the Software will perform substantially in accordance with the functionality described in the Documentation (http://blog.icehrm.com) when operated properly and in the manner specified in the Documentation.
|
||||
|
||||
(ii) You accept all responsibility for the selection of this Software to meet your requirements.
|
||||
|
||||
(iii) Gamonoid Media Pvt Ltd. does not warrant that the Software and/or the Documentation will be suitable for such requirements nor that any use will be uninterrupted and error free.
|
||||
|
||||
(iv) The warranty in (i) shall not apply if you (a) make or cause to be made any modifications to this Software, (b) use the Software in a manner for which it was not intended or (c) use the Software other than as permitted under this Agreement.
|
||||
|
||||
(vii) The warranties and conditions stated in this Agreement are in lieu of all other conditions, warranties or other terms concerning the supply or purported supply of, failure to supply or delay in supplying the Software or the Documentation which might but for this paragraph (vii) have effect between the ICEHRM and you or would otherwise be implied into or incorporated into this Agreement or any collateral contract, whether by statute, common law or otherwise, all of which are hereby excluded (including, without limitation, the implied conditions, warranties or other terms as to satisfactory quality, fitness for purpose or as to the use of reasonable skill and care).
|
||||
|
||||
8. LIMITATION of LIABILITY. Gamonoid Media Pvt Ltd. shall have no liability (whether in contract, tort, restitution or otherwise) for any of the following losses or damage (whether such losses or damage were foreseen, foreseeable, known or otherwise):
|
||||
- Loss of revenue;
|
||||
- Loss of actual or anticipated profits (including for loss of profits on contracts);
|
||||
- Loss of the use of money;
|
||||
- Loss of anticipated savings;
|
||||
- Loss of business;
|
||||
- Loss of opportunity;
|
||||
- Loss of goodwill;
|
||||
- Loss of reputation;
|
||||
- Loss of, damage to or corruption of data;
|
||||
or
|
||||
Any indirect or consequential loss or damage howsoever caused (including, for the avoidance of doubt, where such loss or damage is of the type specified in paragraph (ii), (a) to (ii), (i).
|
||||
The ICEHRM liability (whether in contract, tort, restitution or otherwise) arising out of or in connection with the supply of the Software shall in no circumstances exceed a sum equal to the amount equally paid by you for the Software.
|
||||
The construction and interpretation of this Agreement shall be governed in accordance with the laws of Sri Lanka. The parties hereby submit to the jurisdiction of the courts of Sri Lanka save that ICEHRM as claimant shall be entitled to initiate proceedings in any court of competent jurisdiction.
|
||||
This Agreement contains the entire understanding of the parties with respect to the subject matter hereof and supersedes all and any prior understandings, undertakings and promises between you and ICEHRM, whether oral or in writing, which have been given or may be implied from anything written or said in negotiations between us or our representatives prior to this Agreement and all prior agreements between the parties relating to the matters aforesaid shall cease to have effect as from the Effective Date.
|
||||
7
ext/admin/salary/README.txt
Normal file
7
ext/admin/salary/README.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
This module is licensed under IceHrm Commercial License, which can be found in LICENSE.txt.
|
||||
You are allowed to make any modification required to these module, but only allowed to use
|
||||
the module in one production server (even with modifications).
|
||||
|
||||
Installation
|
||||
------------
|
||||
Copy this module into <icehrm path>/admin/ directory
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if (!class_exists('PayrollAdminManager')) {
|
||||
class PayrollAdminManager extends AbstractModuleManager{
|
||||
if (!class_exists('SalaryAdminManager')) {
|
||||
class SalaryAdminManager extends AbstractModuleManager{
|
||||
|
||||
public function initializeUserClasses(){
|
||||
|
||||
@@ -17,8 +17,7 @@ if (!class_exists('PayrollAdminManager')) {
|
||||
public function setupModuleClassDefinitions(){
|
||||
$this->addModelClass('SalaryComponentType');
|
||||
$this->addModelClass('SalaryComponent');
|
||||
$this->addModelClass('Deduction');
|
||||
|
||||
$this->addModelClass('PayrollEmployee');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,9 +51,10 @@ if (!class_exists('SalaryComponent')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('Deduction')) {
|
||||
class Deduction extends ICEHRM_Record {
|
||||
var $_table = 'Deductions';
|
||||
|
||||
if (!class_exists('PayrollEmployee')) {
|
||||
class PayrollEmployee extends ICEHRM_Record {
|
||||
var $_table = 'PayrollEmployees';
|
||||
|
||||
public function getAdminAccess(){
|
||||
return array("get","element","save","delete");
|
||||
@@ -66,4 +66,3 @@ if (!class_exists('Deduction')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
$moduleName = 'metadata';
|
||||
$moduleName = 'salary';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
include APP_BASE_PATH.'mod-houlejslibs.inc.php';
|
||||
|
||||
$moduleBuilder = new ModuleBuilder();
|
||||
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('SalaryComponentType','SalaryComponentType','Salary Component Types','SalaryComponentTypeAdapter','','',true));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('SalaryComponent','SalaryComponent','Salary Components','SalaryComponentAdapter','',''));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeSalary','EmployeeSalary','Employee Salary','EmployeeSalaryAdapter','','',false,array("setRemoteTable"=>"true")));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeSalary','EmployeeSalary','Employee Salary Components','EmployeeSalaryAdapter','','',false,array("setRemoteTable"=>"true")));
|
||||
|
||||
|
||||
echo UIManager::getInstance()->renderModule($moduleBuilder);
|
||||
@@ -2,7 +2,6 @@
|
||||
* Author: Thilina Hasantha
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* SalaryComponentTypeAdapter
|
||||
*/
|
||||
@@ -96,8 +95,7 @@ DeductionAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"contributor",
|
||||
"type",
|
||||
"deduction_group"
|
||||
];
|
||||
});
|
||||
|
||||
@@ -105,32 +103,52 @@ DeductionAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Name" },
|
||||
{ "sTitle": "Contributor"},
|
||||
{ "sTitle": "Deduction Type"}
|
||||
{ "sTitle": "Calculation Group"}
|
||||
];
|
||||
});
|
||||
|
||||
DeductionAdapter.method('getFormFields', function() {
|
||||
|
||||
var rangeAmounts = [ "rangeAmounts", {"label":"Deduction Amounts","type":"datagroup",
|
||||
var rangeAmounts = [ "rangeAmounts", {"label":"Calculation Process","type":"datagroup",
|
||||
"form":[
|
||||
[ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],[">","Greater than"],[">=","Greater than or Equal"]]}],
|
||||
[ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"none"}],
|
||||
[ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["<","Less than"],["<=","Less than or Equal"]]}],
|
||||
[ "upperLimit", {"label":"Upper Limit","type":"text","validation":"none"}],
|
||||
[ "amount", {"label":"Value","type":"text","validation":"float"}]
|
||||
[ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],["gt","Greater than"],["gte","Greater than or Equal"]]}],
|
||||
[ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"float"}],
|
||||
[ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["lt","Less than"],["lte","Less than or Equal"]]}],
|
||||
[ "upperLimit", {"label":"Upper Limit","type":"text","validation":"float"}],
|
||||
[ "amount", {"label":"Value","type":"text","validation":""}]
|
||||
],
|
||||
"html":'<div id="#_id_#" class="panel panel-default">#_delete_##_edit_#<div class="panel-body">#_renderFunction_#</div></div>',
|
||||
"validation":"none",
|
||||
"custom-validate-function":function (data){
|
||||
var res = {};
|
||||
res['valid'] = true;
|
||||
if(lowerCondition != 'No Lower Limit'){
|
||||
data.lowerLimit = 0;
|
||||
}
|
||||
if(upperCondition != 'No Upper Limit'){
|
||||
data.upperLimit = 0;
|
||||
}
|
||||
res['params'] = data;
|
||||
return res;
|
||||
},
|
||||
"render":function(item){
|
||||
var output = "";
|
||||
var getSymbol = function(text){
|
||||
var map = {};
|
||||
map['gt'] = '>';
|
||||
map['gte'] = '>=';
|
||||
map['lt'] = '<';
|
||||
map['lte'] = '<=';
|
||||
|
||||
return map[text];
|
||||
}
|
||||
if(item.lowerCondition != "No Lower Limit"){
|
||||
output += item.lowerLimit + " " + item.lowerCondition + " ";
|
||||
output += " and ";
|
||||
output += item.lowerLimit + " " + getSymbol(item.lowerCondition) + " ";
|
||||
}
|
||||
|
||||
if(item.upperCondition != "No Upper Limit"){
|
||||
output += item.upperCondition + " " + item.upperLimit + " ";
|
||||
output += " and ";
|
||||
output += getSymbol(item.upperCondition) + " " + item.upperLimit + " ";
|
||||
}
|
||||
if(output == ""){
|
||||
return "Deduction is "+item.amount + " for all ranges";
|
||||
@@ -148,17 +166,16 @@ DeductionAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "name", {"label":"Name","type":"text","validation":""}],
|
||||
[ "contributor", {"label":"Contributor","type":"select","source":[["Employee","Employee"],["Employer","Employer"]]}],
|
||||
[ "type", {"label":"Deduction Type","type":"select","source":[["Fixed","Fixed"],["Percentage","Percentage"]]}],
|
||||
[ "percentage_type", {"label":"Percentage Type","type":"select","source":[["On Component","On Component"],["On Component Type","On Component Type"]]}],
|
||||
[ "componentType", {"label":"Salary Component Type","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponentType","id","name"]}],
|
||||
[ "component", {"label":"Salary Component","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponent","id","name"]}],
|
||||
[ "componentType", {"label":"Salary Component Type","type":"select2multi","allow-null":true,"remote-source":["SalaryComponentType","id","name"]}],
|
||||
[ "component", {"label":"Salary Component","type":"select2multi","allow-null":true,"remote-source":["SalaryComponent","id","name"]}],
|
||||
[ "payrollColumn", {"label":"Payroll Report Column","type":"select2","allow-null":true,"remote-source":["PayrollColumn","id","name"]}],
|
||||
rangeAmounts,
|
||||
[ "country", {"label":"Country","type":"select2","remote-source":["Country","id","name"]}]
|
||||
[ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"None","remote-source":["DeductionGroup","id","name"]}]
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
/*
|
||||
DeductionAdapter.method('doCustomValidation', function(params) {
|
||||
if(params.type == "Fixed"){
|
||||
return null;
|
||||
@@ -177,7 +194,8 @@ DeductionAdapter.method('doCustomValidation', function(params) {
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
*/
|
||||
/*
|
||||
DeductionAdapter.method('postRenderForm', function(object, $tempDomObj) {
|
||||
|
||||
$tempDomObj.find("#field_componentType").hide();
|
||||
@@ -213,6 +231,10 @@ DeductionAdapter.method('postRenderForm', function(object, $tempDomObj) {
|
||||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -232,8 +254,6 @@ EmployeeSalaryAdapter.method('getDataMapping', function() {
|
||||
"id",
|
||||
"employee",
|
||||
"component",
|
||||
"pay_frequency",
|
||||
"currency",
|
||||
"amount",
|
||||
"details"
|
||||
];
|
||||
@@ -244,8 +264,6 @@ EmployeeSalaryAdapter.method('getHeaders', function() {
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Employee" },
|
||||
{ "sTitle": "Salary Component" },
|
||||
{ "sTitle": "Pay Frequency"},
|
||||
{ "sTitle": "Currency"},
|
||||
{ "sTitle": "Amount"},
|
||||
{ "sTitle": "Details"}
|
||||
];
|
||||
@@ -256,8 +274,6 @@ EmployeeSalaryAdapter.method('getFormFields', function() {
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}],
|
||||
[ "component", {"label":"Salary Component","type":"select2","remote-source":["SalaryComponent","id","name"]}],
|
||||
[ "pay_frequency", {"label":"Pay Frequency","type":"select","source":[["Hourly","Hourly"],["Daily","Daily"],["Bi Weekly","Bi Weekly"],["Weekly","Weekly"],["Semi Monthly","Semi Monthly"],["Monthly","Monthly"]]}],
|
||||
[ "currency", {"label":"Currency","type":"select2","remote-source":["CurrencyType","id","name"]}],
|
||||
[ "amount", {"label":"Amount","type":"text","validation":"float"}],
|
||||
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
|
||||
];
|
||||
@@ -272,3 +288,43 @@ EmployeeSalaryAdapter.method('getFilters', function() {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DeductionGroupAdapter
|
||||
*/
|
||||
|
||||
function DeductionGroupAdapter(endPoint,tab,filter,orderBy) {
|
||||
this.initAdapter(endPoint,tab,filter,orderBy);
|
||||
}
|
||||
|
||||
DeductionGroupAdapter.inherits(AdapterBase);
|
||||
|
||||
|
||||
|
||||
DeductionGroupAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"description"
|
||||
];
|
||||
});
|
||||
|
||||
DeductionGroupAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Name" },
|
||||
{ "sTitle": "Details" }
|
||||
];
|
||||
});
|
||||
|
||||
DeductionGroupAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "name", {"label":"Name","type":"text","validation":""}],
|
||||
[ "description", {"label":"Details","type":"textarea","validation":"none"}]
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
ext/admin/salary/meta.json
Normal file
11
ext/admin/salary/meta.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"label":"Salary",
|
||||
"menu":"Payroll",
|
||||
"order":"1",
|
||||
"icon":"fa-money",
|
||||
"user_levels":["Admin"],
|
||||
|
||||
"permissions":
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,14 @@ class SettingsInitialize extends AbstractInitialize{
|
||||
public function init(){
|
||||
if(SettingsManager::getInstance()->getSetting("Api: REST Api Enabled") == "1"){
|
||||
$user = BaseService::getInstance()->getCurrentUser();
|
||||
if(empty($user)){
|
||||
return;
|
||||
}
|
||||
$dbUser = new User();
|
||||
$dbUser->Load("id = ?",array($user->id));
|
||||
$resp = RestApiManager::getInstance()->getAccessTokenForUser($dbUser);
|
||||
if($resp->getStatus() != IceResponse::SUCCESS){
|
||||
LogManager::getInstance()->error("Error occured while creating REST Api acces token for ".$user->username);
|
||||
LogManager::getInstance()->error("Error occurred while creating REST Api access token for ".$user->username);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,37 +25,26 @@ $moduleName = 'settings';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
?><div class="span9">
|
||||
|
||||
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
<li class="active"><a id="tabSetting" href="#tabPageSetting">Settings</a></li>
|
||||
</ul>
|
||||
$moduleBuilder = new ModuleBuilder();
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tabPageSetting">
|
||||
<div id="Setting" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="SettingForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
$options1 = array();
|
||||
$options1['setShowAddNew'] = 'false';
|
||||
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('CompanySetting','Setting','Company','SettingAdapter','{"name":["Company:"]}','name',true,$options1));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('SystemSetting','Setting','System','SettingAdapter','{"name":["System:"]}','name',false,$options1));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmailSetting','Setting','Email','SettingAdapter','{"name":["Email:"]}','name',false,$options1));
|
||||
//$moduleBuilder->addModuleOrGroup(new ModuleTab('LeaveSetting','Setting','Leave / PTO','SettingAdapter','{"name":["Leave:"]}','name',false,$options1));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('LDAPSetting','Setting','LDAP','SettingAdapter','{"name":["LDAP:"]}','name',false,$options1));
|
||||
$moduleBuilder->addModuleOrGroup(new ModuleTab('OtherSetting','Setting','Other','SettingAdapter','{"name":["Projects:","Attendance:","Recruitment:","Notifications:","Expense:","Travel:","Api:"]}','name',false,$options1));
|
||||
echo UIManager::getInstance()->renderModule($moduleBuilder);
|
||||
?>
|
||||
</div>
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
|
||||
modJsList['tabSetting'] = new SettingAdapter('Setting','Setting','','name');
|
||||
modJsList['tabSetting'].setShowAddNew(false);
|
||||
|
||||
var modJs = modJsList['tabSetting'];
|
||||
|
||||
$(window).load(function() {
|
||||
modJs.loadRemoteDataForSettings();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
@@ -62,13 +62,33 @@ SettingAdapter.method('edit', function(id) {
|
||||
|
||||
|
||||
SettingAdapter.method('fillForm', function(object) {
|
||||
this.uber('fillForm',object);
|
||||
|
||||
var metaField = this.getMetaFieldForRendering('value');
|
||||
var metaVal = object[metaField];
|
||||
var formFields = null;
|
||||
|
||||
if(metaVal != "" && metaVal != undefined){
|
||||
var formFields = [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
JSON.parse(metaVal)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
this.uber('fillForm',object, null, formFields);
|
||||
$("#helptext").html(object.description);
|
||||
});
|
||||
|
||||
|
||||
SettingAdapter.method('loadRemoteDataForSettings', function () {
|
||||
var field = ["country", {"label": "Country", "type": "select2", "remote-source": ["Country", "code", "name"]}];
|
||||
var fields = [];
|
||||
var field = null;
|
||||
fields.push(["country", {"label": "Country", "type": "select2multi", "remote-source": ["Country", "id", "name"]}]);
|
||||
fields.push(["currency", {"label": "Currency", "type": "select2multi", "remote-source": ["CurrencyType","id","code+name"]}]);
|
||||
fields.push(["nationality", {"label": "Nationality", "type": "select2multi", "remote-source": ["Nationality","id","name"]}]);
|
||||
|
||||
for(index in fields){
|
||||
field = fields[index];
|
||||
if (field[1]['remote-source'] != undefined && field[1]['remote-source'] != null) {
|
||||
var key = field[1]['remote-source'][0] + "_" + field[1]['remote-source'][1] + "_" + field[1]['remote-source'][2];
|
||||
this.fieldMasterDataKeys[key] = false;
|
||||
@@ -80,6 +100,8 @@ SettingAdapter.method('loadRemoteDataForSettings', function () {
|
||||
|
||||
this.getFieldValues(field[1]['remote-source'], callBackData);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,16 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
|
||||
|
||||
class UsersActionManager extends SubActionManager{
|
||||
public function changePassword($req){
|
||||
if($this->user->user_level == 'Admin' || $this->user->id == $req->id){
|
||||
$user = $this->baseService->getElement('User',$req->id);
|
||||
if(defined('DEMO_MODE')){
|
||||
return new IceResponse(IceResponse::ERROR,"You are not allowed to change the password in demo mode");
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user->Load("id = ?",array($req->id));
|
||||
LogManager::getInstance()->debug("Current User:".print_r($this->user,true));
|
||||
LogManager::getInstance()->debug("Edit User:".print_r($user,true));
|
||||
if($this->user->user_level == 'Admin' || $this->user->id == $user->id){
|
||||
|
||||
if(empty($user->id)){
|
||||
return new IceResponse(IceResponse::ERROR,"Please save the user first");
|
||||
}
|
||||
|
||||
@@ -54,11 +54,40 @@ if (!class_exists('User')) {
|
||||
if(count($users) > 0){
|
||||
return new IceResponse(IceResponse::ERROR,"A user with same authentication email already exist");
|
||||
}
|
||||
|
||||
//Check if you are trying to change user level
|
||||
$oldUser = new User();
|
||||
$oldUser->Load("id = ?",array($obj->id));
|
||||
if($oldUser->user_level != $obj->user_level && $oldUser->user_level == 'Admin'){
|
||||
$adminUsers = $userTemp->Find("user_level = ?",array("Admin"));
|
||||
if(count($adminUsers) == 1 && $adminUsers[0]->id == $obj->id){
|
||||
return new IceResponse(IceResponse::ERROR,"You are the only admin user for the application. You are not allowed to revoke your admin rights");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Check if the user have rights to the default module
|
||||
if(!empty($obj->default_module)){
|
||||
$module = new Module();
|
||||
$module->Load("id = ?",array($obj->default_module));
|
||||
if($module->mod_group == "user"){
|
||||
$module->mod_group = "modules";
|
||||
}
|
||||
$moduleManager = BaseService::getInstance()->getModuleManager($module->mod_group, $module->name);
|
||||
if(!BaseService::getInstance()->isModuleAllowedForGivenUser($moduleManager, $obj)){
|
||||
return new IceResponse(IceResponse::ERROR,"This module can not be set as the default module for the user since the user do not have access to this module");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS,"");
|
||||
}
|
||||
|
||||
|
||||
var $_table = 'Users';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,20 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
|
||||
|
||||
class EmployeesActionManager extends SubActionManager{
|
||||
public function get($req){
|
||||
$profileId = $this->getCurrentProfileId();
|
||||
$subordinate = new Employee();
|
||||
$subordinatesCount = $subordinate->Count("supervisor = ? and id = ?",array($profileId, $req->id));
|
||||
|
||||
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),$req->map,true);
|
||||
|
||||
if($this->user->user_level == 'Admin' || $subordinatesCount > 0){
|
||||
$id = $req->id;
|
||||
}
|
||||
|
||||
if(empty($id)){
|
||||
$id = $profileId;
|
||||
}
|
||||
|
||||
$employee = $this->baseService->getElement('Employee',$id,$req->map,true);
|
||||
|
||||
$subordinate = new Employee();
|
||||
$subordinates = $subordinate->Find("supervisor = ?",array($employee->id));
|
||||
@@ -53,11 +65,19 @@ class EmployeesActionManager extends SubActionManager{
|
||||
}
|
||||
|
||||
public function deleteProfileImage($req){
|
||||
if($this->user->user_level == 'Admin' || $this->user->employee == $req->id){
|
||||
|
||||
$profileId = $this->getCurrentProfileId();
|
||||
$subordinate = new Employee();
|
||||
$subordinatesCount = $subordinate->Count("supervisor = ? and id = ?",array($profileId, $req->id));
|
||||
|
||||
|
||||
if($this->user->user_level == 'Admin' || $this->user->employee == $req->id || $subordinatesCount == 1){
|
||||
$fs = FileService::getInstance();
|
||||
$res = $fs->deleteProfileImage($req->id);
|
||||
return new IceResponse(IceResponse::SUCCESS,$res);
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::ERROR,"Not allowed to delete profile image");
|
||||
}
|
||||
|
||||
public function changePassword($req){
|
||||
@@ -66,7 +86,8 @@ class EmployeesActionManager extends SubActionManager{
|
||||
return new IceResponse(IceResponse::ERROR,"You are not allowed to change passwords of other employees");
|
||||
}
|
||||
|
||||
$user = $this->baseService->getElement('User',$this->user->id);
|
||||
$user = new User();
|
||||
$user->Load("id = ?",array($this->user->id));
|
||||
if(empty($user->id)){
|
||||
return new IceResponse(IceResponse::ERROR,"Error occured while changing password");
|
||||
}
|
||||
|
||||
@@ -1,59 +1,69 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-12 col-md-3">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-2">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-12" style="text-align: center;">
|
||||
<img id="profile_image__id_" src="" class="img-polaroid" style="max-width: 140px;max-height: 140px;">
|
||||
<img id="profile_image__id_" src="" class="img-polaroid img-thumbnail" style="max-width: 140px;max-height: 140px;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-9">
|
||||
<div class="col-xs-12 col-md-10">
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12"><h2 id="name"></h2></div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12">
|
||||
<p>
|
||||
<i class="fa fa-phone"></i> <span id="mobile_phone"></span>
|
||||
<i class="fa fa-envelope"></i> <span id="work_email"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-12" style="font-size:18px;border-bottom: 1px solid #DDD;margin-bottom: 10px;padding-bottom: 10px;">
|
||||
<span id="name"></span><br/>
|
||||
<button id="employeeProfileEditInfo" class="btn btn-inverse btn-xs" onclick="modJs.editEmployee();" style="margin-right:10px;">Edit Info</button>
|
||||
<button id="employeeUploadProfileImage" onclick="showUploadDialog('profile_image__id_','Upload Profile Image','profile_image',_id_,'profile_image__id_','src','url','image');return false;" class="btn btn-xs btn-inverse" type="button" style="margin-right:10px;">Upload Profile Image</button>
|
||||
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-xs btn-inverse" type="button">Delete Profile Image</button>
|
||||
<button id="employeeUpdatePassword" onclick="modJs.changePassword();return false;" class="btn btn-xs btn-inverse" type="button">Change Password</button>
|
||||
<button id="employeeProfileEditInfo" class="btn btn-small btn-success" onclick="modJs.editEmployee();" style="margin-right:10px;"><i class="fa fa-edit"></i> Edit Info</button>
|
||||
<button id="employeeUploadProfileImage" onclick="showUploadDialog('profile_image__id_','Upload Profile Image','profile_image',_id_,'profile_image__id_','src','url','image');return false;" class="btn btn-small btn-primary" type="button" style="margin-right:10px;"><i class="fa fa-upload"></i> Upload Profile Image</button>
|
||||
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-small btn-warning" type="button" style="margin-right:10px;"><i class="fa fa-times"></i> Delete Profile Image</button>
|
||||
<button id="employeeUpdatePassword" onclick="modJs.changePassword();return false;" class="btn btn-small btn-success" type="button" style="margin-right:10px;"><i class="fa fa-lock"></i> Change Password</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid" style="border-top: 1px;">
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;font-size:13px;">Employee Id</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;font-size:13px;">#_label_employee_id_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employee_id"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">NIC Number</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_nic_num_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nic_num"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">EPF/CPF No</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_ssn_num_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="ssn_num"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid" style="margin-left:10px;">
|
||||
<div class="col-xs-12">
|
||||
<hr/>
|
||||
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Personal Information</span><br/><br/>
|
||||
<div class="row" style="margin-left:10px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Personal Information</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Driver's License Number</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_driving_license_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="driving_license"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Other Id</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_other_id_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="other_id"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Birth Day</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_birthday_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="birthday"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Gender</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_gender_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="gender"></label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,87 +71,78 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Nationality</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_nationality_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nationality_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Marital Status</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_marital_status_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="marital_status"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Joined Date</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_joined_date_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="joined_date"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="col-xs-12">
|
||||
<hr/>
|
||||
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Contact Information</span><br/><br/>
|
||||
<div class="row" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Contact Information</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Address 1</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_address1_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address1"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Address 2</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_address2_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address2"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">City</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_city_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="city"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Country</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_country_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="country_Name"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Postal Code</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_postal_code_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="postal_code"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Home Phone</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_home_phone_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="home_phone"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Mobile Phone</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="mobile_phone"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Work Phone</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_work_phone_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_phone"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Work Email</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_email"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Private Email</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_private_email_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="private_email"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="col-xs-12">
|
||||
<hr/>
|
||||
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Job Details</span><br/><br/>
|
||||
<div class="row" style="margin-left:10px;margin-top:20px;">
|
||||
<div class="panel panel-default" style="width:97.5%;">
|
||||
<div class="panel-heading"><h4>Job Details</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Job Title</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_job_title_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="job_title_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Employment Status</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_employment_status_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employment_status_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
@@ -149,18 +150,19 @@
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="supervisor_Name"></label>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Subordinates</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Direct Reports</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="subordinates"></label>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-fluid">
|
||||
<div class="col-xs-6 col-md-3" style="font-size:16px;">
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">Department</label>
|
||||
<label class="control-label col-xs-12" style="font-size:13px;">#_label_department_#</label>
|
||||
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="department_Name"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
17
ext/modules/employees/dashboard.html
Normal file
17
ext/modules/employees/dashboard.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-red">
|
||||
<div class="inner">
|
||||
<h3>My Profile</h3>
|
||||
<p>
|
||||
Edit Details
|
||||
</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-ios7-person"></i>
|
||||
</div>
|
||||
<a href="#_moduleLink_#" class="small-box-footer" id="myProfileLink">
|
||||
Manage Profile <i class="fa fa-arrow-circle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,9 +25,32 @@ $moduleName = 'employees';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
$fieldNameMap = BaseService::getInstance()->getFieldNameMappings("Employee");
|
||||
$customFields = BaseService::getInstance()->getCustomFields("Employee");
|
||||
?>
|
||||
<script type="text/javascript" src="<?=BASE_URL.'js/raphael-min.js?v='.$jsVersion?>"></script>
|
||||
<script type="text/javascript" src="<?=BASE_URL.'js/graffle.js?v='.$jsVersion?>"></script>
|
||||
<script type="text/javascript" src="<?=BASE_URL.'js/d3js/d3.js?v='.$jsVersion?>"></script>
|
||||
<script type="text/javascript" src="<?=BASE_URL.'js/d3js/d3.layout.js?v='.$jsVersion?>"></script>
|
||||
<style type="text/css">
|
||||
|
||||
|
||||
.node circle {
|
||||
cursor: pointer;
|
||||
fill: #fff;
|
||||
stroke: steelblue;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.node text {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
path.link {
|
||||
fill: none;
|
||||
stroke: #ccc;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="span9">
|
||||
|
||||
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
@@ -37,27 +60,24 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tabPageEmployee">
|
||||
<div id="Employee" class="container reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
<div id="Employee" class="container reviewBlock" data-content="List" style="padding:25px 0px 0px 0px; width:99%;">
|
||||
|
||||
</div>
|
||||
<div id="EmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabPageCompanyGraph">
|
||||
<div id="CompanyGraph" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
<div class="tab-pane reviewBlock" id="tabPageCompanyGraph" style="overflow-x: scroll;">
|
||||
|
||||
</div>
|
||||
<div id="CompanyGraphForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
modJsList['tabEmployee'] = new EmployeeAdapter('Employee');
|
||||
modJsList['tabEmployee'].setFieldNameMap(<?=json_encode($fieldNameMap)?>);
|
||||
modJsList['tabEmployee'].setCustomFields(<?=json_encode($customFields)?>);
|
||||
modJsList['tabCompanyGraph'] = new CompanyGraphAdapter('CompanyStructure');
|
||||
|
||||
var modJs = modJsList['tabEmployee'];
|
||||
|
||||
@@ -22,12 +22,57 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
|
||||
|
||||
function EmployeeAdapter(endPoint) {
|
||||
this.initAdapter(endPoint);
|
||||
this.fieldNameMap = {};
|
||||
this.hiddenFields = {};
|
||||
this.tableFields = {};
|
||||
this.formOnlyFields = {};
|
||||
this.customFields = [];
|
||||
}
|
||||
|
||||
EmployeeAdapter.inherits(AdapterBase);
|
||||
|
||||
this.currentUserId = null;
|
||||
|
||||
EmployeeAdapter.method('setFieldNameMap', function(fields) {
|
||||
var field;
|
||||
for(var i=0;i<fields.length;i++){
|
||||
field = fields[i];
|
||||
this.fieldNameMap[field.name] = field;
|
||||
if(field.display == "Hidden"){
|
||||
this.hiddenFields[field.name] = field;
|
||||
}else{
|
||||
if(field.display == "Table and Form"){
|
||||
this.tableFields[field.name] = field;
|
||||
}else{
|
||||
this.formOnlyFields[field.name] = field;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
EmployeeAdapter.method('setCustomFields', function(fields) {
|
||||
var field, parsed;
|
||||
for(var i=0;i<fields.length;i++){
|
||||
field = fields[i];
|
||||
if(field.display != "Hidden" && field.data != "" && field.data != undefined){
|
||||
try{
|
||||
parsed = JSON.parse(field.data);
|
||||
if(parsed == undefined || parsed == null){
|
||||
continue;
|
||||
}else if(parsed.length != 2){
|
||||
continue;
|
||||
}else if(parsed[1].type == undefined || parsed[1].type == null){
|
||||
continue;
|
||||
}
|
||||
this.customFields.push(parsed);
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
EmployeeAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
@@ -55,7 +100,7 @@ EmployeeAdapter.method('getHeaders', function() {
|
||||
});
|
||||
|
||||
EmployeeAdapter.method('getFormFields', function() {
|
||||
|
||||
var fields, newFields = [];
|
||||
var employee_id, ssn_num, employment_status, job_title, pay_grade, joined_date, department, work_email, country;
|
||||
|
||||
if(this.checkPermission("Edit Employee Number") == "Yes"){
|
||||
@@ -112,7 +157,7 @@ EmployeeAdapter.method('getFormFields', function() {
|
||||
country = [ "country", {"label":"Country","type":"placeholder","remote-source":["Country","code","name"]}];
|
||||
}
|
||||
|
||||
return [
|
||||
fields = [
|
||||
[ "id", {"label":"ID","type":"hidden","validation":""}],
|
||||
employee_id,
|
||||
[ "first_name", {"label":"First Name","type":"text","validation":""}],
|
||||
@@ -144,6 +189,24 @@ EmployeeAdapter.method('getFormFields', function() {
|
||||
joined_date,
|
||||
department
|
||||
];
|
||||
|
||||
for(var i=0;i<this.customFields.length;i++){
|
||||
fields.push(this.customFields[i]);
|
||||
}
|
||||
|
||||
|
||||
for(var i=0;i<fields.length;i++){
|
||||
tempField = fields[i];
|
||||
if(this.hiddenFields[tempField[0]] == undefined || this.hiddenFields[tempField[0]] == null ){
|
||||
if(this.fieldNameMap[tempField[0]] != undefined && this.fieldNameMap[tempField[0]] != null){
|
||||
title = this.fieldNameMap[tempField[0]].textMapped;
|
||||
tempField[1]['label'] = title;
|
||||
}
|
||||
newFields.push(tempField);
|
||||
}
|
||||
}
|
||||
|
||||
return newFields;
|
||||
});
|
||||
|
||||
EmployeeAdapter.method('getSourceMapping' , function() {
|
||||
@@ -187,17 +250,28 @@ EmployeeAdapter.method('modEmployeeDeleteProfileImageCallBack', function(data) {
|
||||
});
|
||||
|
||||
EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) {
|
||||
var fields = this.getFormFields();
|
||||
var currentEmpId = data[1];
|
||||
var userEmpId = data[2];
|
||||
data = data[0];
|
||||
var html = this.getCustomTemplate('myDetails.html');
|
||||
|
||||
for(var i=0;i<fields.length;i++) {
|
||||
if(this.fieldNameMap[fields[i][0]] != undefined && this.fieldNameMap[fields[i][0]] != null){
|
||||
title = this.fieldNameMap[fields[i][0]].textMapped;
|
||||
html = html.replace("#_label_"+fields[i][0]+"_#",title);
|
||||
}
|
||||
}
|
||||
|
||||
html = html.replace(/#_.+_#/i,"");
|
||||
|
||||
html = html.replace(/_id_/g,data.id);
|
||||
|
||||
$("#"+this.getTableName()).html(html);
|
||||
var fields = this.getFormFields();
|
||||
|
||||
for(var i=0;i<fields.length;i++) {
|
||||
$("#"+this.getTableName()+" #" + fields[i][0]).html(data[fields[i][0]]);
|
||||
$("#"+this.getTableName()+" #" + fields[i][0]+"_Name").html(data[fields[i][0]+"_Name"]);
|
||||
}
|
||||
|
||||
var subordinates = "";
|
||||
@@ -218,13 +292,6 @@ EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) {
|
||||
|
||||
$("#"+this.getTableName()+" #subordinates").html(subordinates);
|
||||
|
||||
$("#"+this.getTableName()+" #nationality_Name").html(data.nationality_Name);
|
||||
$("#"+this.getTableName()+" #employment_status_Name").html(data.employment_status_Name);
|
||||
$("#"+this.getTableName()+" #job_title_Name").html(data.job_title_Name);
|
||||
$("#"+this.getTableName()+" #country_Name").html(data.country_Name);
|
||||
$("#"+this.getTableName()+" #province_Name").html(data.province_Name);
|
||||
$("#"+this.getTableName()+" #supervisor_Name").html(data.supervisor_Name);
|
||||
$("#"+this.getTableName()+" #department_Name").html(data.department_Name);
|
||||
|
||||
$("#"+this.getTableName()+" #name").html(data.first_name + " " + data.last_name);
|
||||
this.currentUserId = data.id;
|
||||
@@ -318,16 +385,15 @@ EmployeeAdapter.method('changePasswordFailCallBack', function(callBackData,serve
|
||||
* Company Graph
|
||||
*/
|
||||
|
||||
|
||||
function CompanyGraphAdapter(endPoint) {
|
||||
function CompanyStructureAdapter(endPoint) {
|
||||
this.initAdapter(endPoint);
|
||||
}
|
||||
|
||||
CompanyGraphAdapter.inherits(AdapterBase);
|
||||
CompanyStructureAdapter.inherits(AdapterBase);
|
||||
|
||||
|
||||
|
||||
CompanyGraphAdapter.method('getDataMapping', function() {
|
||||
CompanyStructureAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"title",
|
||||
@@ -338,7 +404,7 @@ CompanyGraphAdapter.method('getDataMapping', function() {
|
||||
];
|
||||
});
|
||||
|
||||
CompanyGraphAdapter.method('getHeaders', function() {
|
||||
CompanyStructureAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID","bVisible":false },
|
||||
{ "sTitle": "Name" },
|
||||
@@ -349,7 +415,7 @@ CompanyGraphAdapter.method('getHeaders', function() {
|
||||
];
|
||||
});
|
||||
|
||||
CompanyGraphAdapter.method('getFormFields', function() {
|
||||
CompanyStructureAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden","validation":""}],
|
||||
[ "title", {"label":"Name","type":"text","validation":""}],
|
||||
@@ -361,25 +427,252 @@ CompanyGraphAdapter.method('getFormFields', function() {
|
||||
];
|
||||
});
|
||||
|
||||
CompanyGraphAdapter.method('createTable', function(elementId) {
|
||||
|
||||
|
||||
function CompanyGraphAdapter(endPoint) {
|
||||
this.initAdapter(endPoint);
|
||||
this.nodeIdCounter = 0;
|
||||
}
|
||||
|
||||
CompanyGraphAdapter.inherits(CompanyStructureAdapter);
|
||||
|
||||
|
||||
CompanyGraphAdapter.method('convertToTree', function(data) {
|
||||
var ice = {};
|
||||
ice['id'] = -1;
|
||||
ice['title'] = '';
|
||||
ice['name'] = '';
|
||||
ice['children'] = [];
|
||||
|
||||
var parent = null;
|
||||
|
||||
var added = {};
|
||||
|
||||
|
||||
for(var i=0;i<data.length;i++){
|
||||
|
||||
data[i].name = data[i].title;
|
||||
|
||||
if(data[i].parent != null && data[i].parent != undefined){
|
||||
parent = this.findParent(data,data[i].parent);
|
||||
if(parent != null){
|
||||
if(parent.children == undefined || parent.children == null){
|
||||
parent.children = [];
|
||||
}
|
||||
parent.children.push(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(var i=0;i<data.length;i++){
|
||||
if(data[i].parent == null || data[i].parent == undefined){
|
||||
ice['children'].push(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ice;
|
||||
|
||||
});
|
||||
|
||||
|
||||
CompanyGraphAdapter.method('findParent', function(data, parent) {
|
||||
for(var i=0;i<data.length;i++){
|
||||
if(data[i].title == parent || data[i].title == parent){
|
||||
return data[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
CompanyGraphAdapter.method('createTable', function(elementId) {
|
||||
$("#tabPageCompanyGraph").html("");
|
||||
var that = this;
|
||||
var sourceData = this.sourceData;
|
||||
|
||||
if(modJs['r'] == undefined || modJs['r'] == null){
|
||||
modJs['r'] = Raphael("CompanyGraph", 800, 1000);
|
||||
}else{
|
||||
return;
|
||||
//this.fixCyclicParent(sourceData);
|
||||
var treeData = this.convertToTree(sourceData);
|
||||
|
||||
var m = [20, 120, 20, 120],
|
||||
w = 5000 - m[1] - m[3],
|
||||
h = 1000 - m[0] - m[2],
|
||||
root;
|
||||
|
||||
var tree = d3.layout.tree()
|
||||
.size([h, w]);
|
||||
|
||||
this.diagonal = d3.svg.diagonal()
|
||||
.projection(function(d) { return [d.y, d.x]; });
|
||||
|
||||
this.vis = d3.select("#tabPageCompanyGraph").append("svg:svg")
|
||||
.attr("width", w + m[1] + m[3])
|
||||
.attr("height", h + m[0] + m[2])
|
||||
.append("svg:g")
|
||||
.attr("transform", "translate(" + m[3] + "," + m[0] + ")");
|
||||
|
||||
root = treeData;
|
||||
root.x0 = h / 2;
|
||||
root.y0 = 0;
|
||||
|
||||
function toggleAll(d) {
|
||||
if (d.children) {
|
||||
console.log(d.name);
|
||||
d.children.forEach(toggleAll);
|
||||
that.toggle(d);
|
||||
}
|
||||
|
||||
var r = modJs['r'];
|
||||
|
||||
for(var i=0; i< sourceData.length; i++){
|
||||
sourceData[i].parent = sourceData[i]._original[6];
|
||||
}
|
||||
this.update(root, tree, root);
|
||||
|
||||
var hierarchy = new HierarchyJs();
|
||||
var nodes = hierarchy.createNodes(sourceData);
|
||||
hierarchy.createHierarchy(nodes, r);
|
||||
|
||||
|
||||
});
|
||||
|
||||
CompanyGraphAdapter.method('update', function(source, tree, root) {
|
||||
var that = this;
|
||||
var duration = d3.event && d3.event.altKey ? 5000 : 500;
|
||||
|
||||
// Compute the new tree layout.
|
||||
var nodes = tree.nodes(root).reverse();
|
||||
|
||||
// Normalize for fixed-depth.
|
||||
nodes.forEach(function(d) { d.y = d.depth * 180; });
|
||||
|
||||
// Update the nodes<65>
|
||||
var node = that.vis.selectAll("g.node")
|
||||
.data(nodes, function(d) { return d.id || (d.id = ++that.nodeIdCounter); });
|
||||
|
||||
// Enter any new nodes at the parent's previous position.
|
||||
var nodeEnter = node.enter().append("svg:g")
|
||||
.attr("class", "node")
|
||||
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
|
||||
.on("click", function(d) { that.toggle(d); that.update(d, tree, root); });
|
||||
|
||||
nodeEnter.append("svg:circle")
|
||||
.attr("r", 1e-6)
|
||||
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
||||
|
||||
nodeEnter.append("svg:text")
|
||||
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
|
||||
.attr("dy", ".35em")
|
||||
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
||||
.text(function(d) { return d.name; })
|
||||
.style("fill-opacity", 1e-6);
|
||||
|
||||
// Transition nodes to their new position.
|
||||
var nodeUpdate = node.transition()
|
||||
.duration(duration)
|
||||
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
|
||||
|
||||
nodeUpdate.select("circle")
|
||||
.attr("r", 4.5)
|
||||
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
||||
|
||||
nodeUpdate.select("text")
|
||||
.style("fill-opacity", 1);
|
||||
|
||||
// Transition exiting nodes to the parent's new position.
|
||||
var nodeExit = node.exit().transition()
|
||||
.duration(duration)
|
||||
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
|
||||
.remove();
|
||||
|
||||
nodeExit.select("circle")
|
||||
.attr("r", 1e-6);
|
||||
|
||||
nodeExit.select("text")
|
||||
.style("fill-opacity", 1e-6);
|
||||
|
||||
// Update the links<6B>
|
||||
var link = that.vis.selectAll("path.link")
|
||||
.data(tree.links(nodes), function(d) { return d.target.id; });
|
||||
|
||||
// Enter any new links at the parent's previous position.
|
||||
link.enter().insert("svg:path", "g")
|
||||
.attr("class", "link")
|
||||
.attr("d", function(d) {
|
||||
var o = {x: source.x0, y: source.y0};
|
||||
return that.diagonal({source: o, target: o});
|
||||
})
|
||||
.transition()
|
||||
.duration(duration)
|
||||
.attr("d", that.diagonal);
|
||||
|
||||
// Transition links to their new position.
|
||||
link.transition()
|
||||
.duration(duration)
|
||||
.attr("d", that.diagonal);
|
||||
|
||||
// Transition exiting nodes to the parent's new position.
|
||||
link.exit().transition()
|
||||
.duration(duration)
|
||||
.attr("d", function(d) {
|
||||
var o = {x: source.x, y: source.y};
|
||||
return that.diagonal({source: o, target: o});
|
||||
})
|
||||
.remove();
|
||||
|
||||
// Stash the old positions for transition.
|
||||
nodes.forEach(function(d) {
|
||||
d.x0 = d.x;
|
||||
d.y0 = d.y;
|
||||
});
|
||||
});
|
||||
|
||||
// Toggle children.
|
||||
CompanyGraphAdapter.method('toggle', function(d) {
|
||||
if (d.children) {
|
||||
d._children = d.children;
|
||||
d.children = null;
|
||||
} else {
|
||||
d.children = d._children;
|
||||
d._children = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
CompanyGraphAdapter.method('getSourceDataById', function(id) {
|
||||
|
||||
for(var i=0; i< this.sourceData.length; i++){
|
||||
if(this.sourceData[i].id == id){
|
||||
return this.sourceData[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
});
|
||||
|
||||
CompanyGraphAdapter.method('fixCyclicParent', function(sourceData) {
|
||||
var errorMsg = "";
|
||||
for(var i=0; i< sourceData.length; i++){
|
||||
var obj = sourceData[i];
|
||||
|
||||
|
||||
var curObj = obj;
|
||||
var parentIdArr = {};
|
||||
parentIdArr[curObj.id] = 1;
|
||||
|
||||
while(curObj.parent != null && curObj.parent != undefined){
|
||||
var parent = this.getSourceDataById(curObj.parent);
|
||||
if(parent == null){
|
||||
break;
|
||||
}else if(parentIdArr[parent.id] == 1){
|
||||
errorMsg = obj.title +"'s parent structure set to "+parent.title+"<br/>";
|
||||
obj.parent = null;
|
||||
break;
|
||||
}
|
||||
parentIdArr[parent.id] = 1;
|
||||
curObj = parent;
|
||||
}
|
||||
}
|
||||
|
||||
if(errorMsg != ""){
|
||||
this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:<br/>"+errorMsg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"order":"2",
|
||||
"icon":"fa-user",
|
||||
"user_levels":["Admin","Manager","Employee"],
|
||||
"dashboardPosition":101,
|
||||
|
||||
"permissions":
|
||||
{
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"Personal Information":"fa-male",
|
||||
"Subordinates":"fa-user",
|
||||
"Leave":"fa-calendar-o",
|
||||
"Time Management":"fa-clock-o",
|
||||
"Documents":"fa-files-o",
|
||||
"Company":"fa-building",
|
||||
"Training":"fa-briefcase",
|
||||
"Travel Management":"fa-plane",
|
||||
"Finance":"fa-money"
|
||||
"Finance":"fa-money"
|
||||
}
|
||||
@@ -32,8 +32,6 @@ EmployeeSalaryAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"component",
|
||||
"pay_frequency",
|
||||
"currency",
|
||||
"amount",
|
||||
"details"
|
||||
];
|
||||
@@ -43,8 +41,6 @@ EmployeeSalaryAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Salary Component" },
|
||||
{ "sTitle": "Pay Frequency"},
|
||||
{ "sTitle": "Currency"},
|
||||
{ "sTitle": "Amount"},
|
||||
{ "sTitle": "Details"}
|
||||
];
|
||||
@@ -54,8 +50,6 @@ EmployeeSalaryAdapter.method('getFormFields', function() {
|
||||
return [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "component", {"label":"Salary Component","type":"select2","remote-source":["SalaryComponent","id","name"]}],
|
||||
[ "pay_frequency", {"label":"Pay Frequency","type":"select","source":[["Hourly","Hourly"],["Daily","Daily"],["Bi Weekly","Bi Weekly"],["Weekly","Weekly"],["Semi Monthly","Semi Monthly"],["Monthly","Monthly"]]}],
|
||||
[ "currency", {"label":"Currency","type":"select","remote-source":["CurrencyType","id","name"]}],
|
||||
[ "amount", {"label":"Amount","type":"text","validation":"float"}],
|
||||
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
|
||||
];
|
||||
|
||||
76
readme.md
76
readme.md
@@ -26,45 +26,37 @@ Installation
|
||||
Upgrade from Previous Versions to Latest Version
|
||||
------------------------------------------------
|
||||
|
||||
* Backup icehrm installation file and DB
|
||||
* Remove all folders except icehrm/app from your existing installation
|
||||
* Copy all folders except icehrm/app into installation folder
|
||||
* Use sql scripts inside 'db_upgrade/(version)' folder to upgrade the icehrm current version
|
||||
Refer: [http://blog.icehrm.com/docs/upgrade/](http://blog.icehrm.com/docs/upgrade/)
|
||||
|
||||
|
||||
Note: If you are upgrading from older versions of icehrm please note that the icehrm leave module is removed since v13.0
|
||||
|
||||
|
||||
|
||||
Following is a list of features supported in each version of icehrm
|
||||
Following is a list of features supported in each edition of icehrm
|
||||
-------------------------------------------------------------------
|
||||
|
||||
### IceHrm Open Source Version
|
||||
### IceHrm Open Source Edition
|
||||
* IceHrm Core Modules - Both Enterprise and Open source versions developed on same core concept. But the core modules in professional and enterprise versions are more feature rich and updated with latest security improvements.
|
||||
* [Company Information Management](http://icehrm.com/compare.php) - Store and manage details about how companies, departments and branches of the organisation are connected
|
||||
* Basic [Employee Management](http://icehrm.com) - Store, manage and retrieve employee information when required
|
||||
* Time sheets - IceHrm is a [timesheet app](http://icehrm.com) / [Open source timesheet management](http://icehrm.com) application to track time spent by employees on various projects
|
||||
* [Attendance Management](http://icehrm.com) - IceHrm can be used as a [attendance management system](http://icehrm.com) effectively for any size a company.
|
||||
* [Performance Charts](http://icehrm.com) - Charts for monitoring attendance hours and comparing attendance with time sheets
|
||||
* [LDAP Login](http://icehrm.com) - Users can share login with company LDAP server
|
||||
* [Travel Management](http://icehrm.com) - Module for managing travel requests
|
||||
|
||||
#### Advanced Employee Module (from v16.0.OS)
|
||||
|
||||
### IceHrm Pro Version | [Buy now for 349.49 USD](http://icehrm.com)
|
||||

|
||||
|
||||
- Update all employee information without having to switch employees.
|
||||
- Search employee skills, qualifications and other information<br/>easily across whole company.
|
||||
- Terminate employees while keeping data in system.
|
||||
- Re-enable temporarily terminated employees with one click.
|
||||
- Employee archive feature to archive data of terminated employees.
|
||||
|
||||
### IceHrm Pro Edition | [Buy now for 349.49 USD](http://icehrm.com)
|
||||
|
||||
IceHrm Profession version (in short IceHrmPro) is the feature rich commercial alternative for icehrm
|
||||
open source version. IceHrm Pro supports following features
|
||||
|
||||
Following features are supported in IceHrm Pro version in addition to the features supported in open source version.
|
||||
|
||||
#### Advanced Employee Module
|
||||
|
||||

|
||||
|
||||
- Update all employee information without having to switch employees.
|
||||
- Search employee skills, qualifications and other information<br/>easily across whole company.
|
||||
- Terminate employees while keeping data in system.
|
||||
- Re-enable temporarily terminated employees with one click.
|
||||
- Employee archive feature to archive data of terminated employees.
|
||||
|
||||
#### Leave Management
|
||||
|
||||
@@ -89,10 +81,14 @@ You can learn more about [IceHrm Pro here](http://blog.icehrm.com/docs/icehrm-pr
|
||||
|
||||
To purchase IceHrmPro please visit [http://icehrm.com/modules.php](http://icehrm.com/modules.php)
|
||||
|
||||
#### Training Management
|
||||
|
||||
### IceHrm Enterprise Version [Starts from 1498 USD](http://icehrm.com)
|
||||
Icehrm [training management system](http://icehrm.com) is for Module for managing courses, training sessions and employee attendance to training sessions.
|
||||
|
||||
In addition to pro version features icehrm enterprise version includes following features
|
||||
|
||||
### IceHrm Hosted Edition [Starts from 1498 USD](http://icehrm.com)
|
||||
|
||||
In addition to pro version features icehrm enterprise hosted edition includes following features
|
||||
|
||||
#### Candidate / Recruitment Management
|
||||
|
||||
@@ -111,12 +107,6 @@ following features
|
||||
|
||||
More about [recruitment module](http://blog.icehrm.com/docs/recruitment/)
|
||||
|
||||
#### LDAP Support
|
||||
|
||||
#### Training Management
|
||||
|
||||
Icehrm [training management system](http://icehrm.com) is for Module for managing courses, training sessions and employee attendance to training sessions.
|
||||
|
||||
|
||||
Your Company Structure (Departments / Branches and other Organization Units)
|
||||
-------------------------------------------
|
||||
@@ -529,9 +519,35 @@ for these clients. The clients section represent both external and internal clie
|
||||
That way you can attach each and every project to a client.
|
||||
|
||||
###Employee Projects
|
||||
|
||||
Under employee projects tab you can assign projects to employees. You need to add projects to employees to enable them to add time against
|
||||
these projects in time-sheets.
|
||||
|
||||
Release note v16.1
|
||||
------------------
|
||||
|
||||
### Fixes
|
||||
* Fix LDAP user login issue
|
||||
* Allow creating users with username having dot and dash
|
||||
|
||||
Release note v16.0
|
||||
------------------
|
||||
### Features
|
||||
* Advanced Employee Management Module is now included in IceHrm Open Source Edition
|
||||
* LDAP Module which was only available in IceHrm Enterprise is now included in open source also
|
||||
* Initial implementation of icehrm REST Api for reading employee details
|
||||
* Improvements to data filtering
|
||||
* Multiple tabs for settings module
|
||||
* Overtime reports - now its possible to calculate overtime for employees.compatible with US overtime rules
|
||||
* Logout the user if tried accessing an unauthorized module
|
||||
* Setting for updating module names
|
||||
|
||||
### Fixes
|
||||
* Fix issue: classes should be loaded even the module is disabled
|
||||
* Deleting the only Admin user is not allowed
|
||||
* Fixes for handling non UTF-8
|
||||
* Fix for non-mandatory select boxes are shown as mandatory
|
||||
|
||||
Release note v15.2
|
||||
------------------
|
||||
|
||||
|
||||
1061
src/adodb512/adodb-active-record.inc.php
Normal file
1061
src/adodb512/adodb-active-record.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
1421
src/adodb512/adodb-active-recordx.inc.php
Normal file
1421
src/adodb512/adodb-active-recordx.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
318
src/adodb512/adodb-csvlib.inc.php
Normal file
318
src/adodb512/adodb-csvlib.inc.php
Normal file
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
global $ADODB_INCLUDED_CSV;
|
||||
$ADODB_INCLUDED_CSV = 1;
|
||||
|
||||
/*
|
||||
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence. See License.txt.
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
|
||||
Library for CSV serialization. This is used by the csv/proxy driver and is the
|
||||
CacheExecute() serialization format.
|
||||
|
||||
==== NOTE ====
|
||||
Format documented at http://php.weblogs.com/ADODB_CSV
|
||||
==============
|
||||
*/
|
||||
|
||||
/**
|
||||
* convert a recordset into special format
|
||||
*
|
||||
* @param rs the recordset
|
||||
*
|
||||
* @return the CSV formated data
|
||||
*/
|
||||
function _rs2serialize(&$rs,$conn=false,$sql='')
|
||||
{
|
||||
$max = ($rs) ? $rs->FieldCount() : 0;
|
||||
|
||||
if ($sql) $sql = urlencode($sql);
|
||||
// metadata setup
|
||||
|
||||
if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete
|
||||
if (is_object($conn)) {
|
||||
$sql .= ','.$conn->Affected_Rows();
|
||||
$sql .= ','.$conn->Insert_ID();
|
||||
} else
|
||||
$sql .= ',,';
|
||||
|
||||
$text = "====-1,0,$sql\n";
|
||||
return $text;
|
||||
}
|
||||
$tt = ($rs->timeCreated) ? $rs->timeCreated : time();
|
||||
|
||||
## changed format from ====0 to ====1
|
||||
$line = "====1,$tt,$sql\n";
|
||||
|
||||
if ($rs->databaseType == 'array') {
|
||||
$rows = $rs->_array;
|
||||
} else {
|
||||
$rows = array();
|
||||
while (!$rs->EOF) {
|
||||
$rows[] = $rs->fields;
|
||||
$rs->MoveNext();
|
||||
}
|
||||
}
|
||||
|
||||
for($i=0; $i < $max; $i++) {
|
||||
$o = $rs->FetchField($i);
|
||||
$flds[] = $o;
|
||||
}
|
||||
|
||||
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
|
||||
$class = $rs->connection->arrayClass;
|
||||
$rs2 = new $class();
|
||||
$rs2->timeCreated = $rs->timeCreated; # memcache fix
|
||||
$rs2->sql = $rs->sql;
|
||||
$rs2->oldProvider = $rs->dataProvider;
|
||||
$rs2->InitArrayFields($rows,$flds);
|
||||
$rs2->fetchMode = $savefetch;
|
||||
return $line.serialize($rs2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open CSV file and convert it into Data.
|
||||
*
|
||||
* @param url file/ftp/http url
|
||||
* @param err returns the error message
|
||||
* @param timeout dispose if recordset has been alive for $timeout secs
|
||||
*
|
||||
* @return recordset, or false if error occured. If no
|
||||
* error occurred in sql INSERT/UPDATE/DELETE,
|
||||
* empty recordset is returned
|
||||
*/
|
||||
function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
|
||||
{
|
||||
$false = false;
|
||||
$err = false;
|
||||
$fp = @fopen($url,'rb');
|
||||
if (!$fp) {
|
||||
$err = $url.' file/URL not found';
|
||||
return $false;
|
||||
}
|
||||
@flock($fp, LOCK_SH);
|
||||
$arr = array();
|
||||
$ttl = 0;
|
||||
|
||||
if ($meta = fgetcsv($fp, 32000, ",")) {
|
||||
// check if error message
|
||||
if (strncmp($meta[0],'****',4) === 0) {
|
||||
$err = trim(substr($meta[0],4,1024));
|
||||
fclose($fp);
|
||||
return $false;
|
||||
}
|
||||
// check for meta data
|
||||
// $meta[0] is -1 means return an empty recordset
|
||||
// $meta[1] contains a time
|
||||
|
||||
if (strncmp($meta[0], '====',4) === 0) {
|
||||
|
||||
if ($meta[0] == "====-1") {
|
||||
if (sizeof($meta) < 5) {
|
||||
$err = "Corrupt first line for format -1";
|
||||
fclose($fp);
|
||||
return $false;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
if ($timeout > 0) {
|
||||
$err = " Illegal Timeout $timeout ";
|
||||
return $false;
|
||||
}
|
||||
|
||||
$rs = new $rsclass($val=true);
|
||||
$rs->fields = array();
|
||||
$rs->timeCreated = $meta[1];
|
||||
$rs->EOF = true;
|
||||
$rs->_numOfFields = 0;
|
||||
$rs->sql = urldecode($meta[2]);
|
||||
$rs->affectedrows = (integer)$meta[3];
|
||||
$rs->insertid = $meta[4];
|
||||
return $rs;
|
||||
}
|
||||
# Under high volume loads, we want only 1 thread/process to _write_file
|
||||
# so that we don't have 50 processes queueing to write the same data.
|
||||
# We use probabilistic timeout, ahead of time.
|
||||
#
|
||||
# -4 sec before timeout, give processes 1/32 chance of timing out
|
||||
# -2 sec before timeout, give processes 1/16 chance of timing out
|
||||
# -1 sec after timeout give processes 1/4 chance of timing out
|
||||
# +0 sec after timeout, give processes 100% chance of timing out
|
||||
if (sizeof($meta) > 1) {
|
||||
if($timeout >0){
|
||||
$tdiff = (integer)( $meta[1]+$timeout - time());
|
||||
if ($tdiff <= 2) {
|
||||
switch($tdiff) {
|
||||
case 4:
|
||||
case 3:
|
||||
if ((rand() & 31) == 0) {
|
||||
fclose($fp);
|
||||
$err = "Timeout 3";
|
||||
return $false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ((rand() & 15) == 0) {
|
||||
fclose($fp);
|
||||
$err = "Timeout 2";
|
||||
return $false;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ((rand() & 3) == 0) {
|
||||
fclose($fp);
|
||||
$err = "Timeout 1";
|
||||
return $false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fclose($fp);
|
||||
$err = "Timeout 0";
|
||||
return $false;
|
||||
} // switch
|
||||
|
||||
} // if check flush cache
|
||||
}// (timeout>0)
|
||||
$ttl = $meta[1];
|
||||
}
|
||||
//================================================
|
||||
// new cache format - use serialize extensively...
|
||||
if ($meta[0] === '====1') {
|
||||
// slurp in the data
|
||||
$MAXSIZE = 128000;
|
||||
|
||||
$text = fread($fp,$MAXSIZE);
|
||||
if (strlen($text)) {
|
||||
while ($txt = fread($fp,$MAXSIZE)) {
|
||||
$text .= $txt;
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
$rs = unserialize($text);
|
||||
if (is_object($rs)) $rs->timeCreated = $ttl;
|
||||
else {
|
||||
$err = "Unable to unserialize recordset";
|
||||
//echo htmlspecialchars($text),' !--END--!<p>';
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
$meta = false;
|
||||
$meta = fgetcsv($fp, 32000, ",");
|
||||
if (!$meta) {
|
||||
fclose($fp);
|
||||
$err = "Unexpected EOF 1";
|
||||
return $false;
|
||||
}
|
||||
}
|
||||
|
||||
// Get Column definitions
|
||||
$flds = array();
|
||||
foreach($meta as $o) {
|
||||
$o2 = explode(':',$o);
|
||||
if (sizeof($o2)!=3) {
|
||||
$arr[] = $meta;
|
||||
$flds = false;
|
||||
break;
|
||||
}
|
||||
$fld = new ADOFieldObject();
|
||||
$fld->name = urldecode($o2[0]);
|
||||
$fld->type = $o2[1];
|
||||
$fld->max_length = $o2[2];
|
||||
$flds[] = $fld;
|
||||
}
|
||||
} else {
|
||||
fclose($fp);
|
||||
$err = "Recordset had unexpected EOF 2";
|
||||
return $false;
|
||||
}
|
||||
|
||||
// slurp in the data
|
||||
$MAXSIZE = 128000;
|
||||
|
||||
$text = '';
|
||||
while ($txt = fread($fp,$MAXSIZE)) {
|
||||
$text .= $txt;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
@$arr = unserialize($text);
|
||||
//var_dump($arr);
|
||||
if (!is_array($arr)) {
|
||||
$err = "Recordset had unexpected EOF (in serialized recordset)";
|
||||
if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!";
|
||||
return $false;
|
||||
}
|
||||
$rs = new $rsclass();
|
||||
$rs->timeCreated = $ttl;
|
||||
$rs->InitArrayFields($arr,$flds);
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a file $filename and its $contents (normally for caching) with file locking
|
||||
* Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked)
|
||||
*/
|
||||
function adodb_write_file($filename, $contents,$debug=false)
|
||||
{
|
||||
# http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
|
||||
# So to simulate locking, we assume that rename is an atomic operation.
|
||||
# First we delete $filename, then we create a $tempfile write to it and
|
||||
# rename to the desired $filename. If the rename works, then we successfully
|
||||
# modified the file exclusively.
|
||||
# What a stupid need - having to simulate locking.
|
||||
# Risks:
|
||||
# 1. $tempfile name is not unique -- very very low
|
||||
# 2. unlink($filename) fails -- ok, rename will fail
|
||||
# 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
|
||||
# 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
|
||||
if (strncmp(PHP_OS,'WIN',3) === 0) {
|
||||
// skip the decimal place
|
||||
$mtime = substr(str_replace(' ','_',microtime()),2);
|
||||
// getmypid() actually returns 0 on Win98 - never mind!
|
||||
$tmpname = $filename.uniqid($mtime).getmypid();
|
||||
if (!($fd = @fopen($tmpname,'w'))) return false;
|
||||
if (fwrite($fd,$contents)) $ok = true;
|
||||
else $ok = false;
|
||||
fclose($fd);
|
||||
|
||||
if ($ok) {
|
||||
@chmod($tmpname,0644);
|
||||
// the tricky moment
|
||||
@unlink($filename);
|
||||
if (!@rename($tmpname,$filename)) {
|
||||
unlink($tmpname);
|
||||
$ok = 0;
|
||||
}
|
||||
if (!$ok) {
|
||||
if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
if (!($fd = @fopen($filename, 'a'))) return false;
|
||||
if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
|
||||
if (fwrite( $fd, $contents )) $ok = true;
|
||||
else $ok = false;
|
||||
fclose($fd);
|
||||
@chmod($filename,0644);
|
||||
}else {
|
||||
fclose($fd);
|
||||
if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
return $ok;
|
||||
}
|
||||
?>
|
||||
1032
src/adodb512/adodb-datadict.inc.php
Normal file
1032
src/adodb512/adodb-datadict.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
258
src/adodb512/adodb-error.inc.php
Normal file
258
src/adodb512/adodb-error.inc.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* Released under both BSD license and Lesser GPL library license.
|
||||
* Whenever there is any discrepancy between the two licenses,
|
||||
* the BSD license will take precedence.
|
||||
*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* The following code is adapted from the PEAR DB error handling code.
|
||||
* Portions (c)1997-2002 The PHP Group.
|
||||
*/
|
||||
|
||||
|
||||
if (!defined("DB_ERROR")) define("DB_ERROR",-1);
|
||||
|
||||
if (!defined("DB_ERROR_SYNTAX")) {
|
||||
define("DB_ERROR_SYNTAX", -2);
|
||||
define("DB_ERROR_CONSTRAINT", -3);
|
||||
define("DB_ERROR_NOT_FOUND", -4);
|
||||
define("DB_ERROR_ALREADY_EXISTS", -5);
|
||||
define("DB_ERROR_UNSUPPORTED", -6);
|
||||
define("DB_ERROR_MISMATCH", -7);
|
||||
define("DB_ERROR_INVALID", -8);
|
||||
define("DB_ERROR_NOT_CAPABLE", -9);
|
||||
define("DB_ERROR_TRUNCATED", -10);
|
||||
define("DB_ERROR_INVALID_NUMBER", -11);
|
||||
define("DB_ERROR_INVALID_DATE", -12);
|
||||
define("DB_ERROR_DIVZERO", -13);
|
||||
define("DB_ERROR_NODBSELECTED", -14);
|
||||
define("DB_ERROR_CANNOT_CREATE", -15);
|
||||
define("DB_ERROR_CANNOT_DELETE", -16);
|
||||
define("DB_ERROR_CANNOT_DROP", -17);
|
||||
define("DB_ERROR_NOSUCHTABLE", -18);
|
||||
define("DB_ERROR_NOSUCHFIELD", -19);
|
||||
define("DB_ERROR_NEED_MORE_DATA", -20);
|
||||
define("DB_ERROR_NOT_LOCKED", -21);
|
||||
define("DB_ERROR_VALUE_COUNT_ON_ROW", -22);
|
||||
define("DB_ERROR_INVALID_DSN", -23);
|
||||
define("DB_ERROR_CONNECT_FAILED", -24);
|
||||
define("DB_ERROR_EXTENSION_NOT_FOUND",-25);
|
||||
define("DB_ERROR_NOSUCHDB", -25);
|
||||
define("DB_ERROR_ACCESS_VIOLATION", -26);
|
||||
}
|
||||
|
||||
function adodb_errormsg($value)
|
||||
{
|
||||
global $ADODB_LANG,$ADODB_LANG_ARRAY;
|
||||
|
||||
if (empty($ADODB_LANG)) $ADODB_LANG = 'en';
|
||||
if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ;
|
||||
else {
|
||||
include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php");
|
||||
}
|
||||
return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR];
|
||||
}
|
||||
|
||||
function adodb_error($provider,$dbType,$errno)
|
||||
{
|
||||
//var_dump($errno);
|
||||
if (is_numeric($errno) && $errno == 0) return 0;
|
||||
switch($provider) {
|
||||
case 'mysql': $map = adodb_error_mysql(); break;
|
||||
|
||||
case 'oracle':
|
||||
case 'oci8': $map = adodb_error_oci8(); break;
|
||||
|
||||
case 'ibase': $map = adodb_error_ibase(); break;
|
||||
|
||||
case 'odbc': $map = adodb_error_odbc(); break;
|
||||
|
||||
case 'mssql':
|
||||
case 'sybase': $map = adodb_error_mssql(); break;
|
||||
|
||||
case 'informix': $map = adodb_error_ifx(); break;
|
||||
|
||||
case 'postgres': return adodb_error_pg($errno); break;
|
||||
|
||||
case 'sqlite': return $map = adodb_error_sqlite(); break;
|
||||
default:
|
||||
return DB_ERROR;
|
||||
}
|
||||
//print_r($map);
|
||||
//var_dump($errno);
|
||||
if (isset($map[$errno])) return $map[$errno];
|
||||
return DB_ERROR;
|
||||
}
|
||||
|
||||
//**************************************************************************************
|
||||
|
||||
function adodb_error_pg($errormsg)
|
||||
{
|
||||
if (is_numeric($errormsg)) return (integer) $errormsg;
|
||||
static $error_regexps = array(
|
||||
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/i' => DB_ERROR_NOSUCHTABLE,
|
||||
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/i' => DB_ERROR_ALREADY_EXISTS,
|
||||
'/divide by zero$/i' => DB_ERROR_DIVZERO,
|
||||
'/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER,
|
||||
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD,
|
||||
'/parser: parse error at or near \"/i' => DB_ERROR_SYNTAX,
|
||||
'/referential integrity violation/i' => DB_ERROR_CONSTRAINT,
|
||||
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint/i'
|
||||
=> DB_ERROR_ALREADY_EXISTS
|
||||
);
|
||||
reset($error_regexps);
|
||||
while (list($regexp,$code) = each($error_regexps)) {
|
||||
if (preg_match($regexp, $errormsg)) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
// Fall back to DB_ERROR if there was no mapping.
|
||||
return DB_ERROR;
|
||||
}
|
||||
|
||||
function adodb_error_odbc()
|
||||
{
|
||||
static $MAP = array(
|
||||
'01004' => DB_ERROR_TRUNCATED,
|
||||
'07001' => DB_ERROR_MISMATCH,
|
||||
'21S01' => DB_ERROR_MISMATCH,
|
||||
'21S02' => DB_ERROR_MISMATCH,
|
||||
'22003' => DB_ERROR_INVALID_NUMBER,
|
||||
'22008' => DB_ERROR_INVALID_DATE,
|
||||
'22012' => DB_ERROR_DIVZERO,
|
||||
'23000' => DB_ERROR_CONSTRAINT,
|
||||
'24000' => DB_ERROR_INVALID,
|
||||
'34000' => DB_ERROR_INVALID,
|
||||
'37000' => DB_ERROR_SYNTAX,
|
||||
'42000' => DB_ERROR_SYNTAX,
|
||||
'IM001' => DB_ERROR_UNSUPPORTED,
|
||||
'S0000' => DB_ERROR_NOSUCHTABLE,
|
||||
'S0001' => DB_ERROR_NOT_FOUND,
|
||||
'S0002' => DB_ERROR_NOSUCHTABLE,
|
||||
'S0011' => DB_ERROR_ALREADY_EXISTS,
|
||||
'S0012' => DB_ERROR_NOT_FOUND,
|
||||
'S0021' => DB_ERROR_ALREADY_EXISTS,
|
||||
'S0022' => DB_ERROR_NOT_FOUND,
|
||||
'S1000' => DB_ERROR_NOSUCHTABLE,
|
||||
'S1009' => DB_ERROR_INVALID,
|
||||
'S1090' => DB_ERROR_INVALID,
|
||||
'S1C00' => DB_ERROR_NOT_CAPABLE
|
||||
);
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_ibase()
|
||||
{
|
||||
static $MAP = array(
|
||||
-104 => DB_ERROR_SYNTAX,
|
||||
-150 => DB_ERROR_ACCESS_VIOLATION,
|
||||
-151 => DB_ERROR_ACCESS_VIOLATION,
|
||||
-155 => DB_ERROR_NOSUCHTABLE,
|
||||
-157 => DB_ERROR_NOSUCHFIELD,
|
||||
-158 => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||
-170 => DB_ERROR_MISMATCH,
|
||||
-171 => DB_ERROR_MISMATCH,
|
||||
-172 => DB_ERROR_INVALID,
|
||||
-204 => DB_ERROR_INVALID,
|
||||
-205 => DB_ERROR_NOSUCHFIELD,
|
||||
-206 => DB_ERROR_NOSUCHFIELD,
|
||||
-208 => DB_ERROR_INVALID,
|
||||
-219 => DB_ERROR_NOSUCHTABLE,
|
||||
-297 => DB_ERROR_CONSTRAINT,
|
||||
-530 => DB_ERROR_CONSTRAINT,
|
||||
-803 => DB_ERROR_CONSTRAINT,
|
||||
-551 => DB_ERROR_ACCESS_VIOLATION,
|
||||
-552 => DB_ERROR_ACCESS_VIOLATION,
|
||||
-922 => DB_ERROR_NOSUCHDB,
|
||||
-923 => DB_ERROR_CONNECT_FAILED,
|
||||
-924 => DB_ERROR_CONNECT_FAILED
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_ifx()
|
||||
{
|
||||
static $MAP = array(
|
||||
'-201' => DB_ERROR_SYNTAX,
|
||||
'-206' => DB_ERROR_NOSUCHTABLE,
|
||||
'-217' => DB_ERROR_NOSUCHFIELD,
|
||||
'-329' => DB_ERROR_NODBSELECTED,
|
||||
'-1204' => DB_ERROR_INVALID_DATE,
|
||||
'-1205' => DB_ERROR_INVALID_DATE,
|
||||
'-1206' => DB_ERROR_INVALID_DATE,
|
||||
'-1209' => DB_ERROR_INVALID_DATE,
|
||||
'-1210' => DB_ERROR_INVALID_DATE,
|
||||
'-1212' => DB_ERROR_INVALID_DATE
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_oci8()
|
||||
{
|
||||
static $MAP = array(
|
||||
1 => DB_ERROR_ALREADY_EXISTS,
|
||||
900 => DB_ERROR_SYNTAX,
|
||||
904 => DB_ERROR_NOSUCHFIELD,
|
||||
923 => DB_ERROR_SYNTAX,
|
||||
942 => DB_ERROR_NOSUCHTABLE,
|
||||
955 => DB_ERROR_ALREADY_EXISTS,
|
||||
1476 => DB_ERROR_DIVZERO,
|
||||
1722 => DB_ERROR_INVALID_NUMBER,
|
||||
2289 => DB_ERROR_NOSUCHTABLE,
|
||||
2291 => DB_ERROR_CONSTRAINT,
|
||||
2449 => DB_ERROR_CONSTRAINT
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_mssql()
|
||||
{
|
||||
static $MAP = array(
|
||||
208 => DB_ERROR_NOSUCHTABLE,
|
||||
2601 => DB_ERROR_ALREADY_EXISTS
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_sqlite()
|
||||
{
|
||||
static $MAP = array(
|
||||
1 => DB_ERROR_SYNTAX
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
|
||||
function adodb_error_mysql()
|
||||
{
|
||||
static $MAP = array(
|
||||
1004 => DB_ERROR_CANNOT_CREATE,
|
||||
1005 => DB_ERROR_CANNOT_CREATE,
|
||||
1006 => DB_ERROR_CANNOT_CREATE,
|
||||
1007 => DB_ERROR_ALREADY_EXISTS,
|
||||
1008 => DB_ERROR_CANNOT_DROP,
|
||||
1045 => DB_ERROR_ACCESS_VIOLATION,
|
||||
1046 => DB_ERROR_NODBSELECTED,
|
||||
1049 => DB_ERROR_NOSUCHDB,
|
||||
1050 => DB_ERROR_ALREADY_EXISTS,
|
||||
1051 => DB_ERROR_NOSUCHTABLE,
|
||||
1054 => DB_ERROR_NOSUCHFIELD,
|
||||
1062 => DB_ERROR_ALREADY_EXISTS,
|
||||
1064 => DB_ERROR_SYNTAX,
|
||||
1100 => DB_ERROR_NOT_LOCKED,
|
||||
1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||
1146 => DB_ERROR_NOSUCHTABLE,
|
||||
1048 => DB_ERROR_CONSTRAINT,
|
||||
2002 => DB_ERROR_CONNECT_FAILED,
|
||||
2005 => DB_ERROR_CONNECT_FAILED
|
||||
);
|
||||
|
||||
return $MAP;
|
||||
}
|
||||
?>
|
||||
79
src/adodb512/adodb-errorhandler.inc.php
Normal file
79
src/adodb512/adodb-errorhandler.inc.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* Released under both BSD license and Lesser GPL library license.
|
||||
* Whenever there is any discrepancy between the two licenses,
|
||||
* the BSD license will take precedence.
|
||||
*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* Latest version is available at http://php.weblogs.com
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// added Claudio Bustos clbustos#entelchile.net
|
||||
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
|
||||
|
||||
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
|
||||
|
||||
/**
|
||||
* Default Error Handler. This will be called with the following params
|
||||
*
|
||||
* @param $dbms the RDBMS you are connecting to
|
||||
* @param $fn the name of the calling function (in uppercase)
|
||||
* @param $errno the native error number from the database
|
||||
* @param $errmsg the native error msg from the database
|
||||
* @param $p1 $fn specific parameter - see below
|
||||
* @param $p2 $fn specific parameter - see below
|
||||
* @param $thisConn $current connection object - can be false if no connection object created
|
||||
*/
|
||||
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
|
||||
{
|
||||
if (error_reporting() == 0) return; // obey @ protocol
|
||||
switch($fn) {
|
||||
case 'EXECUTE':
|
||||
$sql = $p1;
|
||||
$inputparams = $p2;
|
||||
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
|
||||
break;
|
||||
|
||||
case 'PCONNECT':
|
||||
case 'CONNECT':
|
||||
$host = $p1;
|
||||
$database = $p2;
|
||||
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
|
||||
break;
|
||||
default:
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Log connection error somewhere
|
||||
* 0 message is sent to PHP's system logger, using the Operating System's system
|
||||
* logging mechanism or a file, depending on what the error_log configuration
|
||||
* directive is set to.
|
||||
* 1 message is sent by email to the address in the destination parameter.
|
||||
* This is the only message type where the fourth parameter, extra_headers is used.
|
||||
* This message type uses the same internal function as mail() does.
|
||||
* 2 message is sent through the PHP debugging connection.
|
||||
* This option is only available if remote debugging has been enabled.
|
||||
* In this case, the destination parameter specifies the host name or IP address
|
||||
* and optionally, port number, of the socket receiving the debug information.
|
||||
* 3 message is appended to the file destination
|
||||
*/
|
||||
if (defined('ADODB_ERROR_LOG_TYPE')) {
|
||||
$t = date('Y-m-d H:i:s');
|
||||
if (defined('ADODB_ERROR_LOG_DEST'))
|
||||
error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
|
||||
else
|
||||
error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
|
||||
}
|
||||
|
||||
|
||||
//print "<p>$s</p>";
|
||||
trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
|
||||
}
|
||||
?>
|
||||
88
src/adodb512/adodb-errorpear.inc.php
Normal file
88
src/adodb512/adodb-errorpear.inc.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* Latest version is available at http://php.weblogs.com
|
||||
*
|
||||
*/
|
||||
include_once('PEAR.php');
|
||||
|
||||
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
|
||||
|
||||
/*
|
||||
* Enabled the following if you want to terminate scripts when an error occurs
|
||||
*/
|
||||
//PEAR::setErrorHandling (PEAR_ERROR_DIE);
|
||||
|
||||
/*
|
||||
* Name of the PEAR_Error derived class to call.
|
||||
*/
|
||||
if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
|
||||
|
||||
/*
|
||||
* Store the last PEAR_Error object here
|
||||
*/
|
||||
global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
|
||||
|
||||
/**
|
||||
* Error Handler with PEAR support. This will be called with the following params
|
||||
*
|
||||
* @param $dbms the RDBMS you are connecting to
|
||||
* @param $fn the name of the calling function (in uppercase)
|
||||
* @param $errno the native error number from the database
|
||||
* @param $errmsg the native error msg from the database
|
||||
* @param $p1 $fn specific parameter - see below
|
||||
* @param $P2 $fn specific parameter - see below
|
||||
*/
|
||||
function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
|
||||
{
|
||||
global $ADODB_Last_PEAR_Error;
|
||||
|
||||
if (error_reporting() == 0) return; // obey @ protocol
|
||||
switch($fn) {
|
||||
case 'EXECUTE':
|
||||
$sql = $p1;
|
||||
$inputparams = $p2;
|
||||
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
|
||||
break;
|
||||
|
||||
case 'PCONNECT':
|
||||
case 'CONNECT':
|
||||
$host = $p1;
|
||||
$database = $p2;
|
||||
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
|
||||
break;
|
||||
|
||||
default:
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
|
||||
break;
|
||||
}
|
||||
|
||||
$class = ADODB_PEAR_ERROR_CLASS;
|
||||
$ADODB_Last_PEAR_Error = new $class($s, $errno,
|
||||
$GLOBALS['_PEAR_default_error_mode'],
|
||||
$GLOBALS['_PEAR_default_error_options'],
|
||||
$errmsg);
|
||||
|
||||
//print "<p>!$s</p>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last PEAR_Error object. This error might be for an error that
|
||||
* occured several sql statements ago.
|
||||
*/
|
||||
function ADODB_PEAR_Error()
|
||||
{
|
||||
global $ADODB_Last_PEAR_Error;
|
||||
|
||||
return $ADODB_Last_PEAR_Error;
|
||||
}
|
||||
|
||||
?>
|
||||
82
src/adodb512/adodb-exceptions.inc.php
Normal file
82
src/adodb512/adodb-exceptions.inc.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @version V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* Released under both BSD license and Lesser GPL library license.
|
||||
* Whenever there is any discrepancy between the two licenses,
|
||||
* the BSD license will take precedence.
|
||||
*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* Latest version is available at http://php.weblogs.com
|
||||
*
|
||||
* Exception-handling code using PHP5 exceptions (try-catch-throw).
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
|
||||
define('ADODB_ERROR_HANDLER','adodb_throw');
|
||||
|
||||
class ADODB_Exception extends Exception {
|
||||
var $dbms;
|
||||
var $fn;
|
||||
var $sql = '';
|
||||
var $params = '';
|
||||
var $host = '';
|
||||
var $database = '';
|
||||
|
||||
function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
|
||||
{
|
||||
switch($fn) {
|
||||
case 'EXECUTE':
|
||||
$this->sql = $p1;
|
||||
$this->params = $p2;
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
|
||||
break;
|
||||
|
||||
case 'PCONNECT':
|
||||
case 'CONNECT':
|
||||
$user = $thisConnection->user;
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
|
||||
break;
|
||||
default:
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->dbms = $dbms;
|
||||
if ($thisConnection) {
|
||||
$this->host = $thisConnection->host;
|
||||
$this->database = $thisConnection->database;
|
||||
}
|
||||
$this->fn = $fn;
|
||||
$this->msg = $errmsg;
|
||||
|
||||
if (!is_numeric($errno)) $errno = -1;
|
||||
parent::__construct($s,$errno);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Error Handler. This will be called with the following params
|
||||
*
|
||||
* @param $dbms the RDBMS you are connecting to
|
||||
* @param $fn the name of the calling function (in uppercase)
|
||||
* @param $errno the native error number from the database
|
||||
* @param $errmsg the native error msg from the database
|
||||
* @param $p1 $fn specific parameter - see below
|
||||
* @param $P2 $fn specific parameter - see below
|
||||
*/
|
||||
|
||||
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
|
||||
{
|
||||
global $ADODB_EXCEPTION;
|
||||
|
||||
if (error_reporting() == 0) return; // obey @ protocol
|
||||
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
|
||||
else $errfn = 'ADODB_EXCEPTION';
|
||||
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
30
src/adodb512/adodb-iterator.inc.php
Normal file
30
src/adodb512/adodb-iterator.inc.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4.
|
||||
|
||||
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
|
||||
the ADODB_Iterator class.
|
||||
|
||||
$rs = $db->Execute("select * from adoxyz");
|
||||
foreach($rs as $k => $v) {
|
||||
echo $k; print_r($v); echo "<br>";
|
||||
}
|
||||
|
||||
|
||||
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
|
||||
|
||||
|
||||
Moved to adodb.inc.php to improve performance.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
1197
src/adodb512/adodb-lib.inc.php
Normal file
1197
src/adodb512/adodb-lib.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
190
src/adodb512/adodb-memcache.lib.inc.php
Normal file
190
src/adodb512/adodb-memcache.lib.inc.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
global $ADODB_INCLUDED_MEMCACHE;
|
||||
$ADODB_INCLUDED_MEMCACHE = 1;
|
||||
|
||||
global $ADODB_INCLUDED_CSV;
|
||||
if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||
|
||||
/*
|
||||
|
||||
V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence. See License.txt.
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
|
||||
Usage:
|
||||
|
||||
$db = NewADOConnection($driver);
|
||||
$db->memCache = true; /// should we use memCache instead of caching in files
|
||||
$db->memCacheHost = array($ip1, $ip2, $ip3);
|
||||
$db->memCachePort = 11211; /// this is default memCache port
|
||||
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
|
||||
|
||||
$db->Connect(...);
|
||||
$db->CacheExecute($sql);
|
||||
|
||||
Note the memcache class is shared by all connections, is created during the first call to Connect/PConnect.
|
||||
|
||||
Class instance is stored in $ADODB_CACHE
|
||||
*/
|
||||
|
||||
class ADODB_Cache_MemCache {
|
||||
var $createdir = false; // create caching directory structure?
|
||||
|
||||
//-----------------------------
|
||||
// memcache specific variables
|
||||
|
||||
var $hosts; // array of hosts
|
||||
var $port = 11211;
|
||||
var $compress = false; // memcache compression with zlib
|
||||
|
||||
var $_connected = false;
|
||||
var $_memcache = false;
|
||||
|
||||
function ADODB_Cache_MemCache(&$obj)
|
||||
{
|
||||
$this->hosts = $obj->memCacheHost;
|
||||
$this->port = $obj->memCachePort;
|
||||
$this->compress = $obj->memCacheCompress;
|
||||
}
|
||||
|
||||
// implement as lazy connection. The connection only occurs on CacheExecute call
|
||||
function connect(&$err)
|
||||
{
|
||||
if (!function_exists('memcache_pconnect')) {
|
||||
$err = 'Memcache module PECL extension not found!';
|
||||
return false;
|
||||
}
|
||||
|
||||
$memcache = new MemCache;
|
||||
|
||||
if (!is_array($this->hosts)) $this->hosts = array($this->hosts);
|
||||
|
||||
$failcnt = 0;
|
||||
foreach($this->hosts as $host) {
|
||||
if (!@$memcache->addServer($host,$this->port,true)) {
|
||||
$failcnt += 1;
|
||||
}
|
||||
}
|
||||
if ($failcnt == sizeof($this->hosts)) {
|
||||
$err = 'Can\'t connect to any memcache server';
|
||||
return false;
|
||||
}
|
||||
$this->_connected = true;
|
||||
$this->_memcache = $memcache;
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns true or false. true if successful save
|
||||
function writecache($filename, $contents, $debug, $secs2cache)
|
||||
{
|
||||
if (!$this->_connected) {
|
||||
$err = '';
|
||||
if (!$this->connect($err) && $debug) ADOConnection::outp($err);
|
||||
}
|
||||
if (!$this->_memcache) return false;
|
||||
|
||||
if (!$this->_memcache->set($filename, $contents, $this->compress, $secs2cache)) {
|
||||
if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns a recordset
|
||||
function readcache($filename, &$err, $secs2cache, $rsClass)
|
||||
{
|
||||
$false = false;
|
||||
if (!$this->_connected) $this->connect($err);
|
||||
if (!$this->_memcache) return $false;
|
||||
|
||||
$rs = $this->_memcache->get($filename);
|
||||
if (!$rs) {
|
||||
$err = 'Item with such key doesn\'t exists on the memcached server.';
|
||||
return $false;
|
||||
}
|
||||
|
||||
// hack, should actually use _csv2rs
|
||||
$rs = explode("\n", $rs);
|
||||
unset($rs[0]);
|
||||
$rs = join("\n", $rs);
|
||||
$rs = unserialize($rs);
|
||||
if (! is_object($rs)) {
|
||||
$err = 'Unable to unserialize $rs';
|
||||
return $false;
|
||||
}
|
||||
if ($rs->timeCreated == 0) return $rs; // apparently have been reports that timeCreated was set to 0 somewhere
|
||||
|
||||
$tdiff = intval($rs->timeCreated+$secs2cache - time());
|
||||
if ($tdiff <= 2) {
|
||||
switch($tdiff) {
|
||||
case 2:
|
||||
if ((rand() & 15) == 0) {
|
||||
$err = "Timeout 2";
|
||||
return $false;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ((rand() & 3) == 0) {
|
||||
$err = "Timeout 1";
|
||||
return $false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$err = "Timeout 0";
|
||||
return $false;
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
function flushall($debug=false)
|
||||
{
|
||||
if (!$this->_connected) {
|
||||
$err = '';
|
||||
if (!$this->connect($err) && $debug) ADOConnection::outp($err);
|
||||
}
|
||||
if (!$this->_memcache) return false;
|
||||
|
||||
$del = $this->_memcache->flush();
|
||||
|
||||
if ($debug)
|
||||
if (!$del) ADOConnection::outp("flushall: failed!<br>\n");
|
||||
else ADOConnection::outp("flushall: succeeded!<br>\n");
|
||||
|
||||
return $del;
|
||||
}
|
||||
|
||||
function flushcache($filename, $debug=false)
|
||||
{
|
||||
if (!$this->_connected) {
|
||||
$err = '';
|
||||
if (!$this->connect($err) && $debug) ADOConnection::outp($err);
|
||||
}
|
||||
if (!$this->_memcache) return false;
|
||||
|
||||
$del = $this->_memcache->delete($filename);
|
||||
|
||||
if ($debug)
|
||||
if (!$del) ADOConnection::outp("flushcache: $key entry doesn't exist on memcached server!<br>\n");
|
||||
else ADOConnection::outp("flushcache: $key entry flushed from memcached server!<br>\n");
|
||||
|
||||
return $del;
|
||||
}
|
||||
|
||||
// not used for memcache
|
||||
function createdir($dir, $hash)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
290
src/adodb512/adodb-pager.inc.php
Normal file
290
src/adodb512/adodb-pager.inc.php
Normal file
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
This class provides recordset pagination with
|
||||
First/Prev/Next/Last links.
|
||||
|
||||
Feel free to modify this class for your own use as
|
||||
it is very basic. To learn how to use it, see the
|
||||
example in adodb/tests/testpaging.php.
|
||||
|
||||
"Pablo Costa" <pablo@cbsp.com.br> implemented Render_PageLinks().
|
||||
|
||||
Please note, this class is entirely unsupported,
|
||||
and no free support requests except for bug reports
|
||||
will be entertained by the author.
|
||||
|
||||
*/
|
||||
class ADODB_Pager {
|
||||
var $id; // unique id for pager (defaults to 'adodb')
|
||||
var $db; // ADODB connection object
|
||||
var $sql; // sql used
|
||||
var $rs; // recordset generated
|
||||
var $curr_page; // current page number before Render() called, calculated in constructor
|
||||
var $rows; // number of rows per page
|
||||
var $linksPerPage=10; // number of links per page in navigation bar
|
||||
var $showPageLinks;
|
||||
|
||||
var $gridAttributes = 'width=100% border=1 bgcolor=white';
|
||||
|
||||
// Localize text strings here
|
||||
var $first = '<code>|<</code>';
|
||||
var $prev = '<code><<</code>';
|
||||
var $next = '<code>>></code>';
|
||||
var $last = '<code>>|</code>';
|
||||
var $moreLinks = '...';
|
||||
var $startLinks = '...';
|
||||
var $gridHeader = false;
|
||||
var $htmlSpecialChars = true;
|
||||
var $page = 'Page';
|
||||
var $linkSelectedColor = 'red';
|
||||
var $cache = 0; #secs to cache with CachePageExecute()
|
||||
|
||||
//----------------------------------------------
|
||||
// constructor
|
||||
//
|
||||
// $db adodb connection object
|
||||
// $sql sql statement
|
||||
// $id optional id to identify which pager,
|
||||
// if you have multiple on 1 page.
|
||||
// $id should be only be [a-z0-9]*
|
||||
//
|
||||
function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
|
||||
$curr_page = $id.'_curr_page';
|
||||
if (!empty($PHP_SELF)) $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); // htmlspecialchars() to prevent XSS attacks
|
||||
|
||||
$this->sql = $sql;
|
||||
$this->id = $id;
|
||||
$this->db = $db;
|
||||
$this->showPageLinks = $showPageLinks;
|
||||
|
||||
$next_page = $id.'_next_page';
|
||||
|
||||
if (isset($_GET[$next_page])) {
|
||||
$_SESSION[$curr_page] = (integer) $_GET[$next_page];
|
||||
}
|
||||
if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page
|
||||
|
||||
$this->curr_page = $_SESSION[$curr_page];
|
||||
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
// Display link to first page
|
||||
function Render_First($anchor=true)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
if ($anchor) {
|
||||
?>
|
||||
<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a>
|
||||
<?php
|
||||
} else {
|
||||
print "$this->first ";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------
|
||||
// Display link to next page
|
||||
function render_next($anchor=true)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
|
||||
if ($anchor) {
|
||||
?>
|
||||
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a>
|
||||
<?php
|
||||
} else {
|
||||
print "$this->next ";
|
||||
}
|
||||
}
|
||||
|
||||
//------------------
|
||||
// Link to last page
|
||||
//
|
||||
// for better performance with large recordsets, you can set
|
||||
// $this->db->pageExecuteCountRows = false, which disables
|
||||
// last page counting.
|
||||
function render_last($anchor=true)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
|
||||
if (!$this->db->pageExecuteCountRows) return;
|
||||
|
||||
if ($anchor) {
|
||||
?>
|
||||
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a>
|
||||
<?php
|
||||
} else {
|
||||
print "$this->last ";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// original code by "Pablo Costa" <pablo@cbsp.com.br>
|
||||
function render_pagelinks()
|
||||
{
|
||||
global $PHP_SELF;
|
||||
$pages = $this->rs->LastPageNo();
|
||||
$linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
|
||||
for($i=1; $i <= $pages; $i+=$linksperpage)
|
||||
{
|
||||
if($this->rs->AbsolutePage() >= $i)
|
||||
{
|
||||
$start = $i;
|
||||
}
|
||||
}
|
||||
$numbers = '';
|
||||
$end = $start+$linksperpage-1;
|
||||
$link = $this->id . "_next_page";
|
||||
if($end > $pages) $end = $pages;
|
||||
|
||||
|
||||
if ($this->startLinks && $start > 1) {
|
||||
$pos = $start - 1;
|
||||
$numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a> ";
|
||||
}
|
||||
|
||||
for($i=$start; $i <= $end; $i++) {
|
||||
if ($this->rs->AbsolutePage() == $i)
|
||||
$numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font> ";
|
||||
else
|
||||
$numbers .= "<a href=$PHP_SELF?$link=$i>$i</a> ";
|
||||
|
||||
}
|
||||
if ($this->moreLinks && $end < $pages)
|
||||
$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a> ";
|
||||
print $numbers . ' ';
|
||||
}
|
||||
// Link to previous page
|
||||
function render_prev($anchor=true)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
if ($anchor) {
|
||||
?>
|
||||
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a>
|
||||
<?php
|
||||
} else {
|
||||
print "$this->prev ";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Simply rendering of grid. You should override this for
|
||||
// better control over the format of the grid
|
||||
//
|
||||
// We use output buffering to keep code clean and readable.
|
||||
function RenderGrid()
|
||||
{
|
||||
global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
|
||||
include_once(ADODB_DIR.'/tohtml.inc.php');
|
||||
ob_start();
|
||||
$gSQLBlockRows = $this->rows;
|
||||
rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
|
||||
$s = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $s;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Navigation bar
|
||||
//
|
||||
// we use output buffering to keep the code easy to read.
|
||||
function RenderNav()
|
||||
{
|
||||
ob_start();
|
||||
if (!$this->rs->AtFirstPage()) {
|
||||
$this->Render_First();
|
||||
$this->Render_Prev();
|
||||
} else {
|
||||
$this->Render_First(false);
|
||||
$this->Render_Prev(false);
|
||||
}
|
||||
if ($this->showPageLinks){
|
||||
$this->Render_PageLinks();
|
||||
}
|
||||
if (!$this->rs->AtLastPage()) {
|
||||
$this->Render_Next();
|
||||
$this->Render_Last();
|
||||
} else {
|
||||
$this->Render_Next(false);
|
||||
$this->Render_Last(false);
|
||||
}
|
||||
$s = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $s;
|
||||
}
|
||||
|
||||
//-------------------
|
||||
// This is the footer
|
||||
function RenderPageCount()
|
||||
{
|
||||
if (!$this->db->pageExecuteCountRows) return '';
|
||||
$lastPage = $this->rs->LastPageNo();
|
||||
if ($lastPage == -1) $lastPage = 1; // check for empty rs.
|
||||
if ($this->curr_page > $lastPage) $this->curr_page = 1;
|
||||
return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
// Call this class to draw everything.
|
||||
function Render($rows=10)
|
||||
{
|
||||
global $ADODB_COUNTRECS;
|
||||
|
||||
$this->rows = $rows;
|
||||
|
||||
if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;
|
||||
|
||||
$savec = $ADODB_COUNTRECS;
|
||||
if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
|
||||
if ($this->cache)
|
||||
$rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
|
||||
else
|
||||
$rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page);
|
||||
$ADODB_COUNTRECS = $savec;
|
||||
|
||||
$this->rs = $rs;
|
||||
if (!$rs) {
|
||||
print "<h3>Query failed: $this->sql</h3>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
|
||||
$header = $this->RenderNav();
|
||||
else
|
||||
$header = " ";
|
||||
|
||||
$grid = $this->RenderGrid();
|
||||
$footer = $this->RenderPageCount();
|
||||
|
||||
$this->RenderLayout($header,$grid,$footer);
|
||||
|
||||
$rs->Close();
|
||||
$this->rs = false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// override this to control overall layout and formating
|
||||
function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige')
|
||||
{
|
||||
echo "<table ".$attributes."><tr><td>",
|
||||
$header,
|
||||
"</td></tr><tr><td>",
|
||||
$grid,
|
||||
"</td></tr><tr><td>",
|
||||
$footer,
|
||||
"</td></tr></table>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
374
src/adodb512/adodb-pear.inc.php
Normal file
374
src/adodb512/adodb-pear.inc.php
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* Released under both BSD license and Lesser GPL library license.
|
||||
* Whenever there is any discrepancy between the two licenses,
|
||||
* the BSD license will take precedence.
|
||||
*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* PEAR DB Emulation Layer for ADODB.
|
||||
*
|
||||
* The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> |
|
||||
* and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
|
||||
*/
|
||||
|
||||
/*
|
||||
We support:
|
||||
|
||||
DB_Common
|
||||
---------
|
||||
query - returns PEAR_Error on error
|
||||
limitQuery - return PEAR_Error on error
|
||||
prepare - does not return PEAR_Error on error
|
||||
execute - does not return PEAR_Error on error
|
||||
setFetchMode - supports ASSOC and ORDERED
|
||||
errorNative
|
||||
quote
|
||||
nextID
|
||||
disconnect
|
||||
|
||||
getOne
|
||||
getAssoc
|
||||
getRow
|
||||
getCol
|
||||
getAll
|
||||
|
||||
DB_Result
|
||||
---------
|
||||
numRows - returns -1 if not supported
|
||||
numCols
|
||||
fetchInto - does not support passing of fetchmode
|
||||
fetchRows - does not support passing of fetchmode
|
||||
free
|
||||
*/
|
||||
|
||||
define('ADODB_PEAR',dirname(__FILE__));
|
||||
include_once "PEAR.php";
|
||||
include_once ADODB_PEAR."/adodb-errorpear.inc.php";
|
||||
include_once ADODB_PEAR."/adodb.inc.php";
|
||||
|
||||
if (!defined('DB_OK')) {
|
||||
define("DB_OK", 1);
|
||||
define("DB_ERROR",-1);
|
||||
|
||||
// autoExecute constants
|
||||
define('DB_AUTOQUERY_INSERT', 1);
|
||||
define('DB_AUTOQUERY_UPDATE', 2);
|
||||
|
||||
/**
|
||||
* This is a special constant that tells DB the user hasn't specified
|
||||
* any particular get mode, so the default should be used.
|
||||
*/
|
||||
|
||||
define('DB_FETCHMODE_DEFAULT', 0);
|
||||
|
||||
/**
|
||||
* Column data indexed by numbers, ordered from 0 and up
|
||||
*/
|
||||
|
||||
define('DB_FETCHMODE_ORDERED', 1);
|
||||
|
||||
/**
|
||||
* Column data indexed by column names
|
||||
*/
|
||||
|
||||
define('DB_FETCHMODE_ASSOC', 2);
|
||||
|
||||
/* for compatibility */
|
||||
|
||||
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED);
|
||||
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC);
|
||||
|
||||
/**
|
||||
* these are constants for the tableInfo-function
|
||||
* they are bitwised or'ed. so if there are more constants to be defined
|
||||
* in the future, adjust DB_TABLEINFO_FULL accordingly
|
||||
*/
|
||||
|
||||
define('DB_TABLEINFO_ORDER', 1);
|
||||
define('DB_TABLEINFO_ORDERTABLE', 2);
|
||||
define('DB_TABLEINFO_FULL', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* The main "DB" class is simply a container class with some static
|
||||
* methods for creating DB objects as well as some utility functions
|
||||
* common to all parts of DB.
|
||||
*
|
||||
*/
|
||||
|
||||
class DB
|
||||
{
|
||||
/**
|
||||
* Create a new DB object for the specified database type
|
||||
*
|
||||
* @param $type string database type, for example "mysql"
|
||||
*
|
||||
* @return object a newly created DB object, or a DB error code on
|
||||
* error
|
||||
*/
|
||||
|
||||
function factory($type)
|
||||
{
|
||||
include_once(ADODB_DIR."/drivers/adodb-$type.inc.php");
|
||||
$obj = NewADOConnection($type);
|
||||
if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DB object and connect to the specified database
|
||||
*
|
||||
* @param $dsn mixed "data source name", see the DB::parseDSN
|
||||
* method for a description of the dsn format. Can also be
|
||||
* specified as an array of the format returned by DB::parseDSN.
|
||||
*
|
||||
* @param $options mixed if boolean (or scalar), tells whether
|
||||
* this connection should be persistent (for backends that support
|
||||
* this). This parameter can also be an array of options, see
|
||||
* DB_common::setOption for more information on connection
|
||||
* options.
|
||||
*
|
||||
* @return object a newly created DB connection object, or a DB
|
||||
* error object on error
|
||||
*
|
||||
* @see DB::parseDSN
|
||||
* @see DB::isError
|
||||
*/
|
||||
function connect($dsn, $options = false)
|
||||
{
|
||||
if (is_array($dsn)) {
|
||||
$dsninfo = $dsn;
|
||||
} else {
|
||||
$dsninfo = DB::parseDSN($dsn);
|
||||
}
|
||||
switch ($dsninfo["phptype"]) {
|
||||
case 'pgsql': $type = 'postgres7'; break;
|
||||
case 'ifx': $type = 'informix9'; break;
|
||||
default: $type = $dsninfo["phptype"]; break;
|
||||
}
|
||||
|
||||
if (is_array($options) && isset($options["debug"]) &&
|
||||
$options["debug"] >= 2) {
|
||||
// expose php errors with sufficient debug level
|
||||
@include_once("adodb-$type.inc.php");
|
||||
} else {
|
||||
@include_once("adodb-$type.inc.php");
|
||||
}
|
||||
|
||||
@$obj = NewADOConnection($type);
|
||||
if (!is_object($obj)) {
|
||||
$obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
|
||||
return $obj;
|
||||
}
|
||||
if (is_array($options)) {
|
||||
foreach($options as $k => $v) {
|
||||
switch(strtolower($k)) {
|
||||
case 'persist':
|
||||
case 'persistent': $persist = $v; break;
|
||||
#ibase
|
||||
case 'dialect': $obj->dialect = $v; break;
|
||||
case 'charset': $obj->charset = $v; break;
|
||||
case 'buffers': $obj->buffers = $v; break;
|
||||
#ado
|
||||
case 'charpage': $obj->charPage = $v; break;
|
||||
#mysql
|
||||
case 'clientflags': $obj->clientFlags = $v; break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$persist = false;
|
||||
}
|
||||
|
||||
if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
|
||||
else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];
|
||||
|
||||
if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
|
||||
else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
|
||||
|
||||
if (!$ok) $obj = ADODB_PEAR_Error();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB API version
|
||||
*
|
||||
* @return int the DB API version number
|
||||
*/
|
||||
function apiVersion()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether a result code from a DB method is an error
|
||||
*
|
||||
* @param $value int result code
|
||||
*
|
||||
* @return bool whether $value is an error
|
||||
*/
|
||||
function isError($value)
|
||||
{
|
||||
if (!is_object($value)) return false;
|
||||
$class = strtolower(get_class($value));
|
||||
return $class == 'pear_error' || is_subclass_of($value, 'pear_error') ||
|
||||
$class == 'db_error' || is_subclass_of($value, 'db_error');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tell whether a result code from a DB method is a warning.
|
||||
* Warnings differ from errors in that they are generated by DB,
|
||||
* and are not fatal.
|
||||
*
|
||||
* @param $value mixed result value
|
||||
*
|
||||
* @return bool whether $value is a warning
|
||||
*/
|
||||
function isWarning($value)
|
||||
{
|
||||
return false;
|
||||
/*
|
||||
return is_object($value) &&
|
||||
(get_class( $value ) == "db_warning" ||
|
||||
is_subclass_of($value, "db_warning"));*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a data source name
|
||||
*
|
||||
* @param $dsn string Data Source Name to be parsed
|
||||
*
|
||||
* @return array an associative array with the following keys:
|
||||
*
|
||||
* phptype: Database backend used in PHP (mysql, odbc etc.)
|
||||
* dbsyntax: Database used with regards to SQL syntax etc.
|
||||
* protocol: Communication protocol to use (tcp, unix etc.)
|
||||
* hostspec: Host specification (hostname[:port])
|
||||
* database: Database to use on the DBMS server
|
||||
* username: User name for login
|
||||
* password: Password for login
|
||||
*
|
||||
* The format of the supplied DSN is in its fullest form:
|
||||
*
|
||||
* phptype(dbsyntax)://username:password@protocol+hostspec/database
|
||||
*
|
||||
* Most variations are allowed:
|
||||
*
|
||||
* phptype://username:password@protocol+hostspec:110//usr/db_file.db
|
||||
* phptype://username:password@hostspec/database_name
|
||||
* phptype://username:password@hostspec
|
||||
* phptype://username@hostspec
|
||||
* phptype://hostspec/database
|
||||
* phptype://hostspec
|
||||
* phptype(dbsyntax)
|
||||
* phptype
|
||||
*
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
*/
|
||||
function parseDSN($dsn)
|
||||
{
|
||||
if (is_array($dsn)) {
|
||||
return $dsn;
|
||||
}
|
||||
|
||||
$parsed = array(
|
||||
'phptype' => false,
|
||||
'dbsyntax' => false,
|
||||
'protocol' => false,
|
||||
'hostspec' => false,
|
||||
'database' => false,
|
||||
'username' => false,
|
||||
'password' => false
|
||||
);
|
||||
|
||||
// Find phptype and dbsyntax
|
||||
if (($pos = strpos($dsn, '://')) !== false) {
|
||||
$str = substr($dsn, 0, $pos);
|
||||
$dsn = substr($dsn, $pos + 3);
|
||||
} else {
|
||||
$str = $dsn;
|
||||
$dsn = NULL;
|
||||
}
|
||||
|
||||
// Get phptype and dbsyntax
|
||||
// $str => phptype(dbsyntax)
|
||||
if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
|
||||
$parsed['phptype'] = $arr[1];
|
||||
$parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
|
||||
} else {
|
||||
$parsed['phptype'] = $str;
|
||||
$parsed['dbsyntax'] = $str;
|
||||
}
|
||||
|
||||
if (empty($dsn)) {
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
// Get (if found): username and password
|
||||
// $dsn => username:password@protocol+hostspec/database
|
||||
if (($at = strpos($dsn,'@')) !== false) {
|
||||
$str = substr($dsn, 0, $at);
|
||||
$dsn = substr($dsn, $at + 1);
|
||||
if (($pos = strpos($str, ':')) !== false) {
|
||||
$parsed['username'] = urldecode(substr($str, 0, $pos));
|
||||
$parsed['password'] = urldecode(substr($str, $pos + 1));
|
||||
} else {
|
||||
$parsed['username'] = urldecode($str);
|
||||
}
|
||||
}
|
||||
|
||||
// Find protocol and hostspec
|
||||
// $dsn => protocol+hostspec/database
|
||||
if (($pos=strpos($dsn, '/')) !== false) {
|
||||
$str = substr($dsn, 0, $pos);
|
||||
$dsn = substr($dsn, $pos + 1);
|
||||
} else {
|
||||
$str = $dsn;
|
||||
$dsn = NULL;
|
||||
}
|
||||
|
||||
// Get protocol + hostspec
|
||||
// $str => protocol+hostspec
|
||||
if (($pos=strpos($str, '+')) !== false) {
|
||||
$parsed['protocol'] = substr($str, 0, $pos);
|
||||
$parsed['hostspec'] = urldecode(substr($str, $pos + 1));
|
||||
} else {
|
||||
$parsed['hostspec'] = urldecode($str);
|
||||
}
|
||||
|
||||
// Get dabase if any
|
||||
// $dsn => database
|
||||
if (!empty($dsn)) {
|
||||
$parsed['database'] = $dsn;
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a PHP database extension if it is not loaded already.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param $name the base name of the extension (without the .so or
|
||||
* .dll suffix)
|
||||
*
|
||||
* @return bool true if the extension was already or successfully
|
||||
* loaded, false if it could not be loaded
|
||||
*/
|
||||
function assertExtension($name)
|
||||
{
|
||||
if (!extension_loaded($name)) {
|
||||
$dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so';
|
||||
@dl($name . $dlext);
|
||||
}
|
||||
if (!extension_loaded($name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
1099
src/adodb512/adodb-perf.inc.php
Normal file
1099
src/adodb512/adodb-perf.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
16
src/adodb512/adodb-php4.inc.php
Normal file
16
src/adodb512/adodb-php4.inc.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4.
|
||||
*/
|
||||
|
||||
|
||||
class ADODB_BASE_RS {
|
||||
}
|
||||
|
||||
?>
|
||||
1429
src/adodb512/adodb-time.inc.php
Normal file
1429
src/adodb512/adodb-time.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
2225
src/adodb512/adodb-xmlschema.inc.php
Normal file
2225
src/adodb512/adodb-xmlschema.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
2406
src/adodb512/adodb-xmlschema03.inc.php
Normal file
2406
src/adodb512/adodb-xmlschema03.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
4441
src/adodb512/adodb.inc.php
Normal file
4441
src/adodb512/adodb.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
183
src/adodb512/contrib/toxmlrpc.inc.php
Normal file
183
src/adodb512/contrib/toxmlrpc.inc.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Helper functions to convert between ADODB recordset objects and XMLRPC values.
|
||||
* Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs
|
||||
*
|
||||
* @author Daniele Baroncelli
|
||||
* @author Gaetano Giunta
|
||||
* @copyright (c) 2003-2004 Giunta/Baroncelli. All rights reserved.
|
||||
*
|
||||
* @todo some more error checking here and there
|
||||
* @todo document the xmlrpc-struct used to encode recordset info
|
||||
* @todo verify if using xmlrpc_encode($rs->GetArray()) would work with:
|
||||
* - ADODB_FETCH_BOTH
|
||||
* - null values
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include the main libraries
|
||||
*/
|
||||
require_once('xmlrpc.inc');
|
||||
if (!defined('ADODB_DIR')) require_once('adodb.inc.php');
|
||||
|
||||
/**
|
||||
* Builds an xmlrpc struct value out of an AdoDB recordset
|
||||
*/
|
||||
function rs2xmlrpcval(&$adodbrs) {
|
||||
|
||||
$header = rs2xmlrpcval_header($adodbrs);
|
||||
$body = rs2xmlrpcval_body($adodbrs);
|
||||
|
||||
// put it all together and build final xmlrpc struct
|
||||
$xmlrpcrs = new xmlrpcval ( array(
|
||||
"header" => $header,
|
||||
"body" => $body,
|
||||
), "struct");
|
||||
|
||||
return $xmlrpcrs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an xmlrpc struct value describing an AdoDB recordset
|
||||
*/
|
||||
function rs2xmlrpcval_header($adodbrs)
|
||||
{
|
||||
$numfields = $adodbrs->FieldCount();
|
||||
$numrecords = $adodbrs->RecordCount();
|
||||
|
||||
// build structure holding recordset information
|
||||
$fieldstruct = array();
|
||||
for ($i = 0; $i < $numfields; $i++) {
|
||||
$fld = $adodbrs->FetchField($i);
|
||||
$fieldarray = array();
|
||||
if (isset($fld->name))
|
||||
$fieldarray["name"] = new xmlrpcval ($fld->name);
|
||||
if (isset($fld->type))
|
||||
$fieldarray["type"] = new xmlrpcval ($fld->type);
|
||||
if (isset($fld->max_length))
|
||||
$fieldarray["max_length"] = new xmlrpcval ($fld->max_length, "int");
|
||||
if (isset($fld->not_null))
|
||||
$fieldarray["not_null"] = new xmlrpcval ($fld->not_null, "boolean");
|
||||
if (isset($fld->has_default))
|
||||
$fieldarray["has_default"] = new xmlrpcval ($fld->has_default, "boolean");
|
||||
if (isset($fld->default_value))
|
||||
$fieldarray["default_value"] = new xmlrpcval ($fld->default_value);
|
||||
$fieldstruct[$i] = new xmlrpcval ($fieldarray, "struct");
|
||||
}
|
||||
$fieldcount = new xmlrpcval ($numfields, "int");
|
||||
$recordcount = new xmlrpcval ($numrecords, "int");
|
||||
$sql = new xmlrpcval ($adodbrs->sql);
|
||||
$fieldinfo = new xmlrpcval ($fieldstruct, "array");
|
||||
|
||||
$header = new xmlrpcval ( array(
|
||||
"fieldcount" => $fieldcount,
|
||||
"recordcount" => $recordcount,
|
||||
"sql" => $sql,
|
||||
"fieldinfo" => $fieldinfo
|
||||
), "struct");
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an xmlrpc struct value out of an AdoDB recordset
|
||||
* (data values only, no data definition)
|
||||
*/
|
||||
function rs2xmlrpcval_body($adodbrs)
|
||||
{
|
||||
$numfields = $adodbrs->FieldCount();
|
||||
|
||||
// build structure containing recordset data
|
||||
$adodbrs->MoveFirst();
|
||||
$rows = array();
|
||||
while (!$adodbrs->EOF) {
|
||||
$columns = array();
|
||||
// This should work on all cases of fetch mode: assoc, num, both or default
|
||||
if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount())
|
||||
for ($i = 0; $i < $numfields; $i++)
|
||||
if ($adodbrs->fields[$i] === null)
|
||||
$columns[$i] = new xmlrpcval ('');
|
||||
else
|
||||
$columns[$i] = xmlrpc_encode ($adodbrs->fields[$i]);
|
||||
else
|
||||
foreach ($adodbrs->fields as $val)
|
||||
if ($val === null)
|
||||
$columns[] = new xmlrpcval ('');
|
||||
else
|
||||
$columns[] = xmlrpc_encode ($val);
|
||||
|
||||
$rows[] = new xmlrpcval ($columns, "array");
|
||||
|
||||
$adodbrs->MoveNext();
|
||||
}
|
||||
$body = new xmlrpcval ($rows, "array");
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an xmlrpc struct value as string out of an AdoDB recordset
|
||||
*/
|
||||
function rs2xmlrpcstring (&$adodbrs) {
|
||||
$xmlrpc = rs2xmlrpcval ($adodbrs);
|
||||
if ($xmlrpc)
|
||||
return $xmlrpc->serialize();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a well-formed xmlrpc struct object returns an AdoDB object
|
||||
*
|
||||
* @todo add some error checking on the input value
|
||||
*/
|
||||
function xmlrpcval2rs (&$xmlrpcval) {
|
||||
|
||||
$fields_array = array();
|
||||
$data_array = array();
|
||||
|
||||
// rebuild column information
|
||||
$header = $xmlrpcval->structmem('header');
|
||||
|
||||
$numfields = $header->structmem('fieldcount');
|
||||
$numfields = $numfields->scalarval();
|
||||
$numrecords = $header->structmem('recordcount');
|
||||
$numrecords = $numrecords->scalarval();
|
||||
$sqlstring = $header->structmem('sql');
|
||||
$sqlstring = $sqlstring->scalarval();
|
||||
|
||||
$fieldinfo = $header->structmem('fieldinfo');
|
||||
for ($i = 0; $i < $numfields; $i++) {
|
||||
$temp = $fieldinfo->arraymem($i);
|
||||
$fld = new ADOFieldObject();
|
||||
while (list($key,$value) = $temp->structeach()) {
|
||||
if ($key == "name") $fld->name = $value->scalarval();
|
||||
if ($key == "type") $fld->type = $value->scalarval();
|
||||
if ($key == "max_length") $fld->max_length = $value->scalarval();
|
||||
if ($key == "not_null") $fld->not_null = $value->scalarval();
|
||||
if ($key == "has_default") $fld->has_default = $value->scalarval();
|
||||
if ($key == "default_value") $fld->default_value = $value->scalarval();
|
||||
} // while
|
||||
$fields_array[] = $fld;
|
||||
} // for
|
||||
|
||||
// fetch recordset information into php array
|
||||
$body = $xmlrpcval->structmem('body');
|
||||
for ($i = 0; $i < $numrecords; $i++) {
|
||||
$data_array[$i]= array();
|
||||
$xmlrpcrs_row = $body->arraymem($i);
|
||||
for ($j = 0; $j < $numfields; $j++) {
|
||||
$temp = $xmlrpcrs_row->arraymem($j);
|
||||
$data_array[$i][$j] = $temp->scalarval();
|
||||
} // for j
|
||||
} // for i
|
||||
|
||||
// finally build in-memory recordset object and return it
|
||||
$rs = new ADORecordSet_array();
|
||||
$rs->InitArrayFields($data_array,$fields_array);
|
||||
return $rs;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
BIN
src/adodb512/cute_icons_for_site/adodb.gif
Normal file
BIN
src/adodb512/cute_icons_for_site/adodb.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/adodb512/cute_icons_for_site/adodb2.gif
Normal file
BIN
src/adodb512/cute_icons_for_site/adodb2.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
96
src/adodb512/datadict/datadict-access.inc.php
Normal file
96
src/adodb512/datadict/datadict-access.inc.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_access extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'access';
|
||||
var $seqField = false;
|
||||
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'TEXT';
|
||||
case 'XL':
|
||||
case 'X': return 'MEMO';
|
||||
|
||||
case 'C2': return 'TEXT'; // up to 32K
|
||||
case 'X2': return 'MEMO';
|
||||
|
||||
case 'B': return 'BINARY';
|
||||
|
||||
case 'TS':
|
||||
case 'D': return 'DATETIME';
|
||||
case 'T': return 'DATETIME';
|
||||
|
||||
case 'L': return 'BYTE';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'BYTE';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'INTEGER';
|
||||
|
||||
case 'F': return 'DOUBLE';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
if ($fautoinc) {
|
||||
$ftype = 'COUNTER';
|
||||
return '';
|
||||
}
|
||||
if (substr($ftype,0,7) == 'DECIMAL') $ftype = 'DECIMAL';
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) {
|
||||
//$suffix .= " DEFAULT $fdefault";
|
||||
if ($this->debug) ADOConnection::outp("Warning: Access does not supported DEFAULT values (field $fname)");
|
||||
}
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function CreateDatabase($dbname,$options=false)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function SetSchema($schema)
|
||||
{
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
144
src/adodb512/datadict/datadict-db2.inc.php
Normal file
144
src/adodb512/datadict/datadict-db2.inc.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_db2 extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'db2';
|
||||
var $seqField = false;
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL': return 'CLOB';
|
||||
case 'X': return 'VARCHAR(3600)';
|
||||
|
||||
case 'C2': return 'VARCHAR'; // up to 32K
|
||||
case 'X2': return 'VARCHAR(3600)'; // up to 32000, but default page size too small
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'DOUBLE';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($fautoinc) return ' GENERATED ALWAYS AS IDENTITY'; # as identity start with
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function ChangeTableSQL($tablename, $flds, $tableoptions = false)
|
||||
{
|
||||
|
||||
/**
|
||||
Allow basic table changes to DB2 databases
|
||||
DB2 will fatally reject changes to non character columns
|
||||
|
||||
*/
|
||||
|
||||
$validTypes = array("CHAR","VARC");
|
||||
$invalidTypes = array("BIGI","BLOB","CLOB","DATE", "DECI","DOUB", "INTE", "REAL","SMAL", "TIME");
|
||||
// check table exists
|
||||
$cols = $this->MetaColumns($tablename);
|
||||
if ( empty($cols)) {
|
||||
return $this->CreateTableSQL($tablename, $flds, $tableoptions);
|
||||
}
|
||||
|
||||
// already exists, alter table instead
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$alter = 'ALTER TABLE ' . $this->TableName($tablename);
|
||||
$sql = array();
|
||||
|
||||
foreach ( $lines as $id => $v ) {
|
||||
if ( isset($cols[$id]) && is_object($cols[$id]) ) {
|
||||
/**
|
||||
If the first field of $v is the fieldname, and
|
||||
the second is the field type/size, we assume its an
|
||||
attempt to modify the column size, so check that it is allowed
|
||||
$v can have an indeterminate number of blanks between the
|
||||
fields, so account for that too
|
||||
*/
|
||||
$vargs = explode(' ' , $v);
|
||||
// assume that $vargs[0] is the field name.
|
||||
$i=0;
|
||||
// Find the next non-blank value;
|
||||
for ($i=1;$i<sizeof($vargs);$i++)
|
||||
if ($vargs[$i] != '')
|
||||
break;
|
||||
|
||||
// if $vargs[$i] is one of the following, we are trying to change the
|
||||
// size of the field, if not allowed, simply ignore the request.
|
||||
if (in_array(substr($vargs[$i],0,4),$invalidTypes))
|
||||
continue;
|
||||
// insert the appropriate DB2 syntax
|
||||
if (in_array(substr($vargs[$i],0,4),$validTypes)) {
|
||||
array_splice($vargs,$i,0,array('SET','DATA','TYPE'));
|
||||
}
|
||||
|
||||
// Now Look for the NOT NULL statement as this is not allowed in
|
||||
// the ALTER table statement. If it is in there, remove it
|
||||
if (in_array('NOT',$vargs) && in_array('NULL',$vargs)) {
|
||||
for ($i=1;$i<sizeof($vargs);$i++)
|
||||
if ($vargs[$i] == 'NOT')
|
||||
break;
|
||||
array_splice($vargs,$i,2,'');
|
||||
}
|
||||
$v = implode(' ',$vargs);
|
||||
$sql[] = $alter . $this->alterCol . ' ' . $v;
|
||||
} else {
|
||||
$sql[] = $alter . $this->addCol . ' ' . $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
152
src/adodb512/datadict/datadict-firebird.inc.php
Normal file
152
src/adodb512/datadict/datadict-firebird.inc.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
class ADODB2_firebird extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'firebird';
|
||||
var $seqField = false;
|
||||
var $seqPrefix = 'gen_';
|
||||
var $blobSize = 40000;
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL': return 'VARCHAR(32000)';
|
||||
case 'X': return 'VARCHAR(4000)';
|
||||
|
||||
case 'C2': return 'VARCHAR'; // up to 32K
|
||||
case 'X2': return 'VARCHAR(4000)';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'INTEGER';
|
||||
|
||||
case 'F': return 'DOUBLE PRECISION';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function NameQuote($name = NULL)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$name = trim($name);
|
||||
|
||||
if ( !is_object($this->connection) ) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$quote = $this->connection->nameQuote;
|
||||
|
||||
// if name is of the form `name`, quote it
|
||||
if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
|
||||
return $quote . $matches[1] . $quote;
|
||||
}
|
||||
|
||||
// if name contains special characters, quote it
|
||||
if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
|
||||
return $quote . $name . $quote;
|
||||
}
|
||||
|
||||
return $quote . $name . $quote;
|
||||
}
|
||||
|
||||
function CreateDatabase($dbname, $options=false)
|
||||
{
|
||||
$options = $this->_Options($options);
|
||||
$sql = array();
|
||||
|
||||
$sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function _DropAutoIncrement($t)
|
||||
{
|
||||
if (strpos($t,'.') !== false) {
|
||||
$tarr = explode('.',$t);
|
||||
return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"';
|
||||
}
|
||||
return 'DROP GENERATOR "GEN_'.$t;
|
||||
}
|
||||
|
||||
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fautoinc) $this->seqField = $fname;
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE or replace TRIGGER jaddress_insert
|
||||
before insert on jaddress
|
||||
for each row
|
||||
begin
|
||||
IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN
|
||||
NEW."seqField" = GEN_ID("GEN_tabname", 1);
|
||||
end;
|
||||
*/
|
||||
function _Triggers($tabname,$tableoptions)
|
||||
{
|
||||
if (!$this->seqField) return array();
|
||||
|
||||
$tab1 = preg_replace( '/"/', '', $tabname );
|
||||
if ($this->schema) {
|
||||
$t = strpos($tab1,'.');
|
||||
if ($t !== false) $tab = substr($tab1,$t+1);
|
||||
else $tab = $tab1;
|
||||
$seqField = $this->seqField;
|
||||
$seqname = $this->schema.'.'.$this->seqPrefix.$tab;
|
||||
$trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab;
|
||||
} else {
|
||||
$seqField = $this->seqField;
|
||||
$seqname = $this->seqPrefix.$tab1;
|
||||
$trigname = 'trig_'.$seqname;
|
||||
}
|
||||
if (isset($tableoptions['REPLACE']))
|
||||
{ $sql[] = "DROP GENERATOR \"$seqname\"";
|
||||
$sql[] = "CREATE GENERATOR \"$seqname\"";
|
||||
$sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
|
||||
}
|
||||
else
|
||||
{ $sql[] = "CREATE GENERATOR \"$seqname\"";
|
||||
$sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
|
||||
}
|
||||
|
||||
$this->seqField = false;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
126
src/adodb512/datadict/datadict-generic.inc.php
Normal file
126
src/adodb512/datadict/datadict-generic.inc.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_generic extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'generic';
|
||||
var $seqField = false;
|
||||
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'VARCHAR(250)';
|
||||
|
||||
case 'C2': return 'VARCHAR';
|
||||
case 'X2': return 'VARCHAR(250)';
|
||||
|
||||
case 'B': return 'VARCHAR';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'DATE';
|
||||
|
||||
case 'L': return 'DECIMAL(1)';
|
||||
case 'I': return 'DECIMAL(10)';
|
||||
case 'I1': return 'DECIMAL(3)';
|
||||
case 'I2': return 'DECIMAL(5)';
|
||||
case 'I4': return 'DECIMAL(10)';
|
||||
case 'I8': return 'DECIMAL(20)';
|
||||
|
||||
case 'F': return 'DECIMAL(32,8)';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
//db2
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'X': return 'VARCHAR';
|
||||
|
||||
case 'C2': return 'VARCHAR'; // up to 32K
|
||||
case 'X2': return 'VARCHAR';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'DOUBLE';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
// ifx
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';// 255
|
||||
case 'X': return 'TEXT';
|
||||
|
||||
case 'C2': return 'NVARCHAR';
|
||||
case 'X2': return 'TEXT';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'T': return 'DATETIME';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'DECIMAL(20)';
|
||||
|
||||
case 'F': return 'FLOAT';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
*/
|
||||
?>
|
||||
68
src/adodb512/datadict/datadict-ibase.inc.php
Normal file
68
src/adodb512/datadict/datadict-ibase.inc.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_ibase extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'ibase';
|
||||
var $seqField = false;
|
||||
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'VARCHAR(4000)';
|
||||
|
||||
case 'C2': return 'VARCHAR'; // up to 32K
|
||||
case 'X2': return 'VARCHAR(4000)';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'INTEGER';
|
||||
|
||||
case 'F': return 'DOUBLE PRECISION';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
81
src/adodb512/datadict/datadict-informix.inc.php
Normal file
81
src/adodb512/datadict/datadict-informix.inc.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_informix extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'informix';
|
||||
var $seqField = false;
|
||||
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';// 255
|
||||
case 'XL':
|
||||
case 'X': return 'TEXT';
|
||||
|
||||
case 'C2': return 'NVARCHAR';
|
||||
case 'X2': return 'TEXT';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'DATETIME YEAR TO SECOND';
|
||||
|
||||
case 'L': return 'SMALLINT';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'DECIMAL(20)';
|
||||
|
||||
case 'F': return 'FLOAT';
|
||||
case 'N': return 'DECIMAL';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
if ($fautoinc) {
|
||||
$ftype = 'SERIAL';
|
||||
return '';
|
||||
}
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
284
src/adodb512/datadict/datadict-mssql.inc.php
Normal file
284
src/adodb512/datadict/datadict-mssql.inc.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
|
||||
|
||||
Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
|
||||
whether or not they are marked as reserved in SQL Server.
|
||||
|
||||
Quoted identifiers are delimited by double quotation marks ("):
|
||||
SELECT * FROM "Blanks in Table Name"
|
||||
|
||||
Bracketed identifiers are delimited by brackets ([ ]):
|
||||
SELECT * FROM [Blanks In Table Name]
|
||||
|
||||
Quoted identifiers are valid only when the QUOTED_IDENTIFIER option is set to ON. By default,
|
||||
the Microsoft OLE DB Provider for SQL Server and SQL Server ODBC driver set QUOTED_IDENTIFIER ON
|
||||
when they connect.
|
||||
|
||||
In Transact-SQL, the option can be set at various levels using SET QUOTED_IDENTIFIER,
|
||||
the quoted identifier option of sp_dboption, or the user options option of sp_configure.
|
||||
|
||||
When SET ANSI_DEFAULTS is ON, SET QUOTED_IDENTIFIER is enabled.
|
||||
|
||||
Syntax
|
||||
|
||||
SET QUOTED_IDENTIFIER { ON | OFF }
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_mssql extends ADODB_DataDict {
|
||||
var $databaseType = 'mssql';
|
||||
var $dropIndex = 'DROP INDEX %2$s.%1$s';
|
||||
var $renameTable = "EXEC sp_rename '%s','%s'";
|
||||
var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
|
||||
|
||||
var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
|
||||
var $typeXL = 'TEXT';
|
||||
|
||||
//var $alterCol = ' ALTER COLUMN ';
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
$len = -1; // mysql max_length is not accurate
|
||||
switch (strtoupper($t)) {
|
||||
case 'R':
|
||||
case 'INT':
|
||||
case 'INTEGER': return 'I';
|
||||
case 'BIT':
|
||||
case 'TINYINT': return 'I1';
|
||||
case 'SMALLINT': return 'I2';
|
||||
case 'BIGINT': return 'I8';
|
||||
case 'SMALLDATETIME': return 'T';
|
||||
case 'REAL':
|
||||
case 'FLOAT': return 'F';
|
||||
default: return parent::MetaType($t,$len,$fieldobj);
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch(strtoupper($meta)) {
|
||||
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT';
|
||||
case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle
|
||||
case 'C2': return 'NVARCHAR';
|
||||
case 'X2': return 'NTEXT';
|
||||
|
||||
case 'B': return 'IMAGE';
|
||||
|
||||
case 'D': return 'DATETIME';
|
||||
|
||||
case 'TS':
|
||||
case 'T': return 'DATETIME';
|
||||
case 'L': return 'BIT';
|
||||
|
||||
case 'R':
|
||||
case 'I': return 'INT';
|
||||
case 'I1': return 'TINYINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INT';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'REAL';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname $this->addCol";
|
||||
foreach($lines as $v) {
|
||||
$f[] = "\n $v";
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
foreach($lines as $v) {
|
||||
$sql[] = "ALTER TABLE $tabname $this->alterCol $v";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
*/
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds))
|
||||
$flds = explode(',',$flds);
|
||||
$f = array();
|
||||
$s = 'ALTER TABLE ' . $tabname;
|
||||
foreach($flds as $v) {
|
||||
$f[] = "\n$this->dropCol ".$this->NameQuote($v);
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fautoinc) $suffix .= ' IDENTITY(1,1)';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
else if ($suffix == '') $suffix .= ' NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE TABLE
|
||||
[ database_name.[ owner ] . | owner. ] table_name
|
||||
( { < column_definition >
|
||||
| column_name AS computed_column_expression
|
||||
| < table_constraint > ::= [ CONSTRAINT constraint_name ] }
|
||||
|
||||
| [ { PRIMARY KEY | UNIQUE } [ ,...n ]
|
||||
)
|
||||
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
|
||||
|
||||
< column_definition > ::= { column_name data_type }
|
||||
[ COLLATE < collation_name > ]
|
||||
[ [ DEFAULT constant_expression ]
|
||||
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
|
||||
]
|
||||
[ ROWGUIDCOL]
|
||||
[ < column_constraint > ] [ ...n ]
|
||||
|
||||
< column_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ NULL | NOT NULL ]
|
||||
| [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ON {filegroup | DEFAULT} ] ]
|
||||
]
|
||||
| [ [ FOREIGN KEY ]
|
||||
REFERENCES ref_table [ ( ref_column ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( logical_expression )
|
||||
}
|
||||
|
||||
< table_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
{ ( column [ ASC | DESC ] [ ,...n ] ) }
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
]
|
||||
| FOREIGN KEY
|
||||
[ ( column [ ,...n ] ) ]
|
||||
REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( search_conditions )
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
|
||||
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
|
||||
[ WITH < index_option > [ ,...n] ]
|
||||
[ ON filegroup ]
|
||||
< index_option > :: =
|
||||
{ PAD_INDEX |
|
||||
FILLFACTOR = fillfactor |
|
||||
IGNORE_DUP_KEY |
|
||||
DROP_EXISTING |
|
||||
STATISTICS_NORECOMPUTE |
|
||||
SORT_IN_TEMPDB
|
||||
}
|
||||
*/
|
||||
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
|
||||
$clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
|
||||
|
||||
if ( is_array($flds) )
|
||||
$flds = implode(', ',$flds);
|
||||
$s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function _GetSize($ftype, $ty, $fsize, $fprec)
|
||||
{
|
||||
switch ($ftype) {
|
||||
case 'INT':
|
||||
case 'SMALLINT':
|
||||
case 'TINYINT':
|
||||
case 'BIGINT':
|
||||
return $ftype;
|
||||
}
|
||||
if ($ty == 'T') return $ftype;
|
||||
return parent::_GetSize($ftype, $ty, $fsize, $fprec);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
282
src/adodb512/datadict/datadict-mssqlnative.inc.php
Normal file
282
src/adodb512/datadict/datadict-mssqlnative.inc.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
|
||||
|
||||
Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
|
||||
whether or not they are marked as reserved in SQL Server.
|
||||
|
||||
Quoted identifiers are delimited by double quotation marks ("):
|
||||
SELECT * FROM "Blanks in Table Name"
|
||||
|
||||
Bracketed identifiers are delimited by brackets ([ ]):
|
||||
SELECT * FROM [Blanks In Table Name]
|
||||
|
||||
Quoted identifiers are valid only when the QUOTED_IDENTIFIER option is set to ON. By default,
|
||||
the Microsoft OLE DB Provider for SQL Server and SQL Server ODBC driver set QUOTED_IDENTIFIER ON
|
||||
when they connect.
|
||||
|
||||
In Transact-SQL, the option can be set at various levels using SET QUOTED_IDENTIFIER,
|
||||
the quoted identifier option of sp_dboption, or the user options option of sp_configure.
|
||||
|
||||
When SET ANSI_DEFAULTS is ON, SET QUOTED_IDENTIFIER is enabled.
|
||||
|
||||
Syntax
|
||||
|
||||
SET QUOTED_IDENTIFIER { ON | OFF }
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_mssqlnative extends ADODB_DataDict {
|
||||
var $databaseType = 'mssqlnative';
|
||||
var $dropIndex = 'DROP INDEX %2$s.%1$s';
|
||||
var $renameTable = "EXEC sp_rename '%s','%s'";
|
||||
var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
|
||||
|
||||
var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
|
||||
var $typeXL = 'TEXT';
|
||||
|
||||
//var $alterCol = ' ALTER COLUMN ';
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
$len = -1; // mysql max_length is not accurate
|
||||
switch (strtoupper($t)) {
|
||||
case 'R':
|
||||
case 'INT':
|
||||
case 'INTEGER': return 'I';
|
||||
case 'BIT':
|
||||
case 'TINYINT': return 'I1';
|
||||
case 'SMALLINT': return 'I2';
|
||||
case 'BIGINT': return 'I8';
|
||||
|
||||
case 'REAL':
|
||||
case 'FLOAT': return 'F';
|
||||
default: return parent::MetaType($t,$len,$fieldobj);
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch(strtoupper($meta)) {
|
||||
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT';
|
||||
case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle
|
||||
case 'C2': return 'NVARCHAR';
|
||||
case 'X2': return 'NTEXT';
|
||||
|
||||
case 'B': return 'IMAGE';
|
||||
|
||||
case 'D': return 'DATETIME';
|
||||
case 'T': return 'DATETIME';
|
||||
case 'L': return 'BIT';
|
||||
|
||||
case 'R':
|
||||
case 'I': return 'INT';
|
||||
case 'I1': return 'TINYINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INT';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'REAL';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname $this->addCol";
|
||||
foreach($lines as $v) {
|
||||
$f[] = "\n $v";
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
foreach($lines as $v) {
|
||||
$sql[] = "ALTER TABLE $tabname $this->alterCol $v";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
*/
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds))
|
||||
$flds = explode(',',$flds);
|
||||
$f = array();
|
||||
$s = 'ALTER TABLE ' . $tabname;
|
||||
foreach($flds as $v) {
|
||||
$f[] = "\n$this->dropCol ".$this->NameQuote($v);
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fautoinc) $suffix .= ' IDENTITY(1,1)';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
else if ($suffix == '') $suffix .= ' NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE TABLE
|
||||
[ database_name.[ owner ] . | owner. ] table_name
|
||||
( { < column_definition >
|
||||
| column_name AS computed_column_expression
|
||||
| < table_constraint > ::= [ CONSTRAINT constraint_name ] }
|
||||
|
||||
| [ { PRIMARY KEY | UNIQUE } [ ,...n ]
|
||||
)
|
||||
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
|
||||
|
||||
< column_definition > ::= { column_name data_type }
|
||||
[ COLLATE < collation_name > ]
|
||||
[ [ DEFAULT constant_expression ]
|
||||
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
|
||||
]
|
||||
[ ROWGUIDCOL]
|
||||
[ < column_constraint > ] [ ...n ]
|
||||
|
||||
< column_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ NULL | NOT NULL ]
|
||||
| [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ON {filegroup | DEFAULT} ] ]
|
||||
]
|
||||
| [ [ FOREIGN KEY ]
|
||||
REFERENCES ref_table [ ( ref_column ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( logical_expression )
|
||||
}
|
||||
|
||||
< table_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
{ ( column [ ASC | DESC ] [ ,...n ] ) }
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
]
|
||||
| FOREIGN KEY
|
||||
[ ( column [ ,...n ] ) ]
|
||||
REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( search_conditions )
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
|
||||
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
|
||||
[ WITH < index_option > [ ,...n] ]
|
||||
[ ON filegroup ]
|
||||
< index_option > :: =
|
||||
{ PAD_INDEX |
|
||||
FILLFACTOR = fillfactor |
|
||||
IGNORE_DUP_KEY |
|
||||
DROP_EXISTING |
|
||||
STATISTICS_NORECOMPUTE |
|
||||
SORT_IN_TEMPDB
|
||||
}
|
||||
*/
|
||||
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
|
||||
$clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
|
||||
|
||||
if ( is_array($flds) )
|
||||
$flds = implode(', ',$flds);
|
||||
$s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function _GetSize($ftype, $ty, $fsize, $fprec)
|
||||
{
|
||||
switch ($ftype) {
|
||||
case 'INT':
|
||||
case 'SMALLINT':
|
||||
case 'TINYINT':
|
||||
case 'BIGINT':
|
||||
return $ftype;
|
||||
}
|
||||
if ($ty == 'T') return $ftype;
|
||||
return parent::_GetSize($ftype, $ty, $fsize, $fprec);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
182
src/adodb512/datadict/datadict-mysql.inc.php
Normal file
182
src/adodb512/datadict/datadict-mysql.inc.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_mysql extends ADODB_DataDict {
|
||||
var $databaseType = 'mysql';
|
||||
var $alterCol = ' MODIFY COLUMN';
|
||||
var $alterTableAddIndex = true;
|
||||
var $dropTable = 'DROP TABLE IF EXISTS %s'; // requires mysql 3.22 or later
|
||||
|
||||
var $dropIndex = 'DROP INDEX %s ON %s';
|
||||
var $renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s'; // needs column-definition!
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
$is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
|
||||
|
||||
$len = -1; // mysql max_length is not accurate
|
||||
switch (strtoupper($t)) {
|
||||
case 'STRING':
|
||||
case 'CHAR':
|
||||
case 'VARCHAR':
|
||||
case 'TINYBLOB':
|
||||
case 'TINYTEXT':
|
||||
case 'ENUM':
|
||||
case 'SET':
|
||||
if ($len <= $this->blobSize) return 'C';
|
||||
|
||||
case 'TEXT':
|
||||
case 'LONGTEXT':
|
||||
case 'MEDIUMTEXT':
|
||||
return 'X';
|
||||
|
||||
// php_mysql extension always returns 'blob' even if 'text'
|
||||
// so we have to check whether binary...
|
||||
case 'IMAGE':
|
||||
case 'LONGBLOB':
|
||||
case 'BLOB':
|
||||
case 'MEDIUMBLOB':
|
||||
return !empty($fieldobj->binary) ? 'B' : 'X';
|
||||
|
||||
case 'YEAR':
|
||||
case 'DATE': return 'D';
|
||||
|
||||
case 'TIME':
|
||||
case 'DATETIME':
|
||||
case 'TIMESTAMP': return 'T';
|
||||
|
||||
case 'FLOAT':
|
||||
case 'DOUBLE':
|
||||
return 'F';
|
||||
|
||||
case 'INT':
|
||||
case 'INTEGER': return $is_serial ? 'R' : 'I';
|
||||
case 'TINYINT': return $is_serial ? 'R' : 'I1';
|
||||
case 'SMALLINT': return $is_serial ? 'R' : 'I2';
|
||||
case 'MEDIUMINT': return $is_serial ? 'R' : 'I4';
|
||||
case 'BIGINT': return $is_serial ? 'R' : 'I8';
|
||||
default: return 'N';
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch(strtoupper($meta)) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':return 'LONGTEXT';
|
||||
case 'X': return 'TEXT';
|
||||
|
||||
case 'C2': return 'VARCHAR';
|
||||
case 'X2': return 'LONGTEXT';
|
||||
|
||||
case 'B': return 'LONGBLOB';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'DATETIME';
|
||||
case 'L': return 'TINYINT';
|
||||
|
||||
case 'R':
|
||||
case 'I4':
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'TINYINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'DOUBLE';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($funsigned) $suffix .= ' UNSIGNED';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fautoinc) $suffix .= ' AUTO_INCREMENT';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
|
||||
[table_options] [select_statement]
|
||||
create_definition:
|
||||
col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
|
||||
[PRIMARY KEY] [reference_definition]
|
||||
or PRIMARY KEY (index_col_name,...)
|
||||
or KEY [index_name] (index_col_name,...)
|
||||
or INDEX [index_name] (index_col_name,...)
|
||||
or UNIQUE [INDEX] [index_name] (index_col_name,...)
|
||||
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
|
||||
or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
|
||||
[reference_definition]
|
||||
or CHECK (expr)
|
||||
*/
|
||||
|
||||
/*
|
||||
CREATE [UNIQUE|FULLTEXT] INDEX index_name
|
||||
ON tbl_name (col_name[(length)],... )
|
||||
*/
|
||||
|
||||
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
if ($this->alterTableAddIndex) $sql[] = "ALTER TABLE $tabname DROP INDEX $idxname";
|
||||
else $sql[] = sprintf($this->dropIndex, $idxname, $tabname);
|
||||
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if (isset($idxoptions['FULLTEXT'])) {
|
||||
$unique = ' FULLTEXT';
|
||||
} elseif (isset($idxoptions['UNIQUE'])) {
|
||||
$unique = ' UNIQUE';
|
||||
} else {
|
||||
$unique = '';
|
||||
}
|
||||
|
||||
if ( is_array($flds) ) $flds = implode(', ',$flds);
|
||||
|
||||
if ($this->alterTableAddIndex) $s = "ALTER TABLE $tabname ADD $unique INDEX $idxname ";
|
||||
else $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname;
|
||||
|
||||
$s .= ' (' . $flds . ')';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
?>
|
||||
297
src/adodb512/datadict/datadict-oci8.inc.php
Normal file
297
src/adodb512/datadict/datadict-oci8.inc.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_oci8 extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'oci8';
|
||||
var $seqField = false;
|
||||
var $seqPrefix = 'SEQ_';
|
||||
var $dropTable = "DROP TABLE %s CASCADE CONSTRAINTS";
|
||||
var $trigPrefix = 'TRIG_';
|
||||
var $alterCol = ' MODIFY ';
|
||||
var $typeX = 'VARCHAR(4000)';
|
||||
var $typeXL = 'CLOB';
|
||||
|
||||
function MetaType($t,$len=-1)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
switch (strtoupper($t)) {
|
||||
case 'VARCHAR':
|
||||
case 'VARCHAR2':
|
||||
case 'CHAR':
|
||||
case 'VARBINARY':
|
||||
case 'BINARY':
|
||||
if (isset($this) && $len <= $this->blobSize) return 'C';
|
||||
return 'X';
|
||||
|
||||
case 'NCHAR':
|
||||
case 'NVARCHAR2':
|
||||
case 'NVARCHAR':
|
||||
if (isset($this) && $len <= $this->blobSize) return 'C2';
|
||||
return 'X2';
|
||||
|
||||
case 'NCLOB':
|
||||
case 'CLOB':
|
||||
return 'XL';
|
||||
|
||||
case 'LONG RAW':
|
||||
case 'LONG VARBINARY':
|
||||
case 'BLOB':
|
||||
return 'B';
|
||||
|
||||
case 'TIMESTAMP':
|
||||
return 'TS';
|
||||
|
||||
case 'DATE':
|
||||
return 'T';
|
||||
|
||||
case 'INT':
|
||||
case 'SMALLINT':
|
||||
case 'INTEGER':
|
||||
return 'I';
|
||||
|
||||
default:
|
||||
return 'N';
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'X': return $this->typeX;
|
||||
case 'XL': return $this->typeXL;
|
||||
|
||||
case 'C2': return 'NVARCHAR2';
|
||||
case 'X2': return 'NVARCHAR2(4000)';
|
||||
|
||||
case 'B': return 'BLOB';
|
||||
|
||||
case 'TS':
|
||||
return 'TIMESTAMP';
|
||||
|
||||
case 'D':
|
||||
case 'T': return 'DATE';
|
||||
case 'L': return 'NUMBER(1)';
|
||||
case 'I1': return 'NUMBER(3)';
|
||||
case 'I2': return 'NUMBER(5)';
|
||||
case 'I':
|
||||
case 'I4': return 'NUMBER(10)';
|
||||
|
||||
case 'I8': return 'NUMBER(20)';
|
||||
case 'F': return 'NUMBER';
|
||||
case 'N': return 'NUMBER';
|
||||
case 'R': return 'NUMBER(20)';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function CreateDatabase($dbname, $options=false)
|
||||
{
|
||||
$options = $this->_Options($options);
|
||||
$password = isset($options['PASSWORD']) ? $options['PASSWORD'] : 'tiger';
|
||||
$tablespace = isset($options["TABLESPACE"]) ? " DEFAULT TABLESPACE ".$options["TABLESPACE"] : '';
|
||||
$sql[] = "CREATE USER ".$dbname." IDENTIFIED BY ".$password.$tablespace;
|
||||
$sql[] = "GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO $dbname";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname ADD (";
|
||||
foreach($lines as $v) {
|
||||
$f[] = "\n $v";
|
||||
}
|
||||
|
||||
$s .= implode(', ',$f).')';
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname MODIFY(";
|
||||
foreach($lines as $v) {
|
||||
$f[] = "\n $v";
|
||||
}
|
||||
$s .= implode(', ',$f).')';
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v);
|
||||
|
||||
$sql = array();
|
||||
$s = "ALTER TABLE $tabname DROP(";
|
||||
$s .= implode(', ',$flds).') CASCADE CONSTRAINTS';
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function _DropAutoIncrement($t)
|
||||
{
|
||||
if (strpos($t,'.') !== false) {
|
||||
$tarr = explode('.',$t);
|
||||
return "drop sequence ".$tarr[0].".seq_".$tarr[1];
|
||||
}
|
||||
return "drop sequence seq_".$t;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
|
||||
if ($fdefault == "''" && $fnotnull) {// this is null in oracle
|
||||
$fnotnull = false;
|
||||
if ($this->debug) ADOConnection::outp("NOT NULL and DEFAULT='' illegal in Oracle");
|
||||
}
|
||||
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
|
||||
if ($fautoinc) $this->seqField = $fname;
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE or replace TRIGGER jaddress_insert
|
||||
before insert on jaddress
|
||||
for each row
|
||||
begin
|
||||
select seqaddress.nextval into :new.A_ID from dual;
|
||||
end;
|
||||
*/
|
||||
function _Triggers($tabname,$tableoptions)
|
||||
{
|
||||
if (!$this->seqField) return array();
|
||||
|
||||
if ($this->schema) {
|
||||
$t = strpos($tabname,'.');
|
||||
if ($t !== false) $tab = substr($tabname,$t+1);
|
||||
else $tab = $tabname;
|
||||
$seqname = $this->schema.'.'.$this->seqPrefix.$tab;
|
||||
$trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab;
|
||||
} else {
|
||||
$seqname = $this->seqPrefix.$tabname;
|
||||
$trigname = $this->trigPrefix.$seqname;
|
||||
}
|
||||
|
||||
if (strlen($seqname) > 30) {
|
||||
$seqname = $this->seqPrefix.uniqid('');
|
||||
} // end if
|
||||
if (strlen($trigname) > 30) {
|
||||
$trigname = $this->trigPrefix.uniqid('');
|
||||
} // end if
|
||||
|
||||
if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
|
||||
$seqCache = '';
|
||||
if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];}
|
||||
$seqIncr = '';
|
||||
if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];}
|
||||
$seqStart = '';
|
||||
if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];}
|
||||
$sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache";
|
||||
$sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;";
|
||||
|
||||
$this->seqField = false;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
|
||||
[table_options] [select_statement]
|
||||
create_definition:
|
||||
col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
|
||||
[PRIMARY KEY] [reference_definition]
|
||||
or PRIMARY KEY (index_col_name,...)
|
||||
or KEY [index_name] (index_col_name,...)
|
||||
or INDEX [index_name] (index_col_name,...)
|
||||
or UNIQUE [INDEX] [index_name] (index_col_name,...)
|
||||
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
|
||||
or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
|
||||
[reference_definition]
|
||||
or CHECK (expr)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function _IndexSQL($idxname, $tabname, $flds,$idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if (isset($idxoptions['BITMAP'])) {
|
||||
$unique = ' BITMAP';
|
||||
} elseif (isset($idxoptions['UNIQUE'])) {
|
||||
$unique = ' UNIQUE';
|
||||
} else {
|
||||
$unique = '';
|
||||
}
|
||||
|
||||
if ( is_array($flds) )
|
||||
$flds = implode(', ',$flds);
|
||||
$s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
if (isset($idxoptions['oci8']))
|
||||
$s .= $idxoptions['oci8'];
|
||||
|
||||
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function GetCommentSQL($table,$col)
|
||||
{
|
||||
$table = $this->connection->qstr($table);
|
||||
$col = $this->connection->qstr($col);
|
||||
return "select comments from USER_COL_COMMENTS where TABLE_NAME=$table and COLUMN_NAME=$col";
|
||||
}
|
||||
|
||||
function SetCommentSQL($table,$col,$cmt)
|
||||
{
|
||||
$cmt = $this->connection->qstr($cmt);
|
||||
return "COMMENT ON COLUMN $table.$col IS $cmt";
|
||||
}
|
||||
}
|
||||
?>
|
||||
448
src/adodb512/datadict/datadict-postgres.inc.php
Normal file
448
src/adodb512/datadict/datadict-postgres.inc.php
Normal file
@@ -0,0 +1,448 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_postgres extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'postgres';
|
||||
var $seqField = false;
|
||||
var $seqPrefix = 'SEQ_';
|
||||
var $addCol = ' ADD COLUMN';
|
||||
var $quote = '"';
|
||||
var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
|
||||
var $dropTable = 'DROP TABLE %s CASCADE';
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
$is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique &&
|
||||
$fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval(';
|
||||
|
||||
switch (strtoupper($t)) {
|
||||
case 'INTERVAL':
|
||||
case 'CHAR':
|
||||
case 'CHARACTER':
|
||||
case 'VARCHAR':
|
||||
case 'NAME':
|
||||
case 'BPCHAR':
|
||||
if ($len <= $this->blobSize) return 'C';
|
||||
|
||||
case 'TEXT':
|
||||
return 'X';
|
||||
|
||||
case 'IMAGE': // user defined type
|
||||
case 'BLOB': // user defined type
|
||||
case 'BIT': // This is a bit string, not a single bit, so don't return 'L'
|
||||
case 'VARBIT':
|
||||
case 'BYTEA':
|
||||
return 'B';
|
||||
|
||||
case 'BOOL':
|
||||
case 'BOOLEAN':
|
||||
return 'L';
|
||||
|
||||
case 'DATE':
|
||||
return 'D';
|
||||
|
||||
case 'TIME':
|
||||
case 'DATETIME':
|
||||
case 'TIMESTAMP':
|
||||
case 'TIMESTAMPTZ':
|
||||
return 'T';
|
||||
|
||||
case 'INTEGER': return !$is_serial ? 'I' : 'R';
|
||||
case 'SMALLINT':
|
||||
case 'INT2': return !$is_serial ? 'I2' : 'R';
|
||||
case 'INT4': return !$is_serial ? 'I4' : 'R';
|
||||
case 'BIGINT':
|
||||
case 'INT8': return !$is_serial ? 'I8' : 'R';
|
||||
|
||||
case 'OID':
|
||||
case 'SERIAL':
|
||||
return 'R';
|
||||
|
||||
case 'FLOAT4':
|
||||
case 'FLOAT8':
|
||||
case 'DOUBLE PRECISION':
|
||||
case 'REAL':
|
||||
return 'F';
|
||||
|
||||
default:
|
||||
return 'N';
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'TEXT';
|
||||
|
||||
case 'C2': return 'VARCHAR';
|
||||
case 'X2': return 'TEXT';
|
||||
|
||||
case 'B': return 'BYTEA';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'BOOLEAN';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'SMALLINT';
|
||||
case 'I2': return 'INT2';
|
||||
case 'I4': return 'INT4';
|
||||
case 'I8': return 'INT8';
|
||||
|
||||
case 'F': return 'FLOAT8';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a new Column
|
||||
*
|
||||
* reimplementation of the default function as postgres does NOT allow to set the default in the same statement
|
||||
*
|
||||
* @param string $tabname table-name
|
||||
* @param string $flds column-names and types for the changed columns
|
||||
* @return array with SQL strings
|
||||
*/
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
|
||||
foreach($lines as $v) {
|
||||
if (($not_null = preg_match('/NOT NULL/i',$v))) {
|
||||
$v = preg_replace('/NOT NULL/i','',$v);
|
||||
}
|
||||
if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
|
||||
list(,$colname,$default) = $matches;
|
||||
$sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
|
||||
$sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
|
||||
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
|
||||
} else {
|
||||
$sql[] = $alter . $v;
|
||||
}
|
||||
if ($not_null) {
|
||||
list($colname) = explode(' ',$v);
|
||||
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function DropIndexSQL ($idxname, $tabname = NULL)
|
||||
{
|
||||
return array(sprintf($this->dropIndex, $this->TableName($idxname), $this->TableName($tabname)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the definition of one column
|
||||
*
|
||||
* Postgres can't do that on it's own, you need to supply the complete defintion of the new table,
|
||||
* to allow, recreating the table and copying the content over to the new table
|
||||
* @param string $tabname table-name
|
||||
* @param string $flds column-name and type for the changed column
|
||||
* @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
|
||||
* @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
|
||||
* @return array with SQL strings
|
||||
*/
|
||||
/*
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if (!$tableflds) {
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
|
||||
return array();
|
||||
}
|
||||
return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
|
||||
}*/
|
||||
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
// Check if alter single column datatype available - works with 8.0+
|
||||
$has_alter_column = 8.0 <= (float) @$this->serverInfo['version'];
|
||||
|
||||
if ($has_alter_column) {
|
||||
$tabname = $this->TableName($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
|
||||
foreach($lines as $v) {
|
||||
if ($not_null = preg_match('/NOT NULL/i',$v)) {
|
||||
$v = preg_replace('/NOT NULL/i','',$v);
|
||||
}
|
||||
// this next block doesn't work - there is no way that I can see to
|
||||
// explicitly ask a column to be null using $flds
|
||||
else if ($set_null = preg_match('/NULL/i',$v)) {
|
||||
// if they didn't specify not null, see if they explicitely asked for null
|
||||
$v = preg_replace('/\sNULL/i','',$v);
|
||||
}
|
||||
|
||||
if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
|
||||
list(,$colname,$default) = $matches;
|
||||
$v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
|
||||
$sql[] = $alter . $colname . ' TYPE ' . str_replace('DEFAULT '.$default,'',$v);
|
||||
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
|
||||
}
|
||||
else {
|
||||
// drop default?
|
||||
preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches);
|
||||
list (,$colname,$rest) = $matches;
|
||||
$sql[] = $alter . $colname . ' TYPE ' . $rest;
|
||||
}
|
||||
|
||||
list($colname) = explode(' ',$v);
|
||||
if ($not_null) {
|
||||
// this does not error out if the column is already not null
|
||||
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
|
||||
}
|
||||
if ($set_null) {
|
||||
// this does not error out if the column is already null
|
||||
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' DROP NOT NULL';
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// does not have alter column
|
||||
if (!$tableflds) {
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
|
||||
return array();
|
||||
}
|
||||
return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop one column
|
||||
*
|
||||
* Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table,
|
||||
* to allow, recreating the table and copying the content over to the new table
|
||||
* @param string $tabname table-name
|
||||
* @param string $flds column-name and type for the changed column
|
||||
* @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
|
||||
* @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
|
||||
* @return array with SQL strings
|
||||
*/
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
$has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
|
||||
if (!$has_drop_column && !$tableflds) {
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
|
||||
return array();
|
||||
}
|
||||
if ($has_drop_column) {
|
||||
return ADODB_DataDict::DropColumnSQL($tabname, $flds);
|
||||
}
|
||||
return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the content into a temp. table, drop and recreate the original table and copy the content back in
|
||||
*
|
||||
* We also take care to set the values of the sequenz and recreate the indexes.
|
||||
* All this is done in a transaction, to not loose the content of the table, if something went wrong!
|
||||
* @internal
|
||||
* @param string $tabname table-name
|
||||
* @param string $dropflds column-names to drop
|
||||
* @param string $tableflds complete defintion of the new table, eg. for postgres
|
||||
* @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
|
||||
* @return array with SQL strings
|
||||
*/
|
||||
function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
|
||||
{
|
||||
if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
|
||||
$copyflds = array();
|
||||
foreach($this->MetaColumns($tabname) as $fld) {
|
||||
if (!$dropflds || !in_array($fld->name,$dropflds)) {
|
||||
// we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
|
||||
if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
|
||||
in_array($fld->type,array('varchar','char','text','bytea'))) {
|
||||
$copyflds[] = "to_number($fld->name,'S9999999999999D99')";
|
||||
} else {
|
||||
$copyflds[] = $fld->name;
|
||||
}
|
||||
// identify the sequence name and the fld its on
|
||||
if ($fld->primary_key && $fld->has_default &&
|
||||
preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) {
|
||||
$seq_name = $matches[1];
|
||||
$seq_fld = $fld->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$copyflds = implode(', ',$copyflds);
|
||||
|
||||
$tempname = $tabname.'_tmp';
|
||||
$aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
|
||||
$aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
|
||||
$aSql = array_merge($aSql,$this->DropTableSQL($tabname));
|
||||
$aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
|
||||
$aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
|
||||
if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again
|
||||
$seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
|
||||
$aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
|
||||
}
|
||||
$aSql[] = "DROP TABLE $tempname";
|
||||
// recreate the indexes, if they not contain one of the droped columns
|
||||
foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
|
||||
{
|
||||
if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
|
||||
$aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
|
||||
$idx_data['unique'] ? array('UNIQUE') : False));
|
||||
}
|
||||
}
|
||||
$aSql[] = 'COMMIT';
|
||||
return $aSql;
|
||||
}
|
||||
|
||||
function DropTableSQL($tabname)
|
||||
{
|
||||
$sql = ADODB_DataDict::DropTableSQL($tabname);
|
||||
|
||||
$drop_seq = $this->_DropAutoIncrement($tabname);
|
||||
if ($drop_seq) $sql[] = $drop_seq;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
if ($fautoinc) {
|
||||
$ftype = 'SERIAL';
|
||||
return '';
|
||||
}
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
// search for a sequece for the given table (asumes the seqence-name contains the table-name!)
|
||||
// if yes return sql to drop it
|
||||
// this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!!
|
||||
function _DropAutoIncrement($tabname)
|
||||
{
|
||||
$tabname = $this->connection->quote('%'.$tabname.'%');
|
||||
|
||||
$seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
|
||||
|
||||
// check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly
|
||||
if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
|
||||
return False;
|
||||
}
|
||||
return "DROP SEQUENCE ".$seq;
|
||||
}
|
||||
|
||||
function RenameTableSQL($tabname,$newname)
|
||||
{
|
||||
if (!empty($this->schema)) {
|
||||
$rename_from = $this->TableName($tabname);
|
||||
$schema_save = $this->schema;
|
||||
$this->schema = false;
|
||||
$rename_to = $this->TableName($newname);
|
||||
$this->schema = $schema_save;
|
||||
return array (sprintf($this->renameTable, $rename_from, $rename_to));
|
||||
}
|
||||
|
||||
return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
|
||||
{ column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ]
|
||||
| table_constraint } [, ... ]
|
||||
)
|
||||
[ INHERITS ( parent_table [, ... ] ) ]
|
||||
[ WITH OIDS | WITHOUT OIDS ]
|
||||
where column_constraint is:
|
||||
[ CONSTRAINT constraint_name ]
|
||||
{ NOT NULL | NULL | UNIQUE | PRIMARY KEY |
|
||||
CHECK (expression) |
|
||||
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ]
|
||||
[ ON DELETE action ] [ ON UPDATE action ] }
|
||||
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
|
||||
and table_constraint is:
|
||||
[ CONSTRAINT constraint_name ]
|
||||
{ UNIQUE ( column_name [, ... ] ) |
|
||||
PRIMARY KEY ( column_name [, ... ] ) |
|
||||
CHECK ( expression ) |
|
||||
FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
|
||||
[ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] }
|
||||
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
CREATE [ UNIQUE ] INDEX index_name ON table
|
||||
[ USING acc_method ] ( column [ ops_name ] [, ...] )
|
||||
[ WHERE predicate ]
|
||||
CREATE [ UNIQUE ] INDEX index_name ON table
|
||||
[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
|
||||
[ WHERE predicate ]
|
||||
*/
|
||||
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
|
||||
|
||||
$s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
|
||||
|
||||
if (isset($idxoptions['HASH']))
|
||||
$s .= 'USING HASH ';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
if ( is_array($flds) )
|
||||
$flds = implode(', ',$flds);
|
||||
$s .= '(' . $flds . ')';
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function _GetSize($ftype, $ty, $fsize, $fprec)
|
||||
{
|
||||
if (strlen($fsize) && $ty != 'X' && $ty != 'B' && $ty != 'I' && strpos($ftype,'(') === false) {
|
||||
$ftype .= "(".$fsize;
|
||||
if (strlen($fprec)) $ftype .= ",".$fprec;
|
||||
$ftype .= ')';
|
||||
}
|
||||
return $ftype;
|
||||
}
|
||||
}
|
||||
?>
|
||||
122
src/adodb512/datadict/datadict-sapdb.inc.php
Normal file
122
src/adodb512/datadict/datadict-sapdb.inc.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V4.50 6 July 2004 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_sapdb extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'sapdb';
|
||||
var $seqField = false;
|
||||
var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'LONG';
|
||||
|
||||
case 'C2': return 'VARCHAR UNICODE';
|
||||
case 'X2': return 'LONG UNICODE';
|
||||
|
||||
case 'B': return 'LONG';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'TS':
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'BOOLEAN';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'FIXED(3)';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'FIXED(20)';
|
||||
|
||||
case 'F': return 'FLOAT(38)';
|
||||
case 'N': return 'FIXED';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
static $maxdb_type2adodb = array(
|
||||
'VARCHAR' => 'C',
|
||||
'CHARACTER' => 'C',
|
||||
'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
|
||||
'DATE' => 'D',
|
||||
'TIMESTAMP' => 'T',
|
||||
'BOOLEAN' => 'L',
|
||||
'INTEGER' => 'I4',
|
||||
'SMALLINT' => 'I2',
|
||||
'FLOAT' => 'F',
|
||||
'FIXED' => 'N',
|
||||
);
|
||||
$type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
|
||||
|
||||
// convert integer-types simulated with fixed back to integer
|
||||
if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
|
||||
$type = $len == 20 ? 'I8' : 'I1';
|
||||
}
|
||||
if ($fieldobj->auto_increment) $type = 'R';
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($funsigned) $suffix .= ' UNSIGNED';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
|
||||
elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
foreach($flds as $k => $v) {
|
||||
$flds[$k] = $this->NameQuote($v);
|
||||
}
|
||||
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
89
src/adodb512/datadict/datadict-sqlite.inc.php
Normal file
89
src/adodb512/datadict/datadict-sqlite.inc.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
SQLite datadict Andrei Besleaga
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_sqlite extends ADODB_DataDict {
|
||||
var $databaseType = 'sqlite';
|
||||
var $seqField = false;
|
||||
var $addCol=' ADD COLUMN';
|
||||
var $dropTable = 'DROP TABLE IF EXISTS %s';
|
||||
var $dropIndex = 'DROP INDEX IF EXISTS %s';
|
||||
var $renameTable = 'ALTER TABLE %s RENAME TO %s';
|
||||
|
||||
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch(strtoupper($meta)) {
|
||||
case 'C': return 'VARCHAR'; // TEXT , TEXT affinity
|
||||
case 'XL':return 'LONGTEXT'; // TEXT , TEXT affinity
|
||||
case 'X': return 'TEXT'; // TEXT , TEXT affinity
|
||||
|
||||
case 'C2': return 'VARCHAR'; // TEXT , TEXT affinity
|
||||
case 'X2': return 'LONGTEXT'; // TEXT , TEXT affinity
|
||||
|
||||
case 'B': return 'LONGBLOB'; // TEXT , NONE affinity , BLOB
|
||||
|
||||
case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
|
||||
case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
|
||||
case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
|
||||
|
||||
case 'R':
|
||||
case 'I4':
|
||||
case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
|
||||
case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
|
||||
case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
|
||||
case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
|
||||
|
||||
case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
|
||||
case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($funsigned) $suffix .= ' UNSIGNED';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fautoinc) $suffix .= ' AUTOINCREMENT';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
|
||||
return array();
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
|
||||
return array();
|
||||
}
|
||||
|
||||
function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
229
src/adodb512/datadict/datadict-sybase.inc.php
Normal file
229
src/adodb512/datadict/datadict-sybase.inc.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_sybase extends ADODB_DataDict {
|
||||
var $databaseType = 'sybase';
|
||||
|
||||
var $dropIndex = 'DROP INDEX %2$s.%1$s';
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
$len = -1; // mysql max_length is not accurate
|
||||
switch (strtoupper($t)) {
|
||||
|
||||
case 'INT':
|
||||
case 'INTEGER': return 'I';
|
||||
case 'BIT':
|
||||
case 'TINYINT': return 'I1';
|
||||
case 'SMALLINT': return 'I2';
|
||||
case 'BIGINT': return 'I8';
|
||||
|
||||
case 'REAL':
|
||||
case 'FLOAT': return 'F';
|
||||
default: return parent::MetaType($t,$len,$fieldobj);
|
||||
}
|
||||
}
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch(strtoupper($meta)) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'TEXT';
|
||||
|
||||
case 'C2': return 'NVARCHAR';
|
||||
case 'X2': return 'NTEXT';
|
||||
|
||||
case 'B': return 'IMAGE';
|
||||
|
||||
case 'D': return 'DATETIME';
|
||||
case 'TS':
|
||||
case 'T': return 'DATETIME';
|
||||
case 'L': return 'BIT';
|
||||
|
||||
case 'I': return 'INT';
|
||||
case 'I1': return 'TINYINT';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INT';
|
||||
case 'I8': return 'BIGINT';
|
||||
|
||||
case 'F': return 'REAL';
|
||||
case 'N': return 'NUMERIC';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname $this->addCol";
|
||||
foreach($lines as $v) {
|
||||
$f[] = "\n $v";
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
foreach($lines as $v) {
|
||||
$sql[] = "ALTER TABLE $tabname $this->alterCol $v";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
$f = array();
|
||||
$s = "ALTER TABLE $tabname";
|
||||
foreach($flds as $v) {
|
||||
$f[] = "\n$this->dropCol ".$this->NameQuote($v);
|
||||
}
|
||||
$s .= implode(', ',$f);
|
||||
$sql[] = $s;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fautoinc) $suffix .= ' DEFAULT AUTOINCREMENT';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
else if ($suffix == '') $suffix .= ' NULL';
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
/*
|
||||
CREATE TABLE
|
||||
[ database_name.[ owner ] . | owner. ] table_name
|
||||
( { < column_definition >
|
||||
| column_name AS computed_column_expression
|
||||
| < table_constraint > ::= [ CONSTRAINT constraint_name ] }
|
||||
|
||||
| [ { PRIMARY KEY | UNIQUE } [ ,...n ]
|
||||
)
|
||||
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
|
||||
|
||||
< column_definition > ::= { column_name data_type }
|
||||
[ COLLATE < collation_name > ]
|
||||
[ [ DEFAULT constant_expression ]
|
||||
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
|
||||
]
|
||||
[ ROWGUIDCOL]
|
||||
[ < column_constraint > ] [ ...n ]
|
||||
|
||||
< column_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ NULL | NOT NULL ]
|
||||
| [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ON {filegroup | DEFAULT} ] ]
|
||||
]
|
||||
| [ [ FOREIGN KEY ]
|
||||
REFERENCES ref_table [ ( ref_column ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( logical_expression )
|
||||
}
|
||||
|
||||
< table_constraint > ::= [ CONSTRAINT constraint_name ]
|
||||
{ [ { PRIMARY KEY | UNIQUE }
|
||||
[ CLUSTERED | NONCLUSTERED ]
|
||||
{ ( column [ ASC | DESC ] [ ,...n ] ) }
|
||||
[ WITH FILLFACTOR = fillfactor ]
|
||||
[ ON { filegroup | DEFAULT } ]
|
||||
]
|
||||
| FOREIGN KEY
|
||||
[ ( column [ ,...n ] ) ]
|
||||
REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
|
||||
[ ON DELETE { CASCADE | NO ACTION } ]
|
||||
[ ON UPDATE { CASCADE | NO ACTION } ]
|
||||
[ NOT FOR REPLICATION ]
|
||||
| CHECK [ NOT FOR REPLICATION ]
|
||||
( search_conditions )
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
|
||||
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
|
||||
[ WITH < index_option > [ ,...n] ]
|
||||
[ ON filegroup ]
|
||||
< index_option > :: =
|
||||
{ PAD_INDEX |
|
||||
FILLFACTOR = fillfactor |
|
||||
IGNORE_DUP_KEY |
|
||||
DROP_EXISTING |
|
||||
STATISTICS_NORECOMPUTE |
|
||||
SORT_IN_TEMPDB
|
||||
}
|
||||
*/
|
||||
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
|
||||
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
|
||||
if ( isset($idxoptions['DROP']) )
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if ( empty ($flds) ) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
|
||||
$clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
|
||||
|
||||
if ( is_array($flds) )
|
||||
$flds = implode(', ',$flds);
|
||||
$s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
|
||||
|
||||
if ( isset($idxoptions[$this->upperName]) )
|
||||
$s .= $idxoptions[$this->upperName];
|
||||
|
||||
$sql[] = $s;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
?>
|
||||
1090
src/adodb512/docs/docs-active-record.htm
Normal file
1090
src/adodb512/docs/docs-active-record.htm
Normal file
File diff suppressed because it is too large
Load Diff
7796
src/adodb512/docs/docs-adodb.htm
Normal file
7796
src/adodb512/docs/docs-adodb.htm
Normal file
File diff suppressed because it is too large
Load Diff
330
src/adodb512/docs/docs-datadict.htm
Normal file
330
src/adodb512/docs/docs-datadict.htm
Normal file
@@ -0,0 +1,330 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>ADOdb Data Dictionary Manual</title>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<style type="text/css">
|
||||
body, td {
|
||||
/*font-family: Arial, Helvetica, sans-serif;*/
|
||||
font-size: 11pt;
|
||||
}
|
||||
pre {
|
||||
font-size: 9pt;
|
||||
background-color: #EEEEEE; padding: .5em; margin: 0px;
|
||||
}
|
||||
.toplink {
|
||||
font-size: 8pt;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: rgb(255, 255, 255);">
|
||||
<h2>ADOdb Data Dictionary Library for PHP</h2>
|
||||
<p>V5.06 16 Oct 2008 (c) 2000-2010 John Lim (<a
|
||||
href="mailto:jlim#natsoft.com">jlim#natsoft.com</a>).<br>
|
||||
AXMLS (c) 2004 ars Cognita, Inc</p>
|
||||
<p><font size="1">This software is dual licensed using BSD-Style and
|
||||
LGPL. This means you can use it in compiled proprietary and commercial
|
||||
products.</font></p>
|
||||
|
||||
<p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
|
||||
<a href="http://adodb.sourceforge.net/#docs">Other Docs</a>
|
||||
</p>
|
||||
<p>This documentation describes a PHP class library to automate the
|
||||
creation of tables, indexes and foreign key constraints portably for
|
||||
multiple databases. Richard Tango-Lowy and Dan Cech have been kind
|
||||
enough to contribute <a href="#xmlschema">AXMLS</a>, an XML schema
|
||||
system for defining databases. You can contact them at
|
||||
dcech#phpwerx.net and richtl#arscognita.com.</p>
|
||||
<p>Currently the following databases are supported:</p>
|
||||
<p> <b>Well-tested:</b> PostgreSQL, MySQL, Oracle, MSSQL.<br>
|
||||
<b>Beta-quality:</b> DB2, Informix, Sybase, Interbase, Firebird, SQLite.<br>
|
||||
<b>Alpha-quality:</b> MS Access (does not support DEFAULT values) and
|
||||
generic ODBC.
|
||||
</p>
|
||||
<h3>Example Usage</h3>
|
||||
<pre> include_once('adodb.inc.php');<br> <font color="#006600"># First create a normal connection</font><br> $db = NewADOConnection('mysql');<br> $db->Connect(...);<br><br> <font
|
||||
color="#006600"># Then create a data dictionary object, using this connection</font><br> $dict = <strong>NewDataDictionary</strong>($db);<br><br> <font
|
||||
color="#006600"># We have a portable declarative data dictionary format in ADOdb, similar to SQL.<br> # Field types use 1 character codes, and fields are separated by commas.<br> # The following example creates three fields: "col1", "col2" and "col3":</font><br> $flds = " <br> <font
|
||||
color="#663300"><strong> col1 C(32) NOTNULL DEFAULT 'abc',<br> col2 I DEFAULT 0,<br> col3 N(12.2)</strong></font><br> ";<br><br> <font
|
||||
color="#006600"># We demonstrate creating tables and indexes</font><br> $sqlarray = $dict-><strong>CreateTableSQL</strong>($tabname, $flds, $taboptarray);<br> $dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br><br> $idxflds = 'co11, col2';<br> $sqlarray = $dict-><strong>CreateIndexSQL</strong>($idxname, $tabname, $idxflds);<br> $dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br></pre>
|
||||
<h3>More Complex Table Sample</h3>
|
||||
<p>
|
||||
The following string will create a table with a primary key event_id and multiple indexes, including one compound index idx_ev1. The ability to define indexes using the INDEX keyword was added in ADOdb 4.94 by Gaetano Giunta.
|
||||
<pre>
|
||||
$flds = "
|
||||
event_id I(11) NOTNULL AUTOINCREMENT PRIMARY,
|
||||
event_type I(4) NOTNULL <b>INDEX idx_evt</b>,
|
||||
event_start_date T DEFAULT NULL <b>INDEX id_esd</b>,
|
||||
event_end_date T DEFAULT '0000-00-00 00:00:00' <b>INDEX id_eted</b>,
|
||||
event_parent I(11) UNSIGNED NOTNULL DEFAULT 0 <b>INDEX id_evp</b>,
|
||||
event_owner I(11) DEFAULT 0 <b>INDEX idx_ev1</b>,
|
||||
event_project I(11) DEFAULT 0 <b>INDEX idx_ev1</b>,
|
||||
event_times_recuring I(11) UNSIGNED NOTNULL DEFAULT 0,
|
||||
event_icon C(20) DEFAULT 'obj/event',
|
||||
event_description X
|
||||
";
|
||||
$sqlarray = $db-><b>CreateTableSQL</b>($tablename, $flds);
|
||||
$dict-><b>ExecuteSQLArray</b>($sqlarray);
|
||||
</pre>
|
||||
<h3>Class Factory</h3>
|
||||
<h4>NewDataDictionary($connection, $drivername=false)</h4>
|
||||
<p>Creates a new data dictionary object. You pass a database connection object in $connection. The $connection does not have to be actually connected to the database. Some database connection objects are generic (eg. odbtp and odbc). Since 4.53, you can tell ADOdb the actual database with $drivername. E.g.</p>
|
||||
<pre>
|
||||
$db = NewADOConnection('odbtp');
|
||||
$datadict = NewDataDictionary($db, 'mssql'); # force mssql
|
||||
</pre>
|
||||
<h3>Class Functions</h3>
|
||||
<h4>function CreateDatabase($dbname, $optionsarray=false)</h4>
|
||||
<p>Create a database with the name $dbname;</p>
|
||||
<h4>function CreateTableSQL($tabname, $fldarray, $taboptarray=false)</h4>
|
||||
<pre> RETURNS: an array of strings, the sql to be executed, or false<br> $tabname: name of table<br> $fldarray: string (or array) containing field info<br> $taboptarray: array containing table options<br></pre>
|
||||
<p>The new format of $fldarray uses a free text format, where each
|
||||
field is comma-delimited.
|
||||
The first token for each field is the field name, followed by the type
|
||||
and optional
|
||||
field size. Then optional keywords in $otheroptions:</p>
|
||||
<pre> "$fieldname $type $colsize $otheroptions"</pre>
|
||||
<p>The older (and still supported) format of $fldarray is a
|
||||
2-dimensional array, where each row in the 1st dimension represents one
|
||||
field. Each row has this format:</p>
|
||||
<pre> array($fieldname, $type, [,$colsize] [,$otheroptions]*)</pre>
|
||||
<p>The first 2 fields must be the field name and the field type. The
|
||||
field type can be a portable type codes or the actual type for that
|
||||
database.</p>
|
||||
<p>Legal portable type codes include:</p>
|
||||
<pre> C: Varchar, capped to 255 characters.<br> X: Larger varchar, capped to 4000 characters (to be compatible with Oracle). <br> XL: For Oracle, returns CLOB, otherwise the largest varchar size.<br><br> C2: Multibyte varchar<br> X2: Multibyte varchar (largest size)<br><br> B: BLOB (binary large object)<br><br> D: Date (some databases do not support this, and we return a datetime type)<br> T: Datetime or Timestamp accurate to the second.<br> TS: Datetime or Timestamp supporting Sub-second accuracy.<br> Supported by Oracle, PostgreSQL and SQL Server currently. <br> Otherwise equivalent to T.<br>
|
||||
L: Integer field suitable for storing booleans (0 or 1)<br> I: Integer (mapped to I4)<br> I1: 1-byte integer<br> I2: 2-byte integer<br> I4: 4-byte integer<br> I8: 8-byte integer<br> F: Floating point number<br> N: Numeric or decimal number<br></pre>
|
||||
<p>The $colsize field represents the size of the field. If a decimal
|
||||
number is used, then it is assumed that the number following the dot is
|
||||
the precision, so 6.2 means a number of size 6 digits and 2 decimal
|
||||
places. It is recommended that the default for number types be
|
||||
represented as a string to avoid any rounding errors.</p>
|
||||
<p>The $otheroptions include the following keywords (case-insensitive):</p>
|
||||
<pre> AUTO For autoincrement number. Emulated with triggers if not available.<br> Sets NOTNULL also.<br> AUTOINCREMENT Same as auto.<br> KEY Primary key field. Sets NOTNULL also. Compound keys are supported.<br> PRIMARY Same as KEY.<br> DEF Synonym for DEFAULT for lazy typists.<br> DEFAULT The default value. Character strings are auto-quoted unless<br> the string begins and ends with spaces, eg ' SYSDATE '.<br> NOTNULL If field is not null.<br> DEFDATE Set default value to call function to get today's date.<br> DEFTIMESTAMP Set default to call function to get today's datetime.<br> NOQUOTE Prevents autoquoting of default string values.<br> CONSTRAINTS Additional constraints defined at the end of the field<br> definition.<br></pre>
|
||||
<p>The Data Dictonary accepts two formats, the older array
|
||||
specification:</p>
|
||||
<pre> $flds = array(<br> array('COLNAME', 'DECIMAL', '8.4', 'DEFAULT' =gt; 0, 'NOTNULL'),<br> array('id', 'I' , 'AUTO'),<br> array('`MY DATE`', 'D' , 'DEFDATE'),<br> array('NAME', 'C' , '32', 'CONSTRAINTS' =gt; 'FOREIGN KEY REFERENCES reftable')<br> );<br></pre>
|
||||
<p>Or the simpler declarative format:</p>
|
||||
<pre> $flds = "<font color="#660000"><strong><br> COLNAME DECIMAL(8.4) DEFAULT 0 NOTNULL,<br> id I AUTO,<br> `MY DATE` D DEFDATE,<br> NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable'</strong></font><br> ";<br></pre>
|
||||
<p>Note that if you have special characters in the field name (e.g. My
|
||||
Date), you should enclose it in back-quotes. Normally field names are
|
||||
not case-sensitive, but if you enclose it in back-quotes, some
|
||||
databases will treat the names as case-sensitive (eg. Oracle) , and
|
||||
others won't. So be careful.</p>
|
||||
<p>The $taboptarray is the 3rd parameter of the CreateTableSQL
|
||||
function. This contains table specific settings. Legal keywords include:</p>
|
||||
<ul>
|
||||
<li><b>REPLACE</b><br>
|
||||
Indicates that the previous table definition should be removed
|
||||
(dropped)together with ALL data. See first example below. </li>
|
||||
<li><b>DROP</b><br>
|
||||
Drop table. Useful for removing unused tables. </li>
|
||||
<li><b>CONSTRAINTS</b><br>
|
||||
Define this as the key, with the constraint as the value. See the
|
||||
postgresql <a href="#foreignkey">example</a> below. Additional constraints defined for the whole
|
||||
table. You will probably need to prefix this with a comma. </li>
|
||||
</ul>
|
||||
<p>Database specific table options can be defined also using the name
|
||||
of the database type as the array key. In the following example, <em>create
|
||||
the table as ISAM with MySQL, and store the table in the "users"
|
||||
tablespace if using Oracle</em>. And because we specified REPLACE, drop
|
||||
the table first.</p>
|
||||
<pre> $taboptarray = array('mysql' =gt; 'TYPE=ISAM', 'oci8' =gt; 'tablespace users', 'REPLACE');</pre>
|
||||
<p><a name=foreignkey></a>You can also define foreign key constraints. The following is syntax
|
||||
for postgresql:
|
||||
</p>
|
||||
<pre> $taboptarray = array('constraints' =gt; ', FOREIGN KEY (col1) REFERENCES reftable (refcol)');</pre>
|
||||
<h4>function DropTableSQL($tabname)</h4>
|
||||
<p>Returns the SQL to drop the specified table.</p>
|
||||
<h4>function ChangeTableSQL($tabname, $flds, $tableOptions=false, $dropOldFlds=false)</h4>
|
||||
<p>Checks to see if table exists, if table does not exist, behaves like
|
||||
CreateTableSQL. If table exists, generates appropriate ALTER TABLE
|
||||
MODIFY COLUMN commands if field already exists, or ALTER TABLE ADD
|
||||
$column if field does not exist.</p>
|
||||
<p>The class must be connected to the database for ChangeTableSQL to
|
||||
detect the existence of the table. Idea and code contributed by Florian
|
||||
Buzin.</p>
|
||||
<p>Old fields not defined in $flds are not dropped by default. To drop old fields, set $dropOldFlds to true.
|
||||
<h4>function RenameTableSQL($tabname,$newname)</h4>
|
||||
<p>Rename a table. Returns the an array of strings, which is the SQL required to rename a table. Since ADOdb 4.53. Contributed by Ralf Becker.</p>
|
||||
<h4> function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')</h4>
|
||||
<p>Rename a table field. Returns the an array of strings, which is the SQL required to rename a column. The optional $flds is a complete column-defintion-string like for AddColumnSQL, only used by mysql at the moment. Since ADOdb 4.53. Contributed by Ralf Becker.</p>
|
||||
<h4>function CreateIndexSQL($idxname, $tabname, $flds,
|
||||
$idxoptarray=false)</h4>
|
||||
<pre> RETURNS: an array of strings, the sql to be executed, or false<br> $idxname: name of index<br> $tabname: name of table<br> $flds: list of fields as a comma delimited string or an array of strings<br> $idxoptarray: array of index creation options<br></pre>
|
||||
<p>$idxoptarray is similar to $taboptarray in that index specific
|
||||
information can be embedded in the array. Other options include:</p>
|
||||
<pre> CLUSTERED Create clustered index (only mssql)<br> BITMAP Create bitmap index (only oci8)<br> UNIQUE Make unique index<br> FULLTEXT Make fulltext index (only mysql)<br> HASH Create hash index (only postgres)<br> DROP Drop legacy index<br></pre>
|
||||
<h4>function DropIndexSQL ($idxname, $tabname = NULL)</h4>
|
||||
<p>Returns the SQL to drop the specified index.</p>
|
||||
<h4>function AddColumnSQL($tabname, $flds)</h4>
|
||||
<p>Add one or more columns. Not guaranteed to work under all situations.</p>
|
||||
<h4>function AlterColumnSQL($tabname, $flds)</h4>
|
||||
<p>Warning, not all databases support this feature.</p>
|
||||
<h4>function DropColumnSQL($tabname, $flds)</h4>
|
||||
<p>Drop 1 or more columns.</p>
|
||||
<h4>function SetSchema($schema)</h4>
|
||||
<p>Set the schema.</p>
|
||||
<h4>function MetaTables()</h4>
|
||||
<h4>function MetaColumns($tab, $upper=true, $schema=false)</h4>
|
||||
<h4>function MetaPrimaryKeys($tab,$owner=false,$intkey=false)</h4>
|
||||
<h4>function MetaIndexes($table, $primary = false, $owner = false)</h4>
|
||||
<p>These functions are wrappers for the corresponding functions in the
|
||||
connection object. However, the table names will be autoquoted by the
|
||||
TableName function (see below) before being passed to the connection
|
||||
object.</p>
|
||||
<h4>function NameQuote($name = NULL)</h4>
|
||||
<p>If the provided name is quoted with backquotes (`) or contains
|
||||
special characters, returns the name quoted with the appropriate quote
|
||||
character, otherwise the name is returned unchanged.</p>
|
||||
<h4>function TableName($name)</h4>
|
||||
<p>The same as NameQuote, but will prepend the current schema if
|
||||
specified</p>
|
||||
<h4>function MetaType($t,$len=-1,$fieldobj=false)</h4>
|
||||
<h4>function ActualType($meta)</h4>
|
||||
<p>Convert between database-independent 'Meta' and database-specific
|
||||
'Actual' type codes.</p>
|
||||
<h4>function ExecuteSQLArray($sqlarray, $contOnError = true)</h4>
|
||||
<pre> RETURNS: 0 if failed, 1 if executed all but with errors, 2 if executed successfully<br> $sqlarray: an array of strings with sql code (no semicolon at the end of string)<br> $contOnError: if true, then continue executing even if error occurs<br></pre>
|
||||
<p>Executes an array of SQL strings returned by CreateTableSQL or
|
||||
CreateIndexSQL.</p>
|
||||
<hr />
|
||||
<a name="xmlschema"></a>
|
||||
<h2>ADOdb XML Schema (AXMLS)</h2>
|
||||
<p>This is a class contributed by Richard Tango-Lowy and Dan Cech that
|
||||
allows the user to quickly
|
||||
and easily build a database using the excellent ADODB database library
|
||||
and a simple XML formatted file.
|
||||
You can <a href="http://sourceforge.net/projects/adodb-xmlschema/">download
|
||||
the latest version of AXMLS here</a>.</p>
|
||||
<h3>Quick Start</h3>
|
||||
<p>Adodb-xmlschema, or AXMLS, is a set of classes that allow the user
|
||||
to quickly and easily build or upgrade a database on almost any RDBMS
|
||||
using the excellent ADOdb database library and a simple XML formatted
|
||||
schema file. Our goal is to give developers a tool that's simple to
|
||||
use, but that will allow them to create a single file that can build,
|
||||
upgrade, and manipulate databases on most RDBMS platforms.</p>
|
||||
<span style="font-weight: bold;"> Installing axmls</span>
|
||||
<p>The easiest way to install AXMLS to download and install any recent
|
||||
version of the ADOdb database abstraction library. To install AXMLS
|
||||
manually, simply copy the adodb-xmlschema.inc.php file and the xsl
|
||||
directory into your adodb directory.</p>
|
||||
<span style="font-weight: bold;"> Using AXMLS in Your Application</span>
|
||||
<p>There are two steps involved in using AXMLS in your application:
|
||||
first, you must create a schema, or XML representation of your
|
||||
database, and second, you must create the PHP code that will parse and
|
||||
execute the schema.</p>
|
||||
<p>Let's begin with a schema that describes a typical, if simplistic
|
||||
user management table for an application.</p>
|
||||
<pre class="listing"><pre><?xml version="1.0"?><br><schema version="0.2"><br><br> <table name="users"><br> <desc>A typical users table for our application.</desc><br> <field name="userId" type="I"><br> <descr>A unique ID assigned to each user.</descr><br><br> <KEY/><br> <AUTOINCREMENT/><br> </field><br> <br> <field name="userName" type="C" size="16"><NOTNULL/></field><br><br> <br> <index name="userName"><br> <descr>Put a unique index on the user name</descr><br> <col>userName</col><br> <UNIQUE/><br><br> </index><br> </table><br> <br> <sql><br> <descr>Insert some data into the users table.</descr><br> <query>insert into users (userName) values ( 'admin' )</query><br><br> <query>insert into users (userName) values ( 'Joe' )</query><br> </sql><br></schema> <br></pre></pre>
|
||||
<p>Let's take a detailed look at this schema.</p>
|
||||
<p>The opening <?xml version="1.0"?> tag is required by XML. The
|
||||
<schema> tag tells the parser that the enclosed markup defines an
|
||||
XML schema. The version="0.2" attribute sets <em>the version of the
|
||||
AXMLS DTD used by the XML schema.</em> </p>
|
||||
<p>All versions of AXMLS prior to version 1.0 have a schema version of
|
||||
"0.1". The current schema version is "0.2".</p>
|
||||
<pre class="listing"><pre><?xml version="1.0"?><br><schema version="0.2"><br> ...<br></schema><br></pre></pre>
|
||||
<p>Next we define one or more tables. A table consists of a fields (and
|
||||
other objects) enclosed by <table> tags. The name="" attribute
|
||||
specifies the name of the table that will be created in the database.</p>
|
||||
<pre class="listing"><pre><table name="users"><br><br> <desc>A typical users table for our application.</desc><br> <field name="userId" type="I"><br><br> <descr>A unique ID assigned to each user.</descr><br> <KEY/><br> <AUTOINCREMENT/><br> </field><br> <br> <field name="userName" type="C" size="16"><NOTNULL/></field><br><br> <br></table><br></pre></pre>
|
||||
<p>This table is called "users" and has a description and two fields.
|
||||
The description is optional, and is currently only for your own
|
||||
information; it is not applied to the database.</p>
|
||||
<p>The first <field> tag will create a field named "userId" of
|
||||
type "I", or integer. (See the ADOdb Data Dictionary documentation for
|
||||
a list of valid types.) This <field> tag encloses two special
|
||||
field options: <KEY/>, which specifies this field as a primary
|
||||
key, and <AUTOINCREMENT/>, which specifies that the database
|
||||
engine should automatically fill this field with the next available
|
||||
value when a new row is inserted.</p>
|
||||
<p>The second <field> tag will create a field named "userName" of
|
||||
type "C", or character, and of length 16 characters. The
|
||||
<NOTNULL/> option specifies that this field does not allow NULLs.</p>
|
||||
<p>There are two ways to add indexes to a table. The simplest is to
|
||||
mark a field with the <KEY/> option as described above; a primary
|
||||
key is a unique index. The second and more powerful method uses the
|
||||
<index> tags.</p>
|
||||
<pre class="listing"><pre><table name="users"><br> ...<br> <br> <index name="userName"><br> <descr>Put a unique index on the user name</descr><br> <col>userName</col><br><br> <UNIQUE/><br> </index><br> <br></table><br></pre></pre>
|
||||
<p>The <index> tag specifies that an index should be created on
|
||||
the enclosing table. The name="" attribute provides the name of the
|
||||
index that will be created in the database. The description, as above,
|
||||
is for your information only. The <col> tags list each column
|
||||
that will be included in the index. Finally, the <UNIQUE/> tag
|
||||
specifies that this will be created as a unique index.</p>
|
||||
<p>Finally, AXMLS allows you to include arbitrary SQL that will be
|
||||
applied to the database when the schema is executed.</p>
|
||||
<pre class="listing"><pre><sql><br> <descr>Insert some data into the users table.</descr><br> <query>insert into users (userName) values ( 'admin' )</query><br><br> <query>insert into users (userName) values ( 'Joe' )</query><br></sql><br></pre></pre>
|
||||
<p>The <sql> tag encloses any number of SQL queries that you
|
||||
define for your own use.</p>
|
||||
<p>Now that we've defined an XML schema, you need to know how to apply
|
||||
it to your database. Here's a simple PHP script that shows how to load
|
||||
the schema.</p>
|
||||
<pre class="listing"><pre><?PHP<br>/* You must tell the script where to find the ADOdb and<br> * the AXMLS libraries.<br> */
|
||||
require( "path_to_adodb/adodb.inc.php");
|
||||
require( "path_to_adodb/adodb-xmlschema.inc.php" ); # or adodb-xmlschema03.inc.php
|
||||
|
||||
/* Configuration information. Define the schema filename,<br> * RDBMS platform (see the ADODB documentation for valid<br> * platform names), and database connection information here.<br> */<br>$schemaFile = 'example.xml';<br>$platform = 'mysql';<br>$dbHost = 'localhost';<br>$dbName = 'database';<br>$dbUser = 'username';<br>$dbPassword = 'password';<br><br>/* Start by creating a normal ADODB connection.<br> */<br>$db = ADONewConnection( $platform );<br>$db->Connect( $dbHost, $dbUser, $dbPassword, $dbName );<br><br>/* Use the database connection to create a new adoSchema object.<br> */<br>$schema = new adoSchema( $db );<br><br>/* Call ParseSchema() to build SQL from the XML schema file.<br> * Then call ExecuteSchema() to apply the resulting SQL to <br> * the database.<br> */<br>$sql = $schema->ParseSchema( $schemaFile );<br>$result = $schema->ExecuteSchema();<br>?><br></pre></pre>
|
||||
<p>Let's look at each part of the example in turn. After you manually
|
||||
create the database, there are three steps required to load (or
|
||||
upgrade) your schema.</p>
|
||||
<p>First, create a normal ADOdb connection. The variables and values
|
||||
here should be those required to connect to your database.</p>
|
||||
<pre class="listing"><pre>$db = ADONewConnection( 'mysql' );<br>$db->Connect( 'host', 'user', 'password', 'database' );<br></pre></pre>
|
||||
<p>Second, create the adoSchema object that load and manipulate your
|
||||
schema. You must pass an ADOdb database connection object in order to
|
||||
create the adoSchema object.</p>
|
||||
<pre class="listing">$schema = new adoSchema( $db );<br></pre>
|
||||
<p>Third, call ParseSchema() to parse the schema and then
|
||||
ExecuteSchema() to apply it to the database. You must pass
|
||||
ParseSchema() the path and filename of your schema file.</p>
|
||||
<pre class="listing">$schema->ParseSchema( $schemaFile ); <br>$schema->ExecuteSchema();</pre>
|
||||
<p>Execute the above code and then log into your database. If you've
|
||||
done all this right, you should see your tables, indexes, and SQL.</p>
|
||||
<p>You can find the source files for this tutorial in the examples
|
||||
directory as tutorial_shema.xml and tutorial.php. See the class
|
||||
documentation for a more detailed description of the adoSchema methods,
|
||||
including methods and schema elements that are not described in this
|
||||
tutorial.</p>
|
||||
<h3>XML Schema Version 3</h3>
|
||||
<p>In March 2006, we added adodb-xmlschema03.inc.php to the release, which supports version 3 of XML Schema.
|
||||
The adodb-xmlschema.inc.php remains the same as previous releases, and supports version 2 of XML Schema.
|
||||
Version 3 provides some enhancements:
|
||||
|
||||
<ul>
|
||||
<li> Support for updating table data during an upgrade.
|
||||
<li> Support for platform-specific table options and platform negation.
|
||||
<li> Support for unsigned fields.
|
||||
<li> Fixed opt and constraint support
|
||||
<li> Many other fixes such as OPT tag, which allows you to set optional platform settings:
|
||||
</ul>
|
||||
|
||||
<p>Example usage:
|
||||
<pre><?xml version="1.0"?>
|
||||
<b><schema version="0.3"></b>
|
||||
<table name="ats_kb">
|
||||
<descr>ATS KnowledgeBase</descr>
|
||||
<opt platform="mysql">TYPE=INNODB</opt>
|
||||
<field name="recid" type="I"/>
|
||||
<field name="organization_code" type="I4"/>
|
||||
<field name="sub_code" type="C" size="20"/>
|
||||
etc...
|
||||
</pre>
|
||||
<p>To use it, change your code to include adodb-xmlschema03.inc.php.
|
||||
|
||||
<h3>Upgrading</h3>
|
||||
<p>
|
||||
If your schema version is older, than XSLT is used to transform the
|
||||
schema to the newest version. This means that if you are using an older
|
||||
XML schema format, you need to have the XSLT extension installed.
|
||||
If you do not want to require your users to have the XSLT extension
|
||||
installed, make sure you modify your XML schema to conform to the
|
||||
latest version.
|
||||
<hr />
|
||||
<address>If you have any questions or comments, please email them to
|
||||
Richard at richtl#arscognita.com.
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
||||
542
src/adodb512/docs/docs-oracle.htm
Normal file
542
src/adodb512/docs/docs-oracle.htm
Normal file
@@ -0,0 +1,542 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 0.75em 1.5em;
|
||||
font-size: 12px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.greybg {
|
||||
background-color: #eee;
|
||||
padding: 0.75em 1.5em;
|
||||
font-size: 12px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.style1 {color: #660000}
|
||||
</style>
|
||||
<title>ADOdb with PHP and Oracle</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table width=100%><tr><td>
|
||||
<h2>Using ADOdb with PHP and Oracle: an advanced tutorial</h2>
|
||||
</td><td><div align="right"><img src=cute_icons_for_site/adodb.gif width="88" height="31"></div></tr></table>
|
||||
<p><font size="1">(c)2004-2005 John Lim. All rights reserved.</font></p>
|
||||
<h3>1. Introduction</h3>
|
||||
<p>Oracle is the most popular commercial database used with PHP. There are many ways of accessing Oracle databases in PHP. These include:</p>
|
||||
<ul>
|
||||
<li>The oracle extension</li>
|
||||
<li>The oci8 extension</li>
|
||||
<li>PEAR DB library</li>
|
||||
<li>ADOdb library</li>
|
||||
</ul>
|
||||
<p>The wide range of choices is confusing to someone just starting with Oracle and PHP. I will briefly summarize the differences, and show you the advantages of using <a href="http://adodb.sourceforge.net/">ADOdb</a>. </p>
|
||||
<p>First we have the C extensions which provide low-level access to Oracle functionality. These C extensions are precompiled into PHP, or linked in dynamically when the web server starts up. Just in case you need it, here's a <a href=http://www.oracle.com/technology/tech/opensource/php/apache/inst_php_apache_linux.html>guide to installing Oracle and PHP on Linux</a>.</p>
|
||||
<table width="75%" border="1" align="center">
|
||||
<tr valign="top">
|
||||
<td nowrap><b>Oracle extension</b></td>
|
||||
<td>Designed for Oracle 7 or earlier. This is obsolete.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap><b>Oci8 extension</b></td>
|
||||
<td> Despite it's name, which implies it is only for Oracle 8i, this is the standard method for accessing databases running Oracle 8i, 9i or 10g (and later).</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Here is an example of using the oci8 extension to query the <i>emp</i> table of the <i>scott</i> schema with bind parameters:
|
||||
<pre>
|
||||
$conn = OCILogon("scott","tiger", $tnsName);
|
||||
|
||||
$stmt = OCIParse($conn,"select * from emp where empno > :emp order by empno");
|
||||
$emp = 7900;
|
||||
OCIBindByName($stmt, ':emp', $emp);
|
||||
$ok = OCIExecute($stmt);
|
||||
while (OCIFetchInto($stmt,$arr)) {
|
||||
print_r($arr);
|
||||
echo "<hr>";
|
||||
}
|
||||
</pre>
|
||||
<p>This generates the following output:
|
||||
<div class=greybg>
|
||||
Array ( [0] => 7902 [1] => FORD [2] => ANALYST [3] => 7566 [4] => 03/DEC/81 [5] => 3000 [7] => 20 )
|
||||
<hr />
|
||||
Array ( [0] => 7934 [1] => MILLER [2] => CLERK [3] => 7782 [4] => 23/JAN/82 [5] => 1300 [7] => 10 )
|
||||
</div>
|
||||
<p>We also have many higher level PHP libraries that allow you to simplify the above code. The most popular are <a href="http://pear.php.net/">PEAR DB</a> and <a href="http://adodb.sourceforge.net/">ADOdb</a>. Here are some of the differences between these libraries:</p>
|
||||
<table width="75%" border="1" align="center">
|
||||
<tr>
|
||||
<td><b>Feature</b></td>
|
||||
<td><b>PEAR DB 1.6</b></td>
|
||||
<td><b>ADOdb 4.52</b></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>General Style</td>
|
||||
<td>Simple, easy to use. Lacks Oracle specific functionality.</td>
|
||||
<td>Has multi-tier design. Simple high-level design for beginners, and also lower-level advanced Oracle functionality.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Support for Prepare</td>
|
||||
<td>Yes, but only on one statement, as the last prepare overwrites previous prepares.</td>
|
||||
<td>Yes (multiple simultaneous prepare's allowed)</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Support for LOBs</td>
|
||||
<td>No</td>
|
||||
<td>Yes, using update semantics</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Support for REF Cursors</td>
|
||||
<td>No</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Support for IN Parameters</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Support for OUT Parameters</td>
|
||||
<td>No</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Schema creation using XML</td>
|
||||
<td>No</td>
|
||||
<td>Yes, including ability to define tablespaces and constraints</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Provides database portability features</td>
|
||||
<td>No</td>
|
||||
<td>Yes, has some ability to abstract features that differ between databases such as dates, bind parameters, and data types.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Performance monitoring and tracing</td>
|
||||
<td>No</td>
|
||||
<td>Yes. SQL can be traced and linked to web page it was executed on. Explain plan support included.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Recordset caching for frequently used queries</td>
|
||||
<td>No</td>
|
||||
<td>Yes. Provides great speedups for SQL involving complex <i>where, group-by </i>and <i>order-by</i> clauses.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Popularity</td>
|
||||
<td>Yes, part of PEAR release</td>
|
||||
<td>Yes, many open source projects are using this software, including PostNuke, Xaraya, Mambo, Tiki Wiki.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Speed</td>
|
||||
<td>Medium speed.</td>
|
||||
<td>Very high speed. Fastest database abstraction library available for PHP. <a href="http://phplens.com/lens/adodb/">Benchmarks are available</a>.</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>High Speed Extension available</td>
|
||||
<td>No</td>
|
||||
<td>Yes. You can install the optional ADOdb extension, which reimplements the most frequently used parts of ADOdb as fast C code. Note that the source code version of ADOdb runs just fine without this extension, and only makes use of the extension if detected.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p> PEAR DB is good enough for simple web apps. But if you need more power, you can see ADOdb offers more sophisticated functionality. The rest of this article will concentrate on using ADOdb with Oracle. You can find out more about <a href="#connecting">connecting to Oracle</a> later in this guide.</p>
|
||||
<h4>ADOdb Example</h4>
|
||||
<p>In ADOdb, the above oci8 example querying the <i>emp</i> table could be written as:</p>
|
||||
<pre>
|
||||
include "/path/to/adodb.inc.php";
|
||||
$db = NewADOConnection("oci8");
|
||||
$db->Connect($tnsName, "scott", "tiger");
|
||||
|
||||
$rs = $db->Execute("select * from emp where empno>:emp order by empno",
|
||||
array('emp' => 7900));
|
||||
while ($arr = $rs->FetchRow()) {
|
||||
print_r($arr);
|
||||
echo "<hr>";
|
||||
}
|
||||
</pre>
|
||||
<p>The Execute( ) function returns a recordset object, and you can retrieve the rows returned using $recordset->FetchRow( ). </p>
|
||||
<p>If we ignore the initial connection preamble, we can see the ADOdb version is much easier and simpler:</p>
|
||||
<table width="100%" border="1">
|
||||
<tr valign="top" bgcolor="#FFFFFF">
|
||||
<td width="50%" bgcolor="#e0e0e0"><b>Oci8</b></td>
|
||||
<td bgcolor="#e0e0e0"><b>ADOdb</b></td>
|
||||
</tr>
|
||||
<tr valign="top" bgcolor="#CCCCCC">
|
||||
<td><pre><font size="1">$stmt = <b>OCIParse</b>($conn,
|
||||
"select * from emp where empno > :emp");
|
||||
$emp = 7900;
|
||||
<b>OCIBindByName</b>($stmt, ':emp', $emp);
|
||||
$ok = <b>OCIExecute</b>($stmt);
|
||||
|
||||
while (<b>OCIFetchInto</b>($stmt,$arr)) {
|
||||
print_r($arr);
|
||||
echo "<hr>";
|
||||
} </font></pre></td>
|
||||
<td><pre><font size="1">$recordset = $db-><b>Execute</b>("select * from emp where empno>:emp",
|
||||
array('emp' => 7900));
|
||||
|
||||
while ($arr = $recordset-><b>FetchRow</b>()) {
|
||||
print_r($arr);
|
||||
echo "<hr>";
|
||||
}</font></pre></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p> </p>
|
||||
<h3>2. ADOdb Query Semantics</h3>
|
||||
<p>You can also query the database using the standard Microsoft ADO MoveNext( ) metaphor. The data array for the current row is stored in the <i>fields</i> property of the recordset object, $rs.
|
||||
MoveNext( ) offers the highest performance among all the techniques for iterating through a recordset:
|
||||
<pre>
|
||||
$rs = $db->Execute("select * from emp where empno>:emp", array('emp' => 7900));
|
||||
while (!$rs->EOF) {
|
||||
print_r($rs->fields);
|
||||
$rs->MoveNext();
|
||||
}
|
||||
</pre>
|
||||
<p>And if you are interested in having the data returned in a 2-dimensional array, you can use:
|
||||
<pre>
|
||||
$arr = $db->GetArray("select * from emp where empno>:emp", array('emp' => 7900));
|
||||
</pre>
|
||||
<p>Now to obtain only the first row as an array:
|
||||
<pre>
|
||||
$arr = $db->GetRow("select * from emp where empno=:emp", array('emp' => 7900));
|
||||
</pre>
|
||||
<p>Or to retrieve only the first field of the first row:
|
||||
<pre>
|
||||
$arr = $db->GetOne("select ename from emp where empno=:emp", array('emp' => 7900));
|
||||
</pre>
|
||||
<p>For easy pagination support, we provide the SelectLimit function. The following will perform a select query, limiting it to 100 rows, starting from row 201 (row 1 being the 1st row):
|
||||
<pre>
|
||||
$offset = 200; $limitrows = 100;
|
||||
$rs = $db->SelectLimit('select * from table', $limitrows, $offset);
|
||||
</pre>
|
||||
<p>The $offset parameter is optional.
|
||||
<h4>Array Fetch Mode</h4>
|
||||
<p>When data is being returned in an array, you can choose the type of array the data is returned in.
|
||||
<ol>
|
||||
<li> Numeric indexes - use <font size="2" face="Courier New, Courier, mono">$connection->SetFetchMode(ADODB_FETCH_NUM).</font></li>
|
||||
<li>Associative indexes - the keys of the array are the names of the fields (in upper-case). Use <font size="2" face="Courier New, Courier, mono">$connection->SetFetchMode(ADODB_FETCH_ASSOC)</font><font face="Courier New, Courier, mono">.</font></li>
|
||||
<li>Both numeric and associative indexes - use <font size="2" face="Courier New, Courier, mono">$connection->SetFetchMode(ADODB_FETCH_BOTH).</font></li>
|
||||
</ol>
|
||||
<p>The default is ADODB_FETCH_BOTH for Oracle.</p>
|
||||
<h4><b>Caching</b></h4>
|
||||
<p>You can define a database cache directory using $ADODB_CACHE_DIR, and cache the results of frequently used queries that rarely change. This is particularly useful for SQL with complex where clauses and group-by's and order-by's. It is also good for relieving heavily-loaded database servers.</p>
|
||||
<p>This example will cache the following select statement for 3600 seconds (1 hour):</p>
|
||||
<pre>
|
||||
$ADODB_CACHE_DIR = '/var/adodb/tmp';
|
||||
$rs = $db->CacheExecute(3600, "select names from allcountries order by 1");
|
||||
</pre>
|
||||
There are analogous CacheGetArray(
|
||||
), CacheGetRow( ), CacheGetOne( ) and CacheSelectLimit( ) functions. The first parameter is the number of seconds to cache. You can also pass a bind array as a 3rd parameter (not shown above).
|
||||
<p>There is an alternative syntax for the caching functions. The first parameter is omitted, and you set the cacheSecs
|
||||
property of the connection object:
|
||||
<pre>
|
||||
$ADODB_CACHE_DIR = '/var/adodb/tmp';
|
||||
$connection->cacheSecs = 3600;
|
||||
$rs = $connection->CacheExecute($sql, array('id' => 1));
|
||||
</pre>
|
||||
<h3> </h3>
|
||||
<h3>3. Using Prepare( ) For Frequently Used Statements</h3>
|
||||
<p>Prepare( ) is for compiling frequently used SQL statement for reuse. For example, suppose we have a large array which needs to be inserted into an Oracle database. The following will result in a massive speedup in query execution (at least 20-40%), as the SQL statement only needs to be compiled once:</p>
|
||||
<pre>
|
||||
$stmt = $db->Prepare('insert into table (field1, field2) values (:f1, :f2)');
|
||||
foreach ($arrayToInsert as $key => $value) {
|
||||
$db->Execute($stmt, array('f1' => $key, 'f2' => $val);
|
||||
}
|
||||
</pre>
|
||||
<p> </p>
|
||||
<h3>4. Working With LOBs</h3>
|
||||
<p>Oracle treats data which is more than 4000 bytes in length specially. These are called Large Objects, or LOBs for short. Binary LOBs are BLOBs, and character LOBs are CLOBs. In most Oracle libraries, you need to do a lot of work to process LOBs, probably because Oracle designed it to work in systems with little memory. ADOdb tries to make things easy by assuming the LOB can fit into main memory. </p>
|
||||
<p>ADOdb will transparently handle LOBs in <i>select</i> statements. The LOBs are automatically converted to PHP variables without any special coding.</p>
|
||||
<p>For updating records with LOBs, the functions UpdateBlob( ) and UpdateClob( ) are provided. Here's a BLOB example. The parameters should be self-explanatory:
|
||||
<pre>
|
||||
$ok = $db->Execute("insert into aTable (id, name, ablob)
|
||||
values (aSequence.nextVal, 'Name', null)");
|
||||
if (!$ok) return LogError($db->ErrorMsg());
|
||||
<font color="#006600"># params: $tableName, $blobFieldName, $blobValue, $whereClause</font>
|
||||
$db->UpdateBlob('aTable', 'ablob', $blobValue, 'id=aSequence.currVal');
|
||||
</pre>
|
||||
<p>and the analogous CLOB example:
|
||||
<pre>
|
||||
$ok = $db->Execute("insert into aTable (id, name, aclob)
|
||||
values (aSequence.nextVal, 'Name', null)");
|
||||
if (!$ok) return LogError($db->ErrorMsg());
|
||||
$db->UpdateClob('aTable', 'aclob', $clobValue, 'id=aSequence.currVal');
|
||||
</pre>
|
||||
<p>Note that LogError( ) is a user-defined function, and not part of ADOdb.
|
||||
<p>Inserting LOBs is more complicated. Since ADOdb 4.55, we allow you to do this
|
||||
(assuming that the <em>photo</em> field is a BLOB, and we want to store $blob_data into
|
||||
this field, and the primary key is the <em>id</em> field):
|
||||
<pre>
|
||||
$sql = <span class="style1">"INSERT INTO photos ( ID, photo) ".
|
||||
"VALUES ( :id, empty_blob() )".
|
||||
" RETURNING photo INTO :xx"</span>;
|
||||
|
||||
$stmt = $db->PrepareSP($sql);
|
||||
$db->InParameter($stmt, $<strong>id</strong>, <span class="style1">'id'</span>);
|
||||
$blob = $db->InParameter($stmt, $<strong>blob_data</strong>, <span class="style1">'xx'</span>,-1, OCI_B_BLOB);
|
||||
$db->StartTrans();
|
||||
$ok = $db->Execute($stmt);
|
||||
$db->CompleteTrans();
|
||||
</pre>
|
||||
<p>
|
||||
<h3>5. REF CURSORs</h3>
|
||||
<p>Oracle recordsets can be passed around as variables called REF Cursors. For example, in PL/SQL, we could define a function <i>open_tab</i> that returns a REF CURSOR in the first parameter:</p>
|
||||
<pre>
|
||||
TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;
|
||||
|
||||
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
|
||||
BEGIN
|
||||
OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
|
||||
END open_tab;
|
||||
</pre>
|
||||
<p>In ADOdb, we could access this REF Cursor using the ExecuteCursor() function. The following will find
|
||||
all table names that begin with 'A' in the current schema:
|
||||
<pre>
|
||||
$rs = $db->ExecuteCursor("BEGIN open_tab(:refc,'A%'); END;",'refc');
|
||||
while ($arr = $rs->FetchRow()) print_r($arr);
|
||||
</pre>
|
||||
<p>The first parameter is the PL/SQL statement, and the second parameter is the name of the REF Cursor.
|
||||
</p>
|
||||
<p> </p>
|
||||
<h3>6. In and Out Parameters</h3>
|
||||
<p>The following PL/SQL
|
||||
stored procedure requires an input variable, and returns a result into an output variable:
|
||||
<pre>
|
||||
PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
|
||||
BEGIN
|
||||
output := 'I love '||input;
|
||||
END;
|
||||
</pre>
|
||||
<p>The following ADOdb code allows you to call the stored procedure:</p>
|
||||
<pre>
|
||||
$stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;");
|
||||
$input = 'Sophia Loren';
|
||||
$db->InParameter($stmt,$input,'a1');
|
||||
$db->OutParameter($stmt,$output,'a2');
|
||||
$ok = $db->Execute($stmt);
|
||||
if ($ok) echo ($output == 'I love Sophia Loren') ? 'OK' : 'Failed';
|
||||
</pre>
|
||||
<p>PrepareSP( ) is a special function that knows about bind parameters.
|
||||
The main limitation currently is that IN OUT parameters do not work.
|
||||
<h4>Bind Parameters and REF CURSORs</h4>
|
||||
<p>We could also rewrite the REF CURSOR example to use InParameter (requires ADOdb 4.53 or later):
|
||||
<pre>
|
||||
$stmt = $db->PrepareSP("BEGIN adodb.open_tab(:refc,:tabname); END;");
|
||||
$input = 'A%';
|
||||
$db->InParameter($stmt,$input,'tabname');
|
||||
$rs = $db->ExecuteCursor($stmt,'refc');
|
||||
while ($arr = $rs->FetchRow()) print_r($arr);
|
||||
</pre>
|
||||
<h4>Bind Parameters and LOBs</h4>
|
||||
<p>You can also operate on LOBs. In this example, we have IN and OUT parameters using CLOBs.
|
||||
<pre>
|
||||
$text = 'test test test';
|
||||
$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
|
||||
$stmt = $conn -> PrepareSP($sql);
|
||||
$conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB); # -1 means variable length
|
||||
$rs = '';
|
||||
$conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
|
||||
$conn -> Execute($stmt);
|
||||
echo "return = ".$rs."<br>";
|
||||
</pre>
|
||||
<p>Similarly, you can use the constant OCI_B_BLOB to indicate that you are using BLOBs.
|
||||
<h4>Reusing Bind Parameters with CURSOR_SHARING=FORCE</h4>
|
||||
<p>Many web programmers do not care to use bind parameters, and prefer to enter the SQL directly. So instead of:</p>
|
||||
<pre>
|
||||
$arr = $db->GetArray("select * from emp where empno>:emp", array('emp' => 7900));
|
||||
</pre>
|
||||
<p>They prefer entering the values inside the SQL:
|
||||
<pre>
|
||||
$arr = $db->GetArray("select * from emp where empno>7900");
|
||||
</pre>
|
||||
<p>This reduces Oracle performance because Oracle will reuse compiled SQL which is identical to previously compiled SQL. The above example with the values inside the SQL
|
||||
is unlikely to be reused. As an optimization, from Oracle 8.1 onwards, you can set the following session parameter after you login:
|
||||
<pre>
|
||||
ALTER SESSION SET CURSOR_SHARING=FORCE
|
||||
</pre>
|
||||
<p>This will force Oracle to convert all such variables (eg. the 7900 value) into constant bind parameters, improving SQL reuse.</p>
|
||||
<p>More <a href="http://phplens.com/adodb/code.initialization.html#speed">speedup tips</a>.</p>
|
||||
<p> </p>
|
||||
<h3>7. Dates and Datetime in ADOdb</h3>
|
||||
<p>There are two things you need to know about dates in ADOdb. </p>
|
||||
<p>First, to ensure cross-database compability, ADOdb assumes that dates are returned in ISO format (YYYY-MM-DD H24:MI:SS).</p>
|
||||
<p>Secondly, since Oracle treats dates and datetime as the same data type, we decided not to display the time in the default date format. So on login, ADOdb will set the NLS_DATE_FORMAT to 'YYYY-MM-DD'. If you prefer to show the date and time by default, do this:</p>
|
||||
<pre>
|
||||
$db = NewADOConnection('oci8');
|
||||
$db->NLS_DATE_FORMAT = 'RRRR-MM-DD HH24:MI:SS';
|
||||
$db->Connect($tns, $user, $pwd);
|
||||
</pre>
|
||||
<p>Or execute:</p>
|
||||
<pre>$sql = quot;ALTER SESSION SET NLS_DATE_FORMAT = 'RRRR-MM-DD HH24:MI:SS'";
|
||||
$db->Execute($sql);
|
||||
</pre>
|
||||
<p>If you are not concerned about date portability and do not use ADOdb's portability layer, you can use your preferred date format instead.
|
||||
<p>
|
||||
<h3>8. Database Portability Layer</h3>
|
||||
<p>ADOdb provides the following functions for portably generating SQL functions
|
||||
as strings to be merged into your SQL statements:</p>
|
||||
<table width="75%" border="1" align=center>
|
||||
<tr>
|
||||
<td width=30%><b>Function</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DBDate($date)</td>
|
||||
<td>Pass in a UNIX timestamp or ISO date and it will convert it to a date
|
||||
string formatted for INSERT/UPDATE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DBTimeStamp($date)</td>
|
||||
<td>Pass in a UNIX timestamp or ISO date and it will convert it to a timestamp
|
||||
string formatted for INSERT/UPDATE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SQLDate($date, $fmt)</td>
|
||||
<td>Portably generate a date formatted using $fmt mask, for use in SELECT
|
||||
statements.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>OffsetDate($date, $ndays)</td>
|
||||
<td>Portably generate a $date offset by $ndays.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Concat($s1, $s2, ...)</td>
|
||||
<td>Portably concatenate strings. Alternatively, for mssql use mssqlpo driver,
|
||||
which allows || operator.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IfNull($fld, $replaceNull)</td>
|
||||
<td>Returns a string that is the equivalent of MySQL IFNULL or Oracle NVL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Param($name)</td>
|
||||
<td>Generates bind placeholders, using ? or named conventions as appropriate.</td>
|
||||
</tr>
|
||||
<tr><td>$db->sysDate</td><td>Property that holds the SQL function that returns today's date</td>
|
||||
</tr>
|
||||
<tr><td>$db->sysTimeStamp</td><td>Property that holds the SQL function that returns the current
|
||||
timestamp (date+time).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>$db->concat_operator</td><td>Property that holds the concatenation operator
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>$db->length</td><td>Property that holds the name of the SQL strlen function.
|
||||
</td></tr>
|
||||
|
||||
<tr><td>$db->upperCase</td><td>Property that holds the name of the SQL strtoupper function.
|
||||
</td></tr>
|
||||
<tr><td>$db->random</td><td>Property that holds the SQL to generate a random number between 0.00 and 1.00.
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>$db->substr</td><td>Property that holds the name of the SQL substring function.
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>ADOdb also provides multiple oracle oci8 drivers for different scenarios:</p>
|
||||
<table width="75%" border="1" align="center">
|
||||
<tr>
|
||||
<td nowrap><b>Driver Name</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>oci805 </td>
|
||||
<td>Specifically for Oracle 8.0.5. This driver has a slower SelectLimit( ).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>oci8</td>
|
||||
<td>The default high performance driver. The keys of associative arrays returned in a recordset are upper-case.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>oci8po</td>
|
||||
<td> The portable Oracle driver. Slightly slower than oci8. This driver uses ? instead of :<i>bindvar</i> for binding variables, which is the standard for other databases. Also the keys of associative arrays are in lower-case like other databases.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Here's an example of calling the <i>oci8po</i> driver. Note that the bind variables use question-mark:</p>
|
||||
<pre>$db = NewADOConnection('oci8po');
|
||||
$db->Connect($tns, $user, $pwd);
|
||||
$db->Execute("insert into atable (f1, f2) values (?,?)", array(12, 'abc'));</pre>
|
||||
<p> <a name=connecting></a>
|
||||
<h3>9. Connecting to Oracle</h3>
|
||||
<p>Before you can use ADOdb, you need to have the Oracle client installed and setup the oci8 extension. This extension comes pre-compiled for Windows (but you still need to enable it in the php.ini file). For information on compiling the oci8 extension for PHP and Apache on Unix, there is an excellent guide at <a href="http://www.oracle.com/technology/tech/opensource/php/apache/inst_php_apache_linux.html">oracle.com</a>. </p>
|
||||
<h4>Should You Use Persistent Connections</h4>
|
||||
<p>One question that is frequently asked is should you use persistent connections to Oracle. Persistent connections allow PHP to recycle existing connections, reusing them after the previous web pages have completed. Non-persistent connections close automatically after the web page has completed. Persistent connections are faster because the cost of reconnecting is expensive, but there is additional resource overhead. As an alternative, Oracle allows you to pool and reuse server processes; this is called <a href="http://www.cise.ufl.edu/help/database/oracle-docs/server.920/a96521/manproc.htm#13132">Shared Server</a> (also known as MTS).</p>
|
||||
<p>The author's benchmarks suggest that using non-persistent connections and the Shared Server configuration offer the best performance. If Shared Server is not an option, only then consider using persistent connections.</p>
|
||||
<h4>Connection Examples</h4>
|
||||
<p>Just in case you are having problems connecting to Oracle, here are some examples:</p>
|
||||
<p>a. PHP and Oracle reside on the same machine, use default SID, with non-persistent connections:</p>
|
||||
<pre> $conn = NewADOConnection('oci8');
|
||||
$conn->Connect(false, 'scott', 'tiger');</pre>
|
||||
<p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS', using persistent connections:</p>
|
||||
<pre> $conn = NewADOConnection('oci8');
|
||||
$conn->PConnect(false, 'scott', 'tiger', 'myTNS');</pre>
|
||||
<p>or</p>
|
||||
<pre> $conn->PConnect('myTNS', 'scott', 'tiger');</pre>
|
||||
<p>c. Host Address and SID</p>
|
||||
<pre>
|
||||
$conn->connectSID = true;
|
||||
$conn->Connect('192.168.0.1', 'scott', 'tiger', 'SID');</pre>
|
||||
<p>d. Host Address and Service Name</p>
|
||||
<pre> $conn->Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre>
|
||||
<p>e. Oracle connection string:
|
||||
<pre> $cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
|
||||
(CONNECT_DATA=(SID=$sid)))";
|
||||
$conn->Connect($cstr, 'scott', 'tiger');
|
||||
</pre>
|
||||
<p>f. ADOdb data source names (dsn):
|
||||
<pre>
|
||||
$dsn = 'oci8://user:pwd@tnsname/?persist'; # persist is optional
|
||||
$conn = ADONewConnection($dsn); # no need for Connect/PConnect
|
||||
|
||||
$dsn = 'oci8://user:pwd@host/sid';
|
||||
$conn = ADONewConnection($dsn);
|
||||
|
||||
$dsn = 'oci8://user:pwd@/'; # oracle on local machine
|
||||
$conn = ADONewConnection($dsn);</pre>
|
||||
<p>With ADOdb data source names,
|
||||
you don't have to call Connect( ) or PConnect( ).
|
||||
</p>
|
||||
<p> </p>
|
||||
<h3>10. Error Checking</h3>
|
||||
<p>The examples in this article are easy to read but a bit simplistic because we ignore error-handling. Execute( ) and Connect( ) will return false on error. So a more realistic way to call Connect( ) and Execute( ) is:
|
||||
<pre>function InvokeErrorHandler()
|
||||
{<br>global $db; ## assume global
|
||||
MyLogFunction($db->ErrorNo(), $db->ErrorMsg());
|
||||
}
|
||||
if (!$db->Connect($tns, $usr, $pwd)) InvokeErrorHandler();
|
||||
|
||||
$rs = $db->Execute("select * from emp where empno>:emp order by empno",
|
||||
array('emp' => 7900));
|
||||
if (!$rs) return InvokeErrorHandler();
|
||||
while ($arr = $rs->FetchRow()) {
|
||||
print_r($arr);
|
||||
echo "<hr>";
|
||||
}
|
||||
</pre>
|
||||
<p>You can retrieve the error message and error number of the last SQL statement executed from ErrorMsg( ) and ErrorNo( ). You can also <a href=http://phplens.com/adodb/using.custom.error.handlers.and.pear_error.html>define a custom error handler function</a>.
|
||||
ADOdb also supports throwing exceptions in PHP5.
|
||||
<p> </p>
|
||||
<h3>Handling Large Recordsets (added 27 May 2005)</h3>
|
||||
The oci8 driver does not support counting the number of records returned in a SELECT statement, so the function RecordCount()
|
||||
is emulated when the global variable $ADODB_COUNTRECS is set to true, which is the default.
|
||||
We emulate this by buffering all the records. This can take up large amounts of memory for big recordsets.
|
||||
Set $ADODB_COUNTRECS to false for the best performance.
|
||||
<p>
|
||||
This variable is checked every time a query is executed, so you can selectively choose which recordsets to count.
|
||||
<p> </p>
|
||||
<h3>11. Other ADOdb Features</h3>
|
||||
<p><a href="http://phplens.com/lens/adodb/docs-datadict.htm">Schema generation</a>. This allows you to define a schema using XML and import it into different RDBMS systems portably.</p>
|
||||
<p><a href="http://phplens.com/lens/adodb/docs-perf.htm">Performance monitoring and tracing</a>. Highlights of performance monitoring include identification of poor and suspicious SQL, with explain plan support, and identifying which web pages the SQL ran on.</p>
|
||||
<p> </p>
|
||||
<h3>12. Download</h3>
|
||||
<p>You can <a href="http://adodb.sourceforge.net/#download">download ADOdb from sourceforge</a>. ADOdb uses a BSD style license. That means that it is free for commercial use, and redistribution without source code is allowed.</p>
|
||||
<p> </p>
|
||||
<h3>13. Resources</h3>
|
||||
<ul>
|
||||
<li>Oracle's <a href="http://www.oracle.com/technology/pub/articles/php_experts/index.html">Hitchhiker Guide to PHP</a></li>
|
||||
<li>OTN article on <a href=http://www.oracle.com/technology/pub/articles/deployphp/lim_deployphp.html>Optimizing PHP and Oracle</a> by this author.
|
||||
<li>Oracle has an excellent <a href="http://www.oracle.com/technology/tech/opensource/php/php_troubleshooting_faq.html">FAQ on PHP</a></li>
|
||||
<li>PHP <a href="http://php.net/oci8">oci8</a> manual pages</li>
|
||||
<li><a href=http://phplens.com/lens/lensforum/topics.php?id=4>ADOdb forums</a>.
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
965
src/adodb512/docs/docs-perf.htm
Normal file
965
src/adodb512/docs/docs-perf.htm
Normal file
@@ -0,0 +1,965 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>ADOdb Performance Monitoring Library</title>
|
||||
<style type="text/css">
|
||||
body, td {
|
||||
/*font-family: Arial, Helvetica, sans-serif;*/
|
||||
font-size: 11pt;
|
||||
}
|
||||
pre {
|
||||
font-size: 9pt;
|
||||
background-color: #EEEEEE; padding: .5em; margin: 0px;
|
||||
}
|
||||
.toplink {
|
||||
font-size: 8pt;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>The ADOdb Performance Monitoring Library</h3>
|
||||
<p>V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim#natsoft.com)</p>
|
||||
<p><font size="1">This software is dual licensed using BSD-Style and
|
||||
LGPL. This means you can use it in compiled proprietary and commercial
|
||||
products.</font></p>
|
||||
<p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
|
||||
<a href="http://adodb.sourceforge.net/#docs">Other Docs</a>
|
||||
</p>
|
||||
<h3>Introduction</h3>
|
||||
<p>This module, part of the ADOdb package, provides both CLI and HTML
|
||||
interfaces for viewing key performance indicators of your database.
|
||||
This is very useful because web apps such as the popular phpMyAdmin
|
||||
currently do not provide effective database health monitoring tools.
|
||||
The module provides the following: </p>
|
||||
<ul>
|
||||
<li>A quick health check of your database server using <code>$perf->HealthCheck()</code>
|
||||
or <code>$perf->HealthCheckCLI()</code>. </li>
|
||||
<li>User interface for performance monitoring, <code>$perf->UI()</code>.
|
||||
This UI displays:
|
||||
<ul>
|
||||
<li>the health check, </li>
|
||||
<li>all SQL logged and their query plans, </li>
|
||||
<li>a list of all tables in the current database</li>
|
||||
<li>an interface to continiously poll the server for key
|
||||
performance indicators such as CPU, Hit Ratio, Disk I/O</li>
|
||||
<li>a form where you can enter and run SQL interactively.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Gives you an API to build database monitoring tools for a server
|
||||
farm, for example calling <code>$perf->DBParameter('data cache hit
|
||||
ratio')</code> returns this very important statistic in a database
|
||||
independant manner. </li>
|
||||
</ul>
|
||||
<p>ADOdb also has the ability to log all SQL executed, using <a
|
||||
href="docs-adodb.htm#logsql">LogSQL</a>. All SQL logged can be
|
||||
analyzed through the performance monitor <a href="#ui">UI</a>. In the <i>View
|
||||
SQL</i> mode, we categorize the SQL into 3 types:
|
||||
</p>
|
||||
<ul>
|
||||
<li><b>Suspicious SQL</b>: queries with high average execution times,
|
||||
and are potential candidates for rewriting</li>
|
||||
<li><b>Expensive SQL</b>: queries with high total execution times
|
||||
(#executions * avg execution time). Optimizing these queries will
|
||||
reduce your database server load.</li>
|
||||
<li><b>Invalid SQL</b>: queries that generate errors.</li>
|
||||
</ul>
|
||||
<p>Each query is hyperlinked to a description of the query plan, and
|
||||
every PHP script that executed that query is also shown.</p>
|
||||
<p>Please note that the information presented is a very basic database
|
||||
health check, and does not provide a complete overview of database
|
||||
performance. Although some attempt has been made to make it work across
|
||||
multiple databases in the same way, it is impossible to do so. For the
|
||||
health check, we do try to display the following key database
|
||||
parameters for all drivers:</p>
|
||||
<ul>
|
||||
<li><b>data cache size</b> - The amount of memory allocated to the
|
||||
cache.</li>
|
||||
<li><b>data cache hit ratio</b> - A measure of how effective the
|
||||
cache is, as a percentage. The higher, the better.</li>
|
||||
<li><b>current connections</b> - The number of sessions currently
|
||||
connected to the database. </li>
|
||||
</ul>
|
||||
<p>You will need to connect to the database as an administrator to view
|
||||
most of the parameters. </p>
|
||||
<p>Code improvements as very welcome, particularly adding new database
|
||||
parameters and automated tuning hints.</p>
|
||||
<a name="usage"></a>
|
||||
<h3>Usage</h3>
|
||||
<p>Currently, the following drivers: <em>mysql</em>, <em>postgres</em>,
|
||||
<em>oci8</em>, <em>mssql</em>, <i>informix</i> and <em>db2</em> are
|
||||
supported. To create a new performance monitor, call NewPerfMonitor( )
|
||||
as demonstrated below: </p>
|
||||
<pre><?php<br>include_once('adodb.inc.php');<br>session_start(); <font
|
||||
color="#006600"># session variables required for monitoring</font><br>$conn = ADONewConnection($driver);<br>$conn->Connect($server,$user,$pwd,$db);<br>$perf =& NewPerfMonitor($conn);<br>$perf->UI($pollsecs=5);<br>?><br></pre>
|
||||
<p>It is also possible to retrieve a single database parameter:</p>
|
||||
<pre>$size = $perf->DBParameter('data cache size');<br></pre>
|
||||
<p>
|
||||
Thx to Fernando Ortiz for the informix module. </p>
|
||||
<h3>Methods</h3>
|
||||
<a name="ui"></a>
|
||||
<p><font face="Courier New, Courier, mono">function <b>UI($pollsecs=5)</b></font></p>
|
||||
<p>Creates a web-based user interface for performance monitoring. When
|
||||
you click on Poll, server statistics will be displayed every $pollsecs
|
||||
seconds. See <a href="#usage">Usage</a> above. </p>
|
||||
<p>Since 4.11, we allow users to enter and run SQL interactively via
|
||||
the "Run SQL" link. To disable this for security reasons, set this
|
||||
constant before calling $perf->UI(). </p>
|
||||
<p> </p>
|
||||
<pre>define('ADODB_PERF_NO_RUN_SQL',1);</pre>
|
||||
<p>Sample output follows below:</p>
|
||||
<table bgcolor="lightyellow" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> <b><a href="http://php.weblogs.com/adodb?perf=1">ADOdb</a>
|
||||
Performance Monitor</b> for localhost, db=test<br>
|
||||
<font size="-1">PostgreSQL 7.3.2 on i686-pc-cygwin, compiled by
|
||||
GCC gcc (GCC) 3.2 20020927 (prerelease)</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <a href="#">Performance Stats</a> <a href="#">View
|
||||
SQL</a> <a href="#">View Tables</a> <a href="#">Poll
|
||||
Stats</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>postgres7</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>statistics collector</td>
|
||||
<td>TRUE</td>
|
||||
<td>Value must be TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i>
|
||||
and <i>stats_block_level</i> must be set to true in postgresql.conf)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache hit ratio</td>
|
||||
<td>99.7967555299239</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data reads</td>
|
||||
<td>125</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>21.78125000000000000</td>
|
||||
<td>Count of inserts/updates/deletes * coef</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache buffers</td>
|
||||
<td>640</td>
|
||||
<td>Number of cache buffers. <a
|
||||
href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic">Tuning</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cache blocksize</td>
|
||||
<td>8192</td>
|
||||
<td>(estimate)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache size</td>
|
||||
<td>5M</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>operating system cache size</td>
|
||||
<td>80M</td>
|
||||
<td>(effective cache size)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Memory Usage</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sort buffer size</td>
|
||||
<td>1M</td>
|
||||
<td>Size of sort buffer (per query)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>0</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max connections</td>
|
||||
<td>32</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Parameters</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>rollback buffers</td>
|
||||
<td>8</td>
|
||||
<td>WAL buffers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>random page cost</td>
|
||||
<td>4</td>
|
||||
<td>Cost of doing a seek (default=4). See <a
|
||||
href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#less">random_page_cost</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><font face="Courier New, Courier, mono">function <b>HealthCheck</b>()</font></p>
|
||||
<p>Returns database health check parameters as a HTML table. You will
|
||||
need to echo or print the output of this function,</p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>HealthCheckCLI</b>()</font></p>
|
||||
<p>Returns database health check parameters formatted for a command
|
||||
line interface. You will need to echo or print the output of this
|
||||
function. Sample output for mysql:</p>
|
||||
<pre>-- Ratios -- <br> MyISAM cache hit ratio =gt; 56.5635738832 <br> InnoDB cache hit ratio =gt; 0 <br> sql cache hit ratio =gt; 0 <br> -- IO -- <br> data reads =gt; 2622 <br> data writes =gt; 2415.5 <br> -- Data Cache -- <br> MyISAM data cache size =gt; 512K <br> BDB data cache size =gt; 8388600<br> InnoDB data cache size =gt; 8M<br> -- Memory Pools -- <br> read buffer size =gt; 131072 <br> sort buffer size =gt; 65528 <br> table cache =gt; 4 <br> -- Connections -- <br> current connections =gt; 3<br> max connections =gt; 100</pre>
|
||||
<p><font face="Courier New, Courier, mono">function <b>Poll</b>($pollSecs=5)
|
||||
</font> </p>
|
||||
<p> Run in infinite loop, displaying the following information every
|
||||
$pollSecs. This will not work properly if output buffering is enabled.
|
||||
In the example below, $pollSecs=3:
|
||||
</p>
|
||||
<pre>Accumulating statistics...<br> Time WS-CPU% Hit% Sess Reads/s Writes/s<br>11:08:30 0.7 56.56 1 0.0000 0.0000<br>11:08:33 1.8 56.56 2 0.0000 0.0000<br>11:08:36 11.1 56.55 3 2.5000 0.0000<br>11:08:39 9.8 56.55 2 3.1121 0.0000<br>11:08:42 2.8 56.55 1 0.0000 0.0000<br>11:08:45 7.4 56.55 2 0.0000 1.5000<br></pre>
|
||||
<p><b>WS-CPU%</b> is the Web Server CPU load of the server that PHP is
|
||||
running from (eg. the database client), and not the database. The <b>Hit%</b>
|
||||
is the data cache hit ratio. <b>Sess</b> is the current number of
|
||||
sessions connected to the database. If you are using persistent
|
||||
connections, this should not change much. The <b>Reads/s</b> and <b>Writes/s</b>
|
||||
are synthetic values to give the viewer a rough guide to I/O, and are
|
||||
not to be taken literally. </p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>SuspiciousSQL</b>($numsql=10)</font></p>
|
||||
<p>Returns SQL which have high average execution times as a HTML table.
|
||||
Each sql statement
|
||||
is hyperlinked to a new window which details the execution plan and the
|
||||
scripts that execute this SQL.
|
||||
</p>
|
||||
<p> The number of statements returned is determined by $numsql. Data is
|
||||
taken from the adodb_logsql table, where the sql statements are logged
|
||||
when
|
||||
$connection->LogSQL(true) is enabled. The adodb_logsql table is
|
||||
populated using <a href="docs-adodb.htm#logsql">$conn->LogSQL</a>.
|
||||
</p>
|
||||
<p>For Oracle, Ixora Suspicious SQL returns a list of SQL statements
|
||||
that are most cache intensive as a HTML table. These are data intensive
|
||||
SQL statements that could benefit most from tuning. </p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>ExpensiveSQL</b>($numsql=10)</font></p>
|
||||
<p>Returns SQL whose total execution time (avg time * #executions) is
|
||||
high as a HTML table. Each sql statement
|
||||
is hyperlinked to a new window which details the execution plan and the
|
||||
scripts that execute this SQL.
|
||||
</p>
|
||||
<p> The number of statements returned is determined by $numsql. Data is
|
||||
taken from the adodb_logsql table, where the sql statements are logged
|
||||
when
|
||||
$connection->LogSQL(true) is enabled. The adodb_logsql table is
|
||||
populated using <a href="docs-adodb.htm#logsql">$conn->LogSQL</a>.
|
||||
</p>
|
||||
<p>For Oracle, Ixora Expensive SQL returns a list of SQL statements
|
||||
that are taking the most CPU load when run.
|
||||
</p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>InvalidSQL</b>($numsql=10)</font></p>
|
||||
<p>Returns a list of invalid SQL as an HTML table.
|
||||
</p>
|
||||
<p>Data is taken from the adodb_logsql table, where the sql statements
|
||||
are logged when
|
||||
$connection->LogSQL(true) is enabled.
|
||||
</p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>Tables</b>($orderby=1)</font></p>
|
||||
<p>Returns information on all tables in a database, with the first two
|
||||
fields containing the table name and table size, the remaining fields
|
||||
depend on the database driver. If $orderby is set to 1, it will sort by
|
||||
name. If $orderby is set to 2, then it will sort by table size. Some
|
||||
database drivers (mssql and mysql) will ignore the $orderby clause. For
|
||||
postgresql, the information is up-to-date since the last <i>vacuum</i>.
|
||||
Not supported currently for db2.</p>
|
||||
<h3>Raw Functions</h3>
|
||||
<p>Raw functions return values without any formatting.</p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>DBParameter</b>($paramname)</font></p>
|
||||
<p>Returns the value of a database parameter, such as
|
||||
$this->DBParameter("data cache size").</p>
|
||||
<p><font face="Courier New, Courier, mono">function <b>CPULoad</b>()</font></p>
|
||||
<p>Returns the CPU load of the database client (NOT THE SERVER) as a
|
||||
percentage. Only works for Linux and Windows. For Windows, WMI must be
|
||||
available.</p>
|
||||
<h3>$ADODB_PERF_MIN</h3>
|
||||
<p>New in adodb 4.97/5.03 is this global variable, which controls whether sql timings which are too small are not saved. Currently it defaults
|
||||
to 0.05 (seconds). This means that all sql's which are faster than 0.05 seconds to execute are not saved.
|
||||
<h3>Format of $settings Property</h3>
|
||||
<p> To create new database parameters, you need to understand
|
||||
$settings. The $settings data structure is an associative array. Each
|
||||
element of the array defines a database parameter. The key is the name
|
||||
of the database parameter. If no key is defined, then it is assumed to
|
||||
be a section break, and the value is the name of the section break. If
|
||||
this is too confusing, looking at the source code will help a lot!</p>
|
||||
<p> Each database parameter is itself an array consisting of the
|
||||
following elements:</p>
|
||||
<ol start="0">
|
||||
<li> Category code, used to group related db parameters. If the
|
||||
category code is 'HIDE', then
|
||||
the database parameter is not shown when HTML() is called. <br>
|
||||
</li>
|
||||
<li> either
|
||||
<ol type="a">
|
||||
<li>sql string to retrieve value, eg. "select value from
|
||||
v\$parameter where name='db_block_size'", </li>
|
||||
<li>array holding sql string and field to look for, e.g.
|
||||
array('show variables','table_cache'); optional 3rd parameter is the
|
||||
$rs->fields[$index] to use (otherwise $index=1), and optional 4th
|
||||
parameter is a constant to multiply the result with (typically 100 for
|
||||
percentage calculations),</li>
|
||||
<li>a string prefixed by =, then a PHP method of the class is
|
||||
invoked, e.g. to invoke $this->GetIndexValue(), set this array
|
||||
element to '=GetIndexValue', <br>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li> Description of database parameter. If description begins with an
|
||||
=, then it is interpreted as a method call, just as in (1c) above,
|
||||
taking one parameter, the current value. E.g. '=GetIndexDescription'
|
||||
will invoke $this->GetIndexDescription($val). This is useful for
|
||||
generating tuning suggestions. For an example, see WarnCacheRatio().</li>
|
||||
</ol>
|
||||
<p>Example from MySQL, table_cache database parameter:</p>
|
||||
<pre>'table cache' =gt; array('CACHE', # category code<br> array("show variables", 'table_cache'), # array (type 1b)<br> 'Number of tables to keep open'), # description</pre>
|
||||
<h3>Example Health Check Output</h3>
|
||||
<p><a href="#db2">db2</a> <a href="#informix">informix</a> <a
|
||||
href="#mysql">mysql</a> <a href="#mssql">mssql</a> <a href="#oci8">oci8</a>
|
||||
<a href="#postgres">postgres</a></p>
|
||||
<p><a name="db2"></a></p>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>db2</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#ffffff">
|
||||
<td>data cache hit ratio</td>
|
||||
<td>0 </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i></td>
|
||||
</tr>
|
||||
<tr bgcolor="#ffffff">
|
||||
<td>data cache buffers</td>
|
||||
<td>250 </td>
|
||||
<td>See <a
|
||||
href="http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize">tuning
|
||||
reference</a>.</td>
|
||||
</tr>
|
||||
<tr bgcolor="#ffffff">
|
||||
<td>cache blocksize</td>
|
||||
<td>4096 </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#ffffff">
|
||||
<td>data cache size</td>
|
||||
<td>1000K </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i></td>
|
||||
</tr>
|
||||
<tr bgcolor="#ffffff">
|
||||
<td>current connections</td>
|
||||
<td>2 </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<p><a name="informix"></a>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>informix</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Val
|
||||
ue</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache hit
|
||||
ratio</td>
|
||||
<td>95.89</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data
|
||||
reads</td>
|
||||
<td>1883884</td>
|
||||
<td>Page reads</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>1716724</td>
|
||||
<td>Page writes</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>263.0</td>
|
||||
<td>Number of
|
||||
sessions</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
<p> </p>
|
||||
<p><a name="mysql" id="mysql"></a></p>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>mysql</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MyISAM cache hit ratio</td>
|
||||
<td>56.5658301822</td>
|
||||
<td><font color="red"><b>Cache ratio should be at least 90%</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>InnoDB cache hit ratio</td>
|
||||
<td>0</td>
|
||||
<td><font color="red"><b>Cache ratio should be at least 90%</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sql cache hit ratio</td>
|
||||
<td>0</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data reads</td>
|
||||
<td>2622</td>
|
||||
<td>Number of selects (Key_reads is not accurate)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>2415.5</td>
|
||||
<td>Number of inserts/updates/deletes * coef (Key_writes is not
|
||||
accurate)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MyISAM data cache size</td>
|
||||
<td>512K</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BDB data cache size</td>
|
||||
<td>8388600</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>InnoDB data cache size</td>
|
||||
<td>8M</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Memory Pools</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>read buffer size</td>
|
||||
<td>131072</td>
|
||||
<td>(per session)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sort buffer size</td>
|
||||
<td>65528</td>
|
||||
<td>Size of sort buffer (per session)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>table cache</td>
|
||||
<td>4</td>
|
||||
<td>Number of tables to keep open</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>3</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max connections</td>
|
||||
<td>100</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<p><a name="mssql" id="mssql"></a></p>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>mssql</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache hit ratio</td>
|
||||
<td>99.9999694824</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>prepared sql hit ratio</td>
|
||||
<td>99.7738579828</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>adhoc sql hit ratio</td>
|
||||
<td>98.4540169133</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data reads</td>
|
||||
<td>2858</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>1438</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache size</td>
|
||||
<td>4362</td>
|
||||
<td>in K</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>14</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max connections</td>
|
||||
<td>32767</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<p><a name="oci8" id="oci8"></a></p>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>oci8</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache hit ratio</td>
|
||||
<td>96.98</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sql cache hit ratio</td>
|
||||
<td>99.96</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data reads</td>
|
||||
<td>842938</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>16852</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache buffers</td>
|
||||
<td>3072</td>
|
||||
<td>Number of cache buffers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache blocksize</td>
|
||||
<td>8192</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache size</td>
|
||||
<td>48M</td>
|
||||
<td>shared_pool_size</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Memory Pools</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>java pool size</td>
|
||||
<td>0</td>
|
||||
<td>java_pool_size</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sort buffer size</td>
|
||||
<td>512K</td>
|
||||
<td>sort_area_size (per query)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user session buffer size</td>
|
||||
<td>8M</td>
|
||||
<td>large_pool_size</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>1</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max connections</td>
|
||||
<td>170</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache utilization ratio</td>
|
||||
<td>88.46</td>
|
||||
<td>Percentage of data cache actually in use</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user cache utilization ratio</td>
|
||||
<td>91.76</td>
|
||||
<td>Percentage of user cache (large_pool) actually in use</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>rollback segments</td>
|
||||
<td>11</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Transactions</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>peak transactions</td>
|
||||
<td>24</td>
|
||||
<td>Taken from high-water-mark</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max transactions</td>
|
||||
<td>187</td>
|
||||
<td>max transactions / rollback segments < 3.5 (or
|
||||
transactions_per_rollback_segment)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Parameters</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cursor sharing</td>
|
||||
<td>EXACT</td>
|
||||
<td>Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR
|
||||
(9i+). See <a
|
||||
href="http://www.praetoriate.com/oracle_tips_cursor_sharing.htm">cursor_sharing</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>index cache cost</td>
|
||||
<td>0</td>
|
||||
<td>% of indexed data blocks expected in the cache. Recommended
|
||||
is 20-80. Default is 0. See <a
|
||||
href="http://www.dba-oracle.com/oracle_tips_cbo_part1.htm">optimizer_index_caching</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>random page cost</td>
|
||||
<td>100</td>
|
||||
<td>Recommended is 10-50 for TP, and 50 for data warehouses.
|
||||
Default is 100. See <a
|
||||
href="http://www.dba-oracle.com/oracle_tips_cost_adj.htm">optimizer_index_cost_adj</a>.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Suspicious SQL</h3>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><b>LOAD</b></td>
|
||||
<td><b>EXECUTES</b></td>
|
||||
<td><b>SQL_TEXT</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> .73%</td>
|
||||
<td align="right">89</td>
|
||||
<td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o,
|
||||
sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576)
|
||||
and o.obj#=t.obj# and o.owner# = u.user# select i.obj#, i.flags,
|
||||
u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where
|
||||
(bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and
|
||||
(not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and
|
||||
o.owner# = u.user# </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> .84%</td>
|
||||
<td align="right">3</td>
|
||||
<td>select /*+ RULE */ distinct tabs.table_name, tabs.owner ,
|
||||
partitioned, iot_type , TEMPORARY, table_type, table_type_owner from
|
||||
DBA_ALL_TABLES tabs where tabs.owner = :own </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> 3.95%</td>
|
||||
<td align="right">6</td>
|
||||
<td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM
|
||||
DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE
|
||||
obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
|
||||
seg.owner and obj.object_name = seg.segment_name and obj.object_type =
|
||||
seg.segment_type and seg.buffer_pool = buf.name and buf.name =
|
||||
'DEFAULT' </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> 4.50%</td>
|
||||
<td align="right">6</td>
|
||||
<td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM
|
||||
DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE
|
||||
obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
|
||||
seg.owner and obj.object_name = seg.segment_name and obj.object_type =
|
||||
seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">57.34%</td>
|
||||
<td align="right">9267</td>
|
||||
<td>select t.schema, t.name, t.flags, q.name from
|
||||
system.aq$_queue_tables t, sys.aq$_queue_table_affinities aft,
|
||||
system.aq$_queues q where aft.table_objno = t.objno and
|
||||
aft.owner_instance = :1 and q.table_objno = t.objno and q.usage = 0 and
|
||||
bitand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name,
|
||||
aft.table_objno skip locked </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Expensive SQL</h3>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><b>LOAD</b></td>
|
||||
<td><b>EXECUTES</b></td>
|
||||
<td><b>SQL_TEXT</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> 5.24%</td>
|
||||
<td align="right">1</td>
|
||||
<td>select round(sum(bytes)/1048576) from dba_segments </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> 6.89%</td>
|
||||
<td align="right">6</td>
|
||||
<td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM
|
||||
DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE
|
||||
obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
|
||||
seg.owner and obj.object_name = seg.segment_name and obj.object_type =
|
||||
seg.segment_type and seg.buffer_pool = buf.name and buf.name =
|
||||
'DEFAULT' </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"> 7.85%</td>
|
||||
<td align="right">6</td>
|
||||
<td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM
|
||||
DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE
|
||||
obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
|
||||
seg.owner and obj.object_name = seg.segment_name and obj.object_type =
|
||||
seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">33.69%</td>
|
||||
<td align="right">89</td>
|
||||
<td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o,
|
||||
sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576)
|
||||
and o.obj#=t.obj# and o.owner# = u.user# </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">36.44%</td>
|
||||
<td align="right">89</td>
|
||||
<td>select i.obj#, i.flags, u.name, o.name from sys.obj$ o,
|
||||
sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or
|
||||
bitand(i.flags, 512) = 512) and (not((i.type# = 9) and
|
||||
bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><a name="postgres" id="postgres"></a></p>
|
||||
<table bgcolor="white" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<h3>postgres7</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Parameter</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Description</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Ratios</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>statistics collector</td>
|
||||
<td>FALSE</td>
|
||||
<td>Must be set to TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i>
|
||||
and <i>stats_block_level</i> must be set to true in postgresql.conf)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache hit ratio</td>
|
||||
<td>99.9666031916603</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>IO</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data reads</td>
|
||||
<td>15</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data writes</td>
|
||||
<td>0.000000000000000000</td>
|
||||
<td>Count of inserts/updates/deletes * coef</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Data Cache</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache buffers</td>
|
||||
<td>1280</td>
|
||||
<td>Number of cache buffers. <a
|
||||
href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic">Tuning</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cache blocksize</td>
|
||||
<td>8192</td>
|
||||
<td>(estimate)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data cache size</td>
|
||||
<td>10M</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>operating system cache size</td>
|
||||
<td>80000K</td>
|
||||
<td>(effective cache size)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Memory Pools</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sort buffer size</td>
|
||||
<td>1M</td>
|
||||
<td>Size of sort buffer (per query)</td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Connections</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current connections</td>
|
||||
<td>13</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max connections</td>
|
||||
<td>32</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr bgcolor="#f0f0f0">
|
||||
<td colspan="3"><i>Parameters</i> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>rollback buffers</td>
|
||||
<td>8</td>
|
||||
<td>WAL buffers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>random page cost</td>
|
||||
<td>4</td>
|
||||
<td>Cost of doing a seek (default=4). See <a
|
||||
href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#less">random_page_cost</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user