Portions created by the Initial Developer are Copyright (C) 2018 - 2022 the Initial Developer. All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('contact_add') || permission_exists('contact_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (is_uuid($_REQUEST["id"])) { $action = "update"; $contact_uuid = $_REQUEST["id"]; $id = $_REQUEST["id"]; } else { $action = "add"; } //get http post variables and set them to php variables if (is_array($_POST)) { $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_type = $_POST["contact_type"]; $contact_title = $_POST["contact_title"]; $contact_role = $_POST["contact_role"]; $contact_category = $_POST["contact_category"]; $contact_time_zone = $_POST["contact_time_zone"]; $contact_note = $_POST["contact_note"]; $last_mod_date = $_POST["last_mod_date"]; $last_mod_user = $_POST["last_mod_user"]; //$contact_users = $_POST["contact_users"]; //$contact_groups = $_POST["contact_groups"]; $contact_user_uuid = $_POST["contact_user_uuid"]; $contact_group_uuid = $_POST["contact_group_uuid"]; $contact_phones = $_POST["contact_phones"]; $contact_addresses = $_POST["contact_addresses"]; $contact_emails = $_POST["contact_emails"]; $contact_urls = $_POST["contact_urls"]; $contact_relations = $_POST["contact_relations"]; $contact_settings = $_POST["contact_settings"]; $contact_attachments = $_POST["contact_attachments"]; $contact_times = $_POST["contact_times"]; $contact_notes = $_POST["contact_notes"]; } //process the user data and save it to the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //debug info //view_array($_POST, true); //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: contacts.php'); exit; } //process the http post data by submitted action if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { //prepare the array(s) $x = 0; foreach ($_POST['contact_users'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_users'][]['contact_user_uuid'] = $row['contact_user_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_groups'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_groups'][]['contact_group_uuid'] = $row['contact_group_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_phones'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_phones'][]['contact_phone_uuid'] = $row['contact_phone_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_addresses'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_addresses'][]['contact_address_uuid'] = $row['contact_address_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_emails'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_emails'][]['contact_email_uuid'] = $row['contact_email_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_urls'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_urls'][]['contact_url_uuid'] = $row['contact_url_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_relations'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_relations'][]['contact_relation_uuid'] = $row['contact_relation_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_settings'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_settings'][]['contact_setting_uuid'] = $row['contact_setting_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_attachments'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_attachments'][]['contact_attachment_uuid'] = $row['contact_attachment_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_times'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_times'][]['contact_time_uuid'] = $row['contact_time_uuid']; $x++; } } $x = 0; foreach ($_POST['contact_notes'] as $row) { if (is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { $array['contacts'][$x]['checked'] = $row['checked']; $array['contacts'][$x]['contact_notes'][]['contact_note_uuid'] = $row['contact_note_uuid']; $x++; } } //send the array to the database class switch ($_POST['action']) { case 'copy': if (permission_exists('contact_add')) { $obj = new database; $obj->copy($array); } break; case 'delete': if (permission_exists('contact_delete')) { $obj = new database; $obj->delete($array); } break; case 'toggle': if (permission_exists('contact_update')) { $obj = new database; $obj->toggle($array); } break; } //redirect the user if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) { header('Location: contact_edit.php?id='.$id); exit; } } //check for all required data $msg = ''; //if (strlen($contact_type) == 0) { $msg .= $text['message-required']." ".$text['label-contact_type']."
\n"; } //if (strlen($contact_title) == 0) { $msg .= $text['message-required']." ".$text['label-contact_title']."
\n"; } //if (strlen($contact_role) == 0) { $msg .= $text['message-required']." ".$text['label-contact_role']."
\n"; } //if (strlen($contact_category) == 0) { $msg .= $text['message-required']." ".$text['label-contact_category']."
\n"; } //if (strlen($contact_organization) == 0) { $msg .= $text['message-required']." ".$text['label-contact_organization']."
\n"; } //if (strlen($contact_name_prefix) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_prefix']."
\n"; } //if (strlen($contact_name_given) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_given']."
\n"; } //if (strlen($contact_name_middle) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_middle']."
\n"; } //if (strlen($contact_name_family) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_family']."
\n"; } //if (strlen($contact_name_suffix) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_suffix']."
\n"; } //if (strlen($contact_nickname) == 0) { $msg .= $text['message-required']." ".$text['label-contact_nickname']."
\n"; } //if (strlen($contact_time_zone) == 0) { $msg .= $text['message-required']." ".$text['label-contact_time_zone']."
\n"; } //if (strlen($last_mod_date) == 0) { $msg .= $text['message-required']." ".$text['label-last_mod_date']."
\n"; } //if (strlen($last_mod_user) == 0) { $msg .= $text['message-required']." ".$text['label-last_mod_user']."
\n"; } //if (strlen($contact_phones) == 0) { $msg .= $text['message-required']." ".$text['label-contact_phones']."
\n"; } //if (strlen($contact_addresses) == 0) { $msg .= $text['message-required']." ".$text['label-contact_addresses']."
\n"; } //if (strlen($contact_emails) == 0) { $msg .= $text['message-required']." ".$text['label-contact_emails']."
\n"; } //if (strlen($contact_urls) == 0) { $msg .= $text['message-required']." ".$text['label-contact_urls']."
\n"; } //if (strlen($contact_settings) == 0) { $msg .= $text['message-required']." ".$text['label-contact_settings']."
\n"; } //if (strlen($contact_user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-contact_user_uuid']."
\n"; } //if (strlen($contact_group_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-contact_group_uuid']."
\n"; } //if (strlen($contact_note) == 0) { $msg .= $text['message-required']." ".$text['label-contact_note']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add the contact_uuid if (!is_uuid($_POST["contact_uuid"])) { $contact_uuid = uuid(); } //prepare the array $array['contacts'][0]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_type'] = $contact_type; $array['contacts'][0]['contact_title'] = $contact_title; $array['contacts'][0]['contact_role'] = $contact_role; $array['contacts'][0]['contact_category'] = $contact_category; $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_time_zone'] = $contact_time_zone; $array['contacts'][0]['last_mod_date'] = "now()"; $array['contacts'][0]['last_mod_user'] = $_SESSION['user_uuid']; $array['contacts'][0]['contact_note'] = $contact_note; $y = 0; if (isset($contact_user_uuid)) { $array['contacts'][0]['contact_users'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_users'][$y]['contact_user_uuid'] = uuid(); $array['contacts'][0]['contact_users'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_users'][$y]['user_uuid'] = $contact_user_uuid; $y++; } $y = 0; if (isset($contact_group_uuid)) { $array['contacts'][0]['contact_groups'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_groups'][$y]['contact_group_uuid'] = uuid(); $array['contacts'][0]['contact_groups'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_groups'][$y]['group_uuid'] = $contact_group_uuid; $y++; } $y = 0; if (is_array($contact_phones)) { foreach ($contact_phones as $row) { if (strlen($row['phone_number']) > 0) { $array['contacts'][0]['contact_phones'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_phones'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_phones'][$y]['contact_phone_uuid'] = $row["contact_phone_uuid"]; $array['contacts'][0]['contact_phones'][$y]['phone_label'] = $row["phone_label"]; $array['contacts'][0]['contact_phones'][$y]['phone_type_voice'] = $row["phone_type_voice"]; $array['contacts'][0]['contact_phones'][$y]['phone_type_fax'] = $row["phone_type_fax"]; $array['contacts'][0]['contact_phones'][$y]['phone_type_video'] = $row["phone_type_video"]; $array['contacts'][0]['contact_phones'][$y]['phone_type_text'] = $row["phone_type_text"]; $array['contacts'][0]['contact_phones'][$y]['phone_speed_dial'] = $row["phone_speed_dial"]; $array['contacts'][0]['contact_phones'][$y]['phone_country_code'] = $row["phone_country_code"]; $array['contacts'][0]['contact_phones'][$y]['phone_number'] = $row["phone_number"]; $array['contacts'][0]['contact_phones'][$y]['phone_extension'] = $row["phone_extension"]; $array['contacts'][0]['contact_phones'][$y]['phone_primary'] = $row["phone_primary"]; $array['contacts'][0]['contact_phones'][$y]['phone_description'] = $row["phone_description"]; $y++; } } } $y = 0; if (is_array($contact_addresses)) { foreach ($contact_addresses as $row) { if (strlen($row['address_street']) > 0) { $array['contacts'][0]['contact_addresses'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_addresses'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_addresses'][$y]['contact_address_uuid'] = $row["contact_address_uuid"]; $array['contacts'][0]['contact_addresses'][$y]['address_label'] = $row["address_label"]; $array['contacts'][0]['contact_addresses'][$y]['address_type'] = $row["address_type"]; $array['contacts'][0]['contact_addresses'][$y]['address_street'] = $row["address_street"]; $array['contacts'][0]['contact_addresses'][$y]['address_extended'] = $row["address_extended"]; if (permission_exists('address_community')) { $array['contacts'][0]['contact_addresses'][$y]['address_community'] = $row["address_community"]; } $array['contacts'][0]['contact_addresses'][$y]['address_locality'] = $row["address_locality"]; $array['contacts'][0]['contact_addresses'][$y]['address_region'] = $row["address_region"]; $array['contacts'][0]['contact_addresses'][$y]['address_postal_code'] = $row["address_postal_code"]; $array['contacts'][0]['contact_addresses'][$y]['address_country'] = $row["address_country"]; if (permission_exists('address_latitude')) { $array['contacts'][0]['contact_addresses'][$y]['address_latitude'] = $row["address_latitude"]; } if (permission_exists('address_longitude')) { $array['contacts'][0]['contact_addresses'][$y]['address_longitude'] = $row["address_longitude"]; } $array['contacts'][0]['contact_addresses'][$y]['address_primary'] = $row["address_primary"]; $array['contacts'][0]['contact_addresses'][$y]['address_description'] = $row["address_description"]; $y++; } } } $y = 0; if (is_array($contact_emails)) { foreach ($contact_emails as $row) { if (strlen($row['email_address']) > 0) { $array['contacts'][0]['contact_emails'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_emails'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_emails'][$y]['contact_email_uuid'] = $row["contact_email_uuid"]; $array['contacts'][0]['contact_emails'][$y]['email_label'] = $row["email_label"]; $array['contacts'][0]['contact_emails'][$y]['email_address'] = $row["email_address"]; $array['contacts'][0]['contact_emails'][$y]['email_primary'] = $row["email_primary"]; $array['contacts'][0]['contact_emails'][$y]['email_description'] = $row["email_description"]; $y++; } } } $y = 0; if (is_array($contact_urls)) { foreach ($contact_urls as $row) { if (strlen($row['url_address']) > 0) { $array['contacts'][0]['contact_urls'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_urls'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_urls'][$y]['contact_url_uuid'] = $row["contact_url_uuid"]; $array['contacts'][0]['contact_urls'][$y]['url_type'] = $row["url_type"]; $array['contacts'][0]['contact_urls'][$y]['url_label'] = $row["url_label"]; $array['contacts'][0]['contact_urls'][$y]['url_address'] = $row["url_address"]; $array['contacts'][0]['contact_urls'][$y]['url_primary'] = $row["url_primary"]; $array['contacts'][0]['contact_urls'][$y]['url_description'] = $row["url_description"]; $y++; } } } $y = 0; if (is_array($contact_relations)) { foreach ($contact_relations as $row) { if (strlen($row['contact_relation_uuid']) > 0) { $array['contacts'][0]['contact_relations'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_relations'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_relations'][$y]['contact_relation_uuid'] = $row["contact_relation_uuid"]; $array['contacts'][0]['contact_relations'][$y]['relation_label'] = $row["relation_label"]; $array['contacts'][0]['contact_relations'][$y]['relation_contact_uuid'] = $row["relation_contact_uuid"]; $y++; } } } $y = 0; if (is_array($contact_settings)) { foreach ($contact_settings as $row) { if (strlen($row['contact_setting_category']) > 0 && strlen($row['contact_setting_subcategory']) > 0 && strlen($row['contact_setting_name']) > 0) { $array['contacts'][0]['contact_settings'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_settings'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_settings'][$y]['contact_setting_uuid'] = $row["contact_setting_uuid"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_category'] = $row["contact_setting_category"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_subcategory'] = $row["contact_setting_subcategory"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_name'] = $row["contact_setting_name"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_value'] = $row["contact_setting_value"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_order'] = $row["contact_setting_order"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_enabled'] = $row["contact_setting_enabled"]; $array['contacts'][0]['contact_settings'][$y]['contact_setting_description'] = $row["contact_setting_description"]; $y++; } } } $y = 0; if (is_array($contact_attachments)) { foreach ($contact_attachments as $row) { if (strlen($row['attachment_description']) > 0) { $array['contacts'][0]['contact_attachments'][$y]['contact_attachment_uuid'] = $row["contact_attachment_uuid"]; $array['contacts'][0]['contact_attachments'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_attachments'][$y]['contact_uuid'] = $row["contact_uuid"]; $array['contacts'][0]['contact_attachments'][$y]['attachment_primary'] = $row["attachment_primary"]; //$array['contacts'][0]['contact_attachments'][$y]['attachment_filename'] = $row["attachment_filename"]; //$array['contacts'][0]['contact_attachments'][$y]['attachment_content'] = $row["attachment_content"]; $array['contacts'][0]['contact_attachments'][$y]['attachment_description'] = $row["attachment_description"]; //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_date'] = $row["attachment_uploaded_date"]; //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_user_uuid'] = $row["attachment_uploaded_user_uuid"]; //$array['contacts'][0]['contact_attachments'][$y]['attachment_size'] = $row["attachment_size"]; $y++; } } } $y = 0; if (is_array($contact_times)) { foreach ($contact_times as $row) { if (strlen($row['time_start']) > 0) { $array['contacts'][0]['contact_times'][$y]['contact_time_uuid'] = $row["contact_time_uuid"]; $array['contacts'][0]['contact_times'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_times'][$y]['contact_uuid'] = $row["contact_uuid"]; $array['contacts'][0]['contact_times'][$y]['time_start'] = $row["time_start"]; $array['contacts'][0]['contact_times'][$y]['time_stop'] = $row["time_stop"]; $array['contacts'][0]['contact_times'][$y]['time_description'] = $row["time_description"]; $y++; } } } $y = 0; if (is_array($contact_notes)) { foreach ($contact_notes as $row) { if (strlen($row['contact_note']) > 0) { $array['contacts'][0]['contact_notes'][$y]['contact_note_uuid'] = $row["contact_note_uuid"]; $array['contacts'][0]['contact_notes'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_notes'][$y]['contact_uuid'] = $row["contact_uuid"]; $array['contacts'][0]['contact_notes'][$y]['contact_note'] = $row["contact_note"]; $array['contacts'][0]['contact_notes'][$y]['last_mod_date'] = 'now()'; $array['contacts'][0]['contact_notes'][$y]['last_mod_user'] = $_SESSION['username']; $y++; } } } //save the data if (is_array($array) && @sizeof($array) != 0) { //add the permission object $p = new permissions; $p->add('contact_add', 'temp'); $p->add('contact_phone_add', 'temp'); $p->add('contact_address_add', 'temp'); $p->add('contact_user_add', 'temp'); $p->add('contact_group_add', 'temp'); //view_array($array); $database = new database; $database->app_name = 'contacts'; $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c'; $database->save($array); $message = $database->message; unset($array); //view_array($message); $p->delete('contact_add', 'temp'); $p->delete('contact_phone_add', 'temp'); $p->delete('contact_address_add', 'temp'); $p->delete('contact_user_add', 'temp'); $p->delete('contact_group_add', 'temp'); } //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } //header('Location: contacts.php'); header('Location: contact_edit.php?id='.urlencode($contact_uuid)); return; } } //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $sql = "select * from v_contacts "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = :domain_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) { $contact_organization = $row["contact_organization"]; $contact_name_prefix = $row["contact_name_prefix"]; $contact_name_given = $row["contact_name_given"]; $contact_name_middle = $row["contact_name_middle"]; $contact_name_family = $row["contact_name_family"]; $contact_name_suffix = $row["contact_name_suffix"]; $contact_nickname = $row["contact_nickname"]; $contact_type = $row["contact_type"]; $contact_title = $row["contact_title"]; $contact_role = $row["contact_role"]; $contact_category = $row["contact_category"]; $contact_time_zone = $row["contact_time_zone"]; $contact_note = $row["contact_note"]; $last_mod_date = $row["last_mod_date"]; $last_mod_user = $row["last_mod_user"]; //$contact_phones = $row["contact_phones"]; //$contact_addresses = $row["contact_addresses"]; //$contact_emails = $row["contact_emails"]; //$contact_urls = $row["contact_urls"]; //$contact_settings = $row["contact_settings"]; //$contact_user_uuid = $row["contact_user_uuid"]; $contact_user_uuid = $row["contact_user_uuid"]; $contact_group_uuid = $row["contact_group_uuid"]; } unset($sql, $parameters, $row); } //get the users array $sql = "select * from v_users "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "order by username asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $users = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //determine if contact assigned to a user if (is_array($users) && sizeof($users) != 0) { foreach ($users as $user) { if ($user['contact_uuid'] == $contact_uuid) { $contact_user_uuid = $user['user_uuid']; break; } } } //get the users assigned to this contact if (is_uuid($contact_uuid)) { $sql = "select c.domain_uuid, c.contact_uuid, u.username, u.user_uuid, a.contact_user_uuid "; $sql .= "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 "; $sql .= "and u.user_uuid = a.user_uuid "; $sql .= "and c.contact_uuid = a.contact_uuid "; $sql .= "order by u.username asc "; $parameters['contact_uuid'] = $contact_uuid; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $contact_users_assigned = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } //get the assigned groups of this contact if (is_uuid($contact_uuid)) { $sql = "select g.*, cg.contact_group_uuid "; $sql .= "from v_groups as g, v_contact_groups as cg "; $sql .= "where cg.group_uuid = g.group_uuid "; $sql .= "and cg.domain_uuid = :domain_uuid "; $sql .= "and cg.contact_uuid = :contact_uuid "; $sql .= "and cg.group_uuid <> :group_uuid "; $sql .= "order by g.group_name asc "; $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $parameters['group_uuid'] = $_SESSION["user_uuid"]; $database = new database; $contact_groups_assigned = $database->select($sql, $parameters, 'all'); if (is_array($contact_groups_assigned) && @sizeof($contact_groups_assigned) != 0) { foreach ($contact_groups_assigned as $field) { $contact_groups[] = "'".$field['group_uuid']."'"; } } unset($sql, $parameters); } //get the available groups to this contact $sql = "select group_uuid, group_name from v_groups "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; if (is_array($contact_groups) && @sizeof($contact_groups) != 0) { $sql .= "and group_uuid not in (".implode(',', $contact_groups).") "; } $sql .= "order by group_name asc "; $parameters['domain_uuid'] = $domain_uuid; $database = new database; $contact_groups_available = $database->select($sql, $parameters, 'all'); unset($sql, $parameters, $contact_groups); //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_phones "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_phones = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_phone_uuid if (!is_uuid($contact_phone_uuid)) { $contact_phone_uuid = uuid(); } //add an empty row if (!is_array($contact_phones) || count($contact_phones) == 0) { $x = is_array($contact_phones) ? count($contact_phones) : 0; $contact_phones[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_phones[$x]['contact_uuid'] = $contact_uuid; $contact_phones[$x]['contact_phone_uuid'] = uuid(); $contact_phones[$x]['phone_label'] = ''; $contact_phones[$x]['phone_type_voice'] = ''; $contact_phones[$x]['phone_type_fax'] = ''; $contact_phones[$x]['phone_type_video'] = ''; $contact_phones[$x]['phone_type_text'] = ''; $contact_phones[$x]['phone_speed_dial'] = ''; $contact_phones[$x]['phone_country_code'] = ''; $contact_phones[$x]['phone_number'] = ''; $contact_phones[$x]['phone_extension'] = ''; $contact_phones[$x]['phone_primary'] = ''; $contact_phones[$x]['phone_description'] = ''; } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_addresses "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; $sql .= "order by address_street asc"; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_addresses = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_address_uuid if (!is_uuid($contact_address_uuid)) { $contact_address_uuid = uuid(); } //add an empty row if (!is_array($contact_addresses) || count($contact_addresses) == 0) { $x = is_array($contact_addresses) ? count($contact_addresses) : 0; $contact_addresses[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_addresses[$x]['contact_uuid'] = $contact_uuid; $contact_addresses[$x]['contact_address_uuid'] = uuid(); $contact_addresses[$x]['address_label'] = ''; $contact_addresses[$x]['address_type'] = ''; $contact_addresses[$x]['address_street'] = ''; $contact_addresses[$x]['address_extended'] = ''; $contact_addresses[$x]['address_community'] = ''; $contact_addresses[$x]['address_locality'] = ''; $contact_addresses[$x]['address_region'] = ''; $contact_addresses[$x]['address_postal_code'] = ''; $contact_addresses[$x]['address_country'] = ''; $contact_addresses[$x]['address_latitude'] = ''; $contact_addresses[$x]['address_longitude'] = ''; $contact_addresses[$x]['address_primary'] = ''; $contact_addresses[$x]['address_description'] = ''; } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_emails "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_emails = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_email_uuid if (!is_uuid($contact_email_uuid)) { $contact_email_uuid = uuid(); } //add an empty row if (!is_array($contact_emails) || count($contact_emails) == 0) { $x = is_array($contact_emails) ? count($contact_emails) : 0; $contact_emails[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_emails[$x]['contact_uuid'] = $contact_uuid; $contact_emails[$x]['contact_email_uuid'] = uuid(); $contact_emails[$x]['email_label'] = ''; $contact_emails[$x]['email_address'] = ''; $contact_emails[$x]['email_primary'] = ''; $contact_emails[$x]['email_description'] = ''; } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_urls "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; $sql .= "order by url_address asc"; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_urls = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_url_uuid if (!is_uuid($contact_url_uuid)) { $contact_url_uuid = uuid(); } //add an empty row if (!is_array($contact_urls) || count($contact_urls) == 0) { $x = is_array($contact_urls) ? count($contact_urls) : 0; $contact_urls[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_urls[$x]['contact_uuid'] = $contact_uuid; $contact_urls[$x]['contact_url_uuid'] = uuid(); $contact_urls[$x]['url_type'] = ''; $contact_urls[$x]['url_label'] = ''; $contact_urls[$x]['url_address'] = ''; $contact_urls[$x]['url_primary'] = ''; $contact_urls[$x]['url_description'] = ''; } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_relations "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_relations = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_setting_uuid if (!is_uuid($contact_relation_uuid)) { $contact_relation_uuid = uuid(); } //add an empty row if (!is_array($contact_relations) || count($contact_relations) == 0) { $x = is_array($contact_relations) ? count($contact_relations) : 0; $contact_relations[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_relations[$x]['contact_uuid'] = $contact_uuid; $contact_relations[$x]['contact_relation_uuid'] = uuid(); $contact_relations[$x]['relation_label'] = ''; $contact_relations[$x]['relation_contact_uuid'] = ''; } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_settings "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_settings = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_setting_uuid if (!is_uuid($contact_setting_uuid)) { $contact_setting_uuid = uuid(); } //add an empty row if (!is_array($contact_settings) || count($contact_settings) == 0) { $x = is_array($contact_settings) ? count($contact_settings) : 0; $contact_settings[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_settings[$x]['contact_uuid'] = $contact_uuid; $contact_settings[$x]['contact_setting_uuid'] = uuid(); $contact_settings[$x]['contact_setting_category'] = ''; $contact_settings[$x]['contact_setting_subcategory'] = ''; $contact_settings[$x]['contact_setting_name'] = ''; $contact_settings[$x]['contact_setting_value'] = ''; $contact_settings[$x]['contact_setting_order'] = ''; $contact_settings[$x]['contact_setting_enabled'] = ''; $contact_settings[$x]['contact_setting_description'] = ''; } //get the contact attachments if (is_uuid($contact_uuid)) { $sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by attachment_primary desc, attachment_filename asc "; $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_attachments = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } //get the child data if (is_uuid($contact_uuid)) { $sql = "select * from v_contact_times "; $sql .= "where contact_uuid = :contact_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_times = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); } //add the $contact_time_uuid if (!is_uuid($contact_time_uuid)) { $contact_time_uuid = uuid(); } //add an empty row if (!is_array($contact_times)) { $x = is_array($contact_times) ? count($contact_times) : 0; $contact_times[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_times[$x]['contact_uuid'] = $contact_uuid; $contact_times[$x]['contact_time_uuid'] = uuid(); } //get the contact notes $sql = "select * from v_contact_notes "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by last_mod_date desc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_notes = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //add an empty row if (!is_array($contact_times)) { $x = is_array($contact_times) ? count($contact_times) : 0; $contact_times[$x]['domain_uuid'] = $_SESSION['domain_uuid']; $contact_times[$x]['contact_uuid'] = $contact_uuid; $contact_times[$x]['contact_time_uuid'] = uuid(); } //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header $document['title'] = $text['title-contact-edit']; require_once "resources/header.php"; //determine qr branding if ($_SESSION['theme']['qr_brand_type']['text'] == 'image' && $_SESSION['theme']['qr_brand_image']['text'] != '') { echo ""; $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'; } else { echo ""; $qr_option = "image: $('#img-buffer')[0],"; $qr_mode = '4'; $qr_size = '0.2'; } //qr code generation $_GET['type'] = "text"; $qr_vcard = true; include "contacts_vcard.php"; echo ""; echo ""; echo ""; echo ""; //show the content echo "
\n"; echo "\n"; echo "
\n"; echo "
".$text['title-contact-edit']."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'contacts.php']); if ($action == 'update') { if (permission_exists('contact_phone_add')) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('contact_phone_delete')) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } } //add edit if (isset($id)) { if (permission_exists('contact_time_add')) { //detect timer state (and start time) $sql = "select "; $sql .= "time_start "; $sql .= "from v_contact_times "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and user_uuid = :user_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "and time_start is not null "; $sql .= "and time_stop is null "; $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'); $btn_style = $time_start ? 'color: #fff; background-color: #3693df; background-image: none;' : null; unset($sql, $parameters); 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');"]); } 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']); } //add edit //if (isset($id)) { //echo button::create(['type'=>'button','label'=>$text['button-notes'],'icon'=>'','collapse'=>'hide-xs','style'=>'margin-right: 0px;','link'=>"contact_notes.php?id=$id"]); //} //add user if (isset($id) && permission_exists('user_edit')) { 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)]); } 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 ""; } if ( $action == "update" && ( permission_exists('contact_delete') || permission_exists('contact_user_delete') || permission_exists('contact_group_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'],'name'=>'btn_delete','collapse'=>'hide-sm-dn','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','id'=>'btn_save','collapse'=>'hide-xs']); echo "
\n"; echo "
\n"; echo "
\n"; echo $text['description-contact-edit']."\n"; echo "

\n"; if ($action == 'update') { if (permission_exists('contact_add')) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); } if (permission_exists('contact_delete')) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); } } ?> \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-name']."\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_organization']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_name_prefix']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_name_given']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_name_middle']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_name_family']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_name_suffix']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_nickname']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['option-other']."\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_type']."\n"; echo "
\n"; echo "
\n"; if (is_array($_SESSION["contact"]["type"])) { sort($_SESSION["contact"]["type"]); echo " \n"; } else { echo " \n"; } echo "
\n"; echo "
\n"; echo " ".$text['label-contact_title']."\n"; echo "
\n"; echo "
\n"; if (is_array($_SESSION['contact']['contact_title'])) { echo " \n"; } else { echo " \n"; } echo "
\n"; echo "
\n"; echo " ".$text['label-contact_role']."\n"; echo "
\n"; echo "
\n"; if (is_array($_SESSION['contact']['contact_role'])) { echo " \n"; } else { echo " \n"; } echo "
\n"; echo "
\n"; echo " ".$text['label-contact_category']."\n"; echo "
\n"; echo "
\n"; if (is_array($_SESSION['contact']['contact_category'])) { echo " \n"; } else { echo " \n"; } echo "
\n"; echo "
\n"; echo " ".$text['label-contact_time_zone']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_note']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; unset($contact_note); if ($_SESSION['contact']['permissions']['boolean'] == "true") { if (permission_exists('contact_user_view') || permission_exists('contact_group_view')) { echo "
\n"; echo "
\n"; echo " ".$text['label-permissions']."\n"; echo "
\n"; echo "
\n"; if (permission_exists('contact_user_edit')) { echo "
".$text['label-users']."
\n"; echo "
"; if ($action == "update" && is_array($contact_users_assigned) && @sizeof($contact_users_assigned) != 0) { echo "
".$text['label-username']."\n"; if ($contact_users_assigned && permission_exists('contact_user_delete')) { //echo "
\n"; echo "
\n"; echo " ".$text['label-delete']."\n"; //echo " ".$text['label-delete']."\n"; //echo " \n"; echo "
\n"; } echo "
\n"; foreach ($contact_users_assigned as $x => $field) { echo "
".escape($field['username'])."\n"; if ($contact_users_assigned && permission_exists('contact_user_delete')) { if (is_uuid($field['contact_user_uuid'])) { echo "
\n"; //echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { echo "
\n"; } echo "
\n"; } echo "
\n"; } } if (permission_exists('contact_user_add')) { echo "
\n"; echo " \n"; if ($action == "update") { echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]); } unset($users); echo "
\n"; } echo " ".$text['description-users']."\n"; echo "
\n"; } if (permission_exists('contact_group_view')) { echo "
".$text['label-groups']."
"; echo "
"; if (is_array($contact_groups_assigned) && @sizeof($contact_groups_assigned) != 0) { echo "
".$text['label-group']."\n"; if ($contact_groups_assigned && permission_exists('contact_group_delete')) { //echo "
\n"; echo "
\n"; echo " ".$text['label-delete']."\n"; //echo " ".$text['label-delete']."\n"; //echo " \n"; echo "
\n"; } echo "
\n"; foreach ($contact_groups_assigned as $x => $field) { if (strlen($field['group_name']) > 0) { echo "
".escape($field['group_name'])."\n"; if (permission_exists('contact_group_delete')) { if (is_uuid($field['contact_group_uuid'])) { echo "
"; //echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { echo "
"; } echo "
\n"; } echo "
\n"; } } } if (permission_exists('contact_group_add')) { if (is_array($contact_groups_available) && @sizeof($contact_groups_available) != 0) { echo "
\n"; echo " "; if ($action == "update") { echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]); } echo "
\n"; } } echo " ".$text['description-groups']."\n"; echo "
\n"; } echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; } } if (permission_exists('contact_phone_view')) { echo "\n"; $x = 0; foreach($contact_phones as $row) { echo "
\n"; echo "
\n"; echo " ".$text['label-phone_numbers']."\n"; if ($row['phone_primary'] == "1") { echo " \n"; } if (permission_exists('contact_phone_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } echo " \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-phone_label']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_label']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_type']."\n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "  \n"; echo "  \n"; echo " \n"; echo "
\n"; //echo $text['description-phone_type']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_speed_dial']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_extension']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_country_code']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_country_code']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_number']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_speed_dial']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_extension']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_number']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-primary']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_primary']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-phone_description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo $text['description-phone_description']."\n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; //if (is_array($contact_phones) && @sizeof($contact_phones) > 1 && permission_exists('contact_phone_delete')) { // echo "
\n"; // echo " ".$text['label-action']."\n"; // echo "
\n"; // echo "
\n"; // //echo " ".$text['label-action']."\n"; // echo " \n"; // //echo " \n"; // echo " \n"; // echo " \n"; // echo "
\n"; //} echo "
\n"; $x++; } } if (permission_exists('contact_address_view')) { foreach($contact_addresses as $row) { echo "
\n"; echo "
\n"; echo " ".$text['label-addresses']."\n"; if ($row['address_primary'] == "1") { echo " \n"; } if (permission_exists('contact_address_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-address_label']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_type']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_address']."\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; if (permission_exists('address_community')) { echo "
\n"; echo " ".$text['label-address_community']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; } echo "
\n"; echo " ".$text['label-address_locality']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_region']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_postal_code']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_country']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; if (permission_exists('address_latitude')) { echo "
\n"; echo " ".$text['label-address_latitude']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; } if (permission_exists('address_longitude')) { echo "
\n"; echo " ".$text['label-address_longitude']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; } echo "
\n"; echo " ".$text['label-primary']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-address_description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; //if (is_array($contact_addresses) && @sizeof($contact_addresses) > 1 && permission_exists('contact_address_delete')) { // if (is_uuid($row['contact_address_uuid'])) { // echo "
\n"; // echo " ".$text['label-action']."\n"; // echo "
\n"; // echo "
\n"; // echo " \n"; // echo "
\n"; // } //} echo "
\n"; $x++; } } if (permission_exists('contact_email_view')) { $x = 0; foreach($contact_emails as $row) { echo "
\n"; echo "
\n"; echo " ".$text['label-emails']."\n"; if ($row['email_primary'] == "1") { echo " \n"; } if (permission_exists('contact_email_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-email_label']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-email_address']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-primary']."\n"; echo "
\n"; echo "
\n"; echo " \n"; //echo "
\n"; //echo $text['description-email_primary']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-email_description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; //if (is_array($contact_emails) && @sizeof($contact_emails) > 1 && permission_exists('contact_email_delete')) { // if (is_uuid($row['contact_email_uuid'])) { // echo "
\n"; // echo " ".$text['label-action']."\n"; // echo "
\n"; // echo "
\n"; // echo " \n"; // echo "
\n"; // } //} echo "
\n"; $x++; } } if (permission_exists('contact_url_view')) { $x = 0; foreach($contact_urls as $row) { echo "
\n"; echo "
\n"; echo " ".$text['label-contact_url']."\n"; if ($row['url_primary'] == "1") { echo " \n"; } if (permission_exists('contact_url_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; //echo "
\n"; //echo " ".$text['label-url_type']."\n"; //echo "
\n"; //echo "
\n"; //echo " \n"; //echo "
\n"; echo "
\n"; echo " ".$text['label-url_label']."\n"; echo "
\n"; echo "
\n";; //if there are no custom labels add defaults if (is_array($_SESSION["contact"]["url_label"])) { $contact_url_labels = $_SESSION["contact"]["url_label"]; } else { $contact_url_labels[] = $text['option-work']; $contact_url_labels[] = $text['option-personal']; $contact_url_labels[] = $text['option-other']; } sort($contact_url_labels); foreach($contact_url_labels as $label) { $url_label_options[] = ""; } $url_label_found = (in_array($url_label, $contact_url_labels)) ? true : false; echo " \n"; echo " \n"; //echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-url_address']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-primary']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-url_description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; if (is_array($contact_urls) && @sizeof($contact_urls) > 1 && permission_exists('contact_url_delete')) { if (is_uuid($row['contact_url_uuid'])) { echo " \n"; } } //echo "
\n"; //echo " ".$text['description-contact_organization']."\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } } if (permission_exists('contact_relation_view')) { if (is_array($contact_relations)) { $x = 0; foreach($contact_relations as $row) { $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family from v_contacts "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_uuid <> :contact_uuid "; $sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_uuid'] = $row['contact_uuid']; $database = new database; $contacts = $database->select($sql, $parameters, 'all'); echo "
\n"; echo "
\n"; echo " ".$text['label-contact_relation_label']."\n"; if (permission_exists('contact_relation_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; } echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_relation_label']."\n"; echo "
\n"; echo "
\n"; //if there are no custom labels add defaults if (is_array($_SESSION["contact"]["relation_label"])) { $relation_labels = $_SESSION["contact"]["url_label"]; } else { $relation_labels[] = $text['label-contact_relation_option_parent']; $relation_labels[] = $text['label-contact_relation_option_child']; $relation_labels[] = $text['label-contact_relation_option_employee']; $relation_labels[] = $text['label-contact_relation_option_member']; $relation_labels[] = $text['label-contact_relation_option_associate']; $relation_labels[] = $text['label-contact_relation_option_other']; } sort($relation_labels); foreach($relation_labels as $label) { $relation_label_options[] = ""; } $relation_label_found = (in_array($relation_label, $relation_labels)) ? true : false; echo " \n"; //echo " \n"; //echo " \n"; //echo "
\n"; //echo $text['description-relation_label']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_relation_contact']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } } } if (permission_exists('contact_setting_view')) { $x = 0; foreach($contact_settings as $row) { echo "
\n"; echo "
\n"; echo " ".$text['label-contact_settings']."\n"; if (permission_exists('contact_setting_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-contact_setting_category']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_setting_subcategory']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-name']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_setting_value']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-order']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; if (is_array($contact_settings) && @sizeof($contact_settings) > 1 && permission_exists('contact_setting_delete')) { if (is_uuid($row['contact_setting_uuid'])) { echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; } } echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } } if (permission_exists('contact_attachment_view')) { $x = 0; foreach($contact_attachments as $row) { $attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION)); $attachment_type_label = $attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png' ? $text['label-image'] : $text['label-file']; echo "
\n"; echo "
\n"; echo " ".$text['label-attachments']."\n"; if ($row['attachment_primary'] == "1") { echo " \n"; } if (permission_exists('contact_attachment_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; } echo "
\n"; echo "
\n"; //styles and attachment layer echo "\n"; echo "\n"; //script echo "\n"; echo "
\n"; echo " ".$text['label-attachment']."\n"; echo "
\n"; echo "
\n"; $attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION)); //if ($action == 'update') { echo "\n"; if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') { echo ""; } else { echo "".escape($row['attachment_filename']).""; } //} //else { // $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true); // echo " \n"; // echo " ".strtoupper(implode(', ', array_keys($allowed_attachment_types))).""; //} echo "
\n"; echo "
\n"; echo " ".$text['label-attachment_filename']."\n"; echo "
\n"; echo " \n"; echo "
\n"; echo " ".$text['label-attachment_size']."\n"; echo "
\n"; echo "
\n"; echo strtoupper(byte_convert($row['attachment_size']))."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-primary']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } } if (permission_exists('contact_time_view')) { $x = 0; foreach ($contact_times as $row) { echo "
\n"; echo "
\n"; echo " ".$text['header_contact_times']."\n"; if (permission_exists('contact_time_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; } echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-time_start']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-time_stop']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-time_description']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } unset($contact_times); } if (permission_exists('contact_note_view')) { $x = 0; foreach($contact_notes as $row) { $contact_note = $row['contact_note']; $contact_note = escape($contact_note); $contact_note = str_replace("\n","
",$contact_note); if (permission_exists('contact_note_add')) { $list_row_url = "contact_note_edit.php?contact_uuid=".escape($row['contact_uuid'])."&id=".escape($row['contact_note_uuid']); } echo "
\n"; echo "
\n"; echo " ".$text['label-contact_notes']."\n"; if (permission_exists('contact_note_delete')) { echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; } echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-contact_note']."\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-note_user']."\n"; echo "
\n"; echo "
\n"; echo "
".escape($row['last_mod_user']).": ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."
\n"; echo "
\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; $x++; } unset($contact_notes); } //close the grid echo "
\n"; echo "

"; //end the form echo "\n"; echo ""; //include the footer require_once "resources/footer.php"; ?>