Browse Source

Remove \r\n and replace with \n to standardize on line feed only.

Mark Crane 13 years ago
parent
commit
016d163b6c

+ 49 - 49
features/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>

+ 49 - 49
flashphoner/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>

+ 49 - 49
invoices/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>

+ 1 - 1
invoices/v_invoice_items_delete.php

@@ -27,4 +27,4 @@ require_once "includes/footer.php";
 return;
 
 ?>
-
+

+ 319 - 319
invoices/v_invoice_pdf.php

@@ -1,319 +1,319 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-require_once "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (if_group("admin") || if_group("superadmin")) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-
-//action invoice_uuid
-	if (isset($_REQUEST["id"])) {
-		$invoice_uuid = check_str($_REQUEST["id"]);
-	}
-
-//get the invoice details
-	$sql = "";
-	$sql .= "select * from v_invoices ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and invoice_uuid = '$invoice_uuid' ";
-	$sql .= "order by invoice_uuid desc ";
-	$sql .= "limit 1 ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	if ($prep_statement) {
-		$prep_statement->execute();
-		$row = $prep_statement->fetch();
-		$invoice_number = $row['invoice_number'];
-		$contact_uuid_from = $row['contact_uuid_from'];
-		$contact_uuid_to = $row['contact_uuid_to'];
-		$invoice_date = $row['invoice_date'];
-		$invoice_note = $row['invoice_note'];
-		unset ($prep_statement);
-	}
-
-//prepare the invoice date
-	$invoice_date = date("d", strtotime($invoice_date)).' '.date("M", strtotime($invoice_date)).' '.date("Y", strtotime($invoice_date));
-
-//prepare to use fpdf
-	define('FPDF_FONTPATH',$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/fpdf/font/');
-	require('includes/fpdf/fpdf.php');
-
-//create the fpdf object and add the first page
-	$pdf = new FPDF();
-	$pdf->AddPage();
-	$pdf->SetFont('Arial','B',9);
-
-//get contact from name
-	$sql = "";
-	$sql .= "select * from v_contacts ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and contact_uuid = '$contact_uuid_from' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	foreach ($result as &$row) {
-		$from_org = $row["org"];
-		$from_n_given = $row["n_given"];
-		$from_n_family = $row["n_family"];
-		break; //limit to 1 row
-	}
-	unset ($prep_statement);
-
-//get contact from address
-	$sql = "";
-	$sql .= "select * from v_contacts_adr ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and contact_uuid = '$contact_uuid_from' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	foreach ($result as &$row) {
-		$from_adr_type = $row["adr_type"];
-		$from_adr_street = $row["adr_street"];
-		$from_adr_extended = $row["adr_extended"];
-		$from_adr_locality = $row["adr_locality"];
-		$from_adr_region = $row["adr_region"];
-		$from_adr_postal_code = $row["adr_postal_code"];
-		$from_adr_country = $row["adr_country"];
-		break; //limit to 1 row
-	}
-	unset ($prep_statement);
-	$pdf->SetY(10);
-	$pdf->SetFont('Arial','B',9);
-	if (strlen($from_org) > 0) {
-		$pdf->Cell(40,5,$from_org);
-		$pdf->Ln();
-	}
-	else {
-		if (strlen($from_n_given.$from_n_family) > 0) {
-			$pdf->Cell(40,5,$from_n_given.' '.$from_n_family);
-			$pdf->Ln();
-		}
-	}
-	$pdf->SetFont('Arial','',9);
-	$pdf->Cell(40,5,$from_adr_street.' '.$from_adr_extended);
-	$pdf->Ln();
-	$pdf->Cell(40,5,$from_adr_locality.', '.$from_adr_region.' '.$from_adr_country.' '.$from_adr_postal_code);
-	$pdf->Ln();
-	$pdf->Ln();
-
-//get contact to name
-	$sql = "";
-	$sql .= "select * from v_contacts ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and contact_uuid = '$contact_uuid_to' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	foreach ($result as &$row) {
-		$to_org = $row["org"];
-		$to_n_given = $row["n_given"];
-		$to_n_family = $row["n_family"];
-		break; //limit to 1 row
-	}
-	unset ($prep_statement);
-
-//get contact to address
-	$sql = "";
-	$sql .= "select * from v_contacts_adr ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and contact_uuid = '$contact_uuid_to' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	foreach ($result as &$row) {
-		$to_adr_type = $row["adr_type"];
-		$to_adr_street = $row["adr_street"];
-		$to_adr_extended = $row["adr_extended"];
-		$to_adr_locality = $row["adr_locality"];
-		$to_adr_region = $row["adr_region"];
-		$to_adr_postal_code = $row["adr_postal_code"];
-		$to_adr_country = $row["adr_country"];
-		break; //limit to 1 row
-	}
-	unset ($prep_statement);
-	$pdf->SetY(40);
-	$pdf->SetFont('Arial','B',9);
-	if (strlen($to_org) > 0) {
-		$pdf->Cell(40,5,$to_org);
-		$pdf->Ln();
-	}
-	else {
-		if (strlen($to_n_given.$to_n_family) > 0) {
-			$pdf->Cell(40,5,$to_n_given.' '.$to_n_family);
-			$pdf->Ln();
-		}
-	}
-	$pdf->SetFont('Arial','',9);
-	$pdf->Cell(40,5,$to_adr_street.' '.$to_adr_extended);
-	$pdf->Ln();
-	$pdf->Cell(40,5,$to_adr_locality.', '.$to_adr_region.' '.$to_adr_country.' '.$to_adr_postal_code);
-	$pdf->Ln();
-	$pdf->Ln();
-	$pdf->Ln();
-
-//invoice info
-	$pdf->SetY(10);
-	$pdf->Cell(150,10,'');
-	$pdf->SetFont('Arial','',23);
-	$pdf->Cell(40,10,"INVOICE");
-	$pdf->Ln();
-	$pdf->SetFont('Arial','',9);
-	$pdf->Cell(150,5,'');
-	$pdf->Cell(40,5,'Invoice Date: '.$invoice_date);
-	$pdf->Ln();
-	$pdf->Cell(150,5,'');
-	$pdf->Cell(40,5,'Invoice Number: '.$invoice_number);
-	$pdf->Ln();
-	$pdf->Ln();
-	$pdf->Ln();
-
-//set the vertical position
-	$pdf->SetY(65);
-
-//table headers array
-	$header = array('Qty', 'Description', 'Unit Price', 'Amount');
-
-//set the table header styles
-	$pdf->SetFillColor(200,200,200);
-	//$pdf->SetTextColor(255);
-	$pdf->SetDrawColor(220,220,220);
-	$pdf->SetLineWidth(0.3);
-
-//set the table cell widths
-	$w[0] = 20;
-	$w[1] = 120;
-	$w[2] = 25;
-	$w[3] = 25;
-	for($i=0;$i<count($header);$i++) {
-		if ($header[$i] == "Description") {
-			//left align
-			$pdf->Cell($w[$i],5,$header[$i],1,0,'L',true);
-		}
-		else {
-			//center
-			$pdf->Cell($w[$i],5,$header[$i],1,0,'C',true);
-		}
-	}
-	$pdf->Ln();
-
-//set the text and background color
-	$pdf->SetFillColor(224,235,255);
-	$pdf->SetTextColor(0);
-	$pdf->SetFont('Arial','',9);
-
-//itemized list
-	$sql = "";
-	$sql .= "select * from v_invoice_items ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and invoice_uuid = '$invoice_uuid' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	$fill = false;
-	$total = 0;
-	foreach ($result as &$row) {
-		$item_qty = $row["item_qty"];
-		$item_desc = $row["item_desc"];
-		//$item_desc = str_replace("\n", "<br />", $item_desc);
-		$item_desc = wordwrap($item_desc, 70, "\n");
-		$item_unit_price = $row["item_unit_price"];
-		$item_sub_total = $item_qty * $item_unit_price;
-
-		$item_desc_array = explode ("\n", $item_desc);
-		$x = 0;
-		foreach ($item_desc_array as $line) {
-			//quantity
-				if ($x == 0) {
-					$pdf->Cell($w[0],6,$item_qty,'LR',0,'C',$fill);
-				}
-				else {
-					$pdf->Cell($w[0],6," ",'LR',0,'C',$fill);
-				}
-			//description
-				$pdf->Cell($w[1],6,$line,'LR',0,'L',$fill);
-			//unit price
-				if ($x == 0) {
-					$pdf->Cell($w[2],6,$item_unit_price,'LR',0,'R',$fill);
-				}
-				else {
-					$pdf->Cell($w[2],6," ",'LR',0,'R',$fill);
-				}
-			//amount
-				if ($x == 0) {
-					$pdf->Cell($w[3],6,number_format($item_sub_total,2),'LR',0,'R',$fill);
-				}
-				else {
-					$pdf->Cell($w[3],6," ",'LR',0,'R',$fill);
-				}
-			//line feed
-				$pdf->Ln(6);
-				$x++;
-		}
-		//line seperator
-			//$pdf->Cell(($w[0]+$w[1]+$w[2]+$w[3]),0.3," ",'TBRL',1,'R',$fill);
-		//alternate the fill
-			if ($fill) {
-				$fill = false;
-			}
-			else {
-				$fill = true;
-			}
-		//sub total
-			$total = $total + $item_sub_total;
-	}
-	unset ($prep_statement);
-	//line seperator
-	$pdf->Cell(($w[0]+$w[1]+$w[2]+$w[3]),0.1," ",'TBRL',1,'R',$fill);
-
-//show the total
-	$pdf->Ln();
-	$pdf->SetFont('Arial','B',9);
-	$pdf->Cell($w[0],6,'','',0,'L','');
-	$pdf->Cell($w[1],6,'','',0,'L','');
-	$pdf->Cell($w[2],6,'','',0,'R','');
-	$pdf->Cell($w[3],6,'Total: '.number_format($total,2),'',0,'R','');
-	$pdf->Ln();
-
-	if (strlen($invoice_note) > 0) {
-		$pdf->SetFont('Arial','B',9);
-		$pdf->Cell($w[0],6,'Notes','',0,'L',$fill);
-		$pdf->Ln();
-		$pdf->Cell($w[0],6,''.$invoice_note,'',0,'L',$fill);
-		$pdf->Ln();
-	}
-
-//closing line
-	//$pdf->Cell(array_sum($w),0,'','T');
-
-//show the pdf
-	$pdf->Output();
-
-?>
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//action invoice_uuid
+	if (isset($_REQUEST["id"])) {
+		$invoice_uuid = check_str($_REQUEST["id"]);
+	}
+
+//get the invoice details
+	$sql = "";
+	$sql .= "select * from v_invoices ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and invoice_uuid = '$invoice_uuid' ";
+	$sql .= "order by invoice_uuid desc ";
+	$sql .= "limit 1 ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	if ($prep_statement) {
+		$prep_statement->execute();
+		$row = $prep_statement->fetch();
+		$invoice_number = $row['invoice_number'];
+		$contact_uuid_from = $row['contact_uuid_from'];
+		$contact_uuid_to = $row['contact_uuid_to'];
+		$invoice_date = $row['invoice_date'];
+		$invoice_note = $row['invoice_note'];
+		unset ($prep_statement);
+	}
+
+//prepare the invoice date
+	$invoice_date = date("d", strtotime($invoice_date)).' '.date("M", strtotime($invoice_date)).' '.date("Y", strtotime($invoice_date));
+
+//prepare to use fpdf
+	define('FPDF_FONTPATH',$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/fpdf/font/');
+	require('includes/fpdf/fpdf.php');
+
+//create the fpdf object and add the first page
+	$pdf = new FPDF();
+	$pdf->AddPage();
+	$pdf->SetFont('Arial','B',9);
+
+//get contact from name
+	$sql = "";
+	$sql .= "select * from v_contacts ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and contact_uuid = '$contact_uuid_from' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	foreach ($result as &$row) {
+		$from_org = $row["org"];
+		$from_n_given = $row["n_given"];
+		$from_n_family = $row["n_family"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+
+//get contact from address
+	$sql = "";
+	$sql .= "select * from v_contacts_adr ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and contact_uuid = '$contact_uuid_from' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	foreach ($result as &$row) {
+		$from_adr_type = $row["adr_type"];
+		$from_adr_street = $row["adr_street"];
+		$from_adr_extended = $row["adr_extended"];
+		$from_adr_locality = $row["adr_locality"];
+		$from_adr_region = $row["adr_region"];
+		$from_adr_postal_code = $row["adr_postal_code"];
+		$from_adr_country = $row["adr_country"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+	$pdf->SetY(10);
+	$pdf->SetFont('Arial','B',9);
+	if (strlen($from_org) > 0) {
+		$pdf->Cell(40,5,$from_org);
+		$pdf->Ln();
+	}
+	else {
+		if (strlen($from_n_given.$from_n_family) > 0) {
+			$pdf->Cell(40,5,$from_n_given.' '.$from_n_family);
+			$pdf->Ln();
+		}
+	}
+	$pdf->SetFont('Arial','',9);
+	$pdf->Cell(40,5,$from_adr_street.' '.$from_adr_extended);
+	$pdf->Ln();
+	$pdf->Cell(40,5,$from_adr_locality.', '.$from_adr_region.' '.$from_adr_country.' '.$from_adr_postal_code);
+	$pdf->Ln();
+	$pdf->Ln();
+
+//get contact to name
+	$sql = "";
+	$sql .= "select * from v_contacts ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and contact_uuid = '$contact_uuid_to' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	foreach ($result as &$row) {
+		$to_org = $row["org"];
+		$to_n_given = $row["n_given"];
+		$to_n_family = $row["n_family"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+
+//get contact to address
+	$sql = "";
+	$sql .= "select * from v_contacts_adr ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and contact_uuid = '$contact_uuid_to' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	foreach ($result as &$row) {
+		$to_adr_type = $row["adr_type"];
+		$to_adr_street = $row["adr_street"];
+		$to_adr_extended = $row["adr_extended"];
+		$to_adr_locality = $row["adr_locality"];
+		$to_adr_region = $row["adr_region"];
+		$to_adr_postal_code = $row["adr_postal_code"];
+		$to_adr_country = $row["adr_country"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+	$pdf->SetY(40);
+	$pdf->SetFont('Arial','B',9);
+	if (strlen($to_org) > 0) {
+		$pdf->Cell(40,5,$to_org);
+		$pdf->Ln();
+	}
+	else {
+		if (strlen($to_n_given.$to_n_family) > 0) {
+			$pdf->Cell(40,5,$to_n_given.' '.$to_n_family);
+			$pdf->Ln();
+		}
+	}
+	$pdf->SetFont('Arial','',9);
+	$pdf->Cell(40,5,$to_adr_street.' '.$to_adr_extended);
+	$pdf->Ln();
+	$pdf->Cell(40,5,$to_adr_locality.', '.$to_adr_region.' '.$to_adr_country.' '.$to_adr_postal_code);
+	$pdf->Ln();
+	$pdf->Ln();
+	$pdf->Ln();
+
+//invoice info
+	$pdf->SetY(10);
+	$pdf->Cell(150,10,'');
+	$pdf->SetFont('Arial','',23);
+	$pdf->Cell(40,10,"INVOICE");
+	$pdf->Ln();
+	$pdf->SetFont('Arial','',9);
+	$pdf->Cell(150,5,'');
+	$pdf->Cell(40,5,'Invoice Date: '.$invoice_date);
+	$pdf->Ln();
+	$pdf->Cell(150,5,'');
+	$pdf->Cell(40,5,'Invoice Number: '.$invoice_number);
+	$pdf->Ln();
+	$pdf->Ln();
+	$pdf->Ln();
+
+//set the vertical position
+	$pdf->SetY(65);
+
+//table headers array
+	$header = array('Qty', 'Description', 'Unit Price', 'Amount');
+
+//set the table header styles
+	$pdf->SetFillColor(200,200,200);
+	//$pdf->SetTextColor(255);
+	$pdf->SetDrawColor(220,220,220);
+	$pdf->SetLineWidth(0.3);
+
+//set the table cell widths
+	$w[0] = 20;
+	$w[1] = 120;
+	$w[2] = 25;
+	$w[3] = 25;
+	for($i=0;$i<count($header);$i++) {
+		if ($header[$i] == "Description") {
+			//left align
+			$pdf->Cell($w[$i],5,$header[$i],1,0,'L',true);
+		}
+		else {
+			//center
+			$pdf->Cell($w[$i],5,$header[$i],1,0,'C',true);
+		}
+	}
+	$pdf->Ln();
+
+//set the text and background color
+	$pdf->SetFillColor(224,235,255);
+	$pdf->SetTextColor(0);
+	$pdf->SetFont('Arial','',9);
+
+//itemized list
+	$sql = "";
+	$sql .= "select * from v_invoice_items ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and invoice_uuid = '$invoice_uuid' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	$fill = false;
+	$total = 0;
+	foreach ($result as &$row) {
+		$item_qty = $row["item_qty"];
+		$item_desc = $row["item_desc"];
+		//$item_desc = str_replace("\n", "<br />", $item_desc);
+		$item_desc = wordwrap($item_desc, 70, "\n");
+		$item_unit_price = $row["item_unit_price"];
+		$item_sub_total = $item_qty * $item_unit_price;
+
+		$item_desc_array = explode ("\n", $item_desc);
+		$x = 0;
+		foreach ($item_desc_array as $line) {
+			//quantity
+				if ($x == 0) {
+					$pdf->Cell($w[0],6,$item_qty,'LR',0,'C',$fill);
+				}
+				else {
+					$pdf->Cell($w[0],6," ",'LR',0,'C',$fill);
+				}
+			//description
+				$pdf->Cell($w[1],6,$line,'LR',0,'L',$fill);
+			//unit price
+				if ($x == 0) {
+					$pdf->Cell($w[2],6,$item_unit_price,'LR',0,'R',$fill);
+				}
+				else {
+					$pdf->Cell($w[2],6," ",'LR',0,'R',$fill);
+				}
+			//amount
+				if ($x == 0) {
+					$pdf->Cell($w[3],6,number_format($item_sub_total,2),'LR',0,'R',$fill);
+				}
+				else {
+					$pdf->Cell($w[3],6," ",'LR',0,'R',$fill);
+				}
+			//line feed
+				$pdf->Ln(6);
+				$x++;
+		}
+		//line seperator
+			//$pdf->Cell(($w[0]+$w[1]+$w[2]+$w[3]),0.3," ",'TBRL',1,'R',$fill);
+		//alternate the fill
+			if ($fill) {
+				$fill = false;
+			}
+			else {
+				$fill = true;
+			}
+		//sub total
+			$total = $total + $item_sub_total;
+	}
+	unset ($prep_statement);
+	//line seperator
+	$pdf->Cell(($w[0]+$w[1]+$w[2]+$w[3]),0.1," ",'TBRL',1,'R',$fill);
+
+//show the total
+	$pdf->Ln();
+	$pdf->SetFont('Arial','B',9);
+	$pdf->Cell($w[0],6,'','',0,'L','');
+	$pdf->Cell($w[1],6,'','',0,'L','');
+	$pdf->Cell($w[2],6,'','',0,'R','');
+	$pdf->Cell($w[3],6,'Total: '.number_format($total,2),'',0,'R','');
+	$pdf->Ln();
+
+	if (strlen($invoice_note) > 0) {
+		$pdf->SetFont('Arial','B',9);
+		$pdf->Cell($w[0],6,'Notes','',0,'L',$fill);
+		$pdf->Ln();
+		$pdf->Cell($w[0],6,''.$invoice_note,'',0,'L',$fill);
+		$pdf->Ln();
+	}
+
+//closing line
+	//$pdf->Cell(array_sum($w),0,'','T');
+
+//show the pdf
+	$pdf->Output();
+
+?>

+ 1 - 1
invoices/v_invoices_delete.php

@@ -34,4 +34,4 @@ require_once "includes/footer.php";
 return;
 
 ?>
-
+

+ 49 - 49
soft_phone/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>

+ 276 - 276
soft_phone/v_softphone.php

@@ -1,277 +1,277 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (if_group("admin") || if_group("superadmin")) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-require_once "includes/header.php";
-
-
-//notes
-	// http://wiki.freeswitch.org/wiki/Mod_portaudio
-	// http://wiki.freeswitch.org/wiki/Freeswitch_softphone
-	// 
-
-
-//echo "<form method='post' name='frm' action=''>\n";
-//echo "</form>";
-
-echo "<div align='center'>\n";
-
-echo "<div id='ajax_response'>\n";
-
-echo "</div>\n";
-
-echo "<table border='0'>\n";
-echo "<tr>\n";
-echo "<td>\n";
-
-	echo "<table border='0' width='225'>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center' colspan='3'>\n";
-	echo "<input style='width: 100%' class='formfld' type='text' id='dial' name='dial' maxlength='10' value=\"\">\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '1';\" value='1'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '2';\" value='2'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '3';\" value='3'>\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '4';\" value='4'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '5';\" value='5'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '6';\" value='6'>\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '7';\" value='7'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '8';\" value='8'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '9';\" value='9'>\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '*';\" value='*'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '0';\" value='0'>\n";
-	echo "</td>\n";
-	echo "<td align='center'>\n";
-	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '#';\" value='#'>\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='center' colspan='3'>\n";
-	echo "<input style='width: 100%' class='formfld' type='text' id='api_cmd' name='api_cmd' value=\"\">\n";
-	//echo "<br \>\n";
-	echo "<input style='width: 100%' class='formfld' type='hidden' id='uid' name='uid' value=\"\">\n";
-	echo "<input style='width: 100%' class='formfld' type='hidden' id='rec' name='rec' value=\"\">\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "</table>\n";
-
-echo "</td>\n";
-echo "<td width='50'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"backspace();\" value='<'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"clear();\" value='clear'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_call();\" value='call'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' disabled class='btn' name='xfer' id = 'xfer' alt='view' onclick=\"xfer();\" value='xfer'>\n";
-//echo "	<input type='button' style='width: 100%; height: 100%;' class='btn' name='' alt='view' onclick=\"rec();\" value='rec'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch();\" value='switch'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch_none();\" value='hold'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"cmd();\" value='cmd'>\n";
-echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_hangup();\" value='end'>\n";
-echo "</td>\n";
-echo "</tr>\n";
-echo "</table>\n";
-
-echo "</div>\n";
-
-?>
-
-<script type="text/javascript">
-function ajaxFunction()
-{
-	var xmlhttp;
-	if (window.XMLHttpRequest)
-	{
-		// code for IE7+, Firefox, Chrome, Opera, Safari
-		xmlhttp=new XMLHttpRequest();
-	}
-	else if (window.ActiveXObject)
-	{
-		// code for IE6, IE5
-		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-	}
-	else
-	{
-		alert("Your browser does not support XMLHTTP!");
-	}
-	xmlhttp.onreadystatechange=function()
-	{
-	if(xmlhttp.readyState==4)
-		{
-			var dial = document.getElementById('dial').value;
-			//alert('dial:'+dial);
-			var response = xmlhttp.responseText;
-			document.getElementById('ajax_response').innerHTML = '<pre>\n'+response+'</pre>\n';
-			//alert('response: '+response);
-			//response = response.replace('SUCCESS:', '');
-			var response_array = response.split(':');
-			if (response_array.length > 1) {
-				document.getElementById('uid').value = response_array[2];
-				document.getElementById('xfer').disabled = false;
-			}
-			//document.myForm.time.value=xmlhttp.responseText;
-		}
-	}
-
-	var api_cmd = document.getElementById('api_cmd').value;
-	//alert('cmd:'. api_cmd);
-	xmlhttp.open("GET","<?php echo PROJECT_PATH; ?>/includes/v_cmd.php?cmd="+escape(api_cmd)+"&rdr=false",true);
-	xmlhttp.send(null);
-}
-
-function backspace() {
-	document.getElementById('api_cmd').value = '';
-	var dial = document.getElementById('dial').value;
-	document.getElementById('dial').value = dial.substr(0, (dial.length -1));
-}
-
-function clear() {
-	document.getElementById('uid').value = '';
-	document.getElementById('api_cmd').value = '';
-	document.getElementById('dial').value = '';
-}
-
-function pa_call() {
-	document.getElementById('api_cmd').value = 'api pa call '+document.getElementById('dial').value;
-	var uid = document.getElementById('uid').value;
-	var dial = document.getElementById('dial').value;
-	if (dial.length == 0) {
-		document.getElementById('api_cmd').value = 'api pa answer';
-		document.getElementById('xfer').disabled = false;
-	}
-	else {
-		if (uid.length > 0) {
-			document.getElementById('api_cmd').value = 'api pa dtmf '+document.getElementById('dial').value;
-		}
-	}
-	ajaxFunction();
-	document.getElementById('dial').value = '';
-}
-
-function xfer() {
-	//uuid_transfer,<uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>],Transfer a session,mod_commands
-	var uid = document.getElementById('uid').value;
-	var dial = document.getElementById('dial').value;
-	if (uid.length > 0) {
-		document.getElementById('api_cmd').value = 'api uuid_transfer '+uid+' '+dial+' XML default';
-	}
-	ajaxFunction();
-	//document.getElementById('dial').value = '';
-}
-
-function rec() {
-	//this function is making the recording but freeswitch crashes after hanging up the call. So it is currently disabled.
-	//uuid_record,<uuid> [start|stop] <path> [<limit>],session record,mod_commands
-	var uid = document.getElementById('uid').value;
-	var rec = document.getElementById('rec').value;
-	if (uid.length > 0) {
-		if (rec.length > 0) {
-			//stop
-			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
-			document.getElementById('rec').value = '';
-		}
-		else {
-			//start
-			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' start C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
-			document.getElementById('rec').value = 'true';
-		}
-	}
-	ajaxFunction();
-	//document.getElementById('dial').value = '';
-}
-
-function pa_switch() {
-	document.getElementById('api_cmd').value = 'api pa switch';
-	ajaxFunction();
-}
-
-function pa_switch_none() {
-	document.getElementById('api_cmd').value = 'api pa switch none';
-	ajaxFunction();
-}
-
-function cmd() {
-	ajaxFunction();
-}
-
-function pa_hangup () {
-	//uid = document.getElementById('uid').value;
-	//document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop';
-	document.getElementById('uid').value = '';
-	document.getElementById('api_cmd').value = 'api pa hangup';
-	document.getElementById('dial').value = '';
-	ajaxFunction();
-
-}
-
-
-</script>
-<?php
-
-require_once "includes/footer.php";
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+
+
+//notes
+	// http://wiki.freeswitch.org/wiki/Mod_portaudio
+	// http://wiki.freeswitch.org/wiki/Freeswitch_softphone
+	// 
+
+
+//echo "<form method='post' name='frm' action=''>\n";
+//echo "</form>";
+
+echo "<div align='center'>\n";
+
+echo "<div id='ajax_response'>\n";
+
+echo "</div>\n";
+
+echo "<table border='0'>\n";
+echo "<tr>\n";
+echo "<td>\n";
+
+	echo "<table border='0' width='225'>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center' colspan='3'>\n";
+	echo "<input style='width: 100%' class='formfld' type='text' id='dial' name='dial' maxlength='10' value=\"\">\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '1';\" value='1'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '2';\" value='2'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '3';\" value='3'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '4';\" value='4'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '5';\" value='5'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '6';\" value='6'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '7';\" value='7'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '8';\" value='8'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '9';\" value='9'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '*';\" value='*'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '0';\" value='0'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '#';\" value='#'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center' colspan='3'>\n";
+	echo "<input style='width: 100%' class='formfld' type='text' id='api_cmd' name='api_cmd' value=\"\">\n";
+	//echo "<br \>\n";
+	echo "<input style='width: 100%' class='formfld' type='hidden' id='uid' name='uid' value=\"\">\n";
+	echo "<input style='width: 100%' class='formfld' type='hidden' id='rec' name='rec' value=\"\">\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>\n";
+
+echo "</td>\n";
+echo "<td width='50'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"backspace();\" value='<'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"clear();\" value='clear'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_call();\" value='call'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' disabled class='btn' name='xfer' id = 'xfer' alt='view' onclick=\"xfer();\" value='xfer'>\n";
+//echo "	<input type='button' style='width: 100%; height: 100%;' class='btn' name='' alt='view' onclick=\"rec();\" value='rec'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch();\" value='switch'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch_none();\" value='hold'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"cmd();\" value='cmd'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_hangup();\" value='end'>\n";
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+
+echo "</div>\n";
+
+?>
+
+<script type="text/javascript">
+function ajaxFunction()
+{
+	var xmlhttp;
+	if (window.XMLHttpRequest)
+	{
+		// code for IE7+, Firefox, Chrome, Opera, Safari
+		xmlhttp=new XMLHttpRequest();
+	}
+	else if (window.ActiveXObject)
+	{
+		// code for IE6, IE5
+		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+	}
+	else
+	{
+		alert("Your browser does not support XMLHTTP!");
+	}
+	xmlhttp.onreadystatechange=function()
+	{
+	if(xmlhttp.readyState==4)
+		{
+			var dial = document.getElementById('dial').value;
+			//alert('dial:'+dial);
+			var response = xmlhttp.responseText;
+			document.getElementById('ajax_response').innerHTML = '<pre>\n'+response+'</pre>\n';
+			//alert('response: '+response);
+			//response = response.replace('SUCCESS:', '');
+			var response_array = response.split(':');
+			if (response_array.length > 1) {
+				document.getElementById('uid').value = response_array[2];
+				document.getElementById('xfer').disabled = false;
+			}
+			//document.myForm.time.value=xmlhttp.responseText;
+		}
+	}
+
+	var api_cmd = document.getElementById('api_cmd').value;
+	//alert('cmd:'. api_cmd);
+	xmlhttp.open("GET","<?php echo PROJECT_PATH; ?>/includes/v_cmd.php?cmd="+escape(api_cmd)+"&rdr=false",true);
+	xmlhttp.send(null);
+}
+
+function backspace() {
+	document.getElementById('api_cmd').value = '';
+	var dial = document.getElementById('dial').value;
+	document.getElementById('dial').value = dial.substr(0, (dial.length -1));
+}
+
+function clear() {
+	document.getElementById('uid').value = '';
+	document.getElementById('api_cmd').value = '';
+	document.getElementById('dial').value = '';
+}
+
+function pa_call() {
+	document.getElementById('api_cmd').value = 'api pa call '+document.getElementById('dial').value;
+	var uid = document.getElementById('uid').value;
+	var dial = document.getElementById('dial').value;
+	if (dial.length == 0) {
+		document.getElementById('api_cmd').value = 'api pa answer';
+		document.getElementById('xfer').disabled = false;
+	}
+	else {
+		if (uid.length > 0) {
+			document.getElementById('api_cmd').value = 'api pa dtmf '+document.getElementById('dial').value;
+		}
+	}
+	ajaxFunction();
+	document.getElementById('dial').value = '';
+}
+
+function xfer() {
+	//uuid_transfer,<uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>],Transfer a session,mod_commands
+	var uid = document.getElementById('uid').value;
+	var dial = document.getElementById('dial').value;
+	if (uid.length > 0) {
+		document.getElementById('api_cmd').value = 'api uuid_transfer '+uid+' '+dial+' XML default';
+	}
+	ajaxFunction();
+	//document.getElementById('dial').value = '';
+}
+
+function rec() {
+	//this function is making the recording but freeswitch crashes after hanging up the call. So it is currently disabled.
+	//uuid_record,<uuid> [start|stop] <path> [<limit>],session record,mod_commands
+	var uid = document.getElementById('uid').value;
+	var rec = document.getElementById('rec').value;
+	if (uid.length > 0) {
+		if (rec.length > 0) {
+			//stop
+			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
+			document.getElementById('rec').value = '';
+		}
+		else {
+			//start
+			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' start C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
+			document.getElementById('rec').value = 'true';
+		}
+	}
+	ajaxFunction();
+	//document.getElementById('dial').value = '';
+}
+
+function pa_switch() {
+	document.getElementById('api_cmd').value = 'api pa switch';
+	ajaxFunction();
+}
+
+function pa_switch_none() {
+	document.getElementById('api_cmd').value = 'api pa switch none';
+	ajaxFunction();
+}
+
+function cmd() {
+	ajaxFunction();
+}
+
+function pa_hangup () {
+	//uid = document.getElementById('uid').value;
+	//document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop';
+	document.getElementById('uid').value = '';
+	document.getElementById('api_cmd').value = 'api pa hangup';
+	document.getElementById('dial').value = '';
+	ajaxFunction();
+
+}
+
+
+</script>
+<?php
+
+require_once "includes/footer.php";
 ?>

+ 51 - 51
tickets/root.php

@@ -1,51 +1,51 @@
-<?php
-/*
-	FusionPBX
-      	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Ken Rice <[email protected]>
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
-?>
+<?php
+/*
+	FusionPBX
+      	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Ken Rice <[email protected]>
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 49 - 49
user_contacts/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>

+ 163 - 163
user_contacts/users.php

@@ -1,164 +1,164 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (permission_exists('contacts_view')) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-
-require_once "includes/header.php";
-require_once "includes/paging.php";
-
-//get the http values and set them as php variables
-	$order_by = $_GET["order_by"];
-	$order = $_GET["order"];
-
-//show the content
-	echo "<div align='center'>";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
-
-	echo "<tr class='border'>\n";
-	echo "	<td align=\"center\">\n";
-	echo "		<br>";
-
-	echo "<table width='100%' border='0'><tr>\n";
-	echo "<td width='50%' nowrap='nowrap' align='left'><b>Contact List</b></td>\n";
-	echo "<td width='50%' align='right'>&nbsp;</td>\n";
-	echo "</tr></table>\n";
-
-	$sql = "";
-	$sql .= "select * from v_users ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	$num_rows = count($result);
-	unset ($prep_statement, $result, $sql);
-
-	$rows_per_page = 150;
-	$param = "";
-	$page = $_GET['page'];
-	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
-	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
-	$offset = $rows_per_page * $page; 
-
-	$sql = "";
-	$sql .= "select * from v_users ";
-	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "limit $rows_per_page offset $offset ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	$result_count = count($result);
-	unset ($prep_statement, $sql);
-
-	$c = 0;
-	$row_style["0"] = "row_style0";
-	$row_style["1"] = "row_style1";
-
-	echo "<div align='center'>\n";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
-	echo "<tr>\n";
-	echo thorder_by('username', 'Username', $order_by, $order);
-	echo thorder_by('user_type', 'Type', $order_by, $order);
-	echo thorder_by('user_category', 'Category', $order_by, $order);
-	echo thorder_by('user_first_name', 'First Name', $order_by, $order);
-	echo thorder_by('user_last_name', 'Last Name', $order_by, $order);
-	echo thorder_by('user_company_name', 'Organization', $order_by, $order);
-	echo thorder_by('user_phone_1', 'Phone', $order_by, $order);
-	echo "<td align='right' width='42'>\n";
-	if (permission_exists('contacts_add')) {
-		echo "	<a href='users_edit.php' alt='add'>$v_link_label_add</a>\n";
-	}
-	echo "</td>\n";
-	echo "<tr>\n";
-
-	if ($result_count > 0) {
-		foreach($result as $row) {
-			echo "<tr >\n";
-			if (strlen($row[username]) == 0) {
-				echo "	<td valign='top' class='".$row_style[$c]."'>contact&nbsp;</td>\n";
-			}
-			else {
-				echo "	<td valign='top' class='".$row_style[$c]."'>".$row['username']."&nbsp;</td>\n";
-			}
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_type']."&nbsp;</td>\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_category']."&nbsp;</td>\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_first_name']."&nbsp;</td>\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_last_name']."&nbsp;</td>\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_company_name']."&nbsp;</td>\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_phone_1']."&nbsp;</td>\n";
-			echo "	<td valign='top' align='right'>\n";
-			if (permission_exists('contacts_edit')) {
-				echo "		<a href='users_edit.php?id=".$row['user_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
-			}
-			if (permission_exists('contacts_delete')) {
-				echo "		<a href='users_delete.php?id=".$row['user_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
-			}
-			echo "	</td>\n";
-			echo "</tr>\n";
-			if ($c==0) { $c=1; } else { $c=0; }
-		} //end foreach
-		unset($sql, $result);
-	} //end if results
-
-	echo "<tr>\n";
-	echo "<td colspan='8' align='left'>\n";
-	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
-	echo "	<tr>\n";
-	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
-	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
-	echo "		<td width='33.3%' align='right'>\n";
-	if (permission_exists('contacts_add')) {
-		echo "			<a href='users_edit.php' alt='add'>$v_link_label_add</a>\n";
-	}
-	echo "		</td>\n";
-	echo "	</tr>\n";
- 	echo "	</table>\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "</table>";
-	echo "</div>";
-	echo "<br><br>";
-	echo "<br><br>";
-
-	echo "</td>";
-	echo "</tr>";
-	echo "</table>";
-	echo "</div>";
-	echo "<br><br>";
-
-//show the footer
-	require_once "includes/footer.php";
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('contacts_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+//get the http values and set them as php variables
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+//show the content
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+	echo "<table width='100%' border='0'><tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Contact List</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr></table>\n";
+
+	$sql = "";
+	$sql .= "select * from v_users ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+
+	$rows_per_page = 150;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= "select * from v_users ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo thorder_by('username', 'Username', $order_by, $order);
+	echo thorder_by('user_type', 'Type', $order_by, $order);
+	echo thorder_by('user_category', 'Category', $order_by, $order);
+	echo thorder_by('user_first_name', 'First Name', $order_by, $order);
+	echo thorder_by('user_last_name', 'Last Name', $order_by, $order);
+	echo thorder_by('user_company_name', 'Organization', $order_by, $order);
+	echo thorder_by('user_phone_1', 'Phone', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	if (permission_exists('contacts_add')) {
+		echo "	<a href='users_edit.php' alt='add'>$v_link_label_add</a>\n";
+	}
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+			echo "<tr >\n";
+			if (strlen($row[username]) == 0) {
+				echo "	<td valign='top' class='".$row_style[$c]."'>contact&nbsp;</td>\n";
+			}
+			else {
+				echo "	<td valign='top' class='".$row_style[$c]."'>".$row['username']."&nbsp;</td>\n";
+			}
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_type']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_category']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_first_name']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_last_name']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_company_name']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['user_phone_1']."&nbsp;</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			if (permission_exists('contacts_edit')) {
+				echo "		<a href='users_edit.php?id=".$row['user_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
+			}
+			if (permission_exists('contacts_delete')) {
+				echo "		<a href='users_delete.php?id=".$row['user_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			}
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result);
+	} //end if results
+
+	echo "<tr>\n";
+	echo "<td colspan='8' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	if (permission_exists('contacts_add')) {
+		echo "			<a href='users_edit.php' alt='add'>$v_link_label_add</a>\n";
+	}
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+//show the footer
+	require_once "includes/footer.php";
 ?>

+ 63 - 63
user_contacts/users_delete.php

@@ -1,63 +1,63 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (permission_exists('contacts_delete')) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-
-//get the id
-	if (count($_GET)>0) {
-		$id = $_GET["id"];
-	}
-
-//delete the user
-	if (strlen($id)>0) {
-		$sql = "";
-		$sql .= "delete from v_users ";
-		$sql .= "where domain_uuid = '$domain_uuid' ";
-		$sql .= "and id = '$id' ";
-		$prep_statement = $db->prepare(check_sql($sql));
-		$prep_statement->execute();
-		unset($sql);
-	}
-
-//redirect the user
-	require_once "includes/header.php";
-	echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
-	echo "<div align='center'>\n";
-	echo "Delete Complete\n";
-	echo "</div>\n";
-
-//show the footer
-	require_once "includes/footer.php";
-	return;
-?>
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('contacts_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//get the id
+	if (count($_GET)>0) {
+		$id = $_GET["id"];
+	}
+
+//delete the user
+	if (strlen($id)>0) {
+		$sql = "";
+		$sql .= "delete from v_users ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and id = '$id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql);
+	}
+
+//redirect the user
+	require_once "includes/header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
+	echo "<div align='center'>\n";
+	echo "Delete Complete\n";
+	echo "</div>\n";
+
+//show the footer
+	require_once "includes/footer.php";
+	return;
+?>

+ 1031 - 1031
user_contacts/users_edit.php

@@ -1,1031 +1,1031 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (permission_exists('contacts_add') || permission_exists('contacts_edit')) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-
-//set the action to an add or update
-	if (isset($_REQUEST["id"])) {
-		$action = "update";
-		$user_uuid = check_str($_REQUEST["id"]);
-	}
-	else {
-		$action = "add";
-	}
-
-//get the http post values and set them as php variables
-	if (count($_POST)>0) {
-		$username = check_str($_POST["username"]);
-		$password = check_str($_POST["password"]);
-		$user_type = check_str($_POST["user_type"]);
-		$user_category = check_str($_POST["user_category"]);
-		$user_first_name = check_str($_POST["user_first_name"]);
-		$user_last_name = check_str($_POST["user_last_name"]);
-		$user_company_name = check_str($_POST["user_company_name"]);
-		$user_physical_address_1 = check_str($_POST["user_physical_address_1"]);
-		$user_physical_address_2 = check_str($_POST["user_physical_address_2"]);
-		$user_physical_city = check_str($_POST["user_physical_city"]);
-		$user_physical_state_province = check_str($_POST["user_physical_state_province"]);
-		$user_physical_postal_code = check_str($_POST["user_physical_postal_code"]);
-		$user_physical_country = check_str($_POST["user_physical_country"]);
-		$user_mailing_address_1 = check_str($_POST["user_mailing_address_1"]);
-		$user_mailing_address_2 = check_str($_POST["user_mailing_address_2"]);
-		$user_mailing_city = check_str($_POST["user_mailing_city"]);
-		$user_mailing_state_province = check_str($_POST["user_mailing_state_province"]);
-		$user_mailing_postal_code = check_str($_POST["user_mailing_postal_code"]);
-		$user_mailing_country = check_str($_POST["user_mailing_country"]);
-		$user_billing_address_1 = check_str($_POST["user_billing_address_1"]);
-		$user_billing_address_2 = check_str($_POST["user_billing_address_2"]);
-		$user_billing_city = check_str($_POST["user_billing_city"]);
-		$user_billing_state_province = check_str($_POST["user_billing_state_province"]);
-		$user_billing_postal_code = check_str($_POST["user_billing_postal_code"]);
-		$user_billing_country = check_str($_POST["user_billing_country"]);
-		$user_shipping_address_1 = check_str($_POST["user_shipping_address_1"]);
-		$user_shipping_address_2 = check_str($_POST["user_shipping_address_2"]);
-		$user_shipping_city = check_str($_POST["user_shipping_city"]);
-		$user_shipping_state_province = check_str($_POST["user_shipping_state_province"]);
-		$user_shipping_postal_code = check_str($_POST["user_shipping_postal_code"]);
-		$user_shipping_country = check_str($_POST["user_shipping_country"]);
-		$user_phone_1 = check_str($_POST["user_phone_1"]);
-		$user_phone_1_ext = check_str($_POST["user_phone_1_ext"]);
-		$user_phone_2 = check_str($_POST["user_phone_2"]);
-		$user_phone_2_ext = check_str($_POST["user_phone_2_ext"]);
-		$user_phone_mobile = check_str($_POST["user_phone_mobile"]);
-		$user_phone_fax = check_str($_POST["user_phone_fax"]);
-		$user_phone_emergency_mobile = check_str($_POST["user_phone_emergency_mobile"]);
-		$user_email_emergency = check_str($_POST["user_email_emergency"]);
-		$user_email = check_str($_POST["user_email"]);
-		$user_url = check_str($_POST["user_url"]);
-		$user_notes = check_str($_POST["user_notes"]);
-		$user_optional_1 = check_str($_POST["user_optional_1"]);
-		$user_add_user = check_str($_POST["user_add_user"]);
-		$user_add_date = check_str($_POST["user_add_date"]);
-	}
-
-if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
-
-	$msg = '';
-	if ($action == "update") {
-		$id = check_str($_POST["id"]);
-	}
-
-	//check for all required data
-		//if (strlen($username) == 0) { $msg .= "Please provide: Username<br>\n"; }
-		//if (strlen($password) == 0) { $msg .= "Please provide: Password<br>\n"; }
-		//if (strlen($user_type) == 0) { $msg .= "Please provide: Type<br>\n"; }
-		//if (strlen($user_category) == 0) { $msg .= "Please provide: Category<br>\n"; }
-		//if (strlen($user_first_name) == 0) { $msg .= "Please provide: First Name<br>\n"; }
-		//if (strlen($user_last_name) == 0) { $msg .= "Please provide: Last Name<br>\n"; }
-		//if (strlen($user_company_name) == 0) { $msg .= "Please provide: Organization<br>\n"; }
-		//if (strlen($user_physical_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
-		//if (strlen($user_physical_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
-		//if (strlen($user_physical_city) == 0) { $msg .= "Please provide: City<br>\n"; }
-		//if (strlen($user_physical_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
-		//if (strlen($user_physical_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
-		//if (strlen($user_physical_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
-		//if (strlen($user_mailing_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
-		//if (strlen($user_mailing_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
-		//if (strlen($user_mailing_city) == 0) { $msg .= "Please provide: City<br>\n"; }
-		//if (strlen($user_mailing_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
-		//if (strlen($user_mailing_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
-		//if (strlen($user_mailing_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
-		//if (strlen($user_billing_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
-		//if (strlen($user_billing_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
-		//if (strlen($user_billing_city) == 0) { $msg .= "Please provide: City<br>\n"; }
-		//if (strlen($user_billing_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
-		//if (strlen($user_billing_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
-		//if (strlen($user_billing_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
-		//if (strlen($user_shipping_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
-		//if (strlen($user_shipping_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
-		//if (strlen($user_shipping_city) == 0) { $msg .= "Please provide: City<br>\n"; }
-		//if (strlen($user_shipping_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
-		//if (strlen($user_shipping_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
-		//if (strlen($user_shipping_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
-		//if (strlen($user_phone_1) == 0) { $msg .= "Please provide: Phone 1<br>\n"; }
-		//if (strlen($user_phone_1_ext) == 0) { $msg .= "Please provide: Ext 1<br>\n"; }
-		//if (strlen($user_phone_2) == 0) { $msg .= "Please provide: Phone 2<br>\n"; }
-		//if (strlen($user_phone_2_ext) == 0) { $msg .= "Please provide: Ext 2<br>\n"; }
-		//if (strlen($user_phone_mobile) == 0) { $msg .= "Please provide: Mobile<br>\n"; }
-		//if (strlen($user_phone_fax) == 0) { $msg .= "Please provide: FAX<br>\n"; }
-		//if (strlen($user_phone_emergency_mobile) == 0) { $msg .= "Please provide: Emergency Mobile<br>\n"; }
-		//if (strlen($user_email_emergency) == 0) { $msg .= "Please provide: Emergency Email<br>\n"; }
-		//if (strlen($user_email) == 0) { $msg .= "Please provide: Email<br>\n"; }
-		//if (strlen($user_url) == 0) { $msg .= "Please provide: URL<br>\n"; }
-		//if (strlen($user_notes) == 0) { $msg .= "Please provide: Notes<br>\n"; }
-		//if (strlen($user_optional_1) == 0) { $msg .= "Please provide: Optional 1<br>\n"; }
-		//if (strlen($user_add_user) == 0) { $msg .= "Please provide: Add User<br>\n"; }
-		//if (strlen($user_add_date) == 0) { $msg .= "Please provide: Add Date<br>\n"; }
-		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
-			require_once "includes/header.php";
-			require_once "includes/persistformvar.php";
-			echo "<div align='center'>\n";
-			echo "<table><tr><td>\n";
-			echo $msg."<br />";
-			echo "</td></tr></table>\n";
-			persistformvar($_POST);
-			echo "</div>\n";
-			require_once "includes/footer.php";
-			return;
-		}
-
-		//add or update the database
-			if ($_POST["persistformvar"] != "true") {
-				if ($action == "add" && permission_exists('contacts_add')) {
-					$sql = "insert into v_users ";
-					$sql .= "(";
-					$sql .= "domain_uuid, ";
-					$sql .= "user_uuid, ";
-					//$sql .= "username, ";
-					//$sql .= "password, ";
-					$sql .= "user_type, ";
-					$sql .= "user_category, ";
-					$sql .= "user_first_name, ";
-					$sql .= "user_last_name, ";
-					$sql .= "user_company_name, ";
-					$sql .= "user_physical_address_1, ";
-					$sql .= "user_physical_address_2, ";
-					$sql .= "user_physical_city, ";
-					$sql .= "user_physical_state_province, ";
-					$sql .= "user_physical_postal_code, ";
-					$sql .= "user_physical_country, ";
-					$sql .= "user_mailing_address_1, ";
-					$sql .= "user_mailing_address_2, ";
-					$sql .= "user_mailing_city, ";
-					$sql .= "user_mailing_state_province, ";
-					$sql .= "user_mailing_postal_code, ";
-					$sql .= "user_mailing_country, ";
-					$sql .= "user_billing_address_1, ";
-					$sql .= "user_billing_address_2, ";
-					$sql .= "user_billing_city, ";
-					$sql .= "user_billing_state_province, ";
-					$sql .= "user_billing_postal_code, ";
-					$sql .= "user_billing_country, ";
-					$sql .= "user_shipping_address_1, ";
-					$sql .= "user_shipping_address_2, ";
-					$sql .= "user_shipping_city, ";
-					$sql .= "user_shipping_state_province, ";
-					$sql .= "user_shipping_postal_code, ";
-					$sql .= "user_shipping_country, ";
-					$sql .= "user_phone_1, ";
-					$sql .= "user_phone_1_ext, ";
-					$sql .= "user_phone_2, ";
-					$sql .= "user_phone_2_ext, ";
-					$sql .= "user_phone_mobile, ";
-					$sql .= "user_phone_fax, ";
-					$sql .= "user_phone_emergency_mobile, ";
-					$sql .= "user_email_emergency, ";
-					$sql .= "user_email, ";
-					$sql .= "user_url, ";
-					$sql .= "user_notes, ";
-					$sql .= "user_optional_1, ";
-					$sql .= "user_add_user, ";
-					$sql .= "user_add_date ";
-					$sql .= ")";
-					$sql .= "values ";
-					$sql .= "(";
-					$sql .= "'$domain_uuid', ";
-					$sql .= "'".uuid()."', ";
-					//$sql .= "'$username', ";
-					//$sql .= "'$password', ";
-					$sql .= "'$user_type', ";
-					$sql .= "'$user_category', ";
-					$sql .= "'$user_first_name', ";
-					$sql .= "'$user_last_name', ";
-					$sql .= "'$user_company_name', ";
-					$sql .= "'$user_physical_address_1', ";
-					$sql .= "'$user_physical_address_2', ";
-					$sql .= "'$user_physical_city', ";
-					$sql .= "'$user_physical_state_province', ";
-					$sql .= "'$user_physical_postal_code', ";
-					$sql .= "'$user_physical_country', ";
-					$sql .= "'$user_mailing_address_1', ";
-					$sql .= "'$user_mailing_address_2', ";
-					$sql .= "'$user_mailing_city', ";
-					$sql .= "'$user_mailing_state_province', ";
-					$sql .= "'$user_mailing_postal_code', ";
-					$sql .= "'$user_mailing_country', ";
-					$sql .= "'$user_billing_address_1', ";
-					$sql .= "'$user_billing_address_2', ";
-					$sql .= "'$user_billing_city', ";
-					$sql .= "'$user_billing_state_province', ";
-					$sql .= "'$user_billing_postal_code', ";
-					$sql .= "'$user_billing_country', ";
-					$sql .= "'$user_shipping_address_1', ";
-					$sql .= "'$user_shipping_address_2', ";
-					$sql .= "'$user_shipping_city', ";
-					$sql .= "'$user_shipping_state_province', ";
-					$sql .= "'$user_shipping_postal_code', ";
-					$sql .= "'$user_shipping_country', ";
-					$sql .= "'$user_phone_1', ";
-					$sql .= "'$user_phone_1_ext', ";
-					$sql .= "'$user_phone_2', ";
-					$sql .= "'$user_phone_2_ext', ";
-					$sql .= "'$user_phone_mobile', ";
-					$sql .= "'$user_phone_fax', ";
-					$sql .= "'$user_phone_emergency_mobile', ";
-					$sql .= "'$user_email_emergency', ";
-					$sql .= "'$user_email', ";
-					$sql .= "'$user_url', ";
-					$sql .= "'$user_notes', ";
-					$sql .= "'$user_optional_1', ";
-					$sql .= "'$user_add_user', ";
-					$sql .= "'$user_add_date' ";
-					$sql .= ")";
-					$db->exec(check_sql($sql));
-					unset($sql);
-
-					require_once "includes/header.php";
-					echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
-					echo "<div align='center'>\n";
-					echo "Add Complete\n";
-					echo "</div>\n";
-					require_once "includes/footer.php";
-					return;
-				} //if ($action == "add")
-
-				if ($action == "update" || permission_exists('contacts_edit')) {
-					$sql = "update v_users set ";
-					//$sql .= "username = '$username', ";
-					//if (strlen($password) > 0) {
-					//	$sql .= "password = '$password', ";
-					//}
-					$sql .= "user_type = '$user_type', ";
-					$sql .= "user_category = '$user_category', ";
-					$sql .= "user_first_name = '$user_first_name', ";
-					$sql .= "user_last_name = '$user_last_name', ";
-					$sql .= "user_company_name = '$user_company_name', ";
-					$sql .= "user_physical_address_1 = '$user_physical_address_1', ";
-					$sql .= "user_physical_address_2 = '$user_physical_address_2', ";
-					$sql .= "user_physical_city = '$user_physical_city', ";
-					$sql .= "user_physical_state_province = '$user_physical_state_province', ";
-					$sql .= "user_physical_postal_code = '$user_physical_postal_code', ";
-					$sql .= "user_physical_country = '$user_physical_country', ";
-					$sql .= "user_mailing_address_1 = '$user_mailing_address_1', ";
-					$sql .= "user_mailing_address_2 = '$user_mailing_address_2', ";
-					$sql .= "user_mailing_city = '$user_mailing_city', ";
-					$sql .= "user_mailing_state_province = '$user_mailing_state_province', ";
-					$sql .= "user_mailing_postal_code = '$user_mailing_postal_code', ";
-					$sql .= "user_mailing_country = '$user_mailing_country', ";
-					$sql .= "user_billing_address_1 = '$user_billing_address_1', ";
-					$sql .= "user_billing_address_2 = '$user_billing_address_2', ";
-					$sql .= "user_billing_city = '$user_billing_city', ";
-					$sql .= "user_billing_state_province = '$user_billing_state_province', ";
-					$sql .= "user_billing_postal_code = '$user_billing_postal_code', ";
-					$sql .= "user_billing_country = '$user_billing_country', ";
-					$sql .= "user_shipping_address_1 = '$user_shipping_address_1', ";
-					$sql .= "user_shipping_address_2 = '$user_shipping_address_2', ";
-					$sql .= "user_shipping_city = '$user_shipping_city', ";
-					$sql .= "user_shipping_state_province = '$user_shipping_state_province', ";
-					$sql .= "user_shipping_postal_code = '$user_shipping_postal_code', ";
-					$sql .= "user_shipping_country = '$user_shipping_country', ";
-					$sql .= "user_phone_1 = '$user_phone_1', ";
-					$sql .= "user_phone_1_ext = '$user_phone_1_ext', ";
-					$sql .= "user_phone_2 = '$user_phone_2', ";
-					$sql .= "user_phone_2_ext = '$user_phone_2_ext', ";
-					$sql .= "user_phone_mobile = '$user_phone_mobile', ";
-					$sql .= "user_phone_fax = '$user_phone_fax', ";
-					$sql .= "user_phone_emergency_mobile = '$user_phone_emergency_mobile', ";
-					$sql .= "user_email_emergency = '$user_email_emergency', ";
-					$sql .= "user_email = '$user_email', ";
-					$sql .= "user_url = '$user_url', ";
-					$sql .= "user_notes = '$user_notes', ";
-					$sql .= "user_optional_1 = '$user_optional_1' ";
-					//$sql .= "user_add_user = '$user_add_user', ";
-					//$sql .= "user_add_date = '$user_add_date' ";
-					$sql .= "where domain_uuid = '$domain_uuid' ";
-					$sql .= "and user_uuid = '$id' ";
-					$db->exec(check_sql($sql));
-					unset($sql);
-
-					require_once "includes/header.php";
-					echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
-					echo "<div align='center'>\n";
-					echo "Update Complete\n";
-					echo "</div>\n";
-					require_once "includes/footer.php";
-					return;
-				} //if ($action == "update")
-		} //if ($_POST["persistformvar"] != "true")
-	} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
-
-	//pre-populate the form
-		if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
-			$id = $_GET["id"];
-			$sql = "";
-			$sql .= "select * from v_users ";
-			$sql .= "where domain_uuid = '$domain_uuid' ";
-			$sql .= "and id = '$id' ";
-			$prep_statement = $db->prepare(check_sql($sql));
-			$prep_statement->execute();
-			$result = $prep_statement->fetchAll();
-			foreach ($result as &$row) {
-				//$username = $row["username"];
-				//$password = $row["password"];
-				$user_type = $row["user_type"];
-				$user_category = $row["user_category"];
-				$user_first_name = $row["user_first_name"];
-				$user_last_name = $row["user_last_name"];
-				$user_company_name = $row["user_company_name"];
-				$user_physical_address_1 = $row["user_physical_address_1"];
-				$user_physical_address_2 = $row["user_physical_address_2"];
-				$user_physical_city = $row["user_physical_city"];
-				$user_physical_state_province = $row["user_physical_state_province"];
-				$user_physical_postal_code = $row["user_physical_postal_code"];
-				$user_physical_country = $row["user_physical_country"];
-				$user_mailing_address_1 = $row["user_mailing_address_1"];
-				$user_mailing_address_2 = $row["user_mailing_address_2"];
-				$user_mailing_city = $row["user_mailing_city"];
-				$user_mailing_state_province = $row["user_mailing_state_province"];
-				$user_mailing_postal_code = $row["user_mailing_postal_code"];
-				$user_mailing_country = $row["user_mailing_country"];
-				$user_billing_address_1 = $row["user_billing_address_1"];
-				$user_billing_address_2 = $row["user_billing_address_2"];
-				$user_billing_city = $row["user_billing_city"];
-				$user_billing_state_province = $row["user_billing_state_province"];
-				$user_billing_postal_code = $row["user_billing_postal_code"];
-				$user_billing_country = $row["user_billing_country"];
-				$user_shipping_address_1 = $row["user_shipping_address_1"];
-				$user_shipping_address_2 = $row["user_shipping_address_2"];
-				$user_shipping_city = $row["user_shipping_city"];
-				$user_shipping_state_province = $row["user_shipping_state_province"];
-				$user_shipping_postal_code = $row["user_shipping_postal_code"];
-				$user_shipping_country = $row["user_shipping_country"];
-				$user_phone_1 = $row["user_phone_1"];
-				$user_phone_1_ext = $row["user_phone_1_ext"];
-				$user_phone_2 = $row["user_phone_2"];
-				$user_phone_2_ext = $row["user_phone_2_ext"];
-				$user_phone_mobile = $row["user_phone_mobile"];
-				$user_phone_fax = $row["user_phone_fax"];
-				$user_phone_emergency_mobile = $row["user_phone_emergency_mobile"];
-				$user_email_emergency = $row["user_email_emergency"];
-				$user_email = $row["user_email"];
-				$user_url = $row["user_url"];
-				$user_notes = $row["user_notes"];
-				$user_optional_1 = $row["user_optional_1"];
-				//$user_add_user = $row["user_add_user"];
-				//$user_add_date = $row["user_add_date"];
-				break; //limit to 1 row
-			}
-			unset ($prep_statement);
-		}
-
-	//show the header
-		require_once "includes/header.php";
-
-	//show the content
-			echo "<div align='center'>";
-			echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
-			echo "<tr class=''>\n";
-			echo "	<td align=\"left\">\n";
-			echo "	  <br>";
-
-			$tablewidth = "width='100%'";
-
-			echo "<form method='post' name='frm' action=''>\n";
-			echo "<table width='100%'  border='0' cellpadding='0' cellspacing='0'>\n";
-			echo "<tr>\n";
-			if ($action == "add") {
-				echo "<td width='30%' nowrap><b>Contact Add</b></td>\n";
-			}
-			if ($action == "update") {
-				echo "<td width='30%' nowrap><b>Contact Edit</b></td>\n";
-			}
-			echo "<td width='70%' align='right'>\n";
-			echo "	<input type='button' class='btn' name='' alt='back' onclick=\"window.location='users_vcard.php?id=$id'\" value='vcard'>\n";
-			echo "	<input type='button' class='btn' name='' alt='back' onclick=\"window.location='users.php'\" value='Back'>\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "<tr><td colspan='2'>\n";
-			if ($action == "add") {
-				echo "Add the contact information to the fields below.</td>\n";
-			}
-			if ($action == "update") {
-				echo "Edit the contact information using the fields below.\n";
-			}
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-
-			echo "<br />\n";
-
-		echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
-		echo "<tr>\n";
-		echo "<td valign='top'>\n";
-
-			echo "<b>User Info</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-
-			//echo "<tr>\n";
-			//echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Username:\n";
-			//echo "</td>\n";
-			//echo "<td width='70%' class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='text' name='username' autocomplete='off' maxlength='255' value=\"$username\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			//echo "<tr>\n";
-			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Password:\n";
-			//echo "</td>\n";
-			//echo "<td class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='password' name='password' autocomplete='off' maxlength='255' value=\"$password\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td  width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Type:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<select style='width: 80%;' class='formfld' name='user_type'>\n";
-			echo "	<option value=''></option>\n";
-			if ($user_type == "Individual") {
-				echo "	<option value='Individual' selected>Individual</option>\n";
-			}
-			else {
-				echo "	<option value='Individual'>Individual</option>\n";
-			}
-			if ($user_type == "Organization") {
-				echo "	<option value='Organization' selected>Organization</option>\n";
-			}
-			else {
-				echo "	<option value='Organization'>Organization</option>\n";
-			}
-			echo "	</select>\n";
-
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Category:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_category' maxlength='255' value=\"$user_category\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	First Name:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' style='' type='text' name='user_first_name' maxlength='255' value=\"$user_first_name\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Last Name:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_last_name' maxlength='255' value=\"$user_last_name\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Organization:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_company_name' maxlength='255' value=\"$user_company_name\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-
-
-			echo "<b>Contact Information</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Phone 1:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_1' maxlength='255' value=\"$user_phone_1\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Ext 1:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_1_ext' maxlength='255' value=\"$user_phone_1_ext\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Phone 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_2' maxlength='255' value=\"$user_phone_2\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Ext 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_2_ext' maxlength='255' value=\"$user_phone_2_ext\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Mobile:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_mobile' maxlength='255' value=\"$user_phone_mobile\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	FAX:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_fax' maxlength='255' value=\"$user_phone_fax\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Emergency Mobile:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_emergency_mobile' maxlength='255' value=\"$user_phone_emergency_mobile\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Emergency Email:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_email_emergency' maxlength='255' value=\"$user_email_emergency\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-
-			echo "<b>Additional Information</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Email:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_email' maxlength='255' value=\"$user_email\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	URL:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_url' maxlength='255' value=\"$user_url\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Notes:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<textarea style='width: 80%;' class='formfld' type='text' name='user_notes' rows='5'>$user_notes</textarea> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			//echo "<tr>\n";
-			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Optional 1:\n";
-			//echo "</td>\n";
-			//echo "<td class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_optional_1' maxlength='255' value=\"$user_optional_1\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			//echo "<tr>\n";
-			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Optional 1:\n";
-			//echo "</td>\n";
-			//echo "<td class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_optional_2' maxlength='255' value=\"$user_optional_2\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			echo "</table>\n";
-			echo "</div>\n";
-
-		echo "</td>\n";
-		echo "<td valign='top'>\n";
-
-			echo "<b>Physical Address</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 1:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_address_1' maxlength='255' value=\"$user_physical_address_1\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_address_2' maxlength='255' value=\"$user_physical_address_2\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	City:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_city' maxlength='255' value=\"$user_physical_city\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	State/Province:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_state_province' maxlength='255' value=\"$user_physical_state_province\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Postal Code:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_postal_code' maxlength='255' value=\"$user_physical_postal_code\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Country:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_country' maxlength='255' value=\"$user_physical_country\"> <span class='smalltext'>vcard</span>\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-
-			echo "<b>Postal Address</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 1:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_address_1' maxlength='255' value=\"$user_mailing_address_1\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_address_2' maxlength='255' value=\"$user_mailing_address_2\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	City:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_city' maxlength='255' value=\"$user_mailing_city\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	State/Province:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_state_province' maxlength='255' value=\"$user_mailing_state_province\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Postal Code:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_postal_code' maxlength='255' value=\"$user_mailing_postal_code\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Country:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_country' maxlength='255' value=\"$user_mailing_country\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-
-			echo "<b>Billing Address</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 1:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_address_1' maxlength='255' value=\"$user_billing_address_1\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_address_2' maxlength='255' value=\"$user_billing_address_2\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	City:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_city' maxlength='255' value=\"$user_billing_city\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	State/Province:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_state_province' maxlength='255' value=\"$user_billing_state_province\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Postal Code:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_postal_code' maxlength='255' value=\"$user_billing_postal_code\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Country:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_country' maxlength='255' value=\"$user_billing_country\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-
-			echo "<b>Shipping Address</b><br>";
-			echo "<div align='center' class='' style='padding:10px;'>\n";
-			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
-			echo "<tr>\n";
-			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 1:\n";
-			echo "</td>\n";
-			echo "<td width='70%' class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_address_1' maxlength='255' value=\"$user_shipping_address_1\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Address 2:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_address_2' maxlength='255' value=\"$user_shipping_address_2\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	City:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_city' maxlength='255' value=\"$user_shipping_city\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	State/Province:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_state_province' maxlength='255' value=\"$user_shipping_state_province\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Postal Code:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_postal_code' maxlength='255' value=\"$user_shipping_postal_code\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-
-			echo "<tr>\n";
-			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			echo "	Country:\n";
-			echo "</td>\n";
-			echo "<td class='vtable' align='left'>\n";
-			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_country' maxlength='255' value=\"$user_shipping_country\">\n";
-			echo "<br />\n";
-			echo "\n";
-			echo "</td>\n";
-			echo "</tr>\n";
-			echo "</table>\n";
-			echo "</div>\n";
-		echo "</td>\n";
-		echo "</tr>\n";
-		echo "</table>\n";
-
-			//echo "<tr>\n";
-			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Add User:\n";
-			//echo "</td>\n";
-			//echo "<td class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_add_user' maxlength='255' value=\"$user_add_user\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			//echo "<tr>\n";
-			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
-			//echo "	Add Date:\n";
-			//echo "</td>\n";
-			//echo "<td class='vtable' align='left'>\n";
-			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_add_date' maxlength='255' value=\"$user_add_date\">\n";
-			//echo "<br />\n";
-			//echo "\n";
-			//echo "</td>\n";
-			//echo "</tr>\n";
-
-			echo "	<tr>\n";
-			echo "		<td colspan='2' align='right'>\n";
-			if ($action == "update") {
-				echo "				<input type='hidden' name='id' value='$user_uuid'>\n";
-			}
-			echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
-			echo "		</td>\n";
-			echo "	</tr>";
-			echo "</table>";
-			echo "</form>";
-
-			echo "	</td>";
-			echo "	</tr>";
-			echo "</table>";
-			echo "</div>";
-
-			echo "<br />\n";
-			echo "<br />\n";
-
-//show the footer
-	require_once "includes/footer.php";
-?>
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('contacts_add') || permission_exists('contacts_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//set the action to an add or update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$user_uuid = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+//get the http post values and set them as php variables
+	if (count($_POST)>0) {
+		$username = check_str($_POST["username"]);
+		$password = check_str($_POST["password"]);
+		$user_type = check_str($_POST["user_type"]);
+		$user_category = check_str($_POST["user_category"]);
+		$user_first_name = check_str($_POST["user_first_name"]);
+		$user_last_name = check_str($_POST["user_last_name"]);
+		$user_company_name = check_str($_POST["user_company_name"]);
+		$user_physical_address_1 = check_str($_POST["user_physical_address_1"]);
+		$user_physical_address_2 = check_str($_POST["user_physical_address_2"]);
+		$user_physical_city = check_str($_POST["user_physical_city"]);
+		$user_physical_state_province = check_str($_POST["user_physical_state_province"]);
+		$user_physical_postal_code = check_str($_POST["user_physical_postal_code"]);
+		$user_physical_country = check_str($_POST["user_physical_country"]);
+		$user_mailing_address_1 = check_str($_POST["user_mailing_address_1"]);
+		$user_mailing_address_2 = check_str($_POST["user_mailing_address_2"]);
+		$user_mailing_city = check_str($_POST["user_mailing_city"]);
+		$user_mailing_state_province = check_str($_POST["user_mailing_state_province"]);
+		$user_mailing_postal_code = check_str($_POST["user_mailing_postal_code"]);
+		$user_mailing_country = check_str($_POST["user_mailing_country"]);
+		$user_billing_address_1 = check_str($_POST["user_billing_address_1"]);
+		$user_billing_address_2 = check_str($_POST["user_billing_address_2"]);
+		$user_billing_city = check_str($_POST["user_billing_city"]);
+		$user_billing_state_province = check_str($_POST["user_billing_state_province"]);
+		$user_billing_postal_code = check_str($_POST["user_billing_postal_code"]);
+		$user_billing_country = check_str($_POST["user_billing_country"]);
+		$user_shipping_address_1 = check_str($_POST["user_shipping_address_1"]);
+		$user_shipping_address_2 = check_str($_POST["user_shipping_address_2"]);
+		$user_shipping_city = check_str($_POST["user_shipping_city"]);
+		$user_shipping_state_province = check_str($_POST["user_shipping_state_province"]);
+		$user_shipping_postal_code = check_str($_POST["user_shipping_postal_code"]);
+		$user_shipping_country = check_str($_POST["user_shipping_country"]);
+		$user_phone_1 = check_str($_POST["user_phone_1"]);
+		$user_phone_1_ext = check_str($_POST["user_phone_1_ext"]);
+		$user_phone_2 = check_str($_POST["user_phone_2"]);
+		$user_phone_2_ext = check_str($_POST["user_phone_2_ext"]);
+		$user_phone_mobile = check_str($_POST["user_phone_mobile"]);
+		$user_phone_fax = check_str($_POST["user_phone_fax"]);
+		$user_phone_emergency_mobile = check_str($_POST["user_phone_emergency_mobile"]);
+		$user_email_emergency = check_str($_POST["user_email_emergency"]);
+		$user_email = check_str($_POST["user_email"]);
+		$user_url = check_str($_POST["user_url"]);
+		$user_notes = check_str($_POST["user_notes"]);
+		$user_optional_1 = check_str($_POST["user_optional_1"]);
+		$user_add_user = check_str($_POST["user_add_user"]);
+		$user_add_date = check_str($_POST["user_add_date"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$id = check_str($_POST["id"]);
+	}
+
+	//check for all required data
+		//if (strlen($username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		//if (strlen($password) == 0) { $msg .= "Please provide: Password<br>\n"; }
+		//if (strlen($user_type) == 0) { $msg .= "Please provide: Type<br>\n"; }
+		//if (strlen($user_category) == 0) { $msg .= "Please provide: Category<br>\n"; }
+		//if (strlen($user_first_name) == 0) { $msg .= "Please provide: First Name<br>\n"; }
+		//if (strlen($user_last_name) == 0) { $msg .= "Please provide: Last Name<br>\n"; }
+		//if (strlen($user_company_name) == 0) { $msg .= "Please provide: Organization<br>\n"; }
+		//if (strlen($user_physical_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
+		//if (strlen($user_physical_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
+		//if (strlen($user_physical_city) == 0) { $msg .= "Please provide: City<br>\n"; }
+		//if (strlen($user_physical_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
+		//if (strlen($user_physical_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
+		//if (strlen($user_physical_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
+		//if (strlen($user_mailing_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
+		//if (strlen($user_mailing_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
+		//if (strlen($user_mailing_city) == 0) { $msg .= "Please provide: City<br>\n"; }
+		//if (strlen($user_mailing_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
+		//if (strlen($user_mailing_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
+		//if (strlen($user_mailing_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
+		//if (strlen($user_billing_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
+		//if (strlen($user_billing_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
+		//if (strlen($user_billing_city) == 0) { $msg .= "Please provide: City<br>\n"; }
+		//if (strlen($user_billing_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
+		//if (strlen($user_billing_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
+		//if (strlen($user_billing_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
+		//if (strlen($user_shipping_address_1) == 0) { $msg .= "Please provide: Address 1<br>\n"; }
+		//if (strlen($user_shipping_address_2) == 0) { $msg .= "Please provide: Address 2<br>\n"; }
+		//if (strlen($user_shipping_city) == 0) { $msg .= "Please provide: City<br>\n"; }
+		//if (strlen($user_shipping_state_province) == 0) { $msg .= "Please provide: State/Province<br>\n"; }
+		//if (strlen($user_shipping_postal_code) == 0) { $msg .= "Please provide: Postal Code<br>\n"; }
+		//if (strlen($user_shipping_country) == 0) { $msg .= "Please provide: Country<br>\n"; }
+		//if (strlen($user_phone_1) == 0) { $msg .= "Please provide: Phone 1<br>\n"; }
+		//if (strlen($user_phone_1_ext) == 0) { $msg .= "Please provide: Ext 1<br>\n"; }
+		//if (strlen($user_phone_2) == 0) { $msg .= "Please provide: Phone 2<br>\n"; }
+		//if (strlen($user_phone_2_ext) == 0) { $msg .= "Please provide: Ext 2<br>\n"; }
+		//if (strlen($user_phone_mobile) == 0) { $msg .= "Please provide: Mobile<br>\n"; }
+		//if (strlen($user_phone_fax) == 0) { $msg .= "Please provide: FAX<br>\n"; }
+		//if (strlen($user_phone_emergency_mobile) == 0) { $msg .= "Please provide: Emergency Mobile<br>\n"; }
+		//if (strlen($user_email_emergency) == 0) { $msg .= "Please provide: Emergency Email<br>\n"; }
+		//if (strlen($user_email) == 0) { $msg .= "Please provide: Email<br>\n"; }
+		//if (strlen($user_url) == 0) { $msg .= "Please provide: URL<br>\n"; }
+		//if (strlen($user_notes) == 0) { $msg .= "Please provide: Notes<br>\n"; }
+		//if (strlen($user_optional_1) == 0) { $msg .= "Please provide: Optional 1<br>\n"; }
+		//if (strlen($user_add_user) == 0) { $msg .= "Please provide: Add User<br>\n"; }
+		//if (strlen($user_add_date) == 0) { $msg .= "Please provide: Add Date<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		}
+
+		//add or update the database
+			if ($_POST["persistformvar"] != "true") {
+				if ($action == "add" && permission_exists('contacts_add')) {
+					$sql = "insert into v_users ";
+					$sql .= "(";
+					$sql .= "domain_uuid, ";
+					$sql .= "user_uuid, ";
+					//$sql .= "username, ";
+					//$sql .= "password, ";
+					$sql .= "user_type, ";
+					$sql .= "user_category, ";
+					$sql .= "user_first_name, ";
+					$sql .= "user_last_name, ";
+					$sql .= "user_company_name, ";
+					$sql .= "user_physical_address_1, ";
+					$sql .= "user_physical_address_2, ";
+					$sql .= "user_physical_city, ";
+					$sql .= "user_physical_state_province, ";
+					$sql .= "user_physical_postal_code, ";
+					$sql .= "user_physical_country, ";
+					$sql .= "user_mailing_address_1, ";
+					$sql .= "user_mailing_address_2, ";
+					$sql .= "user_mailing_city, ";
+					$sql .= "user_mailing_state_province, ";
+					$sql .= "user_mailing_postal_code, ";
+					$sql .= "user_mailing_country, ";
+					$sql .= "user_billing_address_1, ";
+					$sql .= "user_billing_address_2, ";
+					$sql .= "user_billing_city, ";
+					$sql .= "user_billing_state_province, ";
+					$sql .= "user_billing_postal_code, ";
+					$sql .= "user_billing_country, ";
+					$sql .= "user_shipping_address_1, ";
+					$sql .= "user_shipping_address_2, ";
+					$sql .= "user_shipping_city, ";
+					$sql .= "user_shipping_state_province, ";
+					$sql .= "user_shipping_postal_code, ";
+					$sql .= "user_shipping_country, ";
+					$sql .= "user_phone_1, ";
+					$sql .= "user_phone_1_ext, ";
+					$sql .= "user_phone_2, ";
+					$sql .= "user_phone_2_ext, ";
+					$sql .= "user_phone_mobile, ";
+					$sql .= "user_phone_fax, ";
+					$sql .= "user_phone_emergency_mobile, ";
+					$sql .= "user_email_emergency, ";
+					$sql .= "user_email, ";
+					$sql .= "user_url, ";
+					$sql .= "user_notes, ";
+					$sql .= "user_optional_1, ";
+					$sql .= "user_add_user, ";
+					$sql .= "user_add_date ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'".uuid()."', ";
+					//$sql .= "'$username', ";
+					//$sql .= "'$password', ";
+					$sql .= "'$user_type', ";
+					$sql .= "'$user_category', ";
+					$sql .= "'$user_first_name', ";
+					$sql .= "'$user_last_name', ";
+					$sql .= "'$user_company_name', ";
+					$sql .= "'$user_physical_address_1', ";
+					$sql .= "'$user_physical_address_2', ";
+					$sql .= "'$user_physical_city', ";
+					$sql .= "'$user_physical_state_province', ";
+					$sql .= "'$user_physical_postal_code', ";
+					$sql .= "'$user_physical_country', ";
+					$sql .= "'$user_mailing_address_1', ";
+					$sql .= "'$user_mailing_address_2', ";
+					$sql .= "'$user_mailing_city', ";
+					$sql .= "'$user_mailing_state_province', ";
+					$sql .= "'$user_mailing_postal_code', ";
+					$sql .= "'$user_mailing_country', ";
+					$sql .= "'$user_billing_address_1', ";
+					$sql .= "'$user_billing_address_2', ";
+					$sql .= "'$user_billing_city', ";
+					$sql .= "'$user_billing_state_province', ";
+					$sql .= "'$user_billing_postal_code', ";
+					$sql .= "'$user_billing_country', ";
+					$sql .= "'$user_shipping_address_1', ";
+					$sql .= "'$user_shipping_address_2', ";
+					$sql .= "'$user_shipping_city', ";
+					$sql .= "'$user_shipping_state_province', ";
+					$sql .= "'$user_shipping_postal_code', ";
+					$sql .= "'$user_shipping_country', ";
+					$sql .= "'$user_phone_1', ";
+					$sql .= "'$user_phone_1_ext', ";
+					$sql .= "'$user_phone_2', ";
+					$sql .= "'$user_phone_2_ext', ";
+					$sql .= "'$user_phone_mobile', ";
+					$sql .= "'$user_phone_fax', ";
+					$sql .= "'$user_phone_emergency_mobile', ";
+					$sql .= "'$user_email_emergency', ";
+					$sql .= "'$user_email', ";
+					$sql .= "'$user_url', ";
+					$sql .= "'$user_notes', ";
+					$sql .= "'$user_optional_1', ";
+					$sql .= "'$user_add_user', ";
+					$sql .= "'$user_add_date' ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					unset($sql);
+
+					require_once "includes/header.php";
+					echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
+					echo "<div align='center'>\n";
+					echo "Add Complete\n";
+					echo "</div>\n";
+					require_once "includes/footer.php";
+					return;
+				} //if ($action == "add")
+
+				if ($action == "update" || permission_exists('contacts_edit')) {
+					$sql = "update v_users set ";
+					//$sql .= "username = '$username', ";
+					//if (strlen($password) > 0) {
+					//	$sql .= "password = '$password', ";
+					//}
+					$sql .= "user_type = '$user_type', ";
+					$sql .= "user_category = '$user_category', ";
+					$sql .= "user_first_name = '$user_first_name', ";
+					$sql .= "user_last_name = '$user_last_name', ";
+					$sql .= "user_company_name = '$user_company_name', ";
+					$sql .= "user_physical_address_1 = '$user_physical_address_1', ";
+					$sql .= "user_physical_address_2 = '$user_physical_address_2', ";
+					$sql .= "user_physical_city = '$user_physical_city', ";
+					$sql .= "user_physical_state_province = '$user_physical_state_province', ";
+					$sql .= "user_physical_postal_code = '$user_physical_postal_code', ";
+					$sql .= "user_physical_country = '$user_physical_country', ";
+					$sql .= "user_mailing_address_1 = '$user_mailing_address_1', ";
+					$sql .= "user_mailing_address_2 = '$user_mailing_address_2', ";
+					$sql .= "user_mailing_city = '$user_mailing_city', ";
+					$sql .= "user_mailing_state_province = '$user_mailing_state_province', ";
+					$sql .= "user_mailing_postal_code = '$user_mailing_postal_code', ";
+					$sql .= "user_mailing_country = '$user_mailing_country', ";
+					$sql .= "user_billing_address_1 = '$user_billing_address_1', ";
+					$sql .= "user_billing_address_2 = '$user_billing_address_2', ";
+					$sql .= "user_billing_city = '$user_billing_city', ";
+					$sql .= "user_billing_state_province = '$user_billing_state_province', ";
+					$sql .= "user_billing_postal_code = '$user_billing_postal_code', ";
+					$sql .= "user_billing_country = '$user_billing_country', ";
+					$sql .= "user_shipping_address_1 = '$user_shipping_address_1', ";
+					$sql .= "user_shipping_address_2 = '$user_shipping_address_2', ";
+					$sql .= "user_shipping_city = '$user_shipping_city', ";
+					$sql .= "user_shipping_state_province = '$user_shipping_state_province', ";
+					$sql .= "user_shipping_postal_code = '$user_shipping_postal_code', ";
+					$sql .= "user_shipping_country = '$user_shipping_country', ";
+					$sql .= "user_phone_1 = '$user_phone_1', ";
+					$sql .= "user_phone_1_ext = '$user_phone_1_ext', ";
+					$sql .= "user_phone_2 = '$user_phone_2', ";
+					$sql .= "user_phone_2_ext = '$user_phone_2_ext', ";
+					$sql .= "user_phone_mobile = '$user_phone_mobile', ";
+					$sql .= "user_phone_fax = '$user_phone_fax', ";
+					$sql .= "user_phone_emergency_mobile = '$user_phone_emergency_mobile', ";
+					$sql .= "user_email_emergency = '$user_email_emergency', ";
+					$sql .= "user_email = '$user_email', ";
+					$sql .= "user_url = '$user_url', ";
+					$sql .= "user_notes = '$user_notes', ";
+					$sql .= "user_optional_1 = '$user_optional_1' ";
+					//$sql .= "user_add_user = '$user_add_user', ";
+					//$sql .= "user_add_date = '$user_add_date' ";
+					$sql .= "where domain_uuid = '$domain_uuid' ";
+					$sql .= "and user_uuid = '$id' ";
+					$db->exec(check_sql($sql));
+					unset($sql);
+
+					require_once "includes/header.php";
+					echo "<meta http-equiv=\"refresh\" content=\"2;url=users.php\">\n";
+					echo "<div align='center'>\n";
+					echo "Update Complete\n";
+					echo "</div>\n";
+					require_once "includes/footer.php";
+					return;
+				} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+	} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+	//pre-populate the form
+		if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+			$id = $_GET["id"];
+			$sql = "";
+			$sql .= "select * from v_users ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and id = '$id' ";
+			$prep_statement = $db->prepare(check_sql($sql));
+			$prep_statement->execute();
+			$result = $prep_statement->fetchAll();
+			foreach ($result as &$row) {
+				//$username = $row["username"];
+				//$password = $row["password"];
+				$user_type = $row["user_type"];
+				$user_category = $row["user_category"];
+				$user_first_name = $row["user_first_name"];
+				$user_last_name = $row["user_last_name"];
+				$user_company_name = $row["user_company_name"];
+				$user_physical_address_1 = $row["user_physical_address_1"];
+				$user_physical_address_2 = $row["user_physical_address_2"];
+				$user_physical_city = $row["user_physical_city"];
+				$user_physical_state_province = $row["user_physical_state_province"];
+				$user_physical_postal_code = $row["user_physical_postal_code"];
+				$user_physical_country = $row["user_physical_country"];
+				$user_mailing_address_1 = $row["user_mailing_address_1"];
+				$user_mailing_address_2 = $row["user_mailing_address_2"];
+				$user_mailing_city = $row["user_mailing_city"];
+				$user_mailing_state_province = $row["user_mailing_state_province"];
+				$user_mailing_postal_code = $row["user_mailing_postal_code"];
+				$user_mailing_country = $row["user_mailing_country"];
+				$user_billing_address_1 = $row["user_billing_address_1"];
+				$user_billing_address_2 = $row["user_billing_address_2"];
+				$user_billing_city = $row["user_billing_city"];
+				$user_billing_state_province = $row["user_billing_state_province"];
+				$user_billing_postal_code = $row["user_billing_postal_code"];
+				$user_billing_country = $row["user_billing_country"];
+				$user_shipping_address_1 = $row["user_shipping_address_1"];
+				$user_shipping_address_2 = $row["user_shipping_address_2"];
+				$user_shipping_city = $row["user_shipping_city"];
+				$user_shipping_state_province = $row["user_shipping_state_province"];
+				$user_shipping_postal_code = $row["user_shipping_postal_code"];
+				$user_shipping_country = $row["user_shipping_country"];
+				$user_phone_1 = $row["user_phone_1"];
+				$user_phone_1_ext = $row["user_phone_1_ext"];
+				$user_phone_2 = $row["user_phone_2"];
+				$user_phone_2_ext = $row["user_phone_2_ext"];
+				$user_phone_mobile = $row["user_phone_mobile"];
+				$user_phone_fax = $row["user_phone_fax"];
+				$user_phone_emergency_mobile = $row["user_phone_emergency_mobile"];
+				$user_email_emergency = $row["user_email_emergency"];
+				$user_email = $row["user_email"];
+				$user_url = $row["user_url"];
+				$user_notes = $row["user_notes"];
+				$user_optional_1 = $row["user_optional_1"];
+				//$user_add_user = $row["user_add_user"];
+				//$user_add_date = $row["user_add_date"];
+				break; //limit to 1 row
+			}
+			unset ($prep_statement);
+		}
+
+	//show the header
+		require_once "includes/header.php";
+
+	//show the content
+			echo "<div align='center'>";
+			echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+			echo "<tr class=''>\n";
+			echo "	<td align=\"left\">\n";
+			echo "	  <br>";
+
+			$tablewidth = "width='100%'";
+
+			echo "<form method='post' name='frm' action=''>\n";
+			echo "<table width='100%'  border='0' cellpadding='0' cellspacing='0'>\n";
+			echo "<tr>\n";
+			if ($action == "add") {
+				echo "<td width='30%' nowrap><b>Contact Add</b></td>\n";
+			}
+			if ($action == "update") {
+				echo "<td width='30%' nowrap><b>Contact Edit</b></td>\n";
+			}
+			echo "<td width='70%' align='right'>\n";
+			echo "	<input type='button' class='btn' name='' alt='back' onclick=\"window.location='users_vcard.php?id=$id'\" value='vcard'>\n";
+			echo "	<input type='button' class='btn' name='' alt='back' onclick=\"window.location='users.php'\" value='Back'>\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "<tr><td colspan='2'>\n";
+			if ($action == "add") {
+				echo "Add the contact information to the fields below.</td>\n";
+			}
+			if ($action == "update") {
+				echo "Edit the contact information using the fields below.\n";
+			}
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+
+			echo "<br />\n";
+
+		echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+		echo "<tr>\n";
+		echo "<td valign='top'>\n";
+
+			echo "<b>User Info</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+
+			//echo "<tr>\n";
+			//echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Username:\n";
+			//echo "</td>\n";
+			//echo "<td width='70%' class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='text' name='username' autocomplete='off' maxlength='255' value=\"$username\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			//echo "<tr>\n";
+			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Password:\n";
+			//echo "</td>\n";
+			//echo "<td class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='password' name='password' autocomplete='off' maxlength='255' value=\"$password\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td  width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Type:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<select style='width: 80%;' class='formfld' name='user_type'>\n";
+			echo "	<option value=''></option>\n";
+			if ($user_type == "Individual") {
+				echo "	<option value='Individual' selected>Individual</option>\n";
+			}
+			else {
+				echo "	<option value='Individual'>Individual</option>\n";
+			}
+			if ($user_type == "Organization") {
+				echo "	<option value='Organization' selected>Organization</option>\n";
+			}
+			else {
+				echo "	<option value='Organization'>Organization</option>\n";
+			}
+			echo "	</select>\n";
+
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Category:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_category' maxlength='255' value=\"$user_category\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	First Name:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' style='' type='text' name='user_first_name' maxlength='255' value=\"$user_first_name\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Last Name:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_last_name' maxlength='255' value=\"$user_last_name\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Organization:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_company_name' maxlength='255' value=\"$user_company_name\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+
+
+			echo "<b>Contact Information</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Phone 1:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_1' maxlength='255' value=\"$user_phone_1\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Ext 1:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_1_ext' maxlength='255' value=\"$user_phone_1_ext\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Phone 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_2' maxlength='255' value=\"$user_phone_2\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Ext 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_2_ext' maxlength='255' value=\"$user_phone_2_ext\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Mobile:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_mobile' maxlength='255' value=\"$user_phone_mobile\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	FAX:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_fax' maxlength='255' value=\"$user_phone_fax\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Emergency Mobile:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_phone_emergency_mobile' maxlength='255' value=\"$user_phone_emergency_mobile\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Emergency Email:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_email_emergency' maxlength='255' value=\"$user_email_emergency\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+
+			echo "<b>Additional Information</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Email:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_email' maxlength='255' value=\"$user_email\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	URL:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_url' maxlength='255' value=\"$user_url\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Notes:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<textarea style='width: 80%;' class='formfld' type='text' name='user_notes' rows='5'>$user_notes</textarea> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			//echo "<tr>\n";
+			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Optional 1:\n";
+			//echo "</td>\n";
+			//echo "<td class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_optional_1' maxlength='255' value=\"$user_optional_1\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			//echo "<tr>\n";
+			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Optional 1:\n";
+			//echo "</td>\n";
+			//echo "<td class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_optional_2' maxlength='255' value=\"$user_optional_2\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			echo "</table>\n";
+			echo "</div>\n";
+
+		echo "</td>\n";
+		echo "<td valign='top'>\n";
+
+			echo "<b>Physical Address</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 1:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_address_1' maxlength='255' value=\"$user_physical_address_1\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_address_2' maxlength='255' value=\"$user_physical_address_2\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	City:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_city' maxlength='255' value=\"$user_physical_city\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	State/Province:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_state_province' maxlength='255' value=\"$user_physical_state_province\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Postal Code:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_postal_code' maxlength='255' value=\"$user_physical_postal_code\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Country:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_physical_country' maxlength='255' value=\"$user_physical_country\"> <span class='smalltext'>vcard</span>\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+
+			echo "<b>Postal Address</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 1:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_address_1' maxlength='255' value=\"$user_mailing_address_1\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_address_2' maxlength='255' value=\"$user_mailing_address_2\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	City:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_city' maxlength='255' value=\"$user_mailing_city\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	State/Province:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_state_province' maxlength='255' value=\"$user_mailing_state_province\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Postal Code:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_postal_code' maxlength='255' value=\"$user_mailing_postal_code\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Country:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_mailing_country' maxlength='255' value=\"$user_mailing_country\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+
+			echo "<b>Billing Address</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 1:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_address_1' maxlength='255' value=\"$user_billing_address_1\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_address_2' maxlength='255' value=\"$user_billing_address_2\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	City:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_city' maxlength='255' value=\"$user_billing_city\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	State/Province:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_state_province' maxlength='255' value=\"$user_billing_state_province\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Postal Code:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_postal_code' maxlength='255' value=\"$user_billing_postal_code\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Country:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_billing_country' maxlength='255' value=\"$user_billing_country\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+
+			echo "<b>Shipping Address</b><br>";
+			echo "<div align='center' class='' style='padding:10px;'>\n";
+			echo "<table $tablewidth cellpadding='6' cellspacing='0'>";
+			echo "<tr>\n";
+			echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 1:\n";
+			echo "</td>\n";
+			echo "<td width='70%' class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_address_1' maxlength='255' value=\"$user_shipping_address_1\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Address 2:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_address_2' maxlength='255' value=\"$user_shipping_address_2\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	City:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_city' maxlength='255' value=\"$user_shipping_city\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	State/Province:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_state_province' maxlength='255' value=\"$user_shipping_state_province\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Postal Code:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_postal_code' maxlength='255' value=\"$user_shipping_postal_code\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Country:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input style='width: 80%;' class='formfld' type='text' name='user_shipping_country' maxlength='255' value=\"$user_shipping_country\">\n";
+			echo "<br />\n";
+			echo "\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+			echo "</table>\n";
+			echo "</div>\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+		echo "</table>\n";
+
+			//echo "<tr>\n";
+			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Add User:\n";
+			//echo "</td>\n";
+			//echo "<td class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_add_user' maxlength='255' value=\"$user_add_user\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			//echo "<tr>\n";
+			//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			//echo "	Add Date:\n";
+			//echo "</td>\n";
+			//echo "<td class='vtable' align='left'>\n";
+			//echo "	<input style='width: 80%;' class='formfld' type='text' name='user_add_date' maxlength='255' value=\"$user_add_date\">\n";
+			//echo "<br />\n";
+			//echo "\n";
+			//echo "</td>\n";
+			//echo "</tr>\n";
+
+			echo "	<tr>\n";
+			echo "		<td colspan='2' align='right'>\n";
+			if ($action == "update") {
+				echo "				<input type='hidden' name='id' value='$user_uuid'>\n";
+			}
+			echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+			echo "		</td>\n";
+			echo "	</tr>";
+			echo "</table>";
+			echo "</form>";
+
+			echo "	</td>";
+			echo "	</tr>";
+			echo "</table>";
+			echo "</div>";
+
+			echo "<br />\n";
+			echo "<br />\n";
+
+//show the footer
+	require_once "includes/footer.php";
+?>

+ 134 - 134
user_contacts/users_vcard.php

@@ -1,135 +1,135 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "includes/require.php";
-require_once "includes/checkauth.php";
-if (permission_exists('contacts_view')) {
-	//access granted
-}
-else {
-	echo "access denied";
-	exit;
-}
-
-require_once "includes/class_vcard.php";
-$vc = new vcard();
-
-if (count($_GET)>0) {
-	$id = $_GET["id"];
-	$sql = "";
-	$sql .= "select * from v_users ";
-	$sql .= "where domain_uuid = '$domain_uuid' ";
-	$sql .= "and id = '$id' ";
-	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll();
-	foreach ($result as &$row) {
-
-		$vc->data[display_name] = $row["user_first_name"]." ".$row["user_last_name"];
-		//$vc->data[zzz] = $row["user_type"];
-		//$vc->data[zzz] = $row["user_category"];
-		$vc->data[first_name] = $row["user_first_name"];
-		$vc->data[last_name] = $row["user_last_name"];
-		$vc->data[company] = $row["user_company_name"];
-
-		$vc->data[work_address] = $row["user_physical_address_1"];
-		$vc->data[work_extended_address] = $row["user_physical_address_2"];
-		$vc->data[work_city] = $row["user_physical_city"];
-		$vc->data[work_state] = $row["user_physical_state_province"];
-		$vc->data[work_postal_code] = $row["user_physical_postal_code"];
-		$vc->data[work_country] = $row["user_physical_country"];
-
-		$vc->data[home_address] = $row["user_physical_address_1"];
-		$vc->data[home_extended_address] = $row["user_physical_address_2"];
-		$vc->data[home_city] = $row["user_physical_city"];
-		$vc->data[home_state] = $row["user_physical_state_province"];
-		$vc->data[home_postal_code] = $row["user_physical_postal_code"];
-		$vc->data[home_country] = $row["user_physical_country"];
-
-		//$vc->data[zzz] = $row["user_mailing_address_1"];
-		//$vc->data[zzz] = $row["user_mailing_address_2"];
-		//$vc->data[zzz] = $row["user_mailing_city"];
-		//$vc->data[zzz] = $row["user_mailing_state_province"];
-		//$vc->data[zzz] = $row["user_mailing_postal_code"];
-		//$vc->data[zzz] = $row["user_mailing_country"];
-		//$vc->data[zzz] = $row["user_billing_address_1"];
-		//$vc->data[zzz] = $row["user_billing_address_2"];
-		//$vc->data[zzz] = $row["user_billing_city"];
-		//$vc->data[zzz] = $row["user_billing_state_province"];
-		//$vc->data[zzz] = $row["user_billing_postal_code"];
-		//$vc->data[zzz] = $row["user_billing_country"];
-		//$vc->data[zzz] = $row["user_shipping_address_1"];
-		//$vc->data[zzz] = $row["user_shipping_address_2"];
-		//$vc->data[zzz] = $row["user_shipping_city"];
-		//$vc->data[zzz] = $row["user_shipping_state_province"];
-		//$vc->data[zzz] = $row["user_shipping_postal_code"];
-		//$vc->data[zzz] = $row["user_shipping_country"];
-		$vc->data[office_tel] = $row["user_phone_1"];
-		$vc->data[home_tel] = $row["user_phone_1"];
-		//$vc->data[zzz] = $row["user_phone_1_ext"];
-		//$vc->data[zzz] = $row["user_phone_2"];
-		//$vc->data[zzz] = $row["user_phone_2_ext"];
-		$vc->data[cell_tel] = $row["user_phone_mobile"];
-		$vc->data[fax_tel] = $row["user_phone_fax"];
-		//$vc->data[zzz] = $row["user_phone_emergency_mobile"];
-		//$vc->data[zzz] = $row["user_email_emergency"];
-		$vc->data[email1] = $row["user_email"];
-		$vc->data[url] = $row["user_url"];
-		$vc->data[note] = $row["user_notes"];
-
-		/*
-		//additional un accounted fields
-		additional_name
-		name_prefix
-		name_suffix
-		nickname
-		title
-		role
-		department
-		work_po_box
-		home_po_box
-		home_extended_address
-		home_address
-		home_city
-		home_state
-		home_postal_code
-		home_country
-		pager_tel
-		email2
-		photo
-		birthday
-		timezone
-		sort_string
-		*/
-
-		break; //limit to 1 row
-	}
-	unset ($prep_statement);
-}
-
-$vc->download();
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('contacts_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+require_once "includes/class_vcard.php";
+$vc = new vcard();
+
+if (count($_GET)>0) {
+	$id = $_GET["id"];
+	$sql = "";
+	$sql .= "select * from v_users ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	foreach ($result as &$row) {
+
+		$vc->data[display_name] = $row["user_first_name"]." ".$row["user_last_name"];
+		//$vc->data[zzz] = $row["user_type"];
+		//$vc->data[zzz] = $row["user_category"];
+		$vc->data[first_name] = $row["user_first_name"];
+		$vc->data[last_name] = $row["user_last_name"];
+		$vc->data[company] = $row["user_company_name"];
+
+		$vc->data[work_address] = $row["user_physical_address_1"];
+		$vc->data[work_extended_address] = $row["user_physical_address_2"];
+		$vc->data[work_city] = $row["user_physical_city"];
+		$vc->data[work_state] = $row["user_physical_state_province"];
+		$vc->data[work_postal_code] = $row["user_physical_postal_code"];
+		$vc->data[work_country] = $row["user_physical_country"];
+
+		$vc->data[home_address] = $row["user_physical_address_1"];
+		$vc->data[home_extended_address] = $row["user_physical_address_2"];
+		$vc->data[home_city] = $row["user_physical_city"];
+		$vc->data[home_state] = $row["user_physical_state_province"];
+		$vc->data[home_postal_code] = $row["user_physical_postal_code"];
+		$vc->data[home_country] = $row["user_physical_country"];
+
+		//$vc->data[zzz] = $row["user_mailing_address_1"];
+		//$vc->data[zzz] = $row["user_mailing_address_2"];
+		//$vc->data[zzz] = $row["user_mailing_city"];
+		//$vc->data[zzz] = $row["user_mailing_state_province"];
+		//$vc->data[zzz] = $row["user_mailing_postal_code"];
+		//$vc->data[zzz] = $row["user_mailing_country"];
+		//$vc->data[zzz] = $row["user_billing_address_1"];
+		//$vc->data[zzz] = $row["user_billing_address_2"];
+		//$vc->data[zzz] = $row["user_billing_city"];
+		//$vc->data[zzz] = $row["user_billing_state_province"];
+		//$vc->data[zzz] = $row["user_billing_postal_code"];
+		//$vc->data[zzz] = $row["user_billing_country"];
+		//$vc->data[zzz] = $row["user_shipping_address_1"];
+		//$vc->data[zzz] = $row["user_shipping_address_2"];
+		//$vc->data[zzz] = $row["user_shipping_city"];
+		//$vc->data[zzz] = $row["user_shipping_state_province"];
+		//$vc->data[zzz] = $row["user_shipping_postal_code"];
+		//$vc->data[zzz] = $row["user_shipping_country"];
+		$vc->data[office_tel] = $row["user_phone_1"];
+		$vc->data[home_tel] = $row["user_phone_1"];
+		//$vc->data[zzz] = $row["user_phone_1_ext"];
+		//$vc->data[zzz] = $row["user_phone_2"];
+		//$vc->data[zzz] = $row["user_phone_2_ext"];
+		$vc->data[cell_tel] = $row["user_phone_mobile"];
+		$vc->data[fax_tel] = $row["user_phone_fax"];
+		//$vc->data[zzz] = $row["user_phone_emergency_mobile"];
+		//$vc->data[zzz] = $row["user_email_emergency"];
+		$vc->data[email1] = $row["user_email"];
+		$vc->data[url] = $row["user_url"];
+		$vc->data[note] = $row["user_notes"];
+
+		/*
+		//additional un accounted fields
+		additional_name
+		name_prefix
+		name_suffix
+		nickname
+		title
+		role
+		department
+		work_po_box
+		home_po_box
+		home_extended_address
+		home_address
+		home_city
+		home_state
+		home_postal_code
+		home_country
+		pager_tel
+		email2
+		photo
+		birthday
+		timezone
+		sort_string
+		*/
+
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+}
+
+$vc->download();
+
 ?>

+ 49 - 49
users_bulk_add/root.php

@@ -1,50 +1,50 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	if (!defined("PATH_SEPARATOR")) {
-		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
-	}
-
-// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
-	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
-	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
-	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
-
-// if the project directory exists then add it to the include path otherwise add the document root to the include path
-	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
-		define('PROJECT_PATH', '/fusionpbx');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
-	}
-	else {
-		define('PROJECT_PATH', '');
-		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
-	}
-
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
 ?>