<?php
                                                                                                    
/***************************************************************************
 *   copyright            : (C) 2010 PCRepairTracker.com
 *   email                : info@pcrepairtracker.com
 *   This program is a copyrighted work.
 *   Please see the license.txt file for details
 *
 ***************************************************************************/
$func = $_REQUEST[func];
                                                                                                    
function nothing() {
require_once("header.php");

echo "<a href=databaseupgrade-1.17to1.18.php?func=do_upgrade>Click Here</a> to upgrade the database from 1.17 to the 1.18 version of PC Repair Tracker.";

require_once("footer.php");
                                                                                                    
}


function do_upgrade() {
require_once("validate.php");
require("deps.php");
require("common.php");

$rs_connect = @mysql_connect($dbhost, $dbuname, $dbpass) or die("Couldn't connect the db");
$rs_select_db = @mysql_select_db($dbname, $rs_connect) or die("Couldn't select the db");


$sql1 = "ALTER TABLE quicklabor CHANGE laborprice laborprice DECIMAL(11,2) NOT NULL DEFAULT '0'";
$sql2 = "ALTER TABLE stock CHANGE stock_upc stock_upc TEXT NOT NULL DEFAULT ''";
$sql3 = "ALTER TABLE pc_scan ADD customprogname TEXT NOT NULL , ADD customprogword TEXT NOT NULL , ADD customprintinfo TEXT NOT NULL , ADD customscantype INT(11) NOT NULL DEFAULT '100'";
$sql4 = "ALTER TABLE pc_wo ADD pcpriority TEXT NOT NULL";


@mysql_query($sql1, $rs_connect);
@mysql_query($sql2, $rs_connect);
@mysql_query($sql3, $rs_connect);
@mysql_query($sql4, $rs_connect);
                            
header("Location: $domain/databaseupgrade-1.17to1.18.php?func=do_upgrade2");
}



function do_upgrade2() {
require_once("header.php");

echo "Upgrade Complete";

require_once("footer.php");

}




switch($func) {
                                                                                                    
    default:
    nothing();
    break;
                                
    case "do_upgrade":
    do_upgrade();
    break;

 case "do_upgrade2":
    do_upgrade2();
    break;


}

?>
