<?php
        //DISREGARD COMMENT        
        /*
        $hostname="localhost";
        $dbuser = "";
        $dbpass = "";
        $database = "clientexec_stable";

        $connection = mysql_connect($hostname, $dbuser, $dbpass) or die (_ERRORDBQUERY);
        mysql_select_db($database, $connection) or die("Can not select database: $database");
        */
        
        //Get Welcome Email from Promotion and move to each individual plan
        $query ="SELECT id,welcomeemail FROM promotion";
        $result = mysql_query($query) or die("ERROR (Getting Welcome Emails): $query");
        while(list($planid,$welcomeemail) = mysql_fetch_row($result)){
        	  //with planid set package welcome emails        	
              $query2 = "UPDATE package SET welcomeemail='$welcomeemail' WHERE planid=".$planid;
              $result2 = mysql_query($query2) or die("Updating welcome email in package: $query2");
        }

        //Get All Domains and their perspective clienttypes
        $query ="SELECT d.id,c.clienttype FROM domains d, users c WHERE d.customerid=c.id";
        $result = mysql_query($query) or die("ERROR (Getting Welcome Emails): $query");
        while(list($domainid,$clienttype) = mysql_fetch_row($result)){
        	  //with clienttype of customer populate domain's promotionid        	
              $query2 = "UPDATE domains SET promotionid=$clienttype WHERE id=".$domainid;
              $result2 = mysql_query($query2) or die("Update Domain with ClientType Error: $query2<br>".mysql_error());
        }                
?>
