Example #1
0
<?php

/* Lots of database changes required for the move from fixed
 * asset manager v2 to v3
 */
RenameTable('assetmanager', 'fixedassets', $db);
AddColumn('assetcategoryid', 'fixedassets', 'varchar(6)', 'NOT NULL', '', 'disposalvalue', $db);
AddColumn('description', 'fixedassets', 'varchar(50)', 'NOT NULL', '', 'assetcategoryid', $db);
AddColumn('longdescription', 'fixedassets', 'text', 'NOT NULL', '', 'description', $db);
AddColumn('depntype', 'fixedassets', 'int(11)', 'NOT NULL', 1, 'longdescription', $db);
AddColumn('depnrate', 'fixedassets', 'double', 'NOT NULL', 0.0, 'depntype', $db);
AddColumn('barcode', 'fixedassets', 'varchar(30)', 'NOT NULL', '', 'depnrate', $db);
ChangeColumnName('depn', 'fixedassets', 'double', 'NOT NULL', 0.0, 'accumdepn', $db);
ChangeColumnName('location', 'fixedassets', 'varchar(6)', 'NOT NULL', '', 'assetlocation', $db);
if (DB_table_exists('fixedassets', $db)) {
    $sql = "desc fixedassets stockid";
    $result = DB_query($sql, $db);
    if (DB_num_rows($result) > 0) {
        $response = executeSQL("UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid,\nfixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription", $db, False);
        if ($response == 0) {
            OutputResult(_('The fixedassets table has been updated from stockmaster'), 'success');
        } else {
            OutputResult(_('The fixedassets table could not be updated from stockmaster'), 'error');
        }
    } else {
        OutputResult(_('The fixedassets table is already correct'), 'info');
    }
} else {
    $response = executeSQL("UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid,\nfixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription", $db, False);
}
Createtable('fixedassetcategories', "CREATE TABLE IF NOT EXISTS `fixedassetcategories` (\n  `categoryid` char(6) NOT NULL DEFAULT '',\n  `categorydescription` char(20) NOT NULL DEFAULT '',\n  `costact` int(11) NOT NULL DEFAULT '0',\n  `depnact` int(11) NOT NULL DEFAULT '0',\n  `disposalact` int(11) NOT NULL DEFAULT '80000',\n  `accumdepnact` int(11) NOT NULL DEFAULT '0',\n  defaultdepnrate double NOT NULL DEFAULT '.2',\n  defaultdepntype int NOT NULL DEFAULT '1',\n  PRIMARY KEY (`categoryid`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8", $db);
Example #2
0
<?php

/* Include the new script for printing quotations in Portrait
 */
InsertRecord('pagesecurity', array('script', 'security'), array('doc/Manual/ManualContents.php', 1), array('script', 'security'), array('doc/Manual/ManualContents.php', 1), $db);
RenameTable('dispatch', 'stockrequest', $db);
RenameTable('dispatchitems', 'stockrequestitems', $db);
AddColumn('decimalplaces', 'stockrequestitems', 'int', 'not null', 0, 'quantity', $db);
AddColumn('uom', 'stockrequestitems', 'varchar(20)', 'not null', '', 'decimalplaces', $db);
ChangeColumnType('dispatchid', 'stockrequest', 'INT (11)', 'NOT NULL', 0, $db);
InsertRecord('systypes', array('typeid'), array('38'), array('typeid', 'typename', 'typeno'), array('38', 'Stock Requests', '0'), $db);
UpdateDBNo(97, $db);
Example #3
0
File: 2.php Project: rrsc/KwaMoja
AddConstraint('taxgrouptaxes', 'taxgrouptaxes_ibfk_1', 'taxgroupid', 'taxgroups', 'taxgroupid', $db);
AddConstraint('taxgrouptaxes', 'taxgrouptaxes_ibfk_2', 'taxauthid', 'taxauthorities', 'taxid', $db);
CreateTable('stockmovestaxes', "CREATE TABLE stockmovestaxes (\n\tstkmoveno int NOT NULL,\n\ttaxauthid tinyint NOT NULL,\n\ttaxontax TINYINT DEFAULT 0 NOT NULL,\n\ttaxcalculationorder TINYINT NOT NULL,\n\ttaxrate double DEFAULT 0 NOT NULL,\n\tPRIMARY KEY (stkmoveno,taxauthid),\n\tKEY (taxauthid),\n\tKEY (taxcalculationorder)\n)", $db);
AddConstraint('stockmovestaxes', 'stockmovestaxes_ibfk_1', 'taxauthid', 'taxauthorities', 'taxid', $db);
DropColumn('taxrate', 'stockmoves', $db);
CreateTable('debtortranstaxes', "CREATE TABLE debtortranstaxes (\n\t`debtortransid` INT NOT NULL ,\n\t`taxauthid` TINYINT NOT NULL ,\n\t`taxamount` DOUBLE NOT NULL,\n\tPRIMARY KEY(debtortransid, taxauthid),\n\tKEY (taxauthid)\n)", $db);
AddConstraint('debtortranstaxes', 'debtortranstaxes_ibfk_1', 'taxauthid', 'taxauthorities', 'taxid', $db);
AddConstraint('debtortranstaxes', 'debtortranstaxes_ibfk_2', 'debtortransid', 'debtortrans', 'id', $db);
DropConstraint('custbranch', 'custbranch_ibfk_5', $db);
ChangeColumnName('taxauthority', 'custbranch', 'TINYINT(4)', 'NOT NULL', '1', 'taxgroupid', $db);
DropIndex('custbranch', 'area_2', $db);
DropIndex('custbranch', 'taxauthority', $db);
AddIndex(array('taxgroupid'), 'custbranch', 'taxgroupid', $db);
//InsertRecord('taxgroups', array('taxgroupid', 'taxgroupdescription'), array(NULL,'Default tax group'), array('taxgroupid', 'taxgroupdescription'), array(NULL,'Default tax group'), $db);
AddConstraint('custbranch', 'custbranch_ibfk_7', 'taxgroupid', 'taxgroups', 'taxgroupid', $db);
RenameTable('taxauthlevels', 'taxauthrates', $db);
AddConstraint('taxauthrates', 'taxauthrates_ibfk_1', 'dispatchtaxprovince', 'taxprovinces', 'taxprovinceid', $db);
ChangeColumnName('taxlevel', 'stockmaster', 'TINYINT(4)', 'NOT NULL', '1', 'taxcatid', $db);
AddIndex(array('taxcatid'), 'stockmaster', 'stockmaster_ibix_1', $db);
AddConstraint('stockmaster', 'stockmaster_ibfk_2', 'taxcatid', 'taxcategories', 'taxcatid', $db);
DropPrimaryKey('salesorderdetails', array('orderno', 'stkcode'), $db);
AddColumn('orderlineno', 'salesorderdetails', 'INT(11)', 'NOT NULL', '0', 'orderno', $db);
AddPrimaryKey('salesorderdetails', array('orderno', 'orderlineno'), $db);
NewConfigValue('FreightTaxCategory', '1', $db);
NewConfigValue('SO_AllowSameItemMultipleTimes', '1', $db);
CreateTable('supptranstaxes', "CREATE TABLE `supptranstaxes` (\n  `supptransid` int(11) NOT NULL default '0',\n  `taxauthid` tinyint(4) NOT NULL default '0',\n  `taxamount` double NOT NULL default '0',\n  PRIMARY KEY  (`supptransid`,`taxauthid`),\n  KEY `taxauthid` (`taxauthid`),\n  CONSTRAINT `supptranstaxes_ibfk_1` FOREIGN KEY (`taxauthid`) REFERENCES `taxauthorities` (`taxid`),\n  CONSTRAINT `supptranstaxes_ibfk_2` FOREIGN KEY (`supptransid`) REFERENCES `supptrans` (`id`)\n)", $db);
DropConstraint('suppliers', 'suppliers_ibfk_3', $db);
ChangeColumnName('taxauthority', 'suppliers', 'TINYINT', 'NOT NULL', '1', 'taxgroupid', $db);
DropIndex('suppliers', 'taxauthority', $db);
AddIndex(array('taxgroupid'), 'suppliers', 'taxgroupid', $db);
AddConstraint('suppliers', 'suppliers_ibfk_3', 'taxgroupid', 'taxgroups', 'taxgroupid', $db);