contact_edit.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes
  22. require_once "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('contact_edit')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //action add or update
  37. if (is_uuid($_REQUEST["id"])) {
  38. $action = "update";
  39. $contact_uuid = $_REQUEST["id"];
  40. }
  41. else {
  42. $action = "add";
  43. }
  44. //get http post variables and set them to php variables
  45. if (count($_POST) > 0) {
  46. //process the http post data by submitted action
  47. if ($_POST['action'] != '' && is_uuid($_POST['contact_uuid'])) {
  48. $array[0]['checked'] = 'true';
  49. $array[0]['uuid'] = $_POST['contact_uuid'];
  50. switch ($_POST['action']) {
  51. case 'delete':
  52. if (permission_exists('contact_delete')) {
  53. $obj = new contacts;
  54. $obj->delete($array);
  55. header('Location: contacts.php');
  56. exit;
  57. }
  58. }
  59. }
  60. $user_uuid = $_POST["user_uuid"];
  61. $group_uuid = $_POST['group_uuid'];
  62. $contact_type = $_POST["contact_type"];
  63. $contact_organization = $_POST["contact_organization"];
  64. $contact_name_prefix = $_POST["contact_name_prefix"];
  65. $contact_name_given = $_POST["contact_name_given"];
  66. $contact_name_middle = $_POST["contact_name_middle"];
  67. $contact_name_family = $_POST["contact_name_family"];
  68. $contact_name_suffix = $_POST["contact_name_suffix"];
  69. $contact_nickname = $_POST["contact_nickname"];
  70. $contact_title = $_POST["contact_title"];
  71. $contact_category = $_POST["contact_category"];
  72. $contact_role = $_POST["contact_role"];
  73. $contact_time_zone = $_POST["contact_time_zone"];
  74. $contact_note = $_POST["contact_note"];
  75. $contact_users_delete = $_POST['contact_users_delete'];
  76. $contact_groups_delete = $_POST['contact_groups_delete'];
  77. }
  78. //process the form data
  79. if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
  80. //set the uuid
  81. if ($action == "update") {
  82. $contact_uuid = $_POST["contact_uuid"];
  83. }
  84. //validate the token
  85. $token = new token;
  86. if (!$token->validate($_SERVER['PHP_SELF'])) {
  87. message::add($text['message-invalid_token'],'negative');
  88. header('Location: contacts.php');
  89. exit;
  90. }
  91. //check for all required data
  92. $msg = '';
  93. //if (strlen($contact_type) == 0) { $msg .= $text['message-required'].$text['label-contact_type']."<br>\n"; }
  94. //if (strlen($contact_organization) == 0) { $msg .= $text['message-required'].$text['label-contact_organization']."<br>\n"; }
  95. //if (strlen($contact_name_prefix) == 0) { $msg .= $text['message-required'].$text['label-contact_name_prefix']."<br>\n"; }
  96. //if (strlen($contact_name_given) == 0) { $msg .= $text['message-required'].$text['label-contact_name_given']."<br>\n"; }
  97. //if (strlen($contact_name_middle) == 0) { $msg .= $text['message-required'].$text['label-contact_name_middle']."<br>\n"; }
  98. //if (strlen($contact_name_family) == 0) { $msg .= $text['message-required'].$text['label-contact_name_family']."<br>\n"; }
  99. //if (strlen($contact_name_suffix) == 0) { $msg .= $text['message-required'].$text['label-contact_name_suffix']."<br>\n"; }
  100. //if (strlen($contact_nickname) == 0) { $msg .= $text['message-required'].$text['label-contact_nickname']."<br>\n"; }
  101. //if (strlen($contact_title) == 0) { $msg .= $text['message-required'].$text['label-contact_title']."<br>\n"; }
  102. //if (strlen($contact_role) == 0) { $msg .= $text['message-required'].$text['label-contact_role']."<br>\n"; }
  103. //if (strlen($contact_time_zone) == 0) { $msg .= $text['message-required'].$text['label-contact_time_zone']."<br>\n"; }
  104. //if (strlen($contact_note) == 0) { $msg .= $text['message-required'].$text['label-contact_note']."<br>\n"; }
  105. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  106. require_once "resources/header.php";
  107. require_once "resources/persist_form_var.php";
  108. echo "<div align='center'>\n";
  109. echo "<table><tr><td>\n";
  110. echo $msg."<br />";
  111. echo "</td></tr></table>\n";
  112. persistformvar($_POST);
  113. echo "</div>\n";
  114. require_once "resources/footer.php";
  115. return;
  116. }
  117. //add or update the database
  118. if ($_POST["persistformvar"] != "true") {
  119. //add the contact
  120. if ($action == "add" && permission_exists('contact_add')) {
  121. $contact_uuid = uuid();
  122. $array['contacts'][0]['contact_uuid'] = $contact_uuid;
  123. message::add($text['message-add']);
  124. }
  125. //update the contact
  126. if ($action == "update") {
  127. $array['contacts'][0]['contact_uuid'] = $contact_uuid;
  128. message::add($text['message-update']);
  129. }
  130. //create array
  131. if (is_array($array) && @sizeof($array) != 0) {
  132. $array['contacts'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
  133. $array['contacts'][0]['contact_type'] = $contact_type;
  134. $array['contacts'][0]['contact_organization'] = $contact_organization;
  135. $array['contacts'][0]['contact_name_prefix'] = $contact_name_prefix;
  136. $array['contacts'][0]['contact_name_given'] = $contact_name_given;
  137. $array['contacts'][0]['contact_name_middle'] = $contact_name_middle;
  138. $array['contacts'][0]['contact_name_family'] = $contact_name_family;
  139. $array['contacts'][0]['contact_name_suffix'] = $contact_name_suffix;
  140. $array['contacts'][0]['contact_nickname'] = $contact_nickname;
  141. $array['contacts'][0]['contact_title'] = $contact_title;
  142. $array['contacts'][0]['contact_category'] = $contact_category;
  143. $array['contacts'][0]['contact_role'] = $contact_role;
  144. $array['contacts'][0]['contact_time_zone'] = $contact_time_zone;
  145. $array['contacts'][0]['contact_note'] = $contact_note;
  146. $array['contacts'][0]['last_mod_date'] = 'now()';
  147. $array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
  148. $p = new permissions;
  149. }
  150. //assign the contact to the user that added the contact
  151. if ($action == "add" && !permission_exists('contact_user_add')) {
  152. $user_uuid = $_SESSION["user_uuid"];
  153. }
  154. //add user to contact users table
  155. if (is_uuid($user_uuid) && (permission_exists('contact_user_add') || $action == "add")) {
  156. $contact_user_uuid = uuid();
  157. $array['contact_users'][0]['domain_uuid'] = $domain_uuid;
  158. $array['contact_users'][0]['contact_user_uuid'] = $contact_user_uuid;
  159. $array['contact_users'][0]['contact_uuid'] = $contact_uuid;
  160. $array['contact_users'][0]['user_uuid'] = $user_uuid;
  161. $p->add('contact_user_add', 'temp');
  162. }
  163. //assign the contact to the group
  164. if (is_uuid($group_uuid) && permission_exists('contact_group_add')) {
  165. $contact_group_uuid = uuid();
  166. $array['contact_groups'][0]['contact_group_uuid'] = $contact_group_uuid;
  167. $array['contact_groups'][0]['domain_uuid'] = $domain_uuid;
  168. $array['contact_groups'][0]['contact_uuid'] = $contact_uuid;
  169. $array['contact_groups'][0]['group_uuid'] = $group_uuid;
  170. $p->add('contact_group_add', 'temp');
  171. }
  172. //execute
  173. if (is_array($array) && @sizeof($array) != 0) {
  174. $database = new database;
  175. $database->app_name = 'contacts';
  176. $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
  177. $database->save($array);
  178. unset($array);
  179. $p->delete('contact_user_add', 'temp');
  180. $p->delete('contact_group_add', 'temp');
  181. }
  182. //delete checked contact properties
  183. $array = array();
  184. if (permission_exists('contact_phone_delete')) { $contact_properties['contact_phones'] = $_POST['contact_phones']; }
  185. if (permission_exists('contact_address_delete')) { $contact_properties['contact_addresses'] = $_POST['contact_addresses']; }
  186. if (permission_exists('contact_email_delete')) { $contact_properties['contact_emails'] = $_POST['contact_emails']; }
  187. if (permission_exists('contact_url_delete')) { $contact_properties['contact_urls'] = $_POST['contact_urls']; }
  188. //if (permission_exists('contact_extension_delete')) { $contact_properties['contact_extensions'] = $_POST['contact_extensions']; }
  189. if (permission_exists('contact_relation_delete')) { $contact_properties['contact_relations'] = $_POST['contact_relations']; }
  190. if (permission_exists('contact_note_delete')) { $contact_properties['contact_notes'] = $_POST['contact_notes']; }
  191. if (permission_exists('contact_time_delete')) { $contact_properties['contact_times'] = $_POST['contact_times']; }
  192. if (permission_exists('contact_setting_delete')) { $contact_properties['contact_settings'] = $_POST['contact_settings']; }
  193. if (permission_exists('contact_attachment_delete')) { $contact_properties['contact_attachments'] = $_POST['contact_attachments']; }
  194. if (@sizeof($contact_properties) != 0) {
  195. $obj = new contacts;
  196. $obj->contact_uuid = $contact_uuid;
  197. $obj->delete_properties($contact_properties);
  198. }
  199. //remove checked users
  200. if (
  201. $action == 'update'
  202. && permission_exists('contact_user_delete')
  203. && is_array($contact_users_delete)
  204. && @sizeof($contact_users_delete) != 0
  205. ) {
  206. $obj = new contacts;
  207. $obj->contact_uuid = $contact_uuid;
  208. $obj->delete_users($contact_users_delete);
  209. }
  210. //remove checked groups
  211. if (
  212. $action == 'update'
  213. && permission_exists('contact_group_delete')
  214. && is_array($contact_groups_delete)
  215. && @sizeof($contact_groups_delete) != 0
  216. ) {
  217. $obj = new contacts;
  218. $obj->contact_uuid = $contact_uuid;
  219. $obj->delete_groups($contact_groups_delete);
  220. }
  221. //redirect the browser
  222. header("Location: contact_edit.php?id=".urlencode($contact_uuid));
  223. exit;
  224. }
  225. }
  226. //pre-populate the form
  227. if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
  228. $contact_uuid = $_GET["id"];
  229. $sql = "select * from v_contacts ";
  230. $sql .= "where domain_uuid = :domain_uuid ";
  231. $sql .= "and contact_uuid = :contact_uuid ";
  232. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  233. $parameters['contact_uuid'] = $contact_uuid;
  234. $database = new database;
  235. $row = $database->select($sql, $parameters, 'row');
  236. if (is_array($row) && @sizeof($row) != 0) {
  237. $contact_type = $row["contact_type"];
  238. $contact_organization = $row["contact_organization"];
  239. $contact_name_prefix = $row["contact_name_prefix"];
  240. $contact_name_given = $row["contact_name_given"];
  241. $contact_name_middle = $row["contact_name_middle"];
  242. $contact_name_family = $row["contact_name_family"];
  243. $contact_name_suffix = $row["contact_name_suffix"];
  244. $contact_nickname = $row["contact_nickname"];
  245. $contact_title = $row["contact_title"];
  246. $contact_category = $row["contact_category"];
  247. $contact_role = $row["contact_role"];
  248. $contact_time_zone = $row["contact_time_zone"];
  249. $contact_note = $row["contact_note"];
  250. }
  251. unset($sql, $parameters, $row);
  252. }
  253. //get the users array
  254. $sql = "select * from v_users ";
  255. $sql .= "where domain_uuid = :domain_uuid ";
  256. $sql .= "order by username asc ";
  257. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  258. $database = new database;
  259. $users = $database->select($sql, $parameters, 'all');
  260. unset($sql, $parameters);
  261. //determine if contact assigned to a user
  262. if (is_array($users) && sizeof($users) != 0) {
  263. foreach ($users as $user) {
  264. if ($user['contact_uuid'] == $contact_uuid) {
  265. $contact_user_uuid = $user['user_uuid'];
  266. break;
  267. }
  268. }
  269. }
  270. //get the users assigned to this contact
  271. $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 ";
  272. $sql .= "where c.contact_uuid = :contact_uuid ";
  273. $sql .= "and c.domain_uuid = :domain_uuid ";
  274. $sql .= "and u.user_uuid = a.user_uuid ";
  275. $sql .= "and c.contact_uuid = a.contact_uuid ";
  276. $sql .= "order by u.username asc ";
  277. $parameters['contact_uuid'] = $contact_uuid;
  278. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  279. $database = new database;
  280. $contact_users_assigned = $database->select($sql, $parameters, 'all');
  281. unset($sql, $parameters);
  282. //get the assigned groups of this contact
  283. $sql = "select g.*, cg.contact_group_uuid ";
  284. $sql .= "from v_groups as g, v_contact_groups as cg ";
  285. $sql .= "where cg.group_uuid = g.group_uuid ";
  286. $sql .= "and cg.domain_uuid = :domain_uuid ";
  287. $sql .= "and cg.contact_uuid = :contact_uuid ";
  288. $sql .= "and cg.group_uuid <> :group_uuid ";
  289. $sql .= "order by g.group_name asc ";
  290. $parameters['domain_uuid'] = $domain_uuid;
  291. $parameters['contact_uuid'] = $contact_uuid;
  292. $parameters['group_uuid'] = $_SESSION["user_uuid"];
  293. $database = new database;
  294. $contact_groups_assigned = $database->select($sql, $parameters, 'all');
  295. if (is_array($contact_groups_assigned) && @sizeof($contact_groups_assigned) != 0) {
  296. foreach ($contact_groups_assigned as $field) {
  297. $contact_groups[] = "'".$field['group_uuid']."'";
  298. }
  299. }
  300. unset($sql, $parameters);
  301. //get the available groups to this contact
  302. $sql = "select group_uuid, group_name from v_groups ";
  303. $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
  304. if (is_array($contact_groups) && @sizeof($contact_groups) != 0) {
  305. $sql .= "and group_uuid not in (".implode(',', $contact_groups).") ";
  306. }
  307. $sql .= "order by group_name asc ";
  308. $parameters['domain_uuid'] = $domain_uuid;
  309. $database = new database;
  310. $contact_groups_available = $database->select($sql, $parameters, 'all');
  311. unset($sql, $parameters, $contact_groups);
  312. //create token
  313. $object = new token;
  314. $token = $object->create($_SERVER['PHP_SELF']);
  315. //show the header
  316. if ($action == "update") {
  317. $document['title'] = $text['title-contact-edit'];
  318. }
  319. else if ($action == "add") {
  320. $document['title'] = $text['title-contact-add'];
  321. }
  322. require_once "resources/header.php";
  323. //determine qr branding
  324. if ($_SESSION['theme']['qr_brand_type']['text'] == 'image' && $_SESSION['theme']['qr_brand_image']['text'] != '') {
  325. echo "<img id='img-buffer' style='display: none;' src='".$_SESSION["theme"]["qr_brand_image"]["text"]."'>";
  326. $qr_option = "image: $('#img-buffer')[0],";
  327. $qr_mode = '4';
  328. $qr_size = '0.2';
  329. }
  330. else if ($_SESSION['theme']['qr_brand_type']['text'] == 'text' && $_SESSION['theme']['qr_brand_text']['text'] != '') {
  331. $qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"';
  332. $qr_mode = '2';
  333. $qr_size = '0.05';
  334. }
  335. else {
  336. echo "<img id='img-buffer' style='display: none;' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png'>";
  337. $qr_option = "image: $('#img-buffer')[0],";
  338. $qr_mode = '4';
  339. $qr_size = '0.2';
  340. }
  341. //qr code generation
  342. $_GET['type'] = "text";
  343. $qr_vcard = true;
  344. include "contacts_vcard.php";
  345. echo "<input type='hidden' id='qr_vcard' value=\"".$qr_vcard."\">";
  346. echo "<style>";
  347. echo " #qr_code_container {";
  348. echo " z-index: 999999; ";
  349. echo " position: absolute; ";
  350. echo " left: 0; ";
  351. echo " top: 0; ";
  352. echo " right: 0; ";
  353. echo " bottom: 0; ";
  354. echo " text-align: center; ";
  355. echo " vertical-align: middle;";
  356. echo " }";
  357. echo " #qr_code {";
  358. echo " display: block; ";
  359. echo " width: 650px; ";
  360. echo " height: 650px; ";
  361. echo " -webkit-box-shadow: 0px 1px 20px #888; ";
  362. echo " -moz-box-shadow: 0px 1px 20px #888; ";
  363. echo " box-shadow: 0px 1px 20px #888;";
  364. echo " }";
  365. echo "</style>";
  366. echo "<script src='".PROJECT_PATH."/resources/jquery/jquery-qrcode.min.js'></script>";
  367. echo "<script language='JavaScript' type='text/javascript'>";
  368. echo " $(document).ready(function() {";
  369. echo " $('#qr_code').qrcode({ ";
  370. echo " render: 'canvas', ";
  371. echo " minVersion: 6, ";
  372. echo " maxVersion: 40, ";
  373. echo " ecLevel: 'H', ";
  374. echo " size: 650, ";
  375. echo " radius: 0.2, ";
  376. echo " quiet: 6, ";
  377. echo " background: '#fff', ";
  378. echo " mode: ".$qr_mode.", ";
  379. echo " mSize: ".$qr_size.", ";
  380. echo " mPosX: 0.5, ";
  381. echo " mPosY: 0.5, ";
  382. echo " text: document.getElementById('qr_vcard').value, ";
  383. echo " ".$qr_option;
  384. echo " });";
  385. echo " });";
  386. echo "</script>";
  387. //show the content
  388. echo "<form name='frm' id='frm' method='post'>\n";
  389. echo "<div class='action_bar' id='action_bar'>\n";
  390. echo " <div class='heading'>";
  391. if ($action == "add") {
  392. echo "<b>".$text['header-contact-add']."</b>";
  393. }
  394. else if ($action == "update") {
  395. echo "<b>".$text['header-contact-edit']."</b>";
  396. }
  397. echo " </div>\n";
  398. echo " <div class='actions'>\n";
  399. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-sm-dn','style'=>'margin-right: 15px;','link'=>'contacts.php']);
  400. if ($action == "update") {
  401. if (permission_exists('contact_time_add')) {
  402. //detect timer state (and start time)
  403. $sql = "select ";
  404. $sql .= "time_start ";
  405. $sql .= "from v_contact_times ";
  406. $sql .= "where domain_uuid = :domain_uuid ";
  407. $sql .= "and user_uuid = :user_uuid ";
  408. $sql .= "and contact_uuid = :contact_uuid ";
  409. $sql .= "and time_start is not null ";
  410. $sql .= "and time_stop is null ";
  411. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  412. $parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
  413. $parameters['contact_uuid'] = $contact_uuid;
  414. $database = new database;
  415. $time_start = $database->select($sql, $parameters, 'column');
  416. $btn_style = $time_start ? 'color: #fff; background-color: #3693df; background-image: none;' : null;
  417. unset($sql, $parameters);
  418. 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');"]);
  419. }
  420. echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
  421. 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']);
  422. }
  423. if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) {
  424. 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)]);
  425. }
  426. if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) {
  427. 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)]);
  428. }
  429. if ($action == "update" && permission_exists('user_edit') && is_uuid($contact_user_uuid)) {
  430. 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)]);
  431. }
  432. if (
  433. $action == "update" && (
  434. permission_exists('contact_phone_add') ||
  435. permission_exists('contact_address_add') ||
  436. permission_exists('contact_email_add') ||
  437. permission_exists('contact_url_add') ||
  438. permission_exists('contact_relation_add') ||
  439. permission_exists('contact_note_add') ||
  440. permission_exists('contact_time_add') ||
  441. permission_exists('contact_setting_add') ||
  442. permission_exists('contact_attachment_add')
  443. )) {
  444. echo "<select class='formfld' style='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";
  445. echo " <option value=''>".$text['button-add']."...</option>\n";
  446. if (permission_exists('contact_phone_add')) { echo "<option value='phone'>".$text['label-phone_number']."</option>\n"; }
  447. if (permission_exists('contact_address_add')) { echo "<option value='address'>".$text['label-address_address']."</option>\n"; }
  448. if (permission_exists('contact_email_add')) { echo "<option value='email'>".$text['label-email']."</option>\n"; }
  449. if (permission_exists('contact_url_add')) { echo "<option value='url'>".$text['label-url']."</option>\n"; }
  450. if (permission_exists('contact_relation_add')) { echo "<option value='relation'>".$text['label-contact_relation_label']."</option>\n"; }
  451. if (permission_exists('contact_note_add')) { echo "<option value='note'>".$text['label-contact_note']."</option>\n"; }
  452. if (permission_exists('contact_time_add')) { echo "<option value='time'>".$text['label-time_time']."</option>\n"; }
  453. if (permission_exists('contact_setting_add')) { echo "<option value='setting'>".$text['label-setting']."</option>\n"; }
  454. if (permission_exists('contact_attachment_add')) { echo "<option value='attachment'>".$text['label-attachment']."</option>\n"; }
  455. echo " </select>";
  456. }
  457. if (
  458. $action == "update" && (
  459. permission_exists('contact_delete') ||
  460. permission_exists('contact_user_delete') ||
  461. permission_exists('contact_group_delete') ||
  462. permission_exists('contact_phone_delete') ||
  463. permission_exists('contact_address_delete') ||
  464. permission_exists('contact_email_delete') ||
  465. permission_exists('contact_url_delete') ||
  466. permission_exists('contact_relation_delete') ||
  467. permission_exists('contact_note_delete') ||
  468. permission_exists('contact_time_delete') ||
  469. permission_exists('contact_setting_delete') ||
  470. permission_exists('contact_attachment_delete')
  471. )) {
  472. 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');"]);
  473. }
  474. if (permission_exists('contact_add')) {
  475. echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>($action != 'update' ?: 'margin-left: 15px;'),'collapse'=>'hide-sm-dn','onclick'=>"document.getElementById('frm').submit();"]);
  476. }
  477. echo " </div>\n";
  478. echo " <div style='clear: both;'></div>\n";
  479. echo "</div>\n";
  480. if (
  481. $action == "update" && (
  482. permission_exists('contact_delete') ||
  483. permission_exists('contact_user_delete') ||
  484. permission_exists('contact_group_delete') ||
  485. permission_exists('contact_phone_delete') ||
  486. permission_exists('contact_address_delete') ||
  487. permission_exists('contact_email_delete') ||
  488. permission_exists('contact_url_delete') ||
  489. permission_exists('contact_relation_delete') ||
  490. permission_exists('contact_note_delete') ||
  491. permission_exists('contact_time_delete') ||
  492. permission_exists('contact_setting_delete') ||
  493. permission_exists('contact_attachment_delete')
  494. )) {
  495. echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
  496. }
  497. if ($action == "add") {
  498. echo $text['description-contact-add']."\n";
  499. }
  500. else if ($action == "update") {
  501. echo $text['description-contact-edit']."\n";
  502. }
  503. echo "<br /><br />\n";
  504. echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
  505. echo "<tr>\n";
  506. echo "<td valign='top' align='left' nowrap='nowrap'>\n";
  507. echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
  508. echo "<tr>\n";
  509. echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  510. echo " ".$text['label-contact_type']."\n";
  511. echo "</td>\n";
  512. echo "<td width='70%' class='vtable' align='left'>\n";
  513. if (is_array($_SESSION["contact"]["type"])) {
  514. sort($_SESSION["contact"]["type"]);
  515. echo " <select class='formfld' name='contact_type'>\n";
  516. echo " <option value=''></option>\n";
  517. foreach($_SESSION["contact"]["type"] as $type) {
  518. echo " <option value='".escape($type)."' ".(($type == $contact_type) ? "selected='selected'" : null).">".escape($type)."</option>\n";
  519. }
  520. echo " </select>\n";
  521. }
  522. else {
  523. echo " <select class='formfld' name='contact_type'>\n";
  524. echo " <option value=''></option>\n";
  525. echo " <option value='customer' ".(($contact_type == "customer") ? "selected='selected'" : null).">".$text['option-contact_type_customer']."</option>\n";
  526. echo " <option value='contractor' ".(($contact_type == "contractor") ? "selected='selected'" : null).">".$text['option-contact_type_contractor']."</option>\n";
  527. echo " <option value='friend' ".(($contact_type == "friend") ? "selected='selected'" : null).">".$text['option-contact_type_friend']."</option>\n";
  528. echo " <option value='lead' ".(($contact_type == "lead") ? "selected='selected'" : null).">".$text['option-contact_type_lead']."</option>\n";
  529. echo " <option value='member' ".(($contact_type == "member") ? "selected='selected'" : null).">".$text['option-contact_type_member']."</option>\n";
  530. echo " <option value='family' ".(($contact_type == "family") ? "selected='selected'" : null).">".$text['option-contact_type_family']."</option>\n";
  531. echo " <option value='subscriber' ".(($contact_type == "subscriber") ? "selected='selected'" : null).">".$text['option-contact_type_subscriber']."</option>\n";
  532. echo " <option value='supplier' ".(($contact_type == "supplier") ? "selected='selected'" : null).">".$text['option-contact_type_supplier']."</option>\n";
  533. echo " <option value='provider' ".(($contact_type == "provider") ? "selected='selected'" : null).">".$text['option-contact_type_provider']."</option>\n";
  534. echo " <option value='user' ".(($contact_type == "user") ? "selected='selected'" : null).">".$text['option-contact_type_user']."</option>\n";
  535. echo " <option value='volunteer' ".(($contact_type == "volunteer") ? "selected='selected'" : null).">".$text['option-contact_type_volunteer']."</option>\n";
  536. echo " </select>\n";
  537. }
  538. echo "</td>\n";
  539. echo "</tr>\n";
  540. echo "<tr>\n";
  541. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  542. echo " ".$text['label-contact_organization']."\n";
  543. echo "</td>\n";
  544. echo "<td class='vtable' align='left'>\n";
  545. echo " <input class='formfld' type='text' name='contact_organization' maxlength='255' value=\"".escape($contact_organization)."\">\n";
  546. echo "</td>\n";
  547. echo "</tr>\n";
  548. echo "<tr>\n";
  549. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  550. echo " ".$text['label-contact_name_prefix']."\n";
  551. echo "</td>\n";
  552. echo "<td class='vtable' align='left'>\n";
  553. echo " <input class='formfld' type='text' name='contact_name_prefix' maxlength='255' value=\"".escape($contact_name_prefix)."\">\n";
  554. echo "</td>\n";
  555. echo "</tr>\n";
  556. echo "<tr>\n";
  557. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  558. echo " ".$text['label-contact_name_given']."\n";
  559. echo "</td>\n";
  560. echo "<td class='vtable' align='left'>\n";
  561. echo " <input class='formfld' type='text' name='contact_name_given' maxlength='255' value=\"".escape($contact_name_given)."\">\n";
  562. echo "</td>\n";
  563. echo "</tr>\n";
  564. echo "<tr>\n";
  565. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  566. echo " ".$text['label-contact_name_middle']."\n";
  567. echo "</td>\n";
  568. echo "<td class='vtable' align='left'>\n";
  569. echo " <input class='formfld' type='text' name='contact_name_middle' maxlength='255' value=\"".escape($contact_name_middle)."\">\n";
  570. echo "</td>\n";
  571. echo "</tr>\n";
  572. echo "<tr>\n";
  573. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  574. echo " ".$text['label-contact_name_family']."\n";
  575. echo "</td>\n";
  576. echo "<td class='vtable' align='left'>\n";
  577. echo " <input class='formfld' type='text' name='contact_name_family' maxlength='255' value=\"".escape($contact_name_family)."\">\n";
  578. echo "</td>\n";
  579. echo "</tr>\n";
  580. echo "<tr>\n";
  581. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  582. echo " ".$text['label-contact_name_suffix']."\n";
  583. echo "</td>\n";
  584. echo "<td class='vtable' align='left'>\n";
  585. echo " <input class='formfld' type='text' name='contact_name_suffix' maxlength='255' value=\"".escape($contact_name_suffix)."\">\n";
  586. echo "</td>\n";
  587. echo "</tr>\n";
  588. echo "<tr>\n";
  589. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  590. echo " ".$text['label-contact_nickname']."\n";
  591. echo "</td>\n";
  592. echo "<td class='vtable' align='left'>\n";
  593. echo " <input class='formfld' type='text' name='contact_nickname' maxlength='255' value=\"".escape($contact_nickname)."\">\n";
  594. echo "</td>\n";
  595. echo "</tr>\n";
  596. echo "<tr>\n";
  597. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  598. echo " ".$text['label-contact_title']."\n";
  599. echo "</td>\n";
  600. echo "<td class='vtable' align='left'>\n";
  601. if (is_array($_SESSION["contact"]["title"])) {
  602. sort($_SESSION["contact"]["title"]);
  603. echo " <select class='formfld' name='contact_title'>\n";
  604. echo " <option value=''></option>\n";
  605. foreach($_SESSION["contact"]["title"] as $title) {
  606. echo " <option value='".escape($title)."' ".(($title == $contact_title) ? "selected='selected'" : null).">".escape($title)."</option>\n";
  607. }
  608. echo " </select>\n";
  609. }
  610. else {
  611. echo " <input class='formfld' type='text' name='contact_title' maxlength='255' value=\"".escape($contact_title)."\">\n";
  612. }
  613. echo "</td>\n";
  614. echo "</tr>\n";
  615. echo "<tr>\n";
  616. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  617. echo " ".$text['label-contact_category']."\n";
  618. echo "</td>\n";
  619. echo "<td class='vtable' align='left'>\n";
  620. if (is_array($_SESSION["contact"]["category"])) {
  621. sort($_SESSION["contact"]["category"]);
  622. echo " <select class='formfld' name='contact_category'>\n";
  623. echo " <option value=''></option>\n";
  624. foreach($_SESSION["contact"]["category"] as $category) {
  625. echo " <option value='".escape($category)."' ".(($category == $contact_category) ? "selected='selected'" : null).">".escape($category)."</option>\n";
  626. }
  627. echo " </select>\n";
  628. }
  629. else {
  630. echo " <input class='formfld' type='text' name='contact_category' maxlength='255' value=\"".escape($contact_category)."\">\n";
  631. }
  632. echo "</td>\n";
  633. echo "</tr>\n";
  634. echo "<tr>\n";
  635. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  636. echo " ".$text['label-contact_role']."\n";
  637. echo "</td>\n";
  638. echo "<td class='vtable' align='left'>\n";
  639. if (is_array($_SESSION["contact"]["role"])) {
  640. sort($_SESSION["contact"]["role"]);
  641. echo " <select class='formfld' name='contact_role'>\n";
  642. echo " <option value=''></option>\n";
  643. foreach($_SESSION["contact"]["role"] as $role) {
  644. echo " <option value='".escape($role)."' ".(($role == $contact_role) ? "selected='selected'" : null).">".escape($role)."</option>\n";
  645. }
  646. echo " </select>\n";
  647. }
  648. else {
  649. echo " <input class='formfld' type='text' name='contact_role' maxlength='255' value=\"".escape($contact_role)."\">\n";
  650. }
  651. echo "</td>\n";
  652. echo "</tr>\n";
  653. echo "<tr>\n";
  654. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  655. echo " ".$text['label-contact_time_zone']."\n";
  656. echo "</td>\n";
  657. echo "<td class='vtable' align='left'>\n";
  658. echo " <input class='formfld' type='text' name='contact_time_zone' maxlength='255' value=\"".escape($contact_time_zone)."\">\n";
  659. echo "</td>\n";
  660. echo "</tr>\n";
  661. if (permission_exists('contact_user_edit')) {
  662. echo " <tr>";
  663. echo " <td class='vncell' valign='top'>".$text['label-users']."</td>";
  664. echo " <td class='vtable' align='left'>";
  665. echo " <table border='0' cellpadding='0' cellspacing='0' style='width: 100%;'>\n";
  666. if ($action == "update" && is_array($contact_users_assigned) && @sizeof($contact_users_assigned) != 0) {
  667. echo " <tr>\n";
  668. echo " <td class='vtable'>".$text['label-username']."</td>\n";
  669. if ($contact_users_assigned && permission_exists('contact_user_delete')) {
  670. echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_users', 'delete_toggle_users');\" onmouseout=\"swap_display('delete_label_users', 'delete_toggle_users');\">\n";
  671. echo " <span id='delete_label_users'>".$text['label-delete']."</span>\n";
  672. echo " <span id='delete_toggle_users'><input type='checkbox' id='checkbox_all_users' name='checkbox_all' onclick=\"edit_all_toggle('users');\"></span>\n";
  673. echo " </td>\n";
  674. }
  675. echo " </tr>\n";
  676. foreach ($contact_users_assigned as $x => $field) {
  677. echo " <tr>\n";
  678. echo " <td class='vtable'>".escape($field['username'])."</td>\n";
  679. if ($contact_users_assigned && permission_exists('contact_user_delete')) {
  680. if (is_uuid($field['contact_user_uuid'])) {
  681. echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
  682. echo " <input type='checkbox' name='contact_users_delete[".$x."][checked]' value='true' class='chk_delete checkbox_users' onclick=\"edit_delete_action('users');\">\n";
  683. echo " <input type='hidden' name='contact_users_delete[".$x."][uuid]' value='".escape($field['contact_user_uuid'])."' />\n";
  684. }
  685. else {
  686. echo " <td>";
  687. }
  688. echo " </td>\n";
  689. }
  690. echo " </tr>\n";
  691. }
  692. }
  693. if (permission_exists('contact_user_add')) {
  694. echo " <tr>\n";
  695. echo " <td class='vtable' style='border-bottom: none;' colspan='2'>\n";
  696. echo " <select name='user_uuid' class='formfld' style='width: auto;'>\n";
  697. echo " <option value=''></option>\n";
  698. foreach ($users as $field) {
  699. if (in_array($field['user_uuid'], array_column($contact_users_assigned, 'user_uuid'))) { continue; } //skip users already assigned
  700. echo " <option value='".escape($field['user_uuid'])."'>".escape($field['username'])."</option>\n";
  701. }
  702. echo " </select>";
  703. if ($action == "update") {
  704. echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
  705. }
  706. unset($users);
  707. echo " </td>\n";
  708. echo " <tr>\n";
  709. }
  710. echo " </table>\n";
  711. echo " ".$text['description-users']."\n";
  712. echo " </td>";
  713. echo " </tr>";
  714. }
  715. if (permission_exists('contact_group_view')) {
  716. echo "<tr>";
  717. echo " <td class='vncell' valign='top'>".$text['label-groups']."</td>";
  718. echo " <td class='vtable'>";
  719. echo " <table border='0' cellpadding='0' cellspacing='0' style='width: 100%;'>\n";
  720. if (is_array($contact_groups_assigned) && @sizeof($contact_groups_assigned) != 0) {
  721. echo " <tr>\n";
  722. echo " <td class='vtable'>".$text['label-group']."</td>\n";
  723. if ($contact_groups_assigned && permission_exists('contact_group_delete')) {
  724. echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_groups', 'delete_toggle_groups');\" onmouseout=\"swap_display('delete_label_groups', 'delete_toggle_groups');\">\n";
  725. echo " <span id='delete_label_groups'>".$text['label-delete']."</span>\n";
  726. echo " <span id='delete_toggle_groups'><input type='checkbox' id='checkbox_all_groups' name='checkbox_all' onclick=\"edit_all_toggle('groups');\"></span>\n";
  727. echo " </td>\n";
  728. }
  729. echo " </tr>\n";
  730. foreach ($contact_groups_assigned as $x => $field) {
  731. if (strlen($field['group_name']) > 0) {
  732. echo " <tr>\n";
  733. echo " <td class='vtable'>".escape($field['group_name'])."</td>\n";
  734. if (permission_exists('contact_group_delete')) {
  735. if (is_uuid($field['contact_group_uuid'])) {
  736. echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
  737. echo " <input type='checkbox' name='contact_groups_delete[".$x."][checked]' value='true' class='chk_delete checkbox_groups' onclick=\"edit_delete_action('groups');\">\n";
  738. echo " <input type='hidden' name='contact_groups_delete[".$x."][uuid]' value='".escape($field['contact_group_uuid'])."' />\n";
  739. }
  740. else {
  741. echo " <td>";
  742. }
  743. echo " </td>\n";
  744. }
  745. echo " </tr>\n";
  746. }
  747. }
  748. }
  749. if (permission_exists('contact_group_add')) {
  750. if (is_array($contact_groups_available) && @sizeof($contact_groups_available) != 0) {
  751. echo " <tr>\n";
  752. echo " <td class='vtable' style='border-bottom: none;' colspan='2'>\n";
  753. echo " <select name='group_uuid' class='formfld' style='width: auto; margin-right: 3px;'>\n";
  754. echo " <option value=''></option>\n";
  755. foreach ($contact_groups_available as $field) {
  756. if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show superadmin group to superadmins
  757. if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin"))) { continue; } //only show admin group to admins
  758. echo " <option value='".escape($field['group_uuid'])."'>".escape($field['group_name'])."</option>\n";
  759. }
  760. echo " </select>";
  761. if ($action == "update") {
  762. echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
  763. }
  764. echo " </td>\n";
  765. echo " </tr>\n";
  766. }
  767. }
  768. echo " </table>\n";
  769. echo " ".$text['description-groups']."\n";
  770. echo " </td>";
  771. echo "</tr>";
  772. }
  773. echo "<tr>\n";
  774. echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  775. echo " ".$text['label-contact_note']."\n";
  776. echo " </td>\n";
  777. echo " <td class='vtable' align='left'>\n";
  778. echo " <textarea class='formfld' style='width: 100%; height: 160px;' name='contact_note'>".$contact_note."</textarea>\n";
  779. echo " </td>\n";
  780. echo "</tr>\n";
  781. echo "</table>";
  782. echo "</td>\n";
  783. if ($action == "update") {
  784. echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
  785. echo "<td width='100%' valign='top'>\n";
  786. if (permission_exists('contact_phone_view')) { require "contact_phones.php"; }
  787. if (permission_exists('contact_address_view')) { require "contact_addresses.php"; }
  788. if (permission_exists('contact_email_view')) { require "contact_emails.php"; }
  789. if (permission_exists('contact_url_view')) { require "contact_urls.php"; }
  790. if (permission_exists('contact_extension_view')) { require "contact_extensions.php"; }
  791. if (permission_exists('contact_relation_view')) { require "contact_relations.php"; }
  792. if (permission_exists('contact_note_view')) { require "contact_notes.php"; }
  793. if (permission_exists('contact_time_view')) { require "contact_times.php"; }
  794. if (permission_exists('contact_setting_view')) { require "contact_settings.php"; }
  795. if (permission_exists('contact_attachment_view')) { require "contact_attachments.php"; }
  796. echo "</td>\n";
  797. }
  798. echo "</tr>\n";
  799. echo "</table>\n";
  800. echo "<br><br>";
  801. if ($action == "update") {
  802. echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
  803. }
  804. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  805. echo "</form>";
  806. //hide the delete button when nothing to delete
  807. if (
  808. $action == 'update' &&
  809. !permission_exists('contact_delete') && (
  810. (!is_array($contact_users_assigned) || @sizeof($contact_users_assigned) == 0) &&
  811. (!is_array($contact_groups_assigned) || @sizeof($contact_groups_assigned) == 0) &&
  812. (!is_array($contact_phones) || @sizeof($contact_phones) == 0) &&
  813. (!is_array($contact_addresses) || @sizeof($contact_addresses) == 0) &&
  814. (!is_array($contact_emails) || @sizeof($contact_emails) == 0) &&
  815. (!is_array($contact_urls) || @sizeof($contact_urls) == 0) &&
  816. (!is_array($contact_extensions) || @sizeof($contact_extensions) == 0) &&
  817. (!is_array($contact_relations) || @sizeof($contact_relations) == 0) &&
  818. (!is_array($contact_notes) || @sizeof($contact_notes) == 0) &&
  819. (!is_array($contact_times) || @sizeof($contact_times) == 0) &&
  820. (!is_array($contact_settings) || @sizeof($contact_settings) == 0) &&
  821. (!is_array($contact_attachments) || @sizeof($contact_attachments) == 0)
  822. )) {
  823. echo "<script>document.getElementsByName('btn_delete')[0].style.display='none';</script>\n";
  824. }
  825. //include the footer
  826. require_once "resources/footer.php";
  827. ?>