Contacts: Implemented a new QR Code generator, includes additional contact detail fields.

This commit is contained in:
Nate Jones
2014-07-26 06:02:21 +00:00
parent ee6a13acd9
commit 9049eecedb
10 changed files with 152 additions and 1520 deletions
+52 -1
View File
@@ -205,6 +205,57 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$document['title'] = $text['title-contact-add']; $document['title'] = $text['title-contact-add'];
} }
$_GET['type'] = "text";
$qr_vcard = true;
include "contacts_vcard.php";
echo "<input type='hidden' id='qr_vcard' value=\"".$qr_vcard."\">";
echo "<style>";
echo " #qr_code_container {";
echo " z-index: 999999; ";
echo " position: absolute; ";
echo " left: 0px; ";
echo " top: 0px; ";
echo " right: 0px; ";
echo " bottom: 0px; ";
echo " text-align: center; ";
echo " vertical-align: middle;";
echo " }";
echo " #qr_code {";
echo " display: block; ";
echo " width: 650px; ";
echo " height: 650px; ";
echo " -webkit-box-shadow: 0px 1px 20px #888; ";
echo " -moz-box-shadow: 0px 1px 20px #888; ";
echo " box-shadow: 0px 1px 20px #888;";
echo " }";
echo "</style>";
echo "<script src='".PROJECT_PATH."/resources/jquery/jquery.qrcode-0.8.0.min.js'></script>";
echo "<script language='JavaScript' type='text/javascript'>";
echo " $(document).ready(function() {";
echo " $(window).load(function() {";
echo " $('#qr_code').qrcode({ ";
echo " render: 'canvas', ";
echo " minVersion: 6, ";
echo " maxVersion: 40, ";
echo " ecLevel: 'H', ";
echo " size: 650, ";
echo " radius: 0.2, ";
echo " quiet: 6, ";
echo " background: '#fff', ";
echo " label: 'FusionPBX', ";
echo " fontname: 'san-serif', ";
echo " fontcolor: '#000', ";
echo " mode: 4, ";
echo " mSize: 0.2, ";
echo " mPosX: 0.5, ";
echo " mPosY: 0.5, ";
echo " image: $('#img-buffer')[0], ";
echo " text: document.getElementById('qr_vcard').value ";
echo " });";
echo " });";
echo " });";
echo "</script>";
echo "<img id='img-buffer' src='qr_code_logo.png' style='display: none;'>";
//show the content //show the content
echo "<div align='center'>"; echo "<div align='center'>";
@@ -226,7 +277,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td width='70%' align='right'>\n"; echo "<td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='contacts.php?".$_GET["query_string"]."'\" value='".$text['button-back']."'>\n"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='contacts.php?".$_GET["query_string"]."'\" value='".$text['button-back']."'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='button' class='btn' name='' alt='".$text['button-qr_code']."' onclick=\"window.location='contacts_vcard.php?id=$contact_uuid&type=image'\" value='".$text['button-qr_code']."'>\n"; echo " <input type='button' class='btn' name='' alt='".$text['button-qr_code']."' onclick=\"$('#qr_code_container').fadeIn(400);\" value='".$text['button-qr_code']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-vcard']."' onclick=\"window.location='contacts_vcard.php?id=$contact_uuid&type=download'\" value='".$text['button-vcard']."'>\n"; echo " <input type='button' class='btn' name='' alt='".$text['button-vcard']."' onclick=\"window.location='contacts_vcard.php?id=$contact_uuid&type=download'\" value='".$text['button-vcard']."'>\n";
} }
if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) { if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) {
+15 -3
View File
@@ -69,8 +69,8 @@ if (count($_GET)>0) {
$vcard->data['company'] = $contact_organization; $vcard->data['company'] = $contact_organization;
$vcard->data['first_name'] = $contact_name_given; $vcard->data['first_name'] = $contact_name_given;
$vcard->data['last_name'] = $contact_name_family; $vcard->data['last_name'] = $contact_name_family;
$vcard->data['contact_email1'] = $contact_email; $vcard->data['email1'] = $contact_email;
$vcard->data['contact_url'] = $contact_url; $vcard->data['url'] = $contact_url;
if ($_GET['type'] == "image" || $_GET['type'] == "html") { if ($_GET['type'] == "image" || $_GET['type'] == "html") {
//don't add this to the QR code at this time //don't add this to the QR code at this time
@@ -142,7 +142,12 @@ if (count($_GET)>0) {
if ($_GET['type'] == "text") { if ($_GET['type'] == "text") {
$vcard->build(); $vcard->build();
$content = $vcard->card; $content = $vcard->card;
echo $content; if ($qr_vcard) {
$qr_vcard = $content;
}
else {
echo $content;
}
} }
//show the vcard in an image qr code //show the vcard in an image qr code
@@ -150,6 +155,13 @@ if (count($_GET)>0) {
$vcard->build(); $vcard->build();
$content = $vcard->card; $content = $vcard->card;
if (isset($_GET['debug'])) {
echo "<pre>";
print_r($vcard->data);
echo "</pre>";
exit;
}
//include //include
require_once PROJECT_PATH."resources/qr/qrcode.php"; require_once PROJECT_PATH."resources/qr/qrcode.php";
Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

+20 -17
View File
@@ -44,7 +44,8 @@ class vcard {
,"home_state"=>null ,"home_state"=>null
,"home_postal_code"=>null ,"home_postal_code"=>null
,"home_country"=>null ,"home_country"=>null
,"office_tel"=>null ,"voice_tel"=>null
,"work_tel"=>null
,"home_tel"=>null ,"home_tel"=>null
,"cell_tel"=>null ,"cell_tel"=>null
,"fax_tel"=>null ,"fax_tel"=>null
@@ -64,7 +65,7 @@ class vcard {
/* /*
build() method checks all the values, builds appropriate defaults for build() method checks all the values, builds appropriate defaults for
missing values, generates the vcard data string. missing values, generates the vcard data string.
*/ */
function build() { function build() {
$this->log .= "vcard build() called<br />"; $this->log .= "vcard build() called<br />";
/* /*
@@ -84,20 +85,21 @@ class vcard {
$this->card .= "VERSION:3.0\r\n"; $this->card .= "VERSION:3.0\r\n";
//$this->card .= "CLASS:".$this->class."\r\n"; //$this->card .= "CLASS:".$this->class."\r\n";
//$this->card .= "PRODID:-//class_vcard from TroyWolf.com//NONSGML Version 1//EN\r\n"; //$this->card .= "PRODID:-//class_vcard from TroyWolf.com//NONSGML Version 1//EN\r\n";
$this->card .= "REV:".$this->revision_date."\r\n"; // $this->card .= "REV:".$this->revision_date."\r\n";
$this->card .= "FN:".$this->data['display_name']."\r\n"; $this->card .= "FN:".$this->data['display_name']."\r\n";
$this->card .= "N:"; $this->card .= "N:";
$this->card .= $this->data['last_name'].";"; $this->card .= $this->data['last_name'].";";
$this->card .= $this->data['first_name'].";"; $this->card .= $this->data['first_name'];
if (strlen($this->data['additional_name']) > 0) { if (strlen($this->data['additional_name']) > 0) {
$this->card .= $this->data['additional_name'].";"; $this->card .= ";".$this->data['additional_name'];
} }
if (strlen($this->data['name_prefix']) > 0) { if (strlen($this->data['name_prefix']) > 0) {
$this->card .= $this->data['name_prefix'].";"; $this->card .= ";".$this->data['name_prefix'];
} }
if (strlen($this->data['name_suffix']) > 0) { if (strlen($this->data['name_suffix']) > 0) {
$this->card .= $this->data['name_suffix']."\r\n"; $this->card .= ";".$this->data['name_suffix'];
} }
$this->card .= "\r\n";
if ($this->data['nickname']) { $this->card .= "NICKNAME:".$this->data['contact_nickname']."\r\n"; } if ($this->data['nickname']) { $this->card .= "NICKNAME:".$this->data['contact_nickname']."\r\n"; }
if ($this->data['title']) { $this->card .= "TITLE:".$this->data['title']."\r\n"; } if ($this->data['title']) { $this->card .= "TITLE:".$this->data['title']."\r\n"; }
if ($this->data['company']) { $this->card .= "ORG:".$this->data['company']; } if ($this->data['company']) { $this->card .= "ORG:".$this->data['company']; }
@@ -156,7 +158,7 @@ class vcard {
$this->card .= $this->data['home_city'].";"; $this->card .= $this->data['home_city'].";";
} }
if (strlen($this->data['home_state']) > 0) { if (strlen($this->data['home_state']) > 0) {
$this->card .= $this->data['home_state'].""; $this->card .= $this->data['home_state'].";";
} }
if (strlen($this->data['home_postal_code']) > 0) { if (strlen($this->data['home_postal_code']) > 0) {
$this->card .= $this->data['home_postal_code'].";"; $this->card .= $this->data['home_postal_code'].";";
@@ -166,19 +168,20 @@ class vcard {
} }
$this->card .= "\r\n"; $this->card .= "\r\n";
} }
if ($this->data['email1']) { $this->card .= "EMAIL;TYPE=internet,pref:".$this->data['email1']."\r\n"; } if ($this->data['email1']) { $this->card .= "EMAIL;PREF=1:".$this->data['email1']."\r\n"; }
if ($this->data['email2']) { $this->card .= "EMAIL;TYPE=internet:".$this->data['email2']."\r\n"; } if ($this->data['email2']) { $this->card .= "EMAIL;PREF=2:".$this->data['email2']."\r\n"; }
if ($this->data['office_tel']) { $this->card .= "TEL;TYPE=work,voice:".$this->data['office_tel']."\r\n"; } if ($this->data['voice_tel']) { $this->card .= "TEL;TYPE=voice:".$this->data['voice_tel']."\r\n"; }
if ($this->data['home_tel']) { $this->card .= "TEL;TYPE=home,voice:".$this->data['home_tel']."\r\n"; } if ($this->data['work_tel']) { $this->card .= "TEL;TYPE=work:".$this->data['work_tel']."\r\n"; }
if ($this->data['cell_tel']) { $this->card .= "TEL;TYPE=cell,voice:".$this->data['cell_tel']."\r\n"; } if ($this->data['home_tel']) { $this->card .= "TEL;TYPE=home:".$this->data['home_tel']."\r\n"; }
if ($this->data['fax_tel']) { $this->card .= "TEL;TYPE=work,fax:".$this->data['fax_tel']."\r\n"; } if ($this->data['cell_tel']) { $this->card .= "TEL;TYPE=cell:".$this->data['cell_tel']."\r\n"; }
if ($this->data['pager_tel']) { $this->card .= "TEL;TYPE=work,pager:".$this->data['pager_tel']."\r\n"; } if ($this->data['fax_tel']) { $this->card .= "TEL;TYPE=fax:".$this->data['fax_tel']."\r\n"; }
if ($this->data['url']) { $this->card .= "URL;TYPE=work:".$this->data['url']."\r\n"; } if ($this->data['pager_tel']) { $this->card .= "TEL;TYPE=pager:".$this->data['pager_tel']."\r\n"; }
if ($this->data['url']) { $this->card .= "URL:".$this->data['url']."\r\n"; }
if ($this->data['birthday']) { $this->card .= "BDAY:".$this->data['birthday']."\r\n"; } if ($this->data['birthday']) { $this->card .= "BDAY:".$this->data['birthday']."\r\n"; }
if ($this->data['role']) { $this->card .= "ROLE:".$this->data['role']."\r\n"; } if ($this->data['role']) { $this->card .= "ROLE:".$this->data['role']."\r\n"; }
if ($this->data['note']) { $this->card .= "NOTE:".$this->data['note']."\r\n"; } if ($this->data['note']) { $this->card .= "NOTE:".$this->data['note']."\r\n"; }
$this->card .= "TZ:".$this->data['timezone']."\r\n"; $this->card .= "TZ:".$this->data['timezone']."\r\n";
$this->card .= "END:VCARD\r\n"; $this->card .= "END:VCARD";
} }
/* /*
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+9
View File
@@ -493,6 +493,15 @@ function confirmdelete(url) {
} }
?> ?>
<?php
// qr code container for contacts
echo "<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>";
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>";
echo " <span id='qr_code' onclick=\"$('#qr_code_container').fadeOut(400);\"></span>";
echo " </td></tr></table>";
echo "</div>";
?>
<div align='center'> <div align='center'>
<table width='90%' class='border' border='0' cellpadding='0' cellspacing='0'> <table width='90%' class='border' border='0' cellpadding='0' cellspacing='0'>
<tr> <tr>
+9
View File
@@ -591,6 +591,15 @@ function confirmdelete(url) {
} }
?> ?>
<?php
// qr code container for contacts
echo "<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>";
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>";
echo " <span id='qr_code' onclick=\"$('#qr_code_container').fadeOut(400);\"></span>";
echo " </td></tr></table>";
echo "</div>";
?>
<div align='center'> <div align='center'>
<table width='90%' class='border.disabled' style='background-color:#FFFFFF;' border='0' cellpadding='0' cellspacing='0'> <table width='90%' class='border.disabled' style='background-color:#FFFFFF;' border='0' cellpadding='0' cellspacing='0'>
<tr> <tr>
+36 -29
View File
@@ -736,39 +736,46 @@ function confirmdelete(url) {
} }
?> ?>
<?php <?php
//get a random background image
//get a random background image $dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/default/images/backgrounds';
$dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/default/images/backgrounds'; $dir_list = opendir($dir);
$dir_list = opendir($dir); $v_background_array = array();
$v_background_array = array(); $x = 0;
$x = 0; while (false !== ($file = readdir($dir_list))) {
while (false !== ($file = readdir($dir_list))) { if ($file != "." AND $file != ".."){
if ($file != "." AND $file != ".."){ $new_path = $dir.'/'.$file;
$new_path = $dir.'/'.$file; $level = explode('/',$new_path);
$level = explode('/',$new_path); if (substr($new_path, -4) == ".svn") {
if (substr($new_path, -4) == ".svn") { //ignore .svn dir and subdir
//ignore .svn dir and subdir }
elseif (substr($new_path, -3) == ".db") {
//ignore .db files
}
else {
$new_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $new_path);
$v_background_array[] = $new_path;
}
if ($x > 1000) { break; };
$x++;
} }
elseif (substr($new_path, -3) == ".db") {
//ignore .db files
}
else {
$new_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $new_path);
$v_background_array[] = $new_path;
}
if ($x > 1000) { break; };
$x++;
} }
} if (strlen($_SESSION['background_image'])== 0) {
if (strlen($_SESSION['background_image'])== 0) { $_SESSION['background_image'] = $v_background_array[array_rand($v_background_array, 1)];
$_SESSION['background_image'] = $v_background_array[array_rand($v_background_array, 1)]; }
}
//show the background //show the background
echo "<div id=\"page-background\"><img src=\"".$_SESSION['background_image']."\" width='100%' height='100%' alt=''></div>\n"; echo "<div id=\"page-background\"><img src=\"".$_SESSION['background_image']."\" width='100%' height='100%' alt=''></div>\n";
?> ?>
<?php
// qr code container for contacts
echo "<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>";
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>";
echo " <span id='qr_code' onclick=\"$('#qr_code_container').fadeOut(400);\"></span>";
echo " </td></tr></table>";
echo "</div>";
?>
<div id="page" align='center'> <div id="page" align='center'>
<table width='90%' class='border.disabled' border='0' cellpadding='0' cellspacing='7'> <table width='90%' class='border.disabled' border='0' cellpadding='0' cellspacing='7'>
+9
View File
@@ -1098,6 +1098,15 @@ legend {
} }
?> ?>
<?php
// qr code container for contacts
echo "<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>";
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>";
echo " <span id='qr_code' onclick=\"$('#qr_code_container').fadeOut(400);\"></span>";
echo " </td></tr></table>";
echo "</div>";
?>
<div id="page" align='center'> <div id="page" align='center'>
<table width='90%' class='border.disabled' border='0' cellpadding='0' cellspacing='0'> <table width='90%' class='border.disabled' border='0' cellpadding='0' cellspacing='0'>
<tr> <tr>