浏览代码

This revision makes trunk unstable I will add will a commit message to notify when its considered stable again. Change v_id to domain_uuid, add primary and foreign keys to the app array.

Mark Crane 13 年之前
父节点
当前提交
4790f677dc

+ 2 - 2
flashphoner/flashphoner.php

@@ -44,7 +44,7 @@ $extension = $_SESSION['user_extension_array'][0]['extension'];
 //get a list of assigned extensions for this user
 $sql = "";
 $sql .= "select * from v_extensions ";
-$sql .= "where v_id = '$v_id' ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
 $sql .= "and user_list like '%|".$_SESSION["username"]."|%' ";
 $prepstatement = $db->prepare(check_sql($sql));
 $prepstatement->execute();
@@ -60,7 +60,7 @@ foreach ($result as &$row) {
 unset ($prepstatement);
 
 if ($x > 0) {
-	$key = guid();
+	$key = uuid();
 	$client_ip = $_SERVER['REMOTE_ADDR'];
 	$sql = sprintf("INSERT INTO v_flashphone_auth (auth_key, hostaddr, createtime, username) values ('%s', '%s', now(), '%s')",
 			$key, $client_ip, $_SESSION["username"]);

+ 28 - 22
flashphoner/v_config.php

@@ -22,26 +22,32 @@
 		$apps[$x]['permissions'][0]['groups'][] = 'admin';
 		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
 
-	// CREATE TABLE v_flashphone_auth 
-		$apps[$x]['db'][0]['table'] = 'v_flashphone_auth';
-		$apps[$x]['db'][0]['fields'][0]['name'] = 'auth_serial';
-		$apps[$x]['db'][0]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][0]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][0]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][0]['fields'][0]['description'] = '';
-		$apps[$x]['db'][0]['fields'][1]['name'] = 'auth_key';
-		$apps[$x]['db'][0]['fields'][1]['type'] = 'text';
-		$apps[$x]['db'][0]['fields'][1]['description'] = '';
-		$apps[$x]['db'][0]['fields'][2]['name'] = 'hostaddr';
-		$apps[$x]['db'][0]['fields'][2]['type'] = 'text';
-		$apps[$x]['db'][0]['fields'][2]['description'] = '';
-		$apps[$x]['db'][0]['fields'][3]['name'] = 'createtime';
-		$apps[$x]['db'][0]['fields'][3]['type']['pgsql'] = 'timestamp';
-		$apps[$x]['db'][0]['fields'][3]['type']['sqlite'] = 'date';
-		$apps[$x]['db'][0]['fields'][3]['type']['mysql'] = 'timestamp';
-		$apps[$x]['db'][0]['fields'][3]['description'] = '';
-		$apps[$x]['db'][0]['fields'][4]['name'] = 'username';
-		$apps[$x]['db'][0]['fields'][4]['type'] = 'text';
-		$apps[$x]['db'][0]['fields'][4]['description'] = '';
+	//schema details
+		$y = 0; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_flashphone_auth';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'auth_serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'auth_key';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hostaddr';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'createtime';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'username';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 
-?>
+?>

+ 51 - 10
invoices/v_config.php

@@ -60,13 +60,29 @@
 		$y = 0; //table array index
 		$z = 0; //field array index
 		$apps[$x]['db'][$y]['table'] = 'v_invoices';
-		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_id';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'id';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'invoice_id';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
 		$z++;
-		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
-		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'domain_id ';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'v_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'contact_id_from';
@@ -94,18 +110,42 @@
 
 		$y = 1; //table array index
 		$apps[$x]['db'][$y]['table'] = 'v_invoice_items';
-		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_item_id';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'id';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'invoice_item_id';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_item_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
-		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_id';
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'item_qty';
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
@@ -121,4 +161,5 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'decimal(10,2)';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Enter the unit price.';
 		$z++;
-?>
+
+?>

+ 2 - 2
invoices/v_invoice_items.php

@@ -25,7 +25,7 @@ require_once "includes/paging.php";
 	//prepare to page the results
 		$sql = "";
 		$sql .= " select count(*) as num_rows from v_invoice_items ";
-		$sql .= " where v_id = '$v_id' ";
+		$sql .= " where domain_uuid = '$domain_uuid' ";
 		$sql .= " and invoice_id = '$invoice_id' ";
 		if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
 		$prep_statement = $db->prepare($sql);
@@ -51,7 +51,7 @@ require_once "includes/paging.php";
 	//get the invoice list
 		$sql = "";
 		$sql .= " select * from v_invoice_items ";
-		$sql .= " where v_id = '$v_id' ";
+		$sql .= " where domain_uuid = '$domain_uuid' ";
 		$sql .= " and invoice_id = '$invoice_id' ";
 		if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
 		$sql .= " limit $rows_per_page offset $offset ";

+ 4 - 4
invoices/v_invoice_items_edit.php

@@ -31,7 +31,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	}
 
 	//check for all required data
-		//if (strlen($v_id) == 0) { $msg .= "Please provide: v_id<br>\n"; }
+		//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
 		//if (strlen($item_qty) == 0) { $msg .= "Please provide: Quantity<br>\n"; }
 		//if (strlen($item_desc) == 0) { $msg .= "Please provide: Description<br>\n"; }
 		//if (strlen($item_unit_price) == 0) { $msg .= "Please provide: Price<br>\n"; }
@@ -54,7 +54,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 			$sql = "insert into v_invoice_items ";
 			$sql .= "(";
 			$sql .= "invoice_id, ";
-			$sql .= "v_id, ";
+			$sql .= "domain_uuid, ";
 			$sql .= "item_qty, ";
 			$sql .= "item_desc, ";
 			$sql .= "item_unit_price ";
@@ -62,7 +62,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 			$sql .= "values ";
 			$sql .= "(";
 			$sql .= "'$invoice_id', ";
-			$sql .= "'$v_id', ";
+			$sql .= "'$domain_uuid', ";
 			$sql .= "'$item_qty', ";
 			$sql .= "'$item_desc', ";
 			$sql .= "'$item_unit_price' ";
@@ -82,7 +82,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 		if ($action == "update") {
 			$sql = "update v_invoice_items set ";
 			$sql .= "invoice_id = '$invoice_id', ";
-			$sql .= "v_id = '$v_id', ";
+			$sql .= "domain_uuid = '$domain_uuid', ";
 			$sql .= "item_qty = '$item_qty', ";
 			$sql .= "item_desc = '$item_desc', ";
 			$sql .= "item_unit_price = '$item_unit_price' ";

+ 6 - 6
invoices/v_invoice_pdf.php

@@ -42,7 +42,7 @@ else {
 //get the invoice details
 	$sql = "";
 	$sql .= "select * from v_invoices ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and invoice_id = '$invoice_id' ";
 	$sql .= "order by invoice_id desc ";
 	$sql .= "limit 1 ";
@@ -73,7 +73,7 @@ else {
 //get contact from name
 	$sql = "";
 	$sql .= "select * from v_contacts ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and contact_id = '$contact_id_from' ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
@@ -89,7 +89,7 @@ else {
 //get contact from address
 	$sql = "";
 	$sql .= "select * from v_contacts_adr ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and contact_id = '$contact_id_from' ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
@@ -127,7 +127,7 @@ else {
 //get contact to name
 	$sql = "";
 	$sql .= "select * from v_contacts ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and contact_id = '$contact_id_to' ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
@@ -143,7 +143,7 @@ else {
 //get contact to address
 	$sql = "";
 	$sql .= "select * from v_contacts_adr ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and contact_id = '$contact_id_to' ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
@@ -232,7 +232,7 @@ else {
 //itemized list
 	$sql = "";
 	$sql .= "select * from v_invoice_items ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and invoice_id = '$invoice_id' ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();

+ 2 - 2
invoices/v_invoices.php

@@ -64,7 +64,7 @@ require_once "includes/paging.php";
 		$sql .= "SELECT count(*) as num_rows FROM v_invoices ";
 		$sql .= "LEFT OUTER JOIN v_contacts ";
 		$sql .= "ON v_invoices.contact_id_to = v_contacts.contact_id ";
-		$sql .= "where v_invoices.v_id = '$v_id' ";
+		$sql .= "where v_invoices.domain_uuid = '$domain_uuid' ";
 		if (strlen($contact_id) > 0) {
 			$sql .= "and v_invoices.contact_id_to = '$contact_id' ";
 		}
@@ -93,7 +93,7 @@ require_once "includes/paging.php";
 		$sql .= "SELECT * FROM v_invoices ";
 		$sql .= "LEFT OUTER JOIN v_contacts ";
 		$sql .= "ON v_invoices.contact_id_to = v_contacts.contact_id ";
-		$sql .= "where v_invoices.v_id = '$v_id' ";
+		$sql .= "where v_invoices.domain_uuid = '$domain_uuid' ";
 		if (strlen($contact_id) > 0) {
 			$sql .= "and v_invoices.contact_id_to = '$contact_id' ";
 		}

+ 7 - 7
invoices/v_invoices_edit.php

@@ -79,7 +79,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 			if ($action == "add") {
 				$sql = "insert into v_invoices ";
 				$sql .= "(";
-				$sql .= "v_id, ";
+				$sql .= "domain_uuid, ";
 				$sql .= "invoice_number, ";
 				$sql .= "contact_id_from, ";
 				$sql .= "contact_id_to, ";
@@ -88,7 +88,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 				$sql .= ")";
 				$sql .= "values ";
 				$sql .= "(";
-				$sql .= "'$v_id', ";
+				$sql .= "'$domain_uuid', ";
 				$sql .= "'$invoice_number', ";
 				$sql .= "'$contact_id_from', ";
 				$sql .= "'$contact_id_to', ";
@@ -114,7 +114,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 				$sql .= "contact_id_from = '$contact_id_from', ";
 				$sql .= "contact_id_to = '$contact_id_to', ";
 				$sql .= "invoice_notes = '$invoice_notes' ";
-				$sql .= "where v_id = '$v_id' ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
 				$sql .= "and invoice_id = '$invoice_id' ";
 				$db->exec(check_sql($sql));
 				unset($sql);
@@ -135,7 +135,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 		$invoice_id = $_GET["id"];
 		$sql = "";
 		$sql .= "select * from v_invoices ";
-		$sql .= "where v_id = '$v_id' ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
 		$sql .= "and invoice_id = '$invoice_id' ";
 		$prep_statement = $db->prepare(check_sql($sql));
 		$prep_statement->execute();
@@ -158,7 +158,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	if ($action == "add") {
 		$sql = "";
 		$sql .= "select * from v_invoices ";
-		$sql .= "where v_id = '$v_id' ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
 		$sql .= "order by invoice_id desc ";
 		$sql .= "limit 1 ";
 		$prep_statement = $db->prepare(check_sql($sql));
@@ -212,7 +212,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	echo "<td class='vtable' align='left'>\n";
 	$sql = "";
 	$sql .= " select contact_id, org, n_given, n_family from v_contacts ";
-	$sql .= " where v_id = '$v_id' ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
 	$sql .= " order by org asc ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();
@@ -255,7 +255,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	echo "<td class='vtable' align='left'>\n";
 	$sql = "";
 	$sql .= " select contact_id, org, n_given, n_family from v_contacts ";
-	$sql .= " where v_id = '$v_id' ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
 	$sql .= " order by org asc ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 5 - 5
templates/template_restore_default.php

@@ -37,8 +37,8 @@ else {
 
 //remove the old menu
 	$sql  = "delete from v_templates ";
-	$sql .= "where v_id = '$v_id' and templatename = 'default' ";
-	$sql .= "or v_id = '$v_id' and templatename = 'horizontal' ";
+	$sql .= "where domain_uuid = '$domain_uuid' and templatename = 'default' ";
+	$sql .= "or domain_uuid = '$domain_uuid' and templatename = 'horizontal' ";
 	//echo $sql;
 	$db->exec(check_sql($sql));
 
@@ -78,7 +78,7 @@ else {
 //load the default menu into an array
 	$sql = "";
 	$sql .= "select * from v_templates ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$prepstatement = $db_default->prepare(check_sql($sql));
 	$prepstatement->execute();
 	$menu_array = $prepstatement->fetchAll();
@@ -97,7 +97,7 @@ else {
 		//insert the defaul menu into the database
 			$sql = "insert into v_templates ";
 			$sql .= "(";
-			$sql .= "v_id, ";
+			$sql .= "domain_uuid, ";
 			$sql .= "templateid, ";
 			$sql .= "templatelanguage, ";
 			$sql .= "templatename, ";
@@ -109,7 +109,7 @@ else {
 			$sql .= ")";
 			$sql .= "values ";
 			$sql .= "(";
-			$sql .= "'$v_id', ";
+			$sql .= "'$domain_uuid', ";
 			$sql .= "'$templateid', "; 
 			$sql .= "'$templatelanguage', ";
 			$sql .= "'$templatename', ";

+ 2 - 2
templates/templates.php

@@ -57,7 +57,7 @@ $order = $_GET["order"];
 
 	$sql = "";
 	$sql .= "select * from v_templates ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();
@@ -74,7 +74,7 @@ $order = $_GET["order"];
 
 	$sql = "";
 	$sql .= "select * from v_templates ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
 	$sql .= " limit $rowsperpage offset $offset ";
 	$prepstatement = $db->prepare(check_sql($sql));

+ 1 - 1
templates/templates_delete.php

@@ -38,7 +38,7 @@ if (count($_GET)>0) {
 if (strlen($id)>0) {
 	$sql = "";
 	$sql .= "delete from v_templates ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and templateid = '$id' ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 4 - 4
templates/templates_edit.php

@@ -95,7 +95,7 @@ if ($_POST["persistformvar"] != "true") {
 	if ($action == "add") {
 		$sql = "insert into v_templates ";
 		$sql .= "(";
-		$sql .= "v_id, ";
+		$sql .= "domain_uuid, ";
 		$sql .= "templatename, ";
 		$sql .= "templatedesc, ";
 		$sql .= "template, ";
@@ -104,7 +104,7 @@ if ($_POST["persistformvar"] != "true") {
 		$sql .= ")";
 		$sql .= "values ";
 		$sql .= "(";
-		$sql .= "'$v_id', ";
+		$sql .= "'$domain_uuid', ";
 		$sql .= "'$templatename', ";
 		$sql .= "'$templatedesc', ";
 		$sql .= "'".base64_encode($template)."', ";
@@ -130,7 +130,7 @@ if ($_POST["persistformvar"] != "true") {
 		$sql .= "template = '".base64_encode($template)."', ";
 		$sql .= "templatemenutype = '$templatemenutype', ";
 		$sql .= "templatemenucss = '".base64_encode($templatemenucss)."' ";
-		$sql .= "where v_id = '$v_id'";
+		$sql .= "where domain_uuid = '$domain_uuid'";
 		$sql .= "and templateid = '$template_id'";
 		$db->exec(check_sql($sql));
 		unset($sql);
@@ -152,7 +152,7 @@ if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
 	$template_id = $_GET["id"];
 	$sql = "";
 	$sql .= "select * from v_templates ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and templateid = '$template_id' ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 214 - 144
tickets/v_config.php

@@ -67,11 +67,11 @@
 		$apps[$x]['permissions'][4]['name'] = 'ticket_assign_queue';
 		$apps[$x]['permissions'][4]['groups'][] = 'admin';
 		$apps[$x]['permissions'][4]['groups'][] = 'superadmin';
-	
+
 		$apps[$x]['permissions'][5]['name'] = 'ticket_config';
 		$apps[$x]['permissions'][5]['groups'][] = 'admin';
 		$apps[$x]['permissions'][5]['groups'][] = 'superadmin';
-	
+
 		$apps[$x]['permissions'][6]['name'] = 'ticket_queue_view';
 		$apps[$x]['permissions'][6]['groups'][] = 'admin';
 		$apps[$x]['permissions'][6]['groups'][] = 'superadmin';
@@ -87,145 +87,215 @@
 		$apps[$x]['permissions'][9]['name'] = 'ticket_queue_delete';
 		$apps[$x]['permissions'][9]['groups'][] = 'admin';
 		$apps[$x]['permissions'][9]['groups'][] = 'superadmin';
-	
-	// CREATE TABLE v_ticket_notes 
-		$apps[$x]['db'][0]['table'] = 'v_ticket_notes';
-		$apps[$x]['db'][0]['fields'][0]['name'] = 'note_id';
-		$apps[$x]['db'][0]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][0]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][0]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][0]['fields'][0]['description'] = '';
-		$apps[$x]['db'][0]['fields'][1]['name'] = 'ticket_id';
-		$apps[$x]['db'][0]['fields'][1]['type'] = 'integer';
-		$apps[$x]['db'][0]['fields'][1]['description'] = '';
-		$apps[$x]['db'][0]['fields'][2]['name'] = 'create_stamp';
-		$apps[$x]['db'][0]['fields'][2]['type']['pgsql'] = 'timestamp with time zone';
-		$apps[$x]['db'][0]['fields'][2]['type']['sqlite'] = 'datetime';
-		$apps[$x]['db'][0]['fields'][2]['type']['mysql'] = 'timestamp';
-		$apps[$x]['db'][0]['fields'][2]['description'] = '';
-		$apps[$x]['db'][0]['fields'][3]['name'] = 'create_user_id';
-		$apps[$x]['db'][0]['fields'][3]['type'] = 'integer';
-		$apps[$x]['db'][0]['fields'][3]['description'] = '';
-		$apps[$x]['db'][0]['fields'][4]['name'] = 'ticket_note';
-		$apps[$x]['db'][0]['fields'][4]['type'] = 'text';
-		$apps[$x]['db'][0]['fields'][4]['description'] = '';
-		$apps[$x]['db'][0]['fields'][5]['name'] = 'file_pointer';
-		$apps[$x]['db'][0]['fields'][5]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][0]['fields'][5]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][0]['fields'][5]['type']['mysql'] = 'text';
-		$apps[$x]['db'][0]['fields'][5]['description'] = '';
-
-	// CREATE TABLE v_ticket_queue_members 
-		$apps[$x]['db'][1]['table'] = 'v_ticket_queue_members';
-		$apps[$x]['db'][1]['fields'][0]['name'] = 'queue_member_id';
-		$apps[$x]['db'][1]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][1]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][1]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][1]['fields'][0]['description'] = '';
-		$apps[$x]['db'][1]['fields'][1]['name'] = 'queue_id';
-		$apps[$x]['db'][1]['fields'][1]['type'] = 'integer';
-		$apps[$x]['db'][1]['fields'][1]['description'] = '';
-		$apps[$x]['db'][1]['fields'][2]['name'] = 'user_id';
-		$apps[$x]['db'][1]['fields'][2]['type'] = 'integer';
-		$apps[$x]['db'][1]['fields'][2]['description'] = '';
-
-	// CREATE TABLE v_ticket_queues 
-		$apps[$x]['db'][2]['table'] = 'v_ticket_queues';
-		$apps[$x]['db'][2]['fields'][0]['name'] = 'queue_id';
-		$apps[$x]['db'][2]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][2]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][2]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][2]['fields'][0]['description'] = '';
-		$apps[$x]['db'][2]['fields'][1]['name'] = 'queue_name';
-		$apps[$x]['db'][2]['fields'][1]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][2]['fields'][1]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][2]['fields'][1]['type']['mysql'] = 'text';
-		$apps[$x]['db'][2]['fields'][1]['description'] = '';
-		$apps[$x]['db'][2]['fields'][2]['name'] = 'queue_email';
-		$apps[$x]['db'][2]['fields'][2]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][2]['fields'][2]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][2]['fields'][2]['type']['mysql'] = 'text';
-		$apps[$x]['db'][2]['fields'][2]['description'] = '';
-		$apps[$x]['db'][2]['fields'][3]['name'] = 'v_id';
-		$apps[$x]['db'][2]['fields'][3]['type'] = 'integer';
-		$apps[$x]['db'][2]['fields'][3]['description'] = '';
-
-	// CREATE TABLE v_ticket_statuses 
-		$apps[$x]['db'][3]['table'] = 'v_ticket_statuses';
-		$apps[$x]['db'][3]['fields'][0]['name'] = 'status_id';
-		$apps[$x]['db'][3]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][3]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][3]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][3]['fields'][0]['description'] = '';
-		$apps[$x]['db'][3]['fields'][1]['name'] = 'status_name';
-		$apps[$x]['db'][3]['fields'][1]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][3]['fields'][1]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][3]['fields'][1]['type']['mysql'] = 'text';
-		$apps[$x]['db'][3]['fields'][1]['description'] = '';
-		$apps[$x]['db'][3]['fields'][2]['name'] = 'v_id';
-		$apps[$x]['db'][3]['fields'][2]['type'] = 'integer';
-		$apps[$x]['db'][3]['fields'][2]['description'] = '';
-
-	// CREATE TABLE v_tickets 
-		$apps[$x]['db'][4]['table'] = 'v_tickets';
-		$apps[$x]['db'][4]['fields'][0]['name'] = 'ticket_id';
-		$apps[$x]['db'][4]['fields'][0]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][4]['fields'][0]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][4]['fields'][0]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
-		$apps[$x]['db'][4]['fields'][0]['description'] = '';
-		$apps[$x]['db'][4]['fields'][1]['name'] = 'queue_id';
-		$apps[$x]['db'][4]['fields'][1]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][1]['description'] = '';
-		$apps[$x]['db'][4]['fields'][2]['name'] = 'v_id';
-		$apps[$x]['db'][4]['fields'][2]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][2]['description'] = '';
-		$apps[$x]['db'][4]['fields'][3]['name'] = 'user_id';
-		$apps[$x]['db'][4]['fields'][3]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][3]['description'] = '';
-		$apps[$x]['db'][4]['fields'][4]['name'] = 'customer_id';
-		$apps[$x]['db'][4]['fields'][4]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][4]['description'] = '';
-		$apps[$x]['db'][4]['fields'][5]['name'] = 'subject';
-		$apps[$x]['db'][4]['fields'][5]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][4]['fields'][5]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][4]['fields'][5]['type']['mysql'] = 'text';
-		$apps[$x]['db'][4]['fields'][5]['description'] = '';
-		$apps[$x]['db'][4]['fields'][6]['name'] = 'create_stamp';
-		$apps[$x]['db'][4]['fields'][6]['type']['pgsql'] = 'timestamp with time zone';
-		$apps[$x]['db'][4]['fields'][6]['type']['sqlite'] = 'datetime';
-		$apps[$x]['db'][4]['fields'][6]['type']['mysql'] = 'timestamp';
-		$apps[$x]['db'][4]['fields'][6]['description'] = '';
-		$apps[$x]['db'][4]['fields'][7]['name'] = 'create_user_id';
-		$apps[$x]['db'][4]['fields'][7]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][7]['description'] = '';
-		$apps[$x]['db'][4]['fields'][8]['name'] = 'ticket_status';
-		$apps[$x]['db'][4]['fields'][8]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][8]['description'] = '';
-		$apps[$x]['db'][4]['fields'][9]['name'] = 'last_update_stamp';
-		$apps[$x]['db'][4]['fields'][9]['type']['pgsql'] = 'timestamp with time zone';
-		$apps[$x]['db'][4]['fields'][9]['type']['sqlite'] = 'datetime';
-		$apps[$x]['db'][4]['fields'][9]['type']['mysql'] = 'timestamp';
-		$apps[$x]['db'][4]['fields'][9]['description'] = '';
-		$apps[$x]['db'][4]['fields'][10]['name'] = 'last_update_user_id';
-		$apps[$x]['db'][4]['fields'][10]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][10]['description'] = '';
-		$apps[$x]['db'][4]['fields'][11]['name'] = 'ticket_uuid';
-		$apps[$x]['db'][4]['fields'][11]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][4]['fields'][11]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][4]['fields'][11]['type']['mysql'] = 'text';
-		$apps[$x]['db'][4]['fields'][11]['description'] = '';
-		$apps[$x]['db'][4]['fields'][12]['name'] = 'ticket_number';
-		$apps[$x]['db'][4]['fields'][12]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][4]['fields'][12]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][4]['fields'][12]['type']['mysql'] = 'text';
-		$apps[$x]['db'][4]['fields'][12]['description'] = '';
-		$apps[$x]['db'][4]['fields'][13]['name'] = 'customer_ticket_number';
-		$apps[$x]['db'][4]['fields'][13]['type']['pgsql'] = 'character varying';
-		$apps[$x]['db'][4]['fields'][13]['type']['sqlite'] = 'text';
-		$apps[$x]['db'][4]['fields'][13]['type']['mysql'] = 'text';
-		$apps[$x]['db'][4]['fields'][13]['description'] = '';
-		$apps[$x]['db'][4]['fields'][14]['name'] = 'ticket_owner';
-		$apps[$x]['db'][4]['fields'][14]['type'] = 'integer';
-		$apps[$x]['db'][4]['fields'][14]['description'] = '';
-
-?>
+
+	//schema details
+		$y = 0; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_ticket_notes';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'note_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'create_stamp';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp with time zone';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'datetime';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'create_user_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_note';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'file_pointer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+
+	// CREATE TABLE v_ticket_queue_members
+		$y = 1; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_ticket_queue_members';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_member_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+
+	// CREATE TABLE v_ticket_queues
+		$y = 2; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_ticket_queues';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_name';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_email';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+
+	// CREATE TABLE v_ticket_statuses
+		$y = 3; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_ticket_statuses';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'status_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'status_name';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+
+	// CREATE TABLE v_tickets
+		$y = 4; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_tickets';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'queue_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'customer_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'subject';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'create_stamp';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp with time zone';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'datetime';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'create_user_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_status';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'last_update_stamp';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp with time zone';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'datetime';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'last_update_user_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_number';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'customer_ticket_number';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'character varying';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'ticket_owner';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+
+?>

+ 6 - 6
tickets/v_manager.php

@@ -54,8 +54,8 @@ if (isset($_REQUEST['queue_name'])) {
 		$sql .= "WHERE queue_id = " . $request['queue_id'] . " ";
 	} else {
 		//do Queue Create
-		$sql .= "INSERT into v_ticket_queues (queue_name, queue_email, v_id) values ";
-		$sql .= "('" . $request['queue_name'] . "', '" . $request['queue_email'] . "', $v_id) ";
+		$sql .= "INSERT into v_ticket_queues (queue_name, queue_email, domain_uuid) values ";
+		$sql .= "('" . $request['queue_name'] . "', '" . $request['queue_email'] . "', $domain_uuid) ";
 	}
 	$db->exec($sql);
 }
@@ -68,8 +68,8 @@ if (isset($_REQUEST['status_name'])) {
 		$sql .= "WHERE status_id = " . $request['status_id'] . " ";
 	} else {
 		//do Status Create
-		$sql .= "INSERT into v_ticket_statuses (status_name, v_id) values ";
-		$sql .= "('" . $request['status_name'] . "', $v_id) ";
+		$sql .= "INSERT into v_ticket_statuses (status_name, domain_uuid) values ";
+		$sql .= "('" . $request['status_name'] . "', $domain_uuid) ";
 	}
 	$db->exec($sql);
 }
@@ -77,7 +77,7 @@ if (isset($_REQUEST['status_name'])) {
 // Get a List of the Ticket Statuses
 $sql = "";
 $sql .= "select * from v_ticket_statuses ";
-$sql .= "where v_id = $v_id ";
+$sql .= "where domain_uuid = $domain_uuid ";
 $sql .= "order by status_id ";
 $prepstatement = $db->prepare(check_sql($sql));
 $prepstatement->execute();
@@ -90,7 +90,7 @@ unset ($prepstatement);
 
 $sql = "";
 $sql .= "select * from v_ticket_queues ";
-$sql .= "where v_id = $v_id ";
+$sql .= "where domain_uuid = $domain_uuid ";
 $sql .= "order by queue_id ";
 $prepstatement = $db->prepare(check_sql($sql));
 $prepstatement->execute();

+ 3 - 3
tickets/v_profile_delete.php

@@ -38,13 +38,13 @@ else {
 
 require_once "includes/header.php";
 
-$v_domain = $_SESSION['domains'][$v_id]['domain'];
+$v_domain = $_SESSION['domains'][$domain_uuid]['domain'];
 
 $profile_id = $_REQUEST['id'];
 
 $sql = "";
 $sql .= "select * from v_xmpp ";
-$sql .= "where v_id = '$v_id' ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
 $sql .= "and xmpp_profile_id = '$profile_id' ";
 
 $prepstatement = $db->prepare(check_sql($sql));
@@ -62,7 +62,7 @@ unset ($prepstatement);
 
 $sql = "";
 $sql .= "delete from v_xmpp ";
-$sql .= "where v_id = '$v_id' ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
 $sql .= "and xmpp_profile_id = '$profile_id' ";
 
 $db->exec(check_sql($sql));

+ 6 - 6
tickets/v_ticket_create.php

@@ -40,12 +40,12 @@ else {
 
 require_once "includes/header.php";
 
-$v_domain = $_SESSION['domains'][$v_id]['domain'];
+$v_domain = $_SESSION['domains'][$domain_uuid]['domain'];
 
 //get a list of Available Queues
 $sql = "";
 $sql .= "select * from v_ticket_queues ";
-$sql .= "where v_id = '$v_id' ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
 $sql .= "order by queue_name ";
 $prepstatement = $db->prepare(check_sql($sql));
 $prepstatement->execute();
@@ -94,10 +94,10 @@ if (strlen($error) > 0) {
 
 // Save New Entry
 if ($action == "add" && permission_exists('ticket_add')) {
-	$ticket_uuid = guid();
+	$ticket_uuid = uuid();
 	$sql = "";
 	$sql .= "insert into v_tickets (";
- 	$sql .= "v_id, ";
+ 	$sql .= "domain_uuid, ";
  	$sql .= "queue_id, ";
  	$sql .= "user_id, ";
  	$sql .= "customer_id, ";
@@ -110,7 +110,7 @@ if ($action == "add" && permission_exists('ticket_add')) {
  	$sql .= "ticket_status, ";
  	$sql .= "customer_ticket_number ";
 	$sql .= ") values (";
- 	$sql .= "$v_id, ";
+ 	$sql .= "$domain_uuid, ";
  	$sql .= "'" . $request['queue_id'] . "', ";
  	$sql .= "'" . $_SESSION['user_id'] . "', ";
  	$sql .= "'" . $_SESSION['customer_id'] . "', ";
@@ -157,7 +157,7 @@ if ($action == "add" && permission_exists('ticket_add')) {
 	$sql = "";
 	$sql .= "SELECT * from v_ticket_queues ";
 	$sql .= "where queue_id = " . $request['queue_id'] . " ";
-	$sql .= "and v_id = $v_id ";
+	$sql .= "and domain_uuid = $domain_uuid ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();
 	$x = 0; 

+ 5 - 5
tickets/v_ticket_update.php

@@ -40,7 +40,7 @@ else {
 
 require_once "includes/header.php";
 
-$v_domain = $_SESSION['domains'][$v_id]['domain'];
+$v_domain = $_SESSION['domains'][$domain_uuid]['domain'];
 
 // Check to see if we're an admin and if we are set the $isadmin to true for use in the template and sql query building
 if (ifgroup("superadmin") || ifgroup("admin")){
@@ -66,14 +66,14 @@ if ($action == "update") {
 
 //get the ticket
 	$sql = "";
-	$sql .= "select a.ticket_id, a.queue_id, a.v_id, a.user_id, a.customer_id, a.subject, ";
+	$sql .= "select a.ticket_id, a.queue_id, a.domain_uuid, a.user_id, a.customer_id, a.subject, ";
 	$sql .= "to_char(a.create_stamp, 'MM-DD-YY HH24-MI-SS') as create_stamp, a.create_user_id, ";
 	$sql .= "a.ticket_status, to_char(a.last_update_stamp, 'MM-DD-YY HH24-MI-SS') as last_update_stamp, ";
 	$sql .= "a.last_update_user_id, a.ticket_uuid, a.ticket_number, a.ticket_owner, a.customer_ticket_number, ";
 	$sql .= "b.username, c.username as create_username, d.username as last_update_username ";
 	$sql .= "from v_tickets as a, v_users as b, v_users as c, v_users as d ";
 	$sql .= "where a.user_id = b.id and a.create_user_id = c.id and a.last_update_user_id = d.id ";
-	$sql .= "and a.v_id = '$v_id' ";
+	$sql .= "and a.domain_uuid = '$domain_uuid' ";
 	if (isset($_REQUEST["id"])) { 
 		$sql .= "and a.ticket_id = '$ticket_id' ";
 	}
@@ -131,7 +131,7 @@ if ($action == "update") {
 
 	$sql = "";
 	$sql .= "SELECT * from v_ticket_statuses ";
-	$sql .= "where v_id = $v_id ";
+	$sql .= "where domain_uuid = $domain_uuid ";
 	$sql .= "ORDER by status_id ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();
@@ -145,7 +145,7 @@ if ($action == "update") {
 
 	$sql = "";
 	$sql .= "SELECT * from v_ticket_queues ";
-	$sql .= "where v_id = $v_id ";
+	$sql .= "where domain_uuid = $domain_uuid ";
 	$sql .= "ORDER by queue_name ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 2 - 2
tickets/v_tickets.php

@@ -45,7 +45,7 @@ if (isset($_REQUEST['show_closed'])) {
 //get a list of assigned extensions for this user
 $sql = "";
 $sql .= "select * from v_tickets ";
-$sql .= "where v_id = '$v_id' ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
 if (!$show_closed) {
 	$sql .= "and ticket_status < 6 ";
 }
@@ -76,7 +76,7 @@ unset ($prepstatement);
 
 $sql = "";
 $sql .= "select * from v_ticket_queues ";
-$sql .= "where v_id = $v_id ";
+$sql .= "where domain_uuid = $domain_uuid ";
 $prepstatement = $db->prepare(check_sql($sql));
 $prepstatement->execute();
 $x = 0;

+ 2 - 2
user_contacts/users.php

@@ -56,7 +56,7 @@ require_once "includes/paging.php";
 
 	$sql = "";
 	$sql .= "select * from v_users ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();
@@ -74,7 +74,7 @@ require_once "includes/paging.php";
 	$sql = "";
 	$sql .= "select * from v_users ";
 	if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "limit $rowsperpage offset $offset ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 1 - 1
user_contacts/users_delete.php

@@ -43,7 +43,7 @@ else {
 	if (strlen($id)>0) {
 		$sql = "";
 		$sql .= "delete from v_users ";
-		$sql .= "where v_id = '$v_id' ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
 		$sql .= "and id = '$id' ";
 		$prepstatement = $db->prepare(check_sql($sql));
 		$prepstatement->execute();

+ 4 - 4
user_contacts/users_edit.php

@@ -163,7 +163,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 				if ($action == "add" && permission_exists('contacts_add')) {
 					$sql = "insert into v_users ";
 					$sql .= "(";
-					$sql .= "v_id, ";
+					$sql .= "domain_uuid, ";
 					//$sql .= "username, ";
 					//$sql .= "password, ";
 					$sql .= "user_type, ";
@@ -212,7 +212,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 					$sql .= ")";
 					$sql .= "values ";
 					$sql .= "(";
-					$sql .= "'$v_id', ";
+					$sql .= "'$domain_uuid', ";
 					//$sql .= "'$username', ";
 					//$sql .= "'$password', ";
 					$sql .= "'$user_type', ";
@@ -320,7 +320,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 					$sql .= "user_optional_1 = '$user_optional_1' ";
 					//$sql .= "user_add_user = '$user_add_user', ";
 					//$sql .= "user_add_date = '$user_add_date' ";
-					$sql .= "where v_id = '$v_id' ";
+					$sql .= "where domain_uuid = '$domain_uuid' ";
 					$sql .= "and id = '$id' ";
 					$db->exec(check_sql($sql));
 					unset($sql);
@@ -341,7 +341,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 			$id = $_GET["id"];
 			$sql = "";
 			$sql .= "select * from v_users ";
-			$sql .= "where v_id = '$v_id' ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
 			$sql .= "and id = '$id' ";
 			$prepstatement = $db->prepare(check_sql($sql));
 			$prepstatement->execute();

+ 1 - 1
user_contacts/users_vcard.php

@@ -41,7 +41,7 @@ if (count($_GET)>0) {
 	$id = $_GET["id"];
 	$sql = "";
 	$sql .= "select * from v_users ";
-	$sql .= "where v_id = '$v_id' ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
 	$sql .= "and id = '$id' ";
 	$prepstatement = $db->prepare(check_sql($sql));
 	$prepstatement->execute();

+ 18 - 3
user_contacts/v_config.php

@@ -41,12 +41,27 @@
 		$apps[$x]['db'][$y]['table'] = 'v_users';
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'id';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer PRIMARY KEY';
-		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'foreign';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
-		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'username';

+ 17 - 17
users_bulk_add/v_users_bulk_add.php

@@ -28,20 +28,20 @@ $dq = '"';
 $self = $_SERVER['PHP_SELF'];
 ini_set('auto_detect_line_endings', '1');
 
-function get_v_ids(PDO $db) {
-	$query 				= sprintf("SELECT v_id, domain FROM v_system_settings;");
+function get_domain_uuids(PDO $db) {
+	$query 				= sprintf("SELECT domain_uuid, domain FROM v_system_settings;");
 	$stmt 				= $db->query($query);
 	$results 			= $stmt->fetchAll(PDO::FETCH_ASSOC);
 	$result_count 		= count($results);
 	for ($i = 0; $i < $result_count; $i++) {
 		$domain 		= $results[$i]['domain'];
-		$v_id 			= $results[$i]['v_id'];
-		$v_ids[$domain]	= $v_id;
+		$domain_uuid 			= $results[$i]['domain_uuid'];
+		$domain_uuids[$domain]	= $domain_uuid;
 	}
-	return $v_ids;
+	return $domain_uuids;
 }
 
-function generate_insert_query($line, $places, $table, PDO $db, $v_ids) {
+function generate_insert_query($line, $places, $table, PDO $db, $domain_uuids) {
 	global $v_salt;
 	foreach ($places as $field => $place) {
 		$fields[] = $field;
@@ -90,11 +90,11 @@ function generate_insert_query($line, $places, $table, PDO $db, $v_ids) {
 			break;
 	}
 
-	if (!in_array('v_id')) {
-		//print "v_id not found, adding one for localhost<br>\n";
-		//printf('<pre>%s</pre>', print_r($v_ids, true));
-		$fields[] = 'v_id';
-		$values[] = $v_ids['localhost'];
+	if (!in_array('domain_uuid')) {
+		//print "domain_uuid not found, adding one for localhost<br>\n";
+		//printf('<pre>%s</pre>', print_r($domain_uuids, true));
+		$fields[] = 'domain_uuid';
+		$values[] = $domain_uuids['localhost'];
 	}
 
 	$query = sprintf('INSERT INTO %s (%s) VALUES (%s);'
@@ -128,11 +128,11 @@ function check_required_fields($line, $all_fields) {
 	return true;
 }
 
-function insert_db_row($db, $line, $places, $table, $v_ids) {
+function insert_db_row($db, $line, $places, $table, $domain_uuids) {
 	global $inserted;
 	//printf("<pre>%s</pre>\n", print_r($inserted, true));
 	$inserted[$table]++;
-	$query = generate_insert_query($line, $places, $table, $db, $v_ids);
+	$query = generate_insert_query($line, $places, $table, $db, $domain_uuids);
 	//print "QUERY: $query<br>\n";
 	if (empty($query)) {
 		return;
@@ -154,7 +154,7 @@ require_once "includes/paging.php";
 
 $inserted = array('v_users' => 0, 'v_extensions' => 0, 'v_group_members' => 0);
 if (is_array($_FILES) && array_key_exists('users_file', $_FILES)) {
-	$v_ids 				= get_v_ids($db);
+	$domain_uuids 				= get_domain_uuids($db);
 	$user_fields 		= get_db_field_names($db, 'v_users');
 	//printf("<pre>users => %s<br></pre>\n", print_r($user_fields, true));
 	$extension_fields 	= get_db_field_names($db, 'v_extensions');
@@ -181,15 +181,15 @@ if (is_array($_FILES) && array_key_exists('users_file', $_FILES)) {
 		if (check_required_fields($line, $all_fields)) {
 			while ($line = fgetcsv($fh, null, ',')) {
 				// create user
-				insert_db_row($db, $line, $user_places, 'v_users', $v_ids);
+				insert_db_row($db, $line, $user_places, 'v_users', $domain_uuids);
 
 				// add user to members group
 				$grp_line 	= array('member', $line[$user_places['username']]);
 				$grp_places	= array('group_id' => 0, 'username' => 1);
-				insert_db_row($db, $grp_line, $grp_places, 'v_group_members', $v_ids);
+				insert_db_row($db, $grp_line, $grp_places, 'v_group_members', $domain_uuids);
 				
 				// add user's extension
-				insert_db_row($db, $line, $extension_places, 'v_extensions', $v_ids);
+				insert_db_row($db, $line, $extension_places, 'v_extensions', $domain_uuids);
 			}
 		}
 		fclose($fh);