Index: modules/base/include/tabledefs_columns_include.php
===================================================================
--- modules/base/include/tabledefs_columns_include.php	(revision 675)
+++ modules/base/include/tabledefs_columns_include.php	(working copy)
@@ -221,7 +221,7 @@
                 tabledefid = '".$this->tabledefuuid."'
                 AND displayorder > ".$therecord["displayorder"];
 
-        if($this->db->query($queryresult)){
+        if($this->db->query($updatestatement)){
 
             $deletestatement = "
                 DELETE FROM
Index: modules/bms/clientemailprojects_edit.php
===================================================================
--- modules/bms/clientemailprojects_edit.php	(revision 675)
+++ modules/bms/clientemailprojects_edit.php	(working copy)
@@ -112,7 +112,7 @@
 		<legend>e-mail</legend>
 		<p>
 			<label for="from">from</label><br />
-			<?php if(is_numeric($therecord["emailfrom"])) $therecord["emailfrom"]=getEmailInfo($therecord["emailfrom"]);?>
+			<?php if(is_numeric($therecord["emailfrom"])) $therecord["emailfrom"]=$thetable->getEmailInfo($therecord["emailfrom"]);?>
 			<input id="from" name="from" value="<?php echo htmlQuotes($therecord["emailfrom"])?>" readonly="readonly" class="uneditable" size="60" />
 		</p>
 		<p>
Index: modules/bms/clients_email.php
===================================================================
--- modules/bms/clients_email.php	(revision 675)
+++ modules/bms/clients_email.php	(working copy)
@@ -1,4 +1,4 @@
-<?php 
+<?php
 /*
  $Rev$ | $LastChangedBy$
  $LastChangedDate$
@@ -40,11 +40,11 @@
 	include("include/fields.php");
 
 	include("./include/clients_email_include.php");
-	
-	
+
+
 	$thecommand="showoptions";
 	if(isset($_POST["command"])) $thecommand=$_POST["command"];
-	
+
 	switch($thecommand){
 		case "send email":
 			 // first build the where clause
@@ -53,7 +53,7 @@
 					$whereclause="WHERE ";
 					foreach($_SESSION["emailids"] as $id)
 						$whereclause.="clients.id=".$id." or ";
-					$whereclause=substr($whereclause,0,strlen($whereclause)-3);					
+					$whereclause=substr($whereclause,0,strlen($whereclause)-3);
 				break;
 				case "savedsearch":
 					$querystatement="SELECT sqlclause FROM usersearches WHERE id=".$_POST["savedsearches"];
@@ -63,19 +63,19 @@
 				break;
 				case "all":
 					$whereclause="";
-				break;						
+				break;
 			}//end switch
 			//next the from:
-			$_SESSION["massemail"]["from"]=str_replace("]",">",str_replace("[","<",$_POST["ds-email"]));			
+			$_SESSION["massemail"]["from"]=str_replace("]",">",str_replace("[","<",$_POST["ds-email"]));
 			$_SESSION["massemail"]["whereclause"]=$whereclause;
 			$_SESSION["massemail"]["subject"]=$_POST["subject"];
 			$_SESSION["massemail"]["body"]=$_POST["body"];
 			$_SESSION["massemail"]["savedproject"]=$_POST["pid"];
-			
+
 			$querystatement="SELECT id,email, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) AS name FROM clients ".$whereclause;
 			$sendqueryresult=$db->query($querystatement);
 			if(!$sendqueryresult) $error = new appError(300,"Error with: ".$querystatement);
-			
+
 		break;
 		case "delete project":
 			deleteProject($db, $_POST["projectid"]);
@@ -96,92 +96,92 @@
 		case "save project":
 			$id=saveProject($db,addSlashesToArray($_POST));
 			$statusmessage="Project Saved";
-			$therecord=loadProject($id);
+			$therecord=loadProject($db, $id);
 			$thecommand="showoptions";
 		break;
-		
+
 		case "done":
 		case "cancel":
 			goURL(APP_PATH."search.php?id=2");
-			
+
 		break;
 	}
-	
-	
+
+
 	$pageTitle="Client/Prospect E-Mail";
- 
+
  	$phpbms->cssIncludes[] = "pages/clientemail.css";
 	$phpbms->jsIncludes[] = "modules/bms/javascript/clientemail.js";
 
 		//Form Elements
 		//==============================================================
 		$theform = new phpbmsForm();
-		
+
 		if(is_numeric($therecord["emailfrom"]))
 			$theid=$therecord["emailfrom"];
 		else
 			$theid=0;
-		
+
 		$theinput = new inputSmartSearch($db, "email", "Pick Active User Email", $theid, "from");
 		$theform->addField($theinput);
-		
+
 		$theform->jsMerge();
 		//==============================================================
 		//End Form Elements
-		
+
 		if($therecord["emailto"]!="selected" AND $therecord["emailto"]!="all")
 			$phpbms->bottomJS[] ='thediv=getObjectFromID("showsavedsearches");thediv.style.display="block"';
 
 		if(!is_numeric($therecord["emailfrom"]))
 			$phpbms->bottomJS[] ='thefield=getObjectFromID("ds-email");thefield.value="'.$therecord["emailfrom"].'"';
-		
+
 		if($thecommand=="send email"){
-		
-			$phpbms->topJS[]='		
-			ids=new Array();			
+
+			$phpbms->topJS[]='
+			ids=new Array();
 			emails=new Array();
 			names= new Array();';
-			
+
 			while($therecord = $db->fetchArray($sendqueryresult)){
 				$phpbms->topJS[]="ids[ids.length]=".$therecord["id"].";";
 				$phpbms->topJS[]="names[names.length]=\"".$therecord["name"]."\";";
 				$phpbms->topJS[]="emails[emails.length]=\"".$therecord["email"]."\";";
-			}			
+			}
 		}//end if
- 
+
  	include("header.php")
 
 ?>
 
 	<div class="bodyline" id="mainBG">
 		<h1 id="topTitle"><span><?php echo $pageTitle?></span></h1>
-		
+
 		<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" name="theform" id="theform">
 	<?php if($thecommand=="showoptions") { ?>
-	
+
 		<input type="hidden" name="pid" id="pid" value="<?php echo $therecord["id"]?>" />
 		<div class="box">
-			
+
 			<p id="toP">
-				<label for="therecords">to</label><br />			
+				<label for="therecords">to</label><br />
 				<select id="therecords" name="therecords" onchange="showSavedSearches(this);">
 					<option value="selected" <?php if ($therecord["emailto"]=="selected") echo "selected=\"selected\""?>>e-mail addresses from selected records (<?php echo count($_SESSION["emailids"]) ?> record<?php if(count($_SESSION["emailids"])>1) echo "s"?>)</option>
 					<option value="savedsearch" <?php if ($therecord["emailto"]!="selected" AND $therecord["emailto"]!="all") echo "selected=\"selected\""?>>e-mail addresses from saved search...</option>
-				</select>				
+				</select>
 			</p>
 			<p id="showsavedsearches" >
 				<label for="savedsearches">load e-mail addresses from saved search...</label><br />
-				<?php showSavedSearches($db,$therecord["emailto"]); ?>			
+				<?php showSavedSearches($db,$therecord["emailto"]); ?>
 			</p>
-			
+
 			<div class="fauxP" id="fromDiv"><?php  $theform->showField("email")?></div>
-			
+
 			<p>
 				<label for="subject">subject</label><br />
-				<input type="text" name="subject" id="subject" maxlength="128" value="<?php echo htmlQuotes($therecord["subject"])?>"/>			
+				<input type="text" name="subject" id="subject" maxlength="128" value="<?php echo htmlQuotes($therecord["subject"])?>"/>
 			</p>
 		</div>
-		
+
 		<div class="box">
 			<p>
 				<label for="addfield">add data field</label><br />
@@ -193,7 +193,7 @@
 				<textarea class="mono" rows="15" name="body" id="body" cols="40" ><?php echo $therecord["body"]?></textarea>
 			</p>
 		</div>
-		
+
 		<div class="box">
 			<div id="projectButtons">
 				<input type="button" name="loademail"	id="loademil" value="load project..." class="Buttons" onclick="showSavedProjects();" />
@@ -204,10 +204,10 @@
 			<div align="right">
 				<input type="submit" name="command" 	id="sendemail" value="send email" class="Buttons" />
 				<input type="submit" name="command" 	id="cancel" value="cancel" class="Buttons" />
-				<input type="submit" name="command" 	id="othercommand" value="" class="Buttons" />				
+				<input type="submit" name="command" 	id="othercommand" value="" class="Buttons" />
 			</div>
 		</div>
-		
+
 		<div id="loadedprojects">
 			<p><?php showSavedProjects($db)?></p>
 			<p align="right">
@@ -217,7 +217,7 @@
 			</p>
 		</div>
 <?php } elseif($thecommand=="send email"){?>
-		
+
 		<div id="processingWrap">
 			<div class="box">
 				<div class="fauxP">
Index: modules/bms/install/tablecolumns.sql
===================================================================
--- modules/bms/install/tablecolumns.sql	(revision 675)
+++ modules/bms/install/tablecolumns.sql	(working copy)
@@ -44,7 +44,7 @@
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883', 'payment', 'paymentmethods.name', 'left', '', '7', '', '0', '', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'e-mail', 'clients.email', 'left', '', '3', '', '0', '', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'has credit', 'clients.hascredit', 'center', '', '1', '', '0', '', 'boolean', 'role:c9439c3c-499b-7bcc-ee14-fec5bfcf5fc2');
-INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'name / location', 'CONCAT(\'[b]\',IF(clients.company != \'\', CONCAT(clients.company,IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(\' (\',if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\'),\')\'), \'\')), IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\')), \'\')),\'[/b][br][space]\', IF(addresses.city != \'\' OR addresses.state !=\'\' OR addresses.postalcode != \'\', CONCAT(IF(addresses.city != \'\',addresses.city,\'\'),\', \',IF(addresses.state != \'\', addresses.state, \'\'),\' \',IF(addresses.postalcode != \'\', addresses.postalcode, \'\')),\'(no location)\'))', 'left', '', '2', 'concat(clients.company,cliennts.lastname,clients.firstname)', '0', '100%', 'bbcode', '');
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'name / location', 'CONCAT(\'[b]\',IF(clients.company != \'\', CONCAT(clients.company,IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(\' (\',if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\'),\')\'), \'\')), IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\')), \'\')),\'[/b][br][space]\', IF(addresses.city != \'\' OR addresses.state !=\'\' OR addresses.postalcode != \'\', CONCAT(IF(addresses.city != \'\',addresses.city,\'\'),\', \',IF(addresses.state != \'\', addresses.state, \'\'),\' \',IF(addresses.postalcode != \'\', addresses.postalcode, \'\')),\'(no location)\'))', 'left', '', '2', 'concat(clients.company,clients.lastname,clients.firstname)', '0', '100%', 'bbcode', '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'type', 'clients.type', 'left', '', '0', '', '0', '', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'phone', 'IF(clients.workphone != \'\' OR clients.homephone != \'\' OR clients.mobilephone != \'\' OR clients.otherphone != \'\',IF(clients.workphone != \'\', concat(clients.workphone, \' (w)\'), IF(clients.homephone != \'\', concat(clients.homephone, \' (h)\'), IF(clients.mobilephone != \'\', concat(clients.mobilephone, \' (m)\'), IF(clients.otherphone != \'\', concat(clients.otherphone, \' (o)\'), \'\')))) ,\'\')', 'left', '', '4', 'concat(clients.workphone, clients.homephone, clients.mobilephone,clients.otherphone)', '0', '', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34', 'part number', 'products.partnumber', 'left', '', '0', '', '0', '', NULL, '');
@@ -83,4 +83,8 @@
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:f993cf23-ad4a-047b-e920-d45fee1dc08e', 'name', 'IF(clients.company != \'\', CONCAT(clients.company,IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(\' (\',if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\'),\')\'), \'\')), IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\')), \'\'))', 'left', '', '2', 'concat(clients.company,clients.lastname,clients.firstname)', '1', '100%', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:fa8a0ddc-87d3-a9e9-60b0-1bab374b2993', 'name', 'shippingmethods.name', 'left', '', '1', '', '0', '99%', NULL, '');
 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:fa8a0ddc-87d3-a9e9-60b0-1bab374b2993', 'estimate', 'shippingmethods.canestimate', 'center', '', '2', '', '0', '', 'boolean', '');
-INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:fa8a0ddc-87d3-a9e9-60b0-1bab374b2993', 'priority', 'shippingmethods.priority', 'right', '', '0', '', '0', '', NULL, '');
\ No newline at end of file
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:fa8a0ddc-87d3-a9e9-60b0-1bab374b2993', 'priority', 'shippingmethods.priority', 'right', '', '0', '', '0', '', NULL, '');
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:b3d23f9e-d363-0357-e383-10eb89f5daa3', 'id', 'contacts.id', 'left', '', 0, '', 0, '', NULL, '');
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:b3d23f9e-d363-0357-e383-10eb89f5daa3', 'phone', 'IF(contacts.workphone != '''' OR contacts.homephone != '''' OR contacts.mobilephone != '''' OR contacts.otherphone != '''',IF(contacts.workphone != '''', concat(contacts.workphone, '' (w)''), IF(contacts.homephone != '''', concat(contacts.homephone, '' (h)''), IF(contacts.mobilephone != '''', concat(contacts.mobilephone, '' (m)''), IF(contacts.otherphone != '''', concat(contacts.otherphone, '' (o)''), '''')))) ,'''')', 'left', '', 3, 'concat(clients.workphone, clients.homephone, clients.mobilephone,clients.otherphone)', 0, '', NULL, '');
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:b3d23f9e-d363-0357-e383-10eb89f5daa3', 'e-mail', 'contacts.email', 'left', '', 2, '', 0, '', NULL, '');
+INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('tbld:b3d23f9e-d363-0357-e383-10eb89f5daa3', 'name', 'CONCAT(''[b]'',IF(contacts.lastname = '''', contacts.firstname, CONCAT(CONCAT(contacts.firstname, '', ''),contacts.lastname)),''[/b]'')', 'left', '', 1, 'concat(contacts.lastname,contacts.firstname)', 0, '100%', 'bbcode', '');
Index: modules/bms/invoices_addresses_ajax.php
===================================================================
--- modules/bms/invoices_addresses_ajax.php	(revision 675)
+++ modules/bms/invoices_addresses_ajax.php	(working copy)
@@ -106,7 +106,7 @@
 
 			} else {
 
-				?><p><em>no records found</em></p><?
+				?><p><em>no records found</em></p><?php
 
 			}//endif numrows
 

