2012-06-04 16:58:40 +02:00
|
|
|
<?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 <markjcrane@fusionpbx.com>
|
2019-03-01 14:08:47 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
2018-08-02 09:12:31 +02:00
|
|
|
|
|
|
|
|
//includes
|
|
|
|
|
require_once "root.php";
|
|
|
|
|
require_once "resources/require.php";
|
|
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
if (permission_exists('contact_view')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2013-05-10 02:40:24 +02:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-10 02:40:24 +02:00
|
|
|
|
2020-01-24 05:24:10 +01:00
|
|
|
|
|
|
|
|
//get the http post data from the contact property lists (numbers, addresses, etc) and process by action
|
|
|
|
|
if (is_array($_POST) && is_uuid($_POST['contact_uuid'])) {
|
|
|
|
|
$contact_uuid = $_POST['contact_uuid'];
|
|
|
|
|
|
|
|
|
|
switch ($_POST['action']) {
|
|
|
|
|
case 'delete_properties':
|
|
|
|
|
$array = array();
|
|
|
|
|
if (permission_exists('contact_phone_delete')) { $contact_properties['contact_phones'] = $_POST['contact_phones']; }
|
|
|
|
|
if (permission_exists('contact_address_delete')) { $contact_properties['contact_addresses'] = $_POST['contact_addresses']; }
|
|
|
|
|
if (permission_exists('contact_email_delete')) { $contact_properties['contact_emails'] = $_POST['contact_emails']; }
|
|
|
|
|
if (permission_exists('contact_url_delete')) { $contact_properties['contact_urls'] = $_POST['contact_urls']; }
|
|
|
|
|
//if (permission_exists('contact_extension_delete')) { $contact_properties['contact_extensions'] = $_POST['contact_extensions']; }
|
|
|
|
|
if (permission_exists('contact_relation_delete')) { $contact_properties['contact_relations'] = $_POST['contact_relations']; }
|
|
|
|
|
if (permission_exists('contact_note_delete')) { $contact_properties['contact_notes'] = $_POST['contact_notes']; }
|
|
|
|
|
if (permission_exists('contact_time_delete')) { $contact_properties['contact_times'] = $_POST['contact_times']; }
|
|
|
|
|
if (permission_exists('contact_setting_delete')) { $contact_properties['contact_settings'] = $_POST['contact_settings']; }
|
|
|
|
|
if (permission_exists('contact_attachment_delete')) { $contact_properties['contact_attachments'] = $_POST['contact_attachments']; }
|
|
|
|
|
|
|
|
|
|
if (@sizeof($contact_properties) != 0) {
|
|
|
|
|
$obj = new contacts;
|
|
|
|
|
$obj->contact_uuid = $contact_uuid;
|
|
|
|
|
$obj->delete_properties($contact_properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header('Location: contact_edit.php?id='.urlencode($contact_uuid));
|
2020-01-26 23:39:48 +01:00
|
|
|
exit;
|
2020-01-24 05:24:10 +01:00
|
|
|
case 'delete_contact':
|
|
|
|
|
if (permission_exists('contact_delete')) {
|
|
|
|
|
$array[0]['checked'] = 'true';
|
|
|
|
|
$array[0]['uuid'] = $contact_uuid;
|
|
|
|
|
|
|
|
|
|
$obj = new contacts;
|
|
|
|
|
$obj->delete($array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header('Location: contacts.php');
|
2020-01-26 23:39:48 +01:00
|
|
|
exit;
|
2020-01-24 05:24:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//action add or update
|
2019-07-28 06:51:01 +02:00
|
|
|
if (is_uuid($_REQUEST["id"])) {
|
2012-06-04 16:58:40 +02:00
|
|
|
$action = "update";
|
2019-07-28 06:51:01 +02:00
|
|
|
$contact_uuid = $_REQUEST["id"];
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$action = "add";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get http post variables and set them to php variables
|
2016-01-18 22:17:59 +01:00
|
|
|
if (count($_POST) > 0) {
|
2019-07-28 06:51:01 +02:00
|
|
|
$user_uuid = $_POST["user_uuid"];
|
2016-04-06 08:27:57 +02:00
|
|
|
$group_uuid = $_POST['group_uuid'];
|
2019-07-28 06:51:01 +02:00
|
|
|
$contact_type = $_POST["contact_type"];
|
|
|
|
|
$contact_organization = $_POST["contact_organization"];
|
|
|
|
|
$contact_name_prefix = $_POST["contact_name_prefix"];
|
|
|
|
|
$contact_name_given = $_POST["contact_name_given"];
|
|
|
|
|
$contact_name_middle = $_POST["contact_name_middle"];
|
|
|
|
|
$contact_name_family = $_POST["contact_name_family"];
|
|
|
|
|
$contact_name_suffix = $_POST["contact_name_suffix"];
|
|
|
|
|
$contact_nickname = $_POST["contact_nickname"];
|
|
|
|
|
$contact_title = $_POST["contact_title"];
|
|
|
|
|
$contact_category = $_POST["contact_category"];
|
|
|
|
|
$contact_role = $_POST["contact_role"];
|
|
|
|
|
$contact_time_zone = $_POST["contact_time_zone"];
|
|
|
|
|
$contact_note = $_POST["contact_note"];
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-20 09:39:54 +02:00
|
|
|
//process the form data
|
|
|
|
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2015-10-20 09:39:54 +02:00
|
|
|
//set the uuid
|
|
|
|
|
if ($action == "update") {
|
2019-07-28 06:51:01 +02:00
|
|
|
$contact_uuid = $_POST["contact_uuid"];
|
2015-10-20 09:39:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-09-18 06:28:22 +02:00
|
|
|
//validate the token
|
|
|
|
|
$token = new token;
|
|
|
|
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
|
|
|
|
message::add($text['message-invalid_token'],'negative');
|
|
|
|
|
header('Location: contacts.php');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-20 09:39:54 +02:00
|
|
|
//check for all required data
|
|
|
|
|
$msg = '';
|
|
|
|
|
//if (strlen($contact_type) == 0) { $msg .= $text['message-required'].$text['label-contact_type']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_organization) == 0) { $msg .= $text['message-required'].$text['label-contact_organization']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_name_prefix) == 0) { $msg .= $text['message-required'].$text['label-contact_name_prefix']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_name_given) == 0) { $msg .= $text['message-required'].$text['label-contact_name_given']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_name_middle) == 0) { $msg .= $text['message-required'].$text['label-contact_name_middle']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_name_family) == 0) { $msg .= $text['message-required'].$text['label-contact_name_family']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_name_suffix) == 0) { $msg .= $text['message-required'].$text['label-contact_name_suffix']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_nickname) == 0) { $msg .= $text['message-required'].$text['label-contact_nickname']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_title) == 0) { $msg .= $text['message-required'].$text['label-contact_title']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_role) == 0) { $msg .= $text['message-required'].$text['label-contact_role']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_time_zone) == 0) { $msg .= $text['message-required'].$text['label-contact_time_zone']."<br>\n"; }
|
|
|
|
|
//if (strlen($contact_note) == 0) { $msg .= $text['message-required'].$text['label-contact_note']."<br>\n"; }
|
|
|
|
|
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
|
|
require_once "resources/header.php";
|
|
|
|
|
require_once "resources/persist_form_var.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 "resources/footer.php";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2015-10-20 09:39:54 +02:00
|
|
|
//add or update the database
|
|
|
|
|
if ($_POST["persistformvar"] != "true") {
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2016-01-18 00:16:51 +01:00
|
|
|
//add the contact
|
2016-01-19 00:53:19 +01:00
|
|
|
if ($action == "add" && permission_exists('contact_add')) {
|
2016-01-18 00:16:51 +01:00
|
|
|
$contact_uuid = uuid();
|
2019-07-28 06:51:01 +02:00
|
|
|
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
|
2016-01-18 00:16:51 +01:00
|
|
|
|
2018-08-31 05:09:01 +02:00
|
|
|
message::add($text['message-add']);
|
2019-07-28 06:51:01 +02:00
|
|
|
}
|
2016-01-18 00:16:51 +01:00
|
|
|
|
2016-01-19 00:53:19 +01:00
|
|
|
//update the contact
|
|
|
|
|
if ($action == "update" && permission_exists('contact_edit')) {
|
2019-07-28 06:51:01 +02:00
|
|
|
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
|
2016-01-19 00:53:19 +01:00
|
|
|
|
2018-08-31 05:09:01 +02:00
|
|
|
message::add($text['message-update']);
|
2019-07-28 06:51:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//create array
|
|
|
|
|
if (is_array($array) && @sizeof($array) != 0) {
|
|
|
|
|
$array['contacts'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$array['contacts'][0]['contact_type'] = $contact_type;
|
|
|
|
|
$array['contacts'][0]['contact_organization'] = $contact_organization;
|
|
|
|
|
$array['contacts'][0]['contact_name_prefix'] = $contact_name_prefix;
|
|
|
|
|
$array['contacts'][0]['contact_name_given'] = $contact_name_given;
|
|
|
|
|
$array['contacts'][0]['contact_name_middle'] = $contact_name_middle;
|
|
|
|
|
$array['contacts'][0]['contact_name_family'] = $contact_name_family;
|
|
|
|
|
$array['contacts'][0]['contact_name_suffix'] = $contact_name_suffix;
|
|
|
|
|
$array['contacts'][0]['contact_nickname'] = $contact_nickname;
|
|
|
|
|
$array['contacts'][0]['contact_title'] = $contact_title;
|
|
|
|
|
$array['contacts'][0]['contact_category'] = $contact_category;
|
|
|
|
|
$array['contacts'][0]['contact_role'] = $contact_role;
|
|
|
|
|
$array['contacts'][0]['contact_time_zone'] = $contact_time_zone;
|
|
|
|
|
$array['contacts'][0]['contact_note'] = $contact_note;
|
|
|
|
|
$array['contacts'][0]['last_mod_date'] = 'now()';
|
|
|
|
|
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
|
|
|
|
|
|
|
|
|
|
$p = new permissions;
|
|
|
|
|
}
|
2016-01-19 00:53:19 +01:00
|
|
|
|
2016-01-18 00:16:51 +01:00
|
|
|
//assign the contact to the user that added the contact
|
2016-01-19 00:53:19 +01:00
|
|
|
if ($action == "add" && !permission_exists('contact_user_add')) {
|
|
|
|
|
$user_uuid = $_SESSION["user_uuid"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add user to contact users table
|
2019-07-28 06:51:01 +02:00
|
|
|
if (is_uuid($user_uuid) && (permission_exists('contact_user_add') || $action == "add")) {
|
2016-01-19 00:53:19 +01:00
|
|
|
$contact_user_uuid = uuid();
|
2019-07-28 06:51:01 +02:00
|
|
|
$array['contact_users'][0]['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$array['contact_users'][0]['contact_user_uuid'] = $contact_user_uuid;
|
|
|
|
|
$array['contact_users'][0]['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$array['contact_users'][0]['user_uuid'] = $user_uuid;
|
|
|
|
|
|
|
|
|
|
$p->add('contact_user_add', 'temp');
|
2016-01-19 00:55:26 +01:00
|
|
|
}
|
2016-01-18 00:16:51 +01:00
|
|
|
|
|
|
|
|
//assign the contact to the group
|
2019-07-28 06:51:01 +02:00
|
|
|
if (is_uuid($group_uuid) && permission_exists('contact_group_add')) {
|
|
|
|
|
$contact_group_uuid = uuid();
|
2019-08-15 18:14:40 +02:00
|
|
|
$array['contact_groups'][0]['contact_group_uuid'] = $contact_group_uuid;
|
|
|
|
|
$array['contact_groups'][0]['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$array['contact_groups'][0]['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$array['contact_groups'][0]['group_uuid'] = $group_uuid;
|
2019-07-28 06:51:01 +02:00
|
|
|
|
|
|
|
|
$p->add('contact_group_add', 'temp');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//execute
|
|
|
|
|
if (is_array($array) && @sizeof($array) != 0) {
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'contacts';
|
|
|
|
|
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
|
|
|
|
|
$database->save($array);
|
|
|
|
|
unset($array);
|
|
|
|
|
|
|
|
|
|
$p->delete('contact_user_add', 'temp');
|
|
|
|
|
$p->delete('contact_group_add', 'temp');
|
2016-01-18 00:16:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//redirect the browser
|
2020-01-24 05:24:10 +01:00
|
|
|
header("Location: contact_edit.php?id=".urlencode($contact_uuid));
|
2019-07-28 06:51:01 +02:00
|
|
|
exit;
|
2014-10-15 22:11:17 +02:00
|
|
|
|
2019-07-28 06:51:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//pre-populate the form
|
2014-11-19 04:44:41 +01:00
|
|
|
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_uuid = $_GET["id"];
|
2013-02-07 10:57:03 +01:00
|
|
|
$sql = "select * from v_contacts ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
|
|
|
|
$sql .= "and contact_uuid = :contact_uuid ";
|
|
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$parameters['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
|
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_type = $row["contact_type"];
|
|
|
|
|
$contact_organization = $row["contact_organization"];
|
2014-11-22 01:06:38 +01:00
|
|
|
$contact_name_prefix = $row["contact_name_prefix"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_name_given = $row["contact_name_given"];
|
2014-11-22 01:06:38 +01:00
|
|
|
$contact_name_middle = $row["contact_name_middle"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_name_family = $row["contact_name_family"];
|
2014-11-22 01:06:38 +01:00
|
|
|
$contact_name_suffix = $row["contact_name_suffix"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_nickname = $row["contact_nickname"];
|
|
|
|
|
$contact_title = $row["contact_title"];
|
2013-02-07 10:57:03 +01:00
|
|
|
$contact_category = $row["contact_category"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$contact_role = $row["contact_role"];
|
|
|
|
|
$contact_time_zone = $row["contact_time_zone"];
|
|
|
|
|
$contact_note = $row["contact_note"];
|
|
|
|
|
}
|
2019-07-28 06:51:01 +02:00
|
|
|
unset($sql, $parameters, $row);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-18 22:17:59 +01:00
|
|
|
//get the users array
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql = "select * from v_users ";
|
|
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
2016-01-18 22:17:59 +01:00
|
|
|
$sql .= "order by username asc ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$database = new database;
|
|
|
|
|
$users = $database->select($sql, $parameters, 'all');
|
|
|
|
|
unset($sql, $parameters);
|
2016-01-18 22:17:59 +01:00
|
|
|
|
2019-03-07 03:54:12 +01:00
|
|
|
//determine if contact assigned to a user
|
|
|
|
|
if (is_array($users) && sizeof($users) != 0) {
|
2020-01-24 05:24:10 +01:00
|
|
|
foreach ($users as $user) {
|
2019-03-07 03:54:12 +01:00
|
|
|
if ($user['contact_uuid'] == $contact_uuid) {
|
|
|
|
|
$contact_user_uuid = $user['user_uuid'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 22:17:59 +01:00
|
|
|
//get the users assigned to this contact
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql = "select u.username, u.user_uuid, a.contact_user_uuid from v_contacts as c, v_users as u, v_contact_users as a ";
|
|
|
|
|
$sql .= "where c.contact_uuid = :contact_uuid ";
|
|
|
|
|
$sql .= "and c.domain_uuid = :domain_uuid ";
|
2016-01-18 23:02:34 +01:00
|
|
|
$sql .= "and u.user_uuid = a.user_uuid ";
|
|
|
|
|
$sql .= "and c.contact_uuid = a.contact_uuid ";
|
2016-01-18 22:17:59 +01:00
|
|
|
$sql .= "order by u.username asc ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$parameters['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$database = new database;
|
|
|
|
|
$contact_users = $database->select($sql, $parameters, 'all');
|
|
|
|
|
unset($sql, $parameters);
|
2016-01-18 22:17:59 +01:00
|
|
|
|
2019-09-18 06:28:22 +02:00
|
|
|
//create token
|
|
|
|
|
$object = new token;
|
|
|
|
|
$token = $object->create($_SERVER['PHP_SELF']);
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the header
|
2013-05-10 02:40:24 +02:00
|
|
|
if ($action == "update") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-contact-edit'];
|
2013-05-10 02:40:24 +02:00
|
|
|
}
|
|
|
|
|
else if ($action == "add") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-contact-add'];
|
2013-05-10 02:40:24 +02:00
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
require_once "resources/header.php";
|
2013-05-10 02:40:24 +02:00
|
|
|
|
2019-09-10 20:08:54 +02:00
|
|
|
//determine qr branding
|
|
|
|
|
if ($_SESSION['theme']['qr_brand_type']['text'] == 'image' && $_SESSION['theme']['qr_brand_image']['text'] != '') {
|
|
|
|
|
echo "<img id='img-buffer' style='display: none;' src='".$_SESSION["theme"]["qr_brand_image"]["text"]."'>";
|
|
|
|
|
$qr_option = "image: $('#img-buffer')[0],";
|
|
|
|
|
$qr_mode = '4';
|
|
|
|
|
$qr_size = '0.2';
|
|
|
|
|
}
|
|
|
|
|
else if ($_SESSION['theme']['qr_brand_type']['text'] == 'text' && $_SESSION['theme']['qr_brand_text']['text'] != '') {
|
|
|
|
|
$qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"';
|
|
|
|
|
$qr_mode = '2';
|
|
|
|
|
$qr_size = '0.05';
|
2017-10-11 07:35:29 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2019-09-10 20:08:54 +02:00
|
|
|
echo "<img id='img-buffer' style='display: none;' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png'>";
|
|
|
|
|
$qr_option = "image: $('#img-buffer')[0],";
|
|
|
|
|
$qr_mode = '4';
|
|
|
|
|
$qr_size = '0.2';
|
2017-10-11 07:35:29 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-18 22:17:59 +01:00
|
|
|
//qr code generation
|
2014-07-26 08:02:21 +02:00
|
|
|
$_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; ";
|
2019-09-10 20:08:54 +02:00
|
|
|
echo " left: 0; ";
|
|
|
|
|
echo " top: 0; ";
|
|
|
|
|
echo " right: 0; ";
|
|
|
|
|
echo " bottom: 0; ";
|
2014-07-26 08:02:21 +02:00
|
|
|
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>";
|
2019-08-19 18:51:21 +02:00
|
|
|
echo "<script src='".PROJECT_PATH."/resources/jquery/jquery-qrcode.min.js'></script>";
|
2014-07-26 08:02:21 +02:00
|
|
|
echo "<script language='JavaScript' type='text/javascript'>";
|
|
|
|
|
echo " $(document).ready(function() {";
|
2019-09-10 20:08:54 +02:00
|
|
|
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 " mode: ".$qr_mode.", ";
|
|
|
|
|
echo " mSize: ".$qr_size.", ";
|
|
|
|
|
echo " mPosX: 0.5, ";
|
|
|
|
|
echo " mPosY: 0.5, ";
|
|
|
|
|
echo " text: document.getElementById('qr_vcard').value, ";
|
|
|
|
|
echo " ".$qr_option;
|
2014-07-26 08:02:21 +02:00
|
|
|
echo " });";
|
|
|
|
|
echo " });";
|
|
|
|
|
echo "</script>";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//show the content
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<div class='action_bar' id='action_bar'>\n";
|
|
|
|
|
echo " <div class='heading'>";
|
|
|
|
|
if ($action == "add") {
|
|
|
|
|
echo "<b>".$text['header-contact-add']."</b>";
|
|
|
|
|
}
|
|
|
|
|
else if ($action == "update") {
|
|
|
|
|
echo "<b>".$text['header-contact-edit']."</b>";
|
2013-05-10 02:40:24 +02:00
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div class='actions'>\n";
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-sm-dn','style'=>'margin-right: 15px;','link'=>'contacts.php']);
|
2013-05-10 02:40:24 +02:00
|
|
|
if ($action == "update") {
|
2015-05-17 08:16:43 +02:00
|
|
|
if (permission_exists('contact_time_add')) {
|
|
|
|
|
//detect timer state (and start time)
|
|
|
|
|
$sql = "select ";
|
|
|
|
|
$sql .= "time_start ";
|
|
|
|
|
$sql .= "from v_contact_times ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
|
|
|
|
$sql .= "and user_uuid = :user_uuid ";
|
|
|
|
|
$sql .= "and contact_uuid = :contact_uuid ";
|
2015-05-17 08:16:43 +02:00
|
|
|
$sql .= "and time_start is not null ";
|
|
|
|
|
$sql .= "and time_stop is null ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
|
|
|
|
|
$parameters['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$time_start = $database->select($sql, $parameters, 'column');
|
2020-01-24 05:24:10 +01:00
|
|
|
$btn_style = $time_start ? 'color: #fff; background-color: #3693df; background-image: none;' : null;
|
2019-07-28 06:51:01 +02:00
|
|
|
unset($sql, $parameters);
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-timer'],'icon'=>'clock','style'=>$btn_style,'title'=>$time_start,'collapse'=>'hide-sm-dn','onclick'=>"window.open('contact_timer.php?domain_uuid=".urlencode($domain_uuid)."&contact_uuid=".urlencode($contact_uuid)."','contact_time_".escape($contact_uuid)."','width=300, height=375, top=30, left='+(screen.width - 350)+', menubar=no, scrollbars=no, status=no, toolbar=no, resizable=no');"]);
|
2015-05-17 08:16:43 +02:00
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid).'&type=download']);
|
2013-05-10 02:40:24 +02:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-invoices'],'icon'=>'file-invoice-dollar','collapse'=>'hide-sm-dn','link'=>'../invoices/invoices.php?id='.urlencode($contact_uuid)]);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2014-08-23 08:50:54 +02:00
|
|
|
if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-certificate'],'icon'=>'certificate','collapse'=>'hide-sm-dn','link'=>'../certificates/index.php?name='.urlencode($contact_name_given." ".$contact_name_family)]);
|
2014-08-23 08:50:54 +02:00
|
|
|
}
|
2019-03-07 03:54:12 +01:00
|
|
|
if ($action == "update" && permission_exists('user_edit') && is_uuid($contact_user_uuid)) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-user'],'icon'=>'user','collapse'=>'hide-sm-dn','link'=>'../../core/users/user_edit.php?id='.urlencode($contact_user_uuid)]);
|
2019-03-07 03:54:12 +01:00
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
if (
|
|
|
|
|
$action == "update" && (
|
|
|
|
|
permission_exists('contact_phone_add') ||
|
|
|
|
|
permission_exists('contact_address_add') ||
|
|
|
|
|
permission_exists('contact_email_add') ||
|
|
|
|
|
permission_exists('contact_url_add') ||
|
|
|
|
|
permission_exists('contact_relation_add') ||
|
|
|
|
|
permission_exists('contact_note_add') ||
|
|
|
|
|
permission_exists('contact_time_add') ||
|
|
|
|
|
permission_exists('contact_setting_add') ||
|
|
|
|
|
permission_exists('contact_attachment_add')
|
|
|
|
|
)) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'style'=>'margin-left: 15px;','collapse'=>'hide-sm-dn','onclick'=>"document.getElementById('select_add').style.display='inline'; this.style.display='none';"]);
|
|
|
|
|
echo "<select class='formfld' style='display: none; width: auto; margin-left: 15px;' id='select_add' onchange=\"document.location.href='contact_' + (this.options[this.selectedIndex].value) + '_edit.php?contact_uuid=".urlencode($contact_uuid)."';\">\n";
|
|
|
|
|
echo " <option value=''>".$text['button-add']."...</option>\n";
|
|
|
|
|
if (permission_exists('contact_phone_add')) { echo "<option value='phone'>".$text['label-phone_number']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_address_add')) { echo "<option value='address'>".$text['label-address_address']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_email_add')) { echo "<option value='email'>".$text['label-email']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_url_add')) { echo "<option value='url'>".$text['label-url']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_relation_add')) { echo "<option value='relation'>".$text['label-contact_relation_label']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_note_add')) { echo "<option value='note'>".$text['label-contact_note']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_time_add')) { echo "<option value='time'>".$text['label-time_time']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_setting_add')) { echo "<option value='setting'>".$text['label-setting']."</option>\n"; }
|
|
|
|
|
if (permission_exists('contact_attachment_add')) { echo "<option value='attachment'>".$text['label-attachment']."</option>\n"; }
|
|
|
|
|
echo " </select>";
|
|
|
|
|
}
|
2020-01-24 05:41:09 +01:00
|
|
|
if ($action == "update") {
|
|
|
|
|
if (
|
|
|
|
|
permission_exists('contact_delete') && (
|
|
|
|
|
permission_exists('contact_phone_delete') ||
|
|
|
|
|
permission_exists('contact_address_delete') ||
|
|
|
|
|
permission_exists('contact_email_delete') ||
|
|
|
|
|
permission_exists('contact_url_delete') ||
|
|
|
|
|
permission_exists('contact_relation_delete') ||
|
|
|
|
|
permission_exists('contact_note_delete') ||
|
|
|
|
|
permission_exists('contact_time_delete') ||
|
|
|
|
|
permission_exists('contact_setting_delete') ||
|
|
|
|
|
permission_exists('contact_attachment_delete')
|
|
|
|
|
)) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-sm-dn','link'=>'#modal-delete']);
|
|
|
|
|
echo modal::create([
|
|
|
|
|
'id'=>'modal-delete',
|
|
|
|
|
'title'=>$text['modal_title-confirmation'],
|
|
|
|
|
'message'=>$text['message-delete_selection'],
|
|
|
|
|
'actions'=>
|
2020-01-26 23:39:48 +01:00
|
|
|
button::create(['type'=>'button','label'=>$text['button-cancel'],'icon'=>'times','collapse'=>'hide-xs','onclick'=>'modal_close();']).
|
2020-01-24 05:41:09 +01:00
|
|
|
button::create(['type'=>'button','label'=>$text['label-contact'],'icon'=>$_SESSION['theme']['button_icon_user'],'style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); if (confirm('".$text['confirm-delete']."')) { document.getElementById('contact_action').value='delete_contact'; document.getElementById('frm').submit(); } else { this.blur(); return false; }"]).
|
|
|
|
|
button::create(['type'=>'button','label'=>$text['label-properties'],'icon'=>'check-square','collapse'=>'never','style'=>'float: right;','onclick'=>"modal_close(); list_action_set('delete_properties'); list_form_submit('form_list');"])
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (permission_exists('contact_delete')) {
|
2020-02-03 16:20:33 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-sm-dn','link'=>'#modal-delete']);
|
2020-01-24 05:41:09 +01:00
|
|
|
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); document.getElementById('contact_action').value='delete_contact'; document.getElementById('frm').submit();"])]);
|
|
|
|
|
}
|
2020-02-03 16:20:33 +01:00
|
|
|
else if (
|
|
|
|
|
permission_exists('contact_phone_delete') ||
|
|
|
|
|
permission_exists('contact_address_delete') ||
|
|
|
|
|
permission_exists('contact_email_delete') ||
|
|
|
|
|
permission_exists('contact_url_delete') ||
|
|
|
|
|
permission_exists('contact_relation_delete') ||
|
|
|
|
|
permission_exists('contact_note_delete') ||
|
|
|
|
|
permission_exists('contact_time_delete') ||
|
|
|
|
|
permission_exists('contact_setting_delete') ||
|
|
|
|
|
permission_exists('contact_attachment_delete')
|
|
|
|
|
) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-sm-dn','link'=>'#modal-delete']);
|
2020-01-24 05:41:09 +01:00
|
|
|
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete_properties'); list_form_submit('form_list');"])]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
}
|
2020-02-25 02:29:23 +01:00
|
|
|
if (permission_exists('contact_edit') || permission_exists('contact_add')) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>($action != 'update' ?: 'margin-left: 15px;'),'collapse'=>'hide-sm-dn','onclick'=>"document.getElementById('frm').submit();"]);
|
|
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div style='clear: both;'></div>\n";
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
|
|
|
|
if ($action == "add") {
|
|
|
|
|
echo $text['description-contact-add']."\n";
|
|
|
|
|
}
|
|
|
|
|
else if ($action == "update") {
|
|
|
|
|
echo $text['description-contact-edit']."\n";
|
2013-05-10 02:40:24 +02:00
|
|
|
}
|
|
|
|
|
echo "<br /><br />\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-11-19 04:44:41 +01:00
|
|
|
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
|
|
|
|
|
echo "<form id='frm' method='post'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-02-26 05:47:41 +01:00
|
|
|
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2014-04-27 01:37:41 +02:00
|
|
|
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_type']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<td width='70%' class='vtable' align='left'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
if (is_array($_SESSION["contact"]["type"])) {
|
|
|
|
|
sort($_SESSION["contact"]["type"]);
|
2014-04-27 12:04:12 +02:00
|
|
|
echo " <select class='formfld' name='contact_type'>\n";
|
2014-11-25 19:38:22 +01:00
|
|
|
echo " <option value=''></option>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
foreach($_SESSION["contact"]["type"] as $type) {
|
|
|
|
|
echo " <option value='".escape($type)."' ".(($type == $contact_type) ? "selected='selected'" : null).">".escape($type)."</option>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2014-04-27 12:04:12 +02:00
|
|
|
echo " <select class='formfld' name='contact_type'>\n";
|
2014-11-25 19:38:22 +01:00
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
echo " <option value='customer' ".(($contact_type == "customer") ? "selected='selected'" : null).">".$text['option-contact_type_customer']."</option>\n";
|
|
|
|
|
echo " <option value='contractor' ".(($contact_type == "contractor") ? "selected='selected'" : null).">".$text['option-contact_type_contractor']."</option>\n";
|
|
|
|
|
echo " <option value='friend' ".(($contact_type == "friend") ? "selected='selected'" : null).">".$text['option-contact_type_friend']."</option>\n";
|
|
|
|
|
echo " <option value='lead' ".(($contact_type == "lead") ? "selected='selected'" : null).">".$text['option-contact_type_lead']."</option>\n";
|
|
|
|
|
echo " <option value='member' ".(($contact_type == "member") ? "selected='selected'" : null).">".$text['option-contact_type_member']."</option>\n";
|
|
|
|
|
echo " <option value='family' ".(($contact_type == "family") ? "selected='selected'" : null).">".$text['option-contact_type_family']."</option>\n";
|
|
|
|
|
echo " <option value='subscriber' ".(($contact_type == "subscriber") ? "selected='selected'" : null).">".$text['option-contact_type_subscriber']."</option>\n";
|
|
|
|
|
echo " <option value='supplier' ".(($contact_type == "supplier") ? "selected='selected'" : null).">".$text['option-contact_type_supplier']."</option>\n";
|
|
|
|
|
echo " <option value='provider' ".(($contact_type == "provider") ? "selected='selected'" : null).">".$text['option-contact_type_provider']."</option>\n";
|
|
|
|
|
echo " <option value='user' ".(($contact_type == "user") ? "selected='selected'" : null).">".$text['option-contact_type_user']."</option>\n";
|
|
|
|
|
echo " <option value='volunteer' ".(($contact_type == "volunteer") ? "selected='selected'" : null).">".$text['option-contact_type_volunteer']."</option>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
echo " </select>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_organization']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_organization' maxlength='255' value=\"".escape($contact_organization)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-11-22 01:06:38 +01:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-contact_name_prefix']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_name_prefix' maxlength='255' value=\"".escape($contact_name_prefix)."\">\n";
|
2014-11-22 01:06:38 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_name_given']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_name_given' maxlength='255' value=\"".escape($contact_name_given)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-11-22 01:06:38 +01:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-contact_name_middle']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_name_middle' maxlength='255' value=\"".escape($contact_name_middle)."\">\n";
|
2014-11-22 01:06:38 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_name_family']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_name_family' maxlength='255' value=\"".escape($contact_name_family)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-22 01:06:38 +01:00
|
|
|
echo " ".$text['label-contact_name_suffix']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_name_suffix' maxlength='255' value=\"".escape($contact_name_suffix)."\">\n";
|
2014-11-22 01:06:38 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_nickname']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_nickname' maxlength='255' value=\"".escape($contact_nickname)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_title']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
if (is_array($_SESSION["contact"]["title"])) {
|
|
|
|
|
sort($_SESSION["contact"]["title"]);
|
2014-07-26 08:31:11 +02:00
|
|
|
echo " <select class='formfld' name='contact_title'>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
echo " <option value=''></option>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
foreach($_SESSION["contact"]["title"] as $title) {
|
|
|
|
|
echo " <option value='".escape($title)."' ".(($title == $contact_title) ? "selected='selected'" : null).">".escape($title)."</option>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_title' maxlength='255' value=\"".escape($contact_title)."\">\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2013-02-07 10:57:03 +01:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_category']."\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
if (is_array($_SESSION["contact"]["category"])) {
|
|
|
|
|
sort($_SESSION["contact"]["category"]);
|
2014-07-26 08:31:11 +02:00
|
|
|
echo " <select class='formfld' name='contact_category'>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
echo " <option value=''></option>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
foreach($_SESSION["contact"]["category"] as $category) {
|
|
|
|
|
echo " <option value='".escape($category)."' ".(($category == $contact_category) ? "selected='selected'" : null).">".escape($category)."</option>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_category' maxlength='255' value=\"".escape($contact_category)."\">\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_role']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
if (is_array($_SESSION["contact"]["role"])) {
|
|
|
|
|
sort($_SESSION["contact"]["role"]);
|
2014-07-26 08:31:11 +02:00
|
|
|
echo " <select class='formfld' name='contact_role'>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
echo " <option value=''></option>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
foreach($_SESSION["contact"]["role"] as $role) {
|
|
|
|
|
echo " <option value='".escape($role)."' ".(($role == $contact_role) ? "selected='selected'" : null).">".escape($role)."</option>\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_role' maxlength='255' value=\"".escape($contact_role)."\">\n";
|
2013-02-07 10:57:03 +01:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2014-11-19 04:44:41 +01:00
|
|
|
echo " ".$text['label-contact_time_zone']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <input class='formfld' type='text' name='contact_time_zone' maxlength='255' value=\"".escape($contact_time_zone)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2016-01-19 00:53:19 +01:00
|
|
|
if (permission_exists('contact_user_edit')) {
|
2016-01-18 22:17:59 +01:00
|
|
|
echo " <tr>";
|
|
|
|
|
echo " <td class='vncell' valign='top'>".$text['label-users']."</td>";
|
|
|
|
|
echo " <td class='vtable' align='left'>";
|
2020-01-24 05:24:10 +01:00
|
|
|
if ($action == "update" && is_array($contact_users) && @sizeof($contact_users) != 0) {
|
|
|
|
|
echo " <table border='0' style='width: 100%;'>\n";
|
|
|
|
|
foreach ($contact_users as $field) {
|
2016-01-18 22:17:59 +01:00
|
|
|
echo " <tr>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <td class='vtable' style='width: 100%;'>".escape($field['username'])."</td>\n";
|
|
|
|
|
echo " <td>\n";
|
2016-01-19 00:53:19 +01:00
|
|
|
if (permission_exists('contact_user_delete')) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <a href='contact_user_delete.php?id=".urlencode($field['contact_user_uuid'])."&contact_uuid=".urlencode($contact_uuid)."' alt='delete' onclick=\"return confirm('".$text['confirm-delete']."');\">$v_link_label_delete</a>\n";
|
2016-01-19 00:53:19 +01:00
|
|
|
}
|
2016-01-18 22:17:59 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </table>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <br />\n";
|
2016-01-18 22:17:59 +01:00
|
|
|
}
|
2016-01-19 00:53:19 +01:00
|
|
|
if (permission_exists('contact_user_add')) {
|
|
|
|
|
echo " <select name=\"user_uuid\" class='formfld' style='width: auto;'>\n";
|
|
|
|
|
echo " <option value=\"\"></option>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
foreach ($users as $field) {
|
|
|
|
|
if (in_array($field['user_uuid'], array_column($contact_users, 'user_uuid'))) { continue; } //skip users already assigned
|
2018-06-13 08:25:52 +02:00
|
|
|
echo " <option value='".escape($field['user_uuid'])."'>".escape($field['username'])."</option>\n";
|
2016-01-19 00:53:19 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>";
|
|
|
|
|
if ($action == "update") {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
|
2016-01-19 00:53:19 +01:00
|
|
|
}
|
|
|
|
|
unset($users);
|
|
|
|
|
echo " <br>\n";
|
|
|
|
|
echo " ".$text['description-users']."\n";
|
2016-01-18 22:17:59 +01:00
|
|
|
}
|
|
|
|
|
echo " </td>";
|
|
|
|
|
echo " </tr>";
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-15 22:11:17 +02:00
|
|
|
if (permission_exists('contact_group_view')) {
|
|
|
|
|
echo "<tr>";
|
2015-02-06 05:11:11 +01:00
|
|
|
echo " <td width='30%' class='vncell' valign='top'>".$text['label-groups']."</td>";
|
2014-10-18 08:49:34 +02:00
|
|
|
echo " <td width='70%' class='vtable'>";
|
2014-10-15 22:11:17 +02:00
|
|
|
$sql = "select ";
|
|
|
|
|
$sql .= "g.*, ";
|
|
|
|
|
$sql .= "cg.contact_group_uuid ";
|
|
|
|
|
$sql .= "from ";
|
|
|
|
|
$sql .= "v_groups as g, ";
|
|
|
|
|
$sql .= "v_contact_groups as cg ";
|
|
|
|
|
$sql .= "where ";
|
|
|
|
|
$sql .= "cg.group_uuid = g.group_uuid ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql .= "and cg.domain_uuid = :domain_uuid ";
|
|
|
|
|
$sql .= "and cg.contact_uuid = :contact_uuid ";
|
|
|
|
|
$sql .= "and cg.group_uuid <> :group_uuid ";
|
2014-10-15 22:11:17 +02:00
|
|
|
$sql .= "order by g.group_name asc ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$parameters['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$parameters['contact_uuid'] = $contact_uuid;
|
|
|
|
|
$parameters['group_uuid'] = $_SESSION["user_uuid"];
|
|
|
|
|
$database = new database;
|
|
|
|
|
$result = $database->select($sql, $parameters, 'all');
|
|
|
|
|
if (is_array($result) && @sizeof($result) != 0) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <table style='width: 100%;'>\n";
|
|
|
|
|
foreach ($result as $field) {
|
2014-10-15 22:11:17 +02:00
|
|
|
if (strlen($field['group_name']) > 0) {
|
|
|
|
|
echo "<tr>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <td class='vtable' style='width: 100%;'>".escape($field['group_name'])."</td>\n";
|
2014-10-15 22:11:17 +02:00
|
|
|
echo " <td>\n";
|
|
|
|
|
if (permission_exists('contact_group_delete') || if_group("superadmin")) {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <a href='contact_group_delete.php?id=".urlencode($field['contact_group_uuid'])."&contact_uuid=".urlencode($contact_uuid)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."');\">$v_link_label_delete</a>\n";
|
2014-10-15 22:11:17 +02:00
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
$assigned_groups[] = $field['group_uuid'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo " <br />\n";
|
|
|
|
|
}
|
2019-07-28 06:51:01 +02:00
|
|
|
unset($sql, $parameters, $result, $field);
|
2014-10-15 22:11:17 +02:00
|
|
|
|
|
|
|
|
if (permission_exists('contact_group_add') || if_group("superadmin")) {
|
|
|
|
|
$sql = "select * from v_groups ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
2015-02-06 05:11:11 +01:00
|
|
|
$sql .= "or domain_uuid is null ";
|
2019-07-28 06:51:01 +02:00
|
|
|
if (is_array($assigned_groups) && @sizeof($assigned_groups) != 0) {
|
|
|
|
|
foreach ($assigned_groups as $index => $assigned_group) {
|
|
|
|
|
$sql_where_and[] = "group_uuid <> :group_uuid_".$index." ";
|
|
|
|
|
$parameters['group_uuid_'.$index] = $assigned_group;
|
|
|
|
|
}
|
|
|
|
|
if (is_array($sql_where_and) && @sizeof($sql_where_and) != 0) {
|
|
|
|
|
$sql .= "and ".implode(' and ', $sql_where_and)." ";
|
|
|
|
|
}
|
2014-10-15 22:11:17 +02:00
|
|
|
}
|
|
|
|
|
$sql .= "order by group_name asc ";
|
2019-07-28 06:51:01 +02:00
|
|
|
$parameters['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$result = $database->select($sql, $parameters, 'all');
|
|
|
|
|
unset($sql, $sql_where_and, $index, $parameters, $assigned_groups, $assigned_group);
|
|
|
|
|
|
|
|
|
|
if (is_array($result) && @sizeof($result) != 0) {
|
2014-10-15 22:11:17 +02:00
|
|
|
echo " <select name='group_uuid' class='formfld' style='width: auto; margin-right: 3px;'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
foreach ($result as $field) {
|
2014-10-15 22:11:17 +02:00
|
|
|
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show superadmin group to superadmins
|
|
|
|
|
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin"))) { continue; } //only show admin group to admins
|
2018-07-02 18:52:38 +02:00
|
|
|
echo "<option value='".escape($field['group_uuid'])."'>".escape($field['group_name'])."</option>\n";
|
2014-10-15 22:11:17 +02:00
|
|
|
}
|
|
|
|
|
echo " </select>";
|
|
|
|
|
|
|
|
|
|
if ($action == "update") {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
|
2014-10-15 22:11:17 +02:00
|
|
|
}
|
|
|
|
|
echo "<br>";
|
|
|
|
|
}
|
2019-07-28 06:51:01 +02:00
|
|
|
unset($result, $field);
|
2014-10-15 22:11:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo " ".$text['description-groups']."\n";
|
|
|
|
|
|
|
|
|
|
echo " </td>";
|
|
|
|
|
echo "</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-contact_note']."\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " <td width='70%' class='vtable' align='left'>\n";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo " <textarea class='formfld' style='width: 100%; height: 160px;' name='contact_note'>".$contact_note."</textarea>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
echo " </td>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</tr>\n";
|
2019-08-19 00:10:05 +02:00
|
|
|
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "</table>";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
if ($action == "update") {
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<input type='hidden' id='contact_action' name='action' value=''>\n";
|
|
|
|
|
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
2019-03-01 14:08:47 +01:00
|
|
|
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "</form>";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
echo "</td>\n";
|
2014-04-27 01:37:41 +02:00
|
|
|
|
|
|
|
|
if ($action == "update") {
|
2014-11-19 04:44:41 +01:00
|
|
|
echo "<td> </td>";
|
2020-01-24 05:24:10 +01:00
|
|
|
echo "<td width='100%' valign='top'>\n";
|
|
|
|
|
|
|
|
|
|
echo "<form id='form_list' method='post'>\n";
|
|
|
|
|
echo "<input type='hidden' id='action' name='action' value=''>\n";
|
|
|
|
|
|
|
|
|
|
if (permission_exists('contact_phone_view')) { require "contact_phones.php"; }
|
|
|
|
|
if (permission_exists('contact_address_view')) { require "contact_addresses.php"; }
|
|
|
|
|
if (permission_exists('contact_email_view')) { require "contact_emails.php"; }
|
|
|
|
|
if (permission_exists('contact_url_view')) { require "contact_urls.php"; }
|
|
|
|
|
if (permission_exists('contact_extension_view')) { require "contact_extensions.php"; }
|
|
|
|
|
if (permission_exists('contact_relation_view')) { require "contact_relations.php"; }
|
|
|
|
|
if (permission_exists('contact_note_view')) { require "contact_notes.php"; }
|
|
|
|
|
if (permission_exists('contact_time_view')) { require "contact_times.php"; }
|
|
|
|
|
if (permission_exists('contact_setting_view')) { require "contact_settings.php"; }
|
|
|
|
|
if (permission_exists('contact_attachment_view')) { require "contact_attachments.php"; }
|
|
|
|
|
|
|
|
|
|
if ($action == "update") {
|
|
|
|
|
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
|
|
|
|
|
}
|
|
|
|
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
|
|
|
|
|
|
|
|
|
echo "</form>";
|
|
|
|
|
|
2014-04-27 01:37:41 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "</table>\n";
|
2015-02-15 12:57:14 +01:00
|
|
|
echo "<br><br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//include the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2016-01-13 04:48:22 +01:00
|
|
|
|
2020-02-25 02:29:23 +01:00
|
|
|
?>
|