Fax Server: Added ability to select an existing Contact as the fax Recipient.

Updated jquery.autosize.input.js to latest version.
This commit is contained in:
Nate Jones 2014-09-05 02:29:29 +00:00
parent 4070aa19cf
commit 7000e201f6
3 changed files with 192 additions and 113 deletions

View File

@ -258,7 +258,7 @@
$text['label-file']['pt-pt'] = "Ficheiro não encontrado."; $text['label-file']['pt-pt'] = "Ficheiro não encontrado.";
$text['label-file']['fr-fr'] = "Fichier non trové"; $text['label-file']['fr-fr'] = "Fichier non trové";
$text['description-2']['en-us'] = "To send a fax, upload a <strong>PDF</strong> or <strong>TIF</strong> file."; $text['description-2']['en-us'] = "To send a fax, upload a <strong>PDF</strong> or <strong>TIF</strong> (requires LibreOffice) file.";
$text['description-2']['es-cl'] = "Para enviar un fax puede subir un archivo .tif o si ghost script está instalado entonces también puede enviar un fax subiendo un archivo PDF."; $text['description-2']['es-cl'] = "Para enviar un fax puede subir un archivo .tif o si ghost script está instalado entonces también puede enviar un fax subiendo un archivo PDF.";
$text['description-2']['pt-pt'] = "Para enviar um fax pode carregar um ficheiro .tif ou, se o ghost script tiver sido instalado, enviar um fax, carregando um ficheiro .pdf."; $text['description-2']['pt-pt'] = "Para enviar um fax pode carregar um ficheiro .tif ou, se o ghost script tiver sido instalado, enviar um fax, carregando um ficheiro .pdf.";
$text['description-2']['fr-fr'] = "Pour envoyer un fax, vous pouvez télécharger un fichier <b>TIF</b>. Si ghost script a été installé, vous pouvez également utiliser un fichier <b>PDF</b>."; $text['description-2']['fr-fr'] = "Pour envoyer un fax, vous pouvez télécharger un fichier <b>TIF</b>. Si ghost script a été installé, vous pouvez également utiliser un fichier <b>PDF</b>.";

View File

@ -654,7 +654,78 @@ else {
echo " ".$text['label-fax-recipient']."\n"; echo " ".$text['label-fax-recipient']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_recipient' class='formfld' style='' value=''>\n";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle(field) {";
echo " if (field == 'to') {";
echo " document.getElementById('fax_recipient_select').selectedIndex = 0;";
echo " $('#fax_recipient_select').toggle();";
echo " $('#fax_recipient').toggle();";
echo " if ($('#fax_recipient').is(':visible')) { $('#fax_recipient').focus(); } else { $('#fax_recipient_select').focus(); }";
echo " }";
echo " }";
echo "</script>";
?>
<script>
function contact_load(obj_sel) {
obj_sel.style.display='none';
document.getElementById('fax_recipient').style.display='';
var selected_option_value = obj_sel.options[obj_sel.selectedIndex].value;
var selected_option_values = selected_option_value.split('|', 2);
document.getElementById('fax_recipient').value = selected_option_values[1];
document.getElementById('fax_number').value = selected_option_values[0];
$("#fax_recipient").css({width: '50%'});
$("#fax_number").css({width: '120px'});
}
</script>
<?
echo " <select class='formfld' style='display: none;' id='fax_recipient_select' onchange='contact_load(this);'>\n";
echo " <option value=''></option>\n";
$sql = "select ";
$sql .= "c.contact_organization, ";
$sql .= "c.contact_name_given, ";
$sql .= "c.contact_name_family, ";
$sql .= "c.contact_nickname, ";
$sql .= "cp.phone_number ";
$sql .= "from ";
$sql .= "v_contacts as c, ";
$sql .= "v_contact_phones as cp ";
$sql .= "where ";
$sql .= "c.contact_uuid = cp.contact_uuid and ";
$sql .= "c.domain_uuid = '".$_SESSION['domain_uuid']."' and ";
$sql .= "cp.domain_uuid = '".$_SESSION['domain_uuid']."' and ";
$sql .= "cp.phone_type = 'fax' and ";
$sql .= "cp.phone_number is not null and ";
$sql .= "cp.phone_number <> '' ";
$sql .= "order by ";
$sql .= "c.contact_organization asc, ";
$sql .= "c.contact_name_given asc, ";
$sql .= "c.contact_name_family asc ";
echo $sql;
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement -> execute();
$result_e = $prep_statement -> fetchAll(PDO::FETCH_NAMED);
foreach ($result_e as &$row) {
if ($row['contact_organization'] != '') {
$contact_option_label = $row['contact_organization'];
}
if ($row['contact_name_given'] != '' || $row['contact_name_family'] != '' || $row['contact_nickname'] != '') {
$contact_option_label .= ($row['contact_organization'] != '') ? "," : null;
$contact_option_label .= ($row['contact_name_given'] != '') ? " ".$row['contact_name_given'] : null;
$contact_option_label .= ($row['contact_name_family'] != '') ? " ".$row['contact_name_family'] : null;
$contact_option_label .= ($row['contact_nickname'] != '') ? " (".$row['contact_nickname'].")" : null;
}
$contact_option_value_recipient = $contact_option_label;
$contact_option_value_faxnumber = $row['phone_number'];
$contact_option_label .= ":&nbsp;&nbsp;".format_phone($row['phone_number']);
echo " <option value=\"".$contact_option_value_faxnumber."|".$contact_option_value_recipient."\">".$contact_option_label."</option>\n";
unset($contact_option_label);
}
unset ($prep_statement);
echo " </select>\n";
echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='' value=''>\n";
echo " <input type='button' id='btn_toggle_recipient' class='btn' name='' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle('to');\">\n";
echo " <br />\n"; echo " <br />\n";
echo " ".$text['description-fax-recipient']."\n"; echo " ".$text['description-fax-recipient']."\n";
echo "</td>\n"; echo "</td>\n";
@ -665,7 +736,7 @@ else {
echo " ".$text['label-fax-number']."\n"; echo " ".$text['label-fax-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_number' class='formfld' style='' value=''>\n"; echo " <input type='text' name='fax_number' id='fax_number' class='formfld' style='' value=''>\n";
echo " <br />\n"; echo " <br />\n";
echo " ".$text['description-fax-number']."\n"; echo " ".$text['description-fax-number']."\n";
echo "</td>\n"; echo "</td>\n";

View File

@ -1,110 +1,118 @@
// source: https://github.com/MartinF/jQuery.Autosize.Input var Plugins;
(function (Plugins) {
var Plugins; var AutosizeInputOptions = (function () {
(function (Plugins) { function AutosizeInputOptions(space) {
var AutosizeInput = (function () { if (typeof space === "undefined") { space = 30; }
function AutosizeInput(input, options) { this.space = space;
var _this = this; }
this._input = $(input); return AutosizeInputOptions;
this._options = options; })();
this._mirror = $('<span style="position:absolute; top:-999px; left:0; white-space:pre;"/>'); Plugins.AutosizeInputOptions = AutosizeInputOptions;
$.each([
'fontFamily', var AutosizeInput = (function () {
'fontSize', function AutosizeInput(input, options) {
'fontWeight', var _this = this;
'fontStyle', this._input = $(input);
'letterSpacing', this._options = $.extend({}, AutosizeInput.getDefaultOptions(), options);
'textTransform',
'wordSpacing', // Init mirror
'textIndent' this._mirror = $('<span style="position:absolute; top:-999px; left:0; white-space:pre;"/>');
], function (i, val) {
_this._mirror[0].style[val] = _this._input.css(val); // Copy to mirror
}); $.each(['fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing', 'textTransform', 'wordSpacing', 'textIndent'], function (i, val) {
$("body").append(this._mirror); _this._mirror[0].style[val] = _this._input.css(val);
this._input.bind("keydown input", function (e) { });
_this.update(); $("body").append(this._mirror);
});
(function () { // Bind events - change update paste click mousedown mouseup focus blur
_this.update(); // IE 9 need keydown to keep updating while deleting (keeping backspace in - else it will first update when backspace is released)
})(); // IE 9 need keyup incase text is selected and backspace/deleted is hit - keydown is to early
} // How to fix problem with hitting the delete "X" in the box - but not updating!? mouseup is apparently to early
Object.defineProperty(AutosizeInput.prototype, "options", { // Could bind separatly and set timer
get: function () { // Add so it automatically updates if value of input is changed http://stackoverflow.com/a/1848414/58524
return this._options; this._input.on("keydown keyup input propertychange change", function (e) {
}, _this.update();
enumerable: true, });
configurable: true
}); // Update
Object.defineProperty(AutosizeInput, "instanceKey", { (function () {
get: function () { _this.update();
return "autosizeInputInstance"; })();
}, }
enumerable: true, AutosizeInput.prototype.getOptions = function () {
configurable: true return this._options;
}); };
AutosizeInput.prototype.update = function () {
var value = this._input.val(); AutosizeInput.prototype.update = function () {
if(!value) { var value = this._input.val() || "";
value = this._input.attr("placeholder");
} if (value === this._mirror.text()) {
if(value === this._mirror.text()) { // Nothing have changed - skip
return; return;
} }
this._mirror.text(value);
var newWidth = this._mirror.width() + this._options.space; // Update mirror
this._input.width(newWidth); this._mirror.text(value);
};
return AutosizeInput; // Calculate the width
})(); var newWidth = this._mirror.width() + this._options.space;
Plugins.AutosizeInput = AutosizeInput;
var AutosizeInputOptions = (function () { // Update the width
function AutosizeInputOptions(space) { this._input.width(newWidth);
if (typeof space === "undefined") { space = 30; } };
this._space = space;
} AutosizeInput.getDefaultOptions = function () {
Object.defineProperty(AutosizeInputOptions.prototype, "space", { return this._defaultOptions;
get: function () { };
return this._space;
}, AutosizeInput.getInstanceKey = function () {
set: function (value) { // Use camelcase because .data()['autosize-input-instance'] will not work
this._space = value; return "autosizeInputInstance";
}, };
enumerable: true, AutosizeInput._defaultOptions = new AutosizeInputOptions();
configurable: true return AutosizeInput;
}); })();
return AutosizeInputOptions; Plugins.AutosizeInput = AutosizeInput;
})();
Plugins.AutosizeInputOptions = AutosizeInputOptions; // jQuery Plugin
(function ($) { (function ($) {
var pluginDataAttributeName = "autosize-input"; var pluginDataAttributeName = "autosize-input";
var validTypes = [ var validTypes = ["text", "password", "search", "url", "tel", "email", "number"];
"text",
"password", // jQuery Plugin
"search", $.fn.autosizeInput = function (options) {
"url", return this.each(function () {
"tel", // Make sure it is only applied to input elements of valid type
"email" // Or let it be the responsibility of the programmer to only select and apply to valid elements?
]; if (!(this.tagName == "INPUT" && $.inArray(this.type, validTypes) > -1)) {
$.fn.autosizeInput = function (options) { // Skip - if not input and of valid type
return this.each(function () { return;
if(!(this.tagName == "INPUT" && $.inArray(this.type, validTypes) > -1)) { }
return;
} var $this = $(this);
var $this = $(this);
if(!$this.data(Plugins.AutosizeInput.instanceKey)) { if (!$this.data(Plugins.AutosizeInput.getInstanceKey())) {
if(options == undefined) { // If instance not already created and attached
var options = $this.data(pluginDataAttributeName); if (options == undefined) {
if(!(options && typeof options == 'object')) { // Try get options from attribute
options = new AutosizeInputOptions(); options = $this.data(pluginDataAttributeName);
} }
}
$this.data(Plugins.AutosizeInput.instanceKey, new Plugins.AutosizeInput(this, options)); // Create and attach instance
} $this.data(Plugins.AutosizeInput.getInstanceKey(), new Plugins.AutosizeInput(this, options));
}); }
}; });
$(function () { };
$("input[data-" + pluginDataAttributeName + "]").autosizeInput();
}); // On Document Ready
})(jQuery); $(function () {
})(Plugins || (Plugins = {})); // Instantiate for all with data-provide=autosize-input attribute
$("input[data-" + pluginDataAttributeName + "]").autosizeInput();
});
// Alternative to use On Document Ready and creating the instance immediately
//$(document).on('focus.autosize-input', 'input[data-autosize-input]', function (e)
//{
// $(this).autosizeInput();
//});
})(jQuery);
})(Plugins || (Plugins = {}));