contact_edit.php 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754
  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) 2018-2024
  17. the Initial Developer. All Rights Reserved.
  18. */
  19. //includes files
  20. require_once dirname(__DIR__, 2) . "/resources/require.php";
  21. require_once "resources/check_auth.php";
  22. //check permissions
  23. if (permission_exists('contact_add') || permission_exists('contact_edit')) {
  24. //access granted
  25. }
  26. else {
  27. echo "access denied";
  28. exit;
  29. }
  30. //connect to the database
  31. $database = new database;
  32. //add multi-lingual support
  33. $language = new text;
  34. $text = $language->get();
  35. //set the defaults
  36. $contact_organization = '';
  37. $contact_name_prefix = '';
  38. $contact_name_given = '';
  39. $contact_name_middle = '';
  40. $contact_name_family = '';
  41. $contact_name_suffix = '';
  42. $contact_nickname = '';
  43. $contact_title = '';
  44. $contact_role = '';
  45. $contact_category = '';
  46. $contact_note = '';
  47. $url_label = '';
  48. $relation_label = '';
  49. $contact_attachments = [];
  50. //set from session variables
  51. $body_text_color = !empty($_SESSION['theme']['body_text_color']['text']) ? $_SESSION['theme']['body_text_color']['text'] : 'false';
  52. //action add or update
  53. if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
  54. $action = "update";
  55. $contact_uuid = $_REQUEST["id"];
  56. $id = $_REQUEST["id"];
  57. }
  58. else {
  59. $action = "add";
  60. }
  61. //get http post variables and set them to php variables
  62. if (!empty($_POST)) {
  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_type = $_POST["contact_type"];
  71. $contact_title = $_POST["contact_title"];
  72. $contact_role = $_POST["contact_role"];
  73. $contact_category = $_POST["contact_category"];
  74. $contact_time_zone = $_POST["contact_time_zone"];
  75. $contact_note = $_POST["contact_note"];
  76. $last_mod_date = $_POST["last_mod_date"] ?? null;
  77. $last_mod_user = $_POST["last_mod_user"] ?? null;
  78. //$contact_users = $_POST["contact_users"];
  79. //$contact_groups = $_POST["contact_groups"];
  80. $contact_user_uuid = ($_SESSION['contact']['permissions']['boolean'] == "true") ? ($_POST["contact_user_uuid"] ?? $_SESSION["user_uuid"]) : ($contact_user_uuid = $_POST["contact_user_uuid"] ?? null);
  81. $contact_group_uuid = $_POST["contact_group_uuid"] ?? null;
  82. $contact_phones = $_POST["contact_phones"];
  83. $contact_addresses = $_POST["contact_addresses"];
  84. $contact_emails = $_POST["contact_emails"];
  85. $contact_urls = $_POST["contact_urls"];
  86. $contact_relations = $_POST["contact_relations"];
  87. $contact_settings = $_POST["contact_settings"];
  88. $contact_attachments = $_POST["contact_attachments"] ?? null;
  89. $contact_times = $_POST["contact_times"] ?? null;
  90. $contact_notes = $_POST["contact_notes"] ?? null;
  91. }
  92. //process the user data and save it to the database
  93. if (!empty($_POST) && empty($_POST["persistformvar"])) {
  94. //debug info
  95. //view_array($_POST, true);
  96. //validate the token
  97. $token = new token;
  98. if (!$token->validate($_SERVER['PHP_SELF'])) {
  99. message::add($text['message-invalid_token'],'negative');
  100. header('Location: contacts.php');
  101. exit;
  102. }
  103. //process the http post data by submitted action
  104. if (!empty($_POST['action'])) {
  105. //prepare the array(s)
  106. $x = 0;
  107. if (!empty($_POST['contact_users']) && is_array($_POST['contact_users']) && @sizeof($_POST['contact_users']) != 0) {
  108. foreach ($_POST['contact_users'] as $row) {
  109. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  110. $array['contacts'][$x]['checked'] = $row['checked'];
  111. $array['contacts'][$x]['contact_users'][]['contact_user_uuid'] = $row['contact_user_uuid'];
  112. $x++;
  113. }
  114. }
  115. }
  116. $x = 0;
  117. if (!empty($_POST['contact_groups']) && is_array($_POST['contact_groups']) && @sizeof($_POST['contact_groups']) != 0) {
  118. foreach ($_POST['contact_groups'] as $row) {
  119. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  120. $array['contacts'][$x]['checked'] = $row['checked'];
  121. $array['contacts'][$x]['contact_groups'][]['contact_group_uuid'] = $row['contact_group_uuid'];
  122. $x++;
  123. }
  124. }
  125. }
  126. $x = 0;
  127. if (!empty($_POST['contact_phones']) && is_array($_POST['contact_phones']) && @sizeof($_POST['contact_phones']) != 0) {
  128. foreach ($_POST['contact_phones'] as $row) {
  129. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  130. $array['contacts'][$x]['checked'] = $row['checked'];
  131. $array['contacts'][$x]['contact_phones'][]['contact_phone_uuid'] = $row['contact_phone_uuid'];
  132. $x++;
  133. }
  134. }
  135. }
  136. $x = 0;
  137. if (!empty($_POST['contact_addresses']) && is_array($_POST['contact_addresses']) && @sizeof($_POST['contact_addresses']) != 0) {
  138. foreach ($_POST['contact_addresses'] as $row) {
  139. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  140. $array['contacts'][$x]['checked'] = $row['checked'];
  141. $array['contacts'][$x]['contact_addresses'][]['contact_address_uuid'] = $row['contact_address_uuid'];
  142. $x++;
  143. }
  144. }
  145. }
  146. $x = 0;
  147. if (!empty($_POST['contact_emails']) && is_array($_POST['contact_emails']) && @sizeof($_POST['contact_emails']) != 0) {
  148. foreach ($_POST['contact_emails'] as $row) {
  149. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  150. $array['contacts'][$x]['checked'] = $row['checked'];
  151. $array['contacts'][$x]['contact_emails'][]['contact_email_uuid'] = $row['contact_email_uuid'];
  152. $x++;
  153. }
  154. }
  155. }
  156. $x = 0;
  157. if (!empty($_POST['contact_urls']) && is_array($_POST['contact_urls']) && @sizeof($_POST['contact_urls']) != 0) {
  158. foreach ($_POST['contact_urls'] as $row) {
  159. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  160. $array['contacts'][$x]['checked'] = $row['checked'];
  161. $array['contacts'][$x]['contact_urls'][]['contact_url_uuid'] = $row['contact_url_uuid'];
  162. $x++;
  163. }
  164. }
  165. }
  166. $x = 0;
  167. if (!empty($_POST['contact_relations']) && is_array($_POST['contact_relations']) && @sizeof($_POST['contact_relations']) != 0) {
  168. foreach ($_POST['contact_relations'] as $row) {
  169. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  170. $array['contacts'][$x]['checked'] = $row['checked'];
  171. $array['contacts'][$x]['contact_relations'][]['contact_relation_uuid'] = $row['contact_relation_uuid'];
  172. $x++;
  173. }
  174. }
  175. }
  176. $x = 0;
  177. if (!empty($_POST['contact_settings']) && is_array($_POST['contact_settings']) && @sizeof($_POST['contact_settings']) != 0) {
  178. foreach ($_POST['contact_settings'] as $row) {
  179. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  180. $array['contacts'][$x]['checked'] = $row['checked'];
  181. $array['contacts'][$x]['contact_settings'][]['contact_setting_uuid'] = $row['contact_setting_uuid'];
  182. $x++;
  183. }
  184. }
  185. }
  186. $x = 0;
  187. if (!empty($_POST['contact_attachments']) && is_array($_POST['contact_attachments']) && @sizeof($_POST['contact_attachments']) != 0) {
  188. foreach ($_POST['contact_attachments'] as $row) {
  189. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  190. $array['contacts'][$x]['checked'] = $row['checked'];
  191. $array['contacts'][$x]['contact_attachments'][]['contact_attachment_uuid'] = $row['contact_attachment_uuid'];
  192. $x++;
  193. }
  194. }
  195. }
  196. $x = 0;
  197. if (!empty($_POST['contact_times']) && is_array($_POST['contact_times']) && @sizeof($_POST['contact_times']) != 0) {
  198. foreach ($_POST['contact_times'] as $row) {
  199. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  200. $array['contacts'][$x]['checked'] = $row['checked'];
  201. $array['contacts'][$x]['contact_times'][]['contact_time_uuid'] = $row['contact_time_uuid'];
  202. $x++;
  203. }
  204. }
  205. }
  206. $x = 0;
  207. if (!empty($_POST['contact_notes']) && is_array($_POST['contact_notes']) && @sizeof($_POST['contact_notes']) != 0) {
  208. foreach ($_POST['contact_notes'] as $row) {
  209. if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') {
  210. $array['contacts'][$x]['checked'] = $row['checked'];
  211. $array['contacts'][$x]['contact_notes'][]['contact_note_uuid'] = $row['contact_note_uuid'];
  212. $x++;
  213. }
  214. }
  215. }
  216. //send the array to the database class
  217. if (!empty($array)) {
  218. switch ($_POST['action']) {
  219. case 'copy':
  220. if (permission_exists('contact_add')) {
  221. $database->copy($array);
  222. }
  223. break;
  224. case 'delete':
  225. if (permission_exists('contact_delete')) {
  226. $database->delete($array);
  227. }
  228. break;
  229. case 'toggle':
  230. if (permission_exists('contact_update')) {
  231. $database->toggle($array);
  232. }
  233. break;
  234. }
  235. }
  236. //redirect the user
  237. if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
  238. header('Location: contact_edit.php?id='.$id);
  239. exit;
  240. }
  241. }
  242. //check for all required data
  243. $msg = '';
  244. //if (empty($contact_type)) { $msg .= $text['message-required']." ".$text['label-contact_type']."<br>\n"; }
  245. //if (empty($contact_title)) { $msg .= $text['message-required']." ".$text['label-contact_title']."<br>\n"; }
  246. //if (empty($contact_role)) { $msg .= $text['message-required']." ".$text['label-contact_role']."<br>\n"; }
  247. //if (empty($contact_category)) { $msg .= $text['message-required']." ".$text['label-contact_category']."<br>\n"; }
  248. //if (empty($contact_organization)) { $msg .= $text['message-required']." ".$text['label-contact_organization']."<br>\n"; }
  249. //if (empty($contact_name_prefix)) { $msg .= $text['message-required']." ".$text['label-contact_name_prefix']."<br>\n"; }
  250. //if (empty($contact_name_given)) { $msg .= $text['message-required']." ".$text['label-contact_name_given']."<br>\n"; }
  251. //if (empty($contact_name_middle)) { $msg .= $text['message-required']." ".$text['label-contact_name_middle']."<br>\n"; }
  252. //if (empty($contact_name_family)) { $msg .= $text['message-required']." ".$text['label-contact_name_family']."<br>\n"; }
  253. //if (empty($contact_name_suffix)) { $msg .= $text['message-required']." ".$text['label-contact_name_suffix']."<br>\n"; }
  254. //if (empty($contact_nickname)) { $msg .= $text['message-required']." ".$text['label-contact_nickname']."<br>\n"; }
  255. //if (empty($contact_time_zone)) { $msg .= $text['message-required']." ".$text['label-contact_time_zone']."<br>\n"; }
  256. //if (empty($last_mod_date)) { $msg .= $text['message-required']." ".$text['label-last_mod_date']."<br>\n"; }
  257. //if (empty($last_mod_user)) { $msg .= $text['message-required']." ".$text['label-last_mod_user']."<br>\n"; }
  258. //if (empty($contact_phones)) { $msg .= $text['message-required']." ".$text['label-contact_phones']."<br>\n"; }
  259. //if (empty($contact_addresses)) { $msg .= $text['message-required']." ".$text['label-contact_addresses']."<br>\n"; }
  260. //if (empty($contact_emails)) { $msg .= $text['message-required']." ".$text['label-contact_emails']."<br>\n"; }
  261. //if (empty($contact_urls)) { $msg .= $text['message-required']." ".$text['label-contact_urls']."<br>\n"; }
  262. //if (empty($contact_settings)) { $msg .= $text['message-required']." ".$text['label-contact_settings']."<br>\n"; }
  263. //if (empty($contact_user_uuid)) { $msg .= $text['message-required']." ".$text['label-contact_user_uuid']."<br>\n"; }
  264. //if (empty($contact_group_uuid)) { $msg .= $text['message-required']." ".$text['label-contact_group_uuid']."<br>\n"; }
  265. //if (empty($contact_note)) { $msg .= $text['message-required']." ".$text['label-contact_note']."<br>\n"; }
  266. if (!empty($msg) && empty($_POST["persistformvar"])) {
  267. require_once "resources/header.php";
  268. require_once "resources/persist_form_var.php";
  269. echo "<div align='center'>\n";
  270. echo "<table><tr><td>\n";
  271. echo $msg."<br />";
  272. echo "</td></tr></table>\n";
  273. persistformvar($_POST);
  274. echo "</div>\n";
  275. require_once "resources/footer.php";
  276. return;
  277. }
  278. //add the contact_uuid
  279. if (empty($_POST["contact_uuid"])) {
  280. $contact_uuid = uuid();
  281. }
  282. //prepare the array
  283. $array['contacts'][0]['contact_uuid'] = $contact_uuid;
  284. $array['contacts'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
  285. $array['contacts'][0]['contact_type'] = $contact_type;
  286. $array['contacts'][0]['contact_title'] = $contact_title;
  287. $array['contacts'][0]['contact_role'] = $contact_role;
  288. $array['contacts'][0]['contact_category'] = $contact_category;
  289. $array['contacts'][0]['contact_organization'] = $contact_organization;
  290. $array['contacts'][0]['contact_name_prefix'] = $contact_name_prefix;
  291. $array['contacts'][0]['contact_name_given'] = $contact_name_given;
  292. $array['contacts'][0]['contact_name_middle'] = $contact_name_middle;
  293. $array['contacts'][0]['contact_name_family'] = $contact_name_family;
  294. $array['contacts'][0]['contact_name_suffix'] = $contact_name_suffix;
  295. $array['contacts'][0]['contact_nickname'] = $contact_nickname;
  296. $array['contacts'][0]['contact_time_zone'] = $contact_time_zone;
  297. $array['contacts'][0]['last_mod_date'] = "now()";
  298. $array['contacts'][0]['last_mod_user'] = $_SESSION['user_uuid'];
  299. $array['contacts'][0]['contact_note'] = $contact_note;
  300. $y = 0;
  301. if (isset($contact_user_uuid)) {
  302. $sql = "select contact_uuid from v_contact_users ";
  303. $sql .= "where contact_uuid = :contact_uuid ";
  304. $sql .= "and user_uuid = :user_uuid ";
  305. $parameters['contact_uuid'] = $contact_uuid;
  306. $parameters['user_uuid'] = $contact_user_uuid;
  307. $users = $database->select($sql, $parameters, 'all');
  308. unset($sql, $parameters);
  309. if (is_array($users) === false || count($users) === 0)
  310. {
  311. $array['contacts'][0]['contact_users'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  312. $array['contacts'][0]['contact_users'][$y]['contact_user_uuid'] = uuid();
  313. $array['contacts'][0]['contact_users'][$y]['contact_uuid'] = $contact_uuid;
  314. $array['contacts'][0]['contact_users'][$y]['user_uuid'] = $contact_user_uuid;
  315. $y++;
  316. }
  317. }
  318. $y = 0;
  319. if (isset($contact_group_uuid)) {
  320. $array['contacts'][0]['contact_groups'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  321. $array['contacts'][0]['contact_groups'][$y]['contact_group_uuid'] = uuid();
  322. $array['contacts'][0]['contact_groups'][$y]['contact_uuid'] = $contact_uuid;
  323. $array['contacts'][0]['contact_groups'][$y]['group_uuid'] = $contact_group_uuid;
  324. $y++;
  325. }
  326. $y = 0;
  327. if (!empty($contact_phones)) {
  328. foreach ($contact_phones as $row) {
  329. if (!empty($row['phone_number'])) {
  330. //add the speed dial
  331. $array['contacts'][0]['contact_phones'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  332. $array['contacts'][0]['contact_phones'][$y]['contact_uuid'] = $contact_uuid;
  333. $array['contacts'][0]['contact_phones'][$y]['contact_phone_uuid'] = $row["contact_phone_uuid"];
  334. $array['contacts'][0]['contact_phones'][$y]['phone_label'] = $row["phone_label"];
  335. $array['contacts'][0]['contact_phones'][$y]['phone_type_voice'] = $row["phone_type_voice"] ?? null;
  336. $array['contacts'][0]['contact_phones'][$y]['phone_type_fax'] = $row["phone_type_fax"] ?? null;
  337. $array['contacts'][0]['contact_phones'][$y]['phone_type_video'] = $row["phone_type_video"] ?? null;
  338. $array['contacts'][0]['contact_phones'][$y]['phone_type_text'] = $row["phone_type_text"] ?? null;
  339. $array['contacts'][0]['contact_phones'][$y]['phone_speed_dial'] = $row["phone_speed_dial"];
  340. $array['contacts'][0]['contact_phones'][$y]['phone_country_code'] = $row["phone_country_code"];
  341. $array['contacts'][0]['contact_phones'][$y]['phone_number'] = $row["phone_number"];
  342. $array['contacts'][0]['contact_phones'][$y]['phone_extension'] = $row["phone_extension"];
  343. $array['contacts'][0]['contact_phones'][$y]['phone_primary'] = $row["phone_primary"];
  344. $array['contacts'][0]['contact_phones'][$y]['phone_description'] = $row["phone_description"];
  345. //clear the cache
  346. if (!empty($row["phone_speed_dial"])) {
  347. $cache = new cache;
  348. $cache->delete("app.dialplan.speed_dial.".$row["phone_speed_dial"]."@".$_SESSION['domain_name']);
  349. }
  350. //increment the row id
  351. $y++;
  352. }
  353. }
  354. }
  355. $y = 0;
  356. if (!empty($contact_addresses)) {
  357. foreach ($contact_addresses as $row) {
  358. if (!empty($row['address_street'])) {
  359. $array['contacts'][0]['contact_addresses'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  360. $array['contacts'][0]['contact_addresses'][$y]['contact_uuid'] = $contact_uuid;
  361. $array['contacts'][0]['contact_addresses'][$y]['contact_address_uuid'] = $row["contact_address_uuid"];
  362. $array['contacts'][0]['contact_addresses'][$y]['address_label'] = $row["address_label"];
  363. $array['contacts'][0]['contact_addresses'][$y]['address_type'] = $row["address_type"];
  364. $array['contacts'][0]['contact_addresses'][$y]['address_street'] = $row["address_street"];
  365. $array['contacts'][0]['contact_addresses'][$y]['address_extended'] = $row["address_extended"];
  366. if (permission_exists('address_community')) {
  367. $array['contacts'][0]['contact_addresses'][$y]['address_community'] = $row["address_community"];
  368. }
  369. $array['contacts'][0]['contact_addresses'][$y]['address_locality'] = $row["address_locality"];
  370. $array['contacts'][0]['contact_addresses'][$y]['address_region'] = $row["address_region"];
  371. $array['contacts'][0]['contact_addresses'][$y]['address_postal_code'] = $row["address_postal_code"];
  372. $array['contacts'][0]['contact_addresses'][$y]['address_country'] = $row["address_country"];
  373. if (permission_exists('address_latitude')) {
  374. $array['contacts'][0]['contact_addresses'][$y]['address_latitude'] = $row["address_latitude"];
  375. }
  376. if (permission_exists('address_longitude')) {
  377. $array['contacts'][0]['contact_addresses'][$y]['address_longitude'] = $row["address_longitude"];
  378. }
  379. $array['contacts'][0]['contact_addresses'][$y]['address_primary'] = $row["address_primary"];
  380. $array['contacts'][0]['contact_addresses'][$y]['address_description'] = $row["address_description"];
  381. $y++;
  382. }
  383. }
  384. }
  385. $y = 0;
  386. if (!empty($contact_emails)) {
  387. foreach ($contact_emails as $row) {
  388. if (!empty($row['email_address'])) {
  389. $array['contacts'][0]['contact_emails'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  390. $array['contacts'][0]['contact_emails'][$y]['contact_uuid'] = $contact_uuid;
  391. $array['contacts'][0]['contact_emails'][$y]['contact_email_uuid'] = $row["contact_email_uuid"];
  392. $array['contacts'][0]['contact_emails'][$y]['email_label'] = $row["email_label"];
  393. $array['contacts'][0]['contact_emails'][$y]['email_address'] = $row["email_address"];
  394. $array['contacts'][0]['contact_emails'][$y]['email_primary'] = $row["email_primary"];
  395. $array['contacts'][0]['contact_emails'][$y]['email_description'] = $row["email_description"];
  396. $y++;
  397. }
  398. }
  399. }
  400. $y = 0;
  401. if (!empty($contact_urls)) {
  402. foreach ($contact_urls as $row) {
  403. if (!empty($row['url_address'])) {
  404. $array['contacts'][0]['contact_urls'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  405. $array['contacts'][0]['contact_urls'][$y]['contact_uuid'] = $contact_uuid;
  406. $array['contacts'][0]['contact_urls'][$y]['contact_url_uuid'] = $row["contact_url_uuid"];
  407. $array['contacts'][0]['contact_urls'][$y]['url_type'] = $row["url_type"] ?? '';
  408. $array['contacts'][0]['contact_urls'][$y]['url_label'] = $row["url_label"];
  409. $array['contacts'][0]['contact_urls'][$y]['url_address'] = $row["url_address"];
  410. $array['contacts'][0]['contact_urls'][$y]['url_primary'] = $row["url_primary"];
  411. $array['contacts'][0]['contact_urls'][$y]['url_description'] = $row["url_description"];
  412. $y++;
  413. }
  414. }
  415. }
  416. $y = 0;
  417. if (!empty($contact_relations)) {
  418. foreach ($contact_relations as $row) {
  419. if (!empty($row['contact_relation_uuid'])) {
  420. $array['contacts'][0]['contact_relations'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  421. $array['contacts'][0]['contact_relations'][$y]['contact_uuid'] = $contact_uuid;
  422. $array['contacts'][0]['contact_relations'][$y]['contact_relation_uuid'] = $row["contact_relation_uuid"];
  423. $array['contacts'][0]['contact_relations'][$y]['relation_label'] = $row["relation_label"];
  424. $array['contacts'][0]['contact_relations'][$y]['relation_contact_uuid'] = $row["relation_contact_uuid"];
  425. $y++;
  426. }
  427. }
  428. }
  429. $y = 0;
  430. if (!empty($contact_settings)) {
  431. foreach ($contact_settings as $row) {
  432. if (strlen($row['contact_setting_category']) > 0 && strlen($row['contact_setting_subcategory']) > 0 && !empty($row['contact_setting_name'])) {
  433. $array['contacts'][0]['contact_settings'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
  434. $array['contacts'][0]['contact_settings'][$y]['contact_uuid'] = $contact_uuid;
  435. $array['contacts'][0]['contact_settings'][$y]['contact_setting_uuid'] = $row["contact_setting_uuid"];
  436. $array['contacts'][0]['contact_settings'][$y]['contact_setting_category'] = $row["contact_setting_category"];
  437. $array['contacts'][0]['contact_settings'][$y]['contact_setting_subcategory'] = $row["contact_setting_subcategory"];
  438. $array['contacts'][0]['contact_settings'][$y]['contact_setting_name'] = $row["contact_setting_name"];
  439. $array['contacts'][0]['contact_settings'][$y]['contact_setting_value'] = $row["contact_setting_value"];
  440. $array['contacts'][0]['contact_settings'][$y]['contact_setting_order'] = $row["contact_setting_order"];
  441. $array['contacts'][0]['contact_settings'][$y]['contact_setting_enabled'] = $row["contact_setting_enabled"];
  442. $array['contacts'][0]['contact_settings'][$y]['contact_setting_description'] = $row["contact_setting_description"];
  443. $y++;
  444. }
  445. }
  446. }
  447. $y = 0;
  448. if (!empty($contact_attachments)) {
  449. foreach ($contact_attachments as $row) {
  450. $array['contacts'][0]['contact_attachments'][$y]['contact_attachment_uuid'] = $row["contact_attachment_uuid"];
  451. $array['contacts'][0]['contact_attachments'][$y]['domain_uuid'] = $row["domain_uuid"];
  452. $array['contacts'][0]['contact_attachments'][$y]['contact_uuid'] = $row["contact_uuid"];
  453. $array['contacts'][0]['contact_attachments'][$y]['attachment_primary'] = $row["attachment_primary"];
  454. //$array['contacts'][0]['contact_attachments'][$y]['attachment_filename'] = $row["attachment_filename"];
  455. //$array['contacts'][0]['contact_attachments'][$y]['attachment_content'] = $row["attachment_content"];
  456. $array['contacts'][0]['contact_attachments'][$y]['attachment_description'] = $row["attachment_description"] ?? null;
  457. //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_date'] = $row["attachment_uploaded_date"];
  458. //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_user_uuid'] = $row["attachment_uploaded_user_uuid"];
  459. //$array['contacts'][0]['contact_attachments'][$y]['attachment_size'] = $row["attachment_size"];
  460. $y++;
  461. }
  462. }
  463. $y = 0;
  464. if (!empty($contact_times)) {
  465. foreach ($contact_times as $row) {
  466. if (!empty($row['time_start'])) {
  467. $array['contacts'][0]['contact_times'][$y]['contact_time_uuid'] = $row["contact_time_uuid"];
  468. $array['contacts'][0]['contact_times'][$y]['domain_uuid'] = $row["domain_uuid"];
  469. $array['contacts'][0]['contact_times'][$y]['contact_uuid'] = $row["contact_uuid"];
  470. $array['contacts'][0]['contact_times'][$y]['time_start'] = $row["time_start"];
  471. $array['contacts'][0]['contact_times'][$y]['time_stop'] = $row["time_stop"];
  472. $array['contacts'][0]['contact_times'][$y]['time_description'] = $row["time_description"];
  473. $y++;
  474. }
  475. }
  476. }
  477. $y = 0;
  478. if (!empty($contact_notes)) {
  479. foreach ($contact_notes as $row) {
  480. if (!empty($row['contact_note'])) {
  481. $array['contacts'][0]['contact_notes'][$y]['contact_note_uuid'] = $row["contact_note_uuid"];
  482. $array['contacts'][0]['contact_notes'][$y]['domain_uuid'] = $row["domain_uuid"];
  483. $array['contacts'][0]['contact_notes'][$y]['contact_uuid'] = $row["contact_uuid"];
  484. $array['contacts'][0]['contact_notes'][$y]['contact_note'] = $row["contact_note"];
  485. $array['contacts'][0]['contact_notes'][$y]['last_mod_date'] = 'now()';
  486. $array['contacts'][0]['contact_notes'][$y]['last_mod_user'] = $_SESSION['username'];
  487. $y++;
  488. }
  489. }
  490. }
  491. //save the data
  492. if (!empty($array)) {
  493. //add the permission object
  494. $p = permissions::new();
  495. $p->add('contact_add', 'temp');
  496. $p->add('contact_phone_add', 'temp');
  497. $p->add('contact_address_add', 'temp');
  498. $p->add('contact_user_add', 'temp');
  499. $p->add('contact_group_add', 'temp');
  500. //view_array($array);
  501. $database->app_name = 'contacts';
  502. $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
  503. $database->save($array);
  504. $message = $database->message;
  505. unset($array);
  506. //view_array($message);
  507. $p->delete('contact_add', 'temp');
  508. $p->delete('contact_phone_add', 'temp');
  509. $p->delete('contact_address_add', 'temp');
  510. $p->delete('contact_user_add', 'temp');
  511. $p->delete('contact_group_add', 'temp');
  512. }
  513. //redirect the user
  514. if (isset($action)) {
  515. if ($action == "add") {
  516. $_SESSION["message"] = $text['message-add'];
  517. }
  518. if ($action == "update") {
  519. $_SESSION["message"] = $text['message-update'];
  520. }
  521. //header('Location: contacts.php');
  522. header('Location: contact_edit.php?id='.urlencode($contact_uuid ?? null));
  523. return;
  524. }
  525. }
  526. //pre-populate the form
  527. if (!empty($_GET) && empty($_POST["persistformvar"])) {
  528. $sql = "select * from v_contacts ";
  529. $sql .= "where contact_uuid = :contact_uuid ";
  530. //$sql .= "and domain_uuid = :domain_uuid ";
  531. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  532. $parameters['contact_uuid'] = $contact_uuid;
  533. $row = $database->select($sql, $parameters ?? null, 'row');
  534. if (!empty($row)) {
  535. $contact_organization = $row["contact_organization"];
  536. $contact_name_prefix = $row["contact_name_prefix"];
  537. $contact_name_given = $row["contact_name_given"];
  538. $contact_name_middle = $row["contact_name_middle"];
  539. $contact_name_family = $row["contact_name_family"];
  540. $contact_name_suffix = $row["contact_name_suffix"];
  541. $contact_nickname = $row["contact_nickname"];
  542. $contact_type = $row["contact_type"];
  543. $contact_title = $row["contact_title"];
  544. $contact_role = $row["contact_role"];
  545. $contact_category = $row["contact_category"];
  546. $contact_time_zone = $row["contact_time_zone"];
  547. $contact_note = $row["contact_note"];
  548. $last_mod_date = $row["last_mod_date"];
  549. $last_mod_user = $row["last_mod_user"];
  550. //$contact_phones = $row["contact_phones"];
  551. //$contact_addresses = $row["contact_addresses"];
  552. //$contact_emails = $row["contact_emails"];
  553. //$contact_urls = $row["contact_urls"];
  554. //$contact_settings = $row["contact_settings"];
  555. //$contact_user_uuid = $row["contact_user_uuid"];
  556. $contact_user_uuid = $row["contact_user_uuid"] ?? '';
  557. $contact_group_uuid = $row["contact_group_uuid"] ?? '';
  558. }
  559. unset($sql, $parameters, $row);
  560. }
  561. //get the users array
  562. $sql = "select * from v_users ";
  563. $sql .= "where domain_uuid = :domain_uuid ";
  564. $sql .= "order by username asc ";
  565. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  566. $users = $database->select($sql, $parameters, 'all');
  567. unset($sql, $parameters);
  568. //determine if contact assigned to a user
  569. if (!empty($users)) {
  570. foreach ($users as $user) {
  571. if (!empty($contact_uuid) && $user['contact_uuid'] == $contact_uuid) {
  572. $contact_user_uuid = $user['user_uuid'];
  573. break;
  574. }
  575. }
  576. }
  577. //get the users assigned to this contact
  578. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  579. $sql = "select c.domain_uuid, c.contact_uuid, u.username, u.user_uuid, a.contact_user_uuid ";
  580. $sql .= "from v_contacts as c, v_users as u, v_contact_users as a ";
  581. $sql .= "where c.contact_uuid = :contact_uuid ";
  582. $sql .= "and c.domain_uuid = :domain_uuid ";
  583. $sql .= "and u.user_uuid = a.user_uuid ";
  584. $sql .= "and c.contact_uuid = a.contact_uuid ";
  585. $sql .= "order by u.username asc ";
  586. $parameters['contact_uuid'] = $contact_uuid;
  587. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  588. $contact_users_assigned = $database->select($sql, $parameters, 'all');
  589. unset($sql, $parameters);
  590. }
  591. //get the assigned groups of this contact
  592. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  593. $sql = "select g.*, cg.contact_group_uuid ";
  594. $sql .= "from v_groups as g, v_contact_groups as cg ";
  595. $sql .= "where cg.group_uuid = g.group_uuid ";
  596. $sql .= "and cg.domain_uuid = :domain_uuid ";
  597. $sql .= "and cg.contact_uuid = :contact_uuid ";
  598. $sql .= "and cg.group_uuid <> :group_uuid ";
  599. $sql .= "order by g.group_name asc ";
  600. $parameters['domain_uuid'] = $domain_uuid;
  601. $parameters['contact_uuid'] = $contact_uuid;
  602. $parameters['group_uuid'] = $_SESSION["user_uuid"];
  603. $contact_groups_assigned = $database->select($sql, $parameters, 'all');
  604. if (!empty($contact_groups_assigned)) {
  605. foreach ($contact_groups_assigned as $field) {
  606. $contact_groups[] = "'".$field['group_uuid']."'";
  607. }
  608. }
  609. unset($sql, $parameters);
  610. }
  611. //get the available groups to this contact
  612. $sql = "select group_uuid, group_name from v_groups ";
  613. $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
  614. if (!empty($contact_groups)) {
  615. $sql .= "and group_uuid not in (".implode(',', $contact_groups).") ";
  616. }
  617. $sql .= "order by group_name asc ";
  618. $parameters['domain_uuid'] = $domain_uuid;
  619. $contact_groups_available = $database->select($sql, $parameters, 'all');
  620. unset($sql, $parameters, $contact_groups);
  621. //get the child data
  622. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  623. $sql = "select * from v_contact_phones ";
  624. $sql .= "where contact_uuid = :contact_uuid ";
  625. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  626. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  627. $parameters['contact_uuid'] = $contact_uuid;
  628. $contact_phones = $database->select($sql, $parameters, 'all');
  629. unset ($sql, $parameters);
  630. }
  631. //add the $contact_phone_uuid
  632. if (empty($contact_phone_uuid)) {
  633. $contact_phone_uuid = uuid();
  634. }
  635. //add an empty row
  636. if (empty($contact_phones) || count($contact_phones) == 0) {
  637. $x = !empty($contact_phones) ? count($contact_phones) : 0;
  638. $contact_phones[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  639. $contact_phones[$x]['contact_uuid'] = $contact_uuid ?? null;
  640. $contact_phones[$x]['contact_phone_uuid'] = uuid();
  641. $contact_phones[$x]['phone_label'] = '';
  642. $contact_phones[$x]['phone_type_voice'] = '';
  643. $contact_phones[$x]['phone_type_fax'] = '';
  644. $contact_phones[$x]['phone_type_video'] = '';
  645. $contact_phones[$x]['phone_type_text'] = '';
  646. $contact_phones[$x]['phone_speed_dial'] = '';
  647. $contact_phones[$x]['phone_country_code'] = '';
  648. $contact_phones[$x]['phone_number'] = '';
  649. $contact_phones[$x]['phone_extension'] = '';
  650. $contact_phones[$x]['phone_primary'] = '';
  651. $contact_phones[$x]['phone_description'] = '';
  652. }
  653. //get the child data
  654. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  655. $sql = "select * from v_contact_addresses ";
  656. $sql .= "where contact_uuid = :contact_uuid ";
  657. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  658. $sql .= "order by address_street asc";
  659. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  660. $parameters['contact_uuid'] = $contact_uuid;
  661. $contact_addresses = $database->select($sql, $parameters, 'all');
  662. unset ($sql, $parameters);
  663. }
  664. //add the $contact_address_uuid
  665. if (empty($contact_address_uuid)) {
  666. $contact_address_uuid = uuid();
  667. }
  668. //add an empty row
  669. if (empty($contact_addresses) || count($contact_addresses) == 0) {
  670. $x = !empty($contact_addresses) ? count($contact_addresses) : 0;
  671. $contact_addresses[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  672. $contact_addresses[$x]['contact_uuid'] = $contact_uuid ?? null;
  673. $contact_addresses[$x]['contact_address_uuid'] = uuid();
  674. $contact_addresses[$x]['address_label'] = '';
  675. $contact_addresses[$x]['address_type'] = '';
  676. $contact_addresses[$x]['address_street'] = '';
  677. $contact_addresses[$x]['address_extended'] = '';
  678. $contact_addresses[$x]['address_community'] = '';
  679. $contact_addresses[$x]['address_locality'] = '';
  680. $contact_addresses[$x]['address_region'] = '';
  681. $contact_addresses[$x]['address_postal_code'] = '';
  682. $contact_addresses[$x]['address_country'] = '';
  683. $contact_addresses[$x]['address_latitude'] = '';
  684. $contact_addresses[$x]['address_longitude'] = '';
  685. $contact_addresses[$x]['address_primary'] = '';
  686. $contact_addresses[$x]['address_description'] = '';
  687. }
  688. //get the child data
  689. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  690. $sql = "select * from v_contact_emails ";
  691. $sql .= "where contact_uuid = :contact_uuid ";
  692. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  693. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  694. $parameters['contact_uuid'] = $contact_uuid;
  695. $contact_emails = $database->select($sql, $parameters, 'all');
  696. unset ($sql, $parameters);
  697. }
  698. //add the $contact_email_uuid
  699. if (empty($contact_email_uuid)) {
  700. $contact_email_uuid = uuid();
  701. }
  702. //add an empty row
  703. if (empty($contact_emails) || count($contact_emails) == 0) {
  704. $x = !empty($contact_emails) ? count($contact_emails) : 0;
  705. $contact_emails[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  706. $contact_emails[$x]['contact_uuid'] = $contact_uuid ?? null;
  707. $contact_emails[$x]['contact_email_uuid'] = uuid();
  708. $contact_emails[$x]['email_label'] = '';
  709. $contact_emails[$x]['email_address'] = '';
  710. $contact_emails[$x]['email_primary'] = '';
  711. $contact_emails[$x]['email_description'] = '';
  712. }
  713. //get the child data
  714. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  715. $sql = "select * from v_contact_urls ";
  716. $sql .= "where contact_uuid = :contact_uuid ";
  717. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  718. $sql .= "order by url_address asc";
  719. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  720. $parameters['contact_uuid'] = $contact_uuid;
  721. $contact_urls = $database->select($sql, $parameters, 'all');
  722. unset ($sql, $parameters);
  723. }
  724. //add the $contact_url_uuid
  725. if (empty($contact_url_uuid)) {
  726. $contact_url_uuid = uuid();
  727. }
  728. //add an empty row
  729. if (empty($contact_urls) || count($contact_urls) == 0) {
  730. $x = !empty($contact_urls) ? count($contact_urls) : 0;
  731. $contact_urls[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  732. $contact_urls[$x]['contact_uuid'] = $contact_uuid ?? null;
  733. $contact_urls[$x]['contact_url_uuid'] = uuid();
  734. $contact_urls[$x]['url_type'] = '';
  735. $contact_urls[$x]['url_label'] = '';
  736. $contact_urls[$x]['url_address'] = '';
  737. $contact_urls[$x]['url_primary'] = '';
  738. $contact_urls[$x]['url_description'] = '';
  739. }
  740. //get the child data
  741. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  742. $sql = "select * from v_contact_relations ";
  743. $sql .= "where contact_uuid = :contact_uuid ";
  744. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  745. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  746. $parameters['contact_uuid'] = $contact_uuid ?? null;
  747. $contact_relations = $database->select($sql, $parameters, 'all');
  748. unset ($sql, $parameters);
  749. }
  750. //add the $contact_setting_uuid
  751. if (empty($contact_relation_uuid)) {
  752. $contact_relation_uuid = uuid();
  753. }
  754. //add an empty row
  755. if (empty($contact_relations) || count($contact_relations) == 0) {
  756. $x = !empty($contact_relations) ? count($contact_relations) : 0;
  757. $contact_relations[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  758. $contact_relations[$x]['contact_uuid'] = $contact_uuid ?? null;
  759. $contact_relations[$x]['contact_relation_uuid'] = uuid();
  760. $contact_relations[$x]['relation_label'] = '';
  761. $contact_relations[$x]['relation_contact_uuid'] = '';
  762. }
  763. //get the child data
  764. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  765. $sql = "select * from v_contact_settings ";
  766. $sql .= "where contact_uuid = :contact_uuid ";
  767. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  768. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  769. $parameters['contact_uuid'] = $contact_uuid;
  770. $contact_settings = $database->select($sql, $parameters, 'all');
  771. unset ($sql, $parameters);
  772. }
  773. //add the $contact_setting_uuid
  774. if (empty($contact_setting_uuid)) {
  775. $contact_setting_uuid = uuid();
  776. }
  777. //add an empty row
  778. if (empty($contact_settings) || count($contact_settings) == 0) {
  779. $x = !empty($contact_settings) ? count($contact_settings) : 0;
  780. $contact_settings[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  781. $contact_settings[$x]['contact_uuid'] = $contact_uuid ?? null;
  782. $contact_settings[$x]['contact_setting_uuid'] = uuid();
  783. $contact_settings[$x]['contact_setting_category'] = '';
  784. $contact_settings[$x]['contact_setting_subcategory'] = '';
  785. $contact_settings[$x]['contact_setting_name'] = '';
  786. $contact_settings[$x]['contact_setting_value'] = '';
  787. $contact_settings[$x]['contact_setting_order'] = '';
  788. $contact_settings[$x]['contact_setting_enabled'] = '';
  789. $contact_settings[$x]['contact_setting_description'] = '';
  790. }
  791. //get the contact attachments
  792. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  793. $sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments ";
  794. $sql .= "where domain_uuid = :domain_uuid ";
  795. $sql .= "and contact_uuid = :contact_uuid ";
  796. $sql .= "order by attachment_primary desc, attachment_filename asc ";
  797. $parameters['domain_uuid'] = $domain_uuid;
  798. $parameters['contact_uuid'] = $contact_uuid;
  799. $contact_attachments = $database->select($sql, $parameters, 'all');
  800. unset($sql, $parameters);
  801. }
  802. //get the child data
  803. if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
  804. $sql = "select * from v_contact_times ";
  805. $sql .= "where contact_uuid = :contact_uuid ";
  806. //$sql .= "and domain_uuid = '".$domain_uuid."' ";
  807. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  808. $parameters['contact_uuid'] = $contact_uuid;
  809. $contact_times = $database->select($sql, $parameters, 'all');
  810. unset ($sql, $parameters);
  811. }
  812. //add the $contact_time_uuid
  813. if (empty($contact_time_uuid)) {
  814. $contact_time_uuid = uuid();
  815. }
  816. //add an empty row
  817. if (empty($contact_times)) {
  818. $x = !empty($contact_times) ? count($contact_times) : 0;
  819. $contact_times[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  820. $contact_times[$x]['contact_uuid'] = $contact_uuid ?? null;
  821. $contact_times[$x]['contact_time_uuid'] = uuid();
  822. }
  823. //get the contact notes
  824. $sql = "select * from v_contact_notes ";
  825. $sql .= "where domain_uuid = :domain_uuid ";
  826. $sql .= "and contact_uuid = :contact_uuid ";
  827. $sql .= "order by last_mod_date desc ";
  828. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  829. $parameters['contact_uuid'] = $contact_uuid ?? null;
  830. $contact_notes = $database->select($sql, $parameters, 'all');
  831. unset($sql, $parameters);
  832. //add an empty row
  833. if (empty($contact_times)) {
  834. $x = !empty($contact_times) ? count($contact_times) : 0;
  835. $contact_times[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
  836. $contact_times[$x]['contact_uuid'] = $contact_uuid ?? null;
  837. $contact_times[$x]['contact_time_uuid'] = uuid();
  838. }
  839. //create token
  840. $object = new token;
  841. $token = $object->create($_SERVER['PHP_SELF']);
  842. //show the header
  843. $document['title'] = $text['title-contact-edit'];
  844. require_once "resources/header.php";
  845. ?>
  846. <script type="text/javascript">
  847. function get_contacts(element_id, id, search) {
  848. var xhttp = new XMLHttpRequest();
  849. xhttp.onreadystatechange = function() {
  850. if (this.readyState == 4 && this.status == 200) {
  851. //create a handle for the contact select object
  852. select = document.getElementById(element_id);
  853. //remove current options
  854. while (select.options.length > 0) {
  855. select.remove(0);
  856. }
  857. //add an empty row
  858. //select.add(new Option('', ''));
  859. //add new options from the json results
  860. obj = JSON.parse(this.responseText);
  861. for (var i=0; i < obj.length; i++) {
  862. select.add(new Option(obj[i].name, obj[i].id));
  863. }
  864. }
  865. };
  866. if (search) {
  867. xhttp.open("GET", "/app/contacts/contact_json.php?search="+search, true);
  868. }
  869. else {
  870. xhttp.open("GET", "/app/contacts/contact_json.php", true);
  871. }
  872. xhttp.send();
  873. }
  874. </script>
  875. <?php
  876. //determine qr branding
  877. if (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') {
  878. echo "<img id='img-buffer' style='display: none;' src='".$_SESSION["theme"]["qr_brand_image"]["text"]."'>";
  879. $qr_option = "image: $('#img-buffer')[0],";
  880. $qr_mode = '4';
  881. $qr_size = '0.2';
  882. }
  883. elseif (empty($_SESSION['theme']['qr_brand_image']['text']) && !empty($_SESSION['theme']['qr_brand_type']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') {
  884. $qr_option = '';
  885. $qr_mode = '3';
  886. $qr_size = '0';
  887. }
  888. elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'text') {
  889. $qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"';
  890. $qr_mode = '2';
  891. $qr_size = '0.05';
  892. }
  893. elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'none') {
  894. $qr_option = '';
  895. $qr_mode = '3';
  896. $qr_size = '0';
  897. }
  898. else {
  899. echo "<img id='img-buffer' style='display: none;' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png'>";
  900. $qr_option = "image: $('#img-buffer')[0],";
  901. $qr_mode = '4';
  902. $qr_size = '0.2';
  903. }
  904. //qr code generation
  905. $_GET['type'] = "text";
  906. $qr_vcard = true;
  907. include "contacts_vcard.php";
  908. echo "<input type='hidden' id='qr_vcard' value=\"".$qr_vcard."\">";
  909. echo "<style>";
  910. echo " #qr_code_container {";
  911. echo " z-index: 999999; ";
  912. echo " position: fixed; ";
  913. echo " left: 0; ";
  914. echo " top: 0; ";
  915. echo " right: 0; ";
  916. echo " bottom: 0; ";
  917. echo " text-align: center; ";
  918. echo " vertical-align: middle;";
  919. echo " }";
  920. echo " #qr_code {";
  921. echo " display: block; ";
  922. echo " width: 100%; ";
  923. echo " max-width: 650px; ";
  924. echo " height: auto; ";
  925. echo " -webkit-box-shadow: 0px 1px 20px #888; ";
  926. echo " -moz-box-shadow: 0px 1px 20px #888; ";
  927. echo " box-shadow: 0px 1px 20px #888;";
  928. echo " }";
  929. echo " #qr_code > img {";
  930. echo " width: 100%; ";
  931. echo " max-width: 650px; ";
  932. echo " height: auto; ";
  933. echo " }";
  934. echo "</style>";
  935. echo "<script src='".PROJECT_PATH."/resources/jquery/jquery-qrcode.min.js'></script>";
  936. echo "<script language='JavaScript' type='text/javascript'>";
  937. echo " $(document).ready(function() {";
  938. echo " $('#qr_code').qrcode({ ";
  939. echo " render: 'image', ";
  940. echo " minVersion: 6, ";
  941. echo " maxVersion: 40, ";
  942. echo " ecLevel: 'H', ";
  943. echo " size: 650, ";
  944. echo " radius: 0.2, ";
  945. echo " quiet: 6, ";
  946. echo " background: '#fff', ";
  947. echo " mode: ".$qr_mode.", ";
  948. echo " mSize: ".$qr_size.", ";
  949. echo " mPosX: 0.5, ";
  950. echo " mPosY: 0.5, ";
  951. echo " text: document.getElementById('qr_vcard').value, ";
  952. echo " ".$qr_option;
  953. echo " });";
  954. echo " });";
  955. echo "</script>";
  956. //styles and attachment viewing layer
  957. if (permission_exists('contact_attachment_view') && !empty($contact_attachments) && is_array($contact_attachments)) {
  958. echo "<style>\n";
  959. echo " #contact_attachment_layer {\n";
  960. echo " z-index: 999999;\n";
  961. echo " position: fixed;\n";
  962. echo " left: 0px;\n";
  963. echo " top: 0px;\n";
  964. echo " right: 0px;\n";
  965. echo " bottom: 0px;\n";
  966. echo " text-align: center;\n";
  967. echo " vertical-align: middle;\n";
  968. echo " }\n";
  969. echo "</style>\n";
  970. echo "<div id='contact_attachment_layer' style='display: none;'></div>\n";
  971. }
  972. //show the content
  973. echo "<form name='frm' id='frm' method='post' action=''>\n";
  974. echo "<input class='formfld' type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
  975. echo "<div class='action_bar' id='action_bar'>\n";
  976. echo " <div class='heading'><b>".$text['title-contact-edit']."</b></div>\n";
  977. echo " <div class='actions'>\n";
  978. 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'=>'contact_view.php?id='.$contact_uuid]);
  979. if ($action == 'update') {
  980. if (permission_exists('contact_phone_add')) {
  981. 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');"]);
  982. }
  983. if (permission_exists('contact_phone_delete')) {
  984. 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');"]);
  985. }
  986. }
  987. //add edit
  988. if (isset($id)) {
  989. if (permission_exists('contact_time_add')) {
  990. //detect timer state (and start time)
  991. $sql = "select ";
  992. $sql .= "time_start ";
  993. $sql .= "from v_contact_times ";
  994. $sql .= "where domain_uuid = :domain_uuid ";
  995. $sql .= "and user_uuid = :user_uuid ";
  996. $sql .= "and contact_uuid = :contact_uuid ";
  997. $sql .= "and time_start is not null ";
  998. $sql .= "and time_stop is null ";
  999. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  1000. $parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
  1001. $parameters['contact_uuid'] = $contact_uuid;
  1002. $time_start = $database->select($sql, $parameters, 'column');
  1003. $btn_style = $time_start ? 'color: #fff; background-color: #3693df; background-image: none;' : null;
  1004. unset($sql, $parameters);
  1005. 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');"]);
  1006. }
  1007. echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
  1008. echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid ?? null).'&type=download']);
  1009. }
  1010. //add edit
  1011. //if (isset($id)) {
  1012. //echo button::create(['type'=>'button','label'=>$text['button-notes'],'icon'=>'','collapse'=>'hide-xs','style'=>'margin-right: 0px;','link'=>"contact_notes.php?id=$id"]);
  1013. //}
  1014. //add user
  1015. if (isset($id) && permission_exists('user_edit')) {
  1016. 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 ?? '')]);
  1017. }
  1018. if (
  1019. $action == "update" && (
  1020. permission_exists('contact_phone_add') ||
  1021. permission_exists('contact_address_add') ||
  1022. permission_exists('contact_email_add') ||
  1023. permission_exists('contact_url_add') ||
  1024. permission_exists('contact_relation_add') ||
  1025. permission_exists('contact_note_add') ||
  1026. permission_exists('contact_time_add') ||
  1027. permission_exists('contact_setting_add') ||
  1028. permission_exists('contact_attachment_add')
  1029. )) {
  1030. 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 ?? null)."';\">\n";
  1031. echo " <option value=''>".$text['button-add']."...</option>\n";
  1032. if (permission_exists('contact_phone_add')) { echo "<option value='phone'>".$text['label-phone_number']."</option>\n"; }
  1033. if (permission_exists('contact_address_add')) { echo "<option value='address'>".$text['label-address_address']."</option>\n"; }
  1034. if (permission_exists('contact_email_add')) { echo "<option value='email'>".$text['label-email']."</option>\n"; }
  1035. if (permission_exists('contact_url_add')) { echo "<option value='url'>".$text['label-url']."</option>\n"; }
  1036. if (permission_exists('contact_relation_add')) { echo "<option value='relation'>".$text['label-contact_relation_label']."</option>\n"; }
  1037. if (permission_exists('contact_note_add')) { echo "<option value='note'>".$text['label-contact_note']."</option>\n"; }
  1038. if (permission_exists('contact_time_add')) { echo "<option value='time'>".$text['label-time_time']."</option>\n"; }
  1039. if (permission_exists('contact_setting_add')) { echo "<option value='setting'>".$text['label-setting']."</option>\n"; }
  1040. if (permission_exists('contact_attachment_add')) { echo "<option value='attachment'>".$text['label-attachment']."</option>\n"; }
  1041. echo " </select>";
  1042. }
  1043. if (
  1044. $action == "update" && (
  1045. permission_exists('contact_delete') ||
  1046. permission_exists('contact_user_delete') ||
  1047. permission_exists('contact_group_delete') ||
  1048. permission_exists('contact_phone_delete') ||
  1049. permission_exists('contact_address_delete') ||
  1050. permission_exists('contact_email_delete') ||
  1051. permission_exists('contact_url_delete') ||
  1052. permission_exists('contact_relation_delete') ||
  1053. permission_exists('contact_note_delete') ||
  1054. permission_exists('contact_time_delete') ||
  1055. permission_exists('contact_setting_delete') ||
  1056. permission_exists('contact_attachment_delete')
  1057. )) {
  1058. 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');"]);
  1059. }
  1060. 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']);
  1061. echo " </div>\n";
  1062. echo " <div style='clear: both;'></div>\n";
  1063. echo "</div>\n";
  1064. echo $text['description-contact-edit']."\n";
  1065. echo "<br /><br />\n";
  1066. if ($action == 'update') {
  1067. if (permission_exists('contact_add')) {
  1068. 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();"])]);
  1069. }
  1070. if (permission_exists('contact_delete')) {
  1071. 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();"])]);
  1072. }
  1073. }
  1074. ?>
  1075. <style>
  1076. * {
  1077. box-sizing: border-box;
  1078. }
  1079. input[type=text], select, textarea {
  1080. width: 100%;
  1081. padding: 12px;
  1082. border: 1px solid #ccc;
  1083. border-radius: 4px;
  1084. resize: vertical;
  1085. }
  1086. label {
  1087. padding: 12px 12px 12px 0;
  1088. display: inline-block;
  1089. }
  1090. input[type=submit] {
  1091. background-color: #4CAF50;
  1092. color: white;
  1093. padding: 12px 20px;
  1094. border: none;
  1095. border-radius: 100px;
  1096. cursor: pointer;
  1097. float: right;
  1098. }
  1099. input[type=submit]:hover {
  1100. background-color: #45a049;
  1101. }
  1102. option:first-child {
  1103. color: #ccc;
  1104. }
  1105. .container {
  1106. border-radius: 5px;
  1107. background-color: #f2f2f2;
  1108. padding: 20px;
  1109. }
  1110. .col-25 {
  1111. float: left;
  1112. width: 25%;
  1113. margin-top: 6px;
  1114. }
  1115. .col-75 {
  1116. float: left;
  1117. width: 75%;
  1118. margin-top: 6px;
  1119. }
  1120. /* clear floats after columns */
  1121. .row:after {
  1122. content: "";
  1123. display: table;
  1124. clear: both;
  1125. }
  1126. /* xs */
  1127. @media screen and (max-width: 600px) {
  1128. div.form_grid {
  1129. width: 100%;
  1130. }
  1131. div.form_set {
  1132. width: 100% !important;
  1133. padding: 20px;
  1134. }
  1135. }
  1136. /* sm+ */
  1137. @media screen and (min-width: 601px) {
  1138. div.form_grid {
  1139. width: calc(100% + 20px);
  1140. }
  1141. div.form_set {
  1142. width: calc(100% - 20px);
  1143. padding: 20px;
  1144. }
  1145. }
  1146. div.card {
  1147. margin-bottom: 20px;
  1148. }
  1149. /* xs - make the two columns stack on top of each other instead of next to each other */
  1150. @media screen and (max-width: 600px) {
  1151. .col-25, .col-75, input[type=submit] {
  1152. width: 100%;
  1153. margin-top: 0;
  1154. }
  1155. }
  1156. @media screen and (max-width: 941px) {
  1157. .empty_row {
  1158. display: none;
  1159. }
  1160. }
  1161. </style>
  1162. <?php
  1163. echo "<div class='form_grid'>\n";
  1164. echo " <div class='form_set card'>\n";
  1165. echo " <div class='heading'>\n";
  1166. echo " <b>".$text['label-name']."</b>\n";
  1167. echo " </div>\n";
  1168. echo " <div style='clear: both;'></div>\n";
  1169. echo " <div class='label'>\n";
  1170. echo " ".$text['label-contact_organization']."\n";
  1171. echo " </div>\n";
  1172. echo " <div class='field no-wrap'>\n";
  1173. echo " <input class='formfld' type='text' name='contact_organization' placeholder='' maxlength='255' value='".escape($contact_organization)."'>\n";
  1174. echo " </div>\n";
  1175. echo " <div class='label'>\n";
  1176. echo " ".$text['label-contact_name_prefix']."\n";
  1177. echo " </div>\n";
  1178. echo " <div class='field no-wrap'>\n";
  1179. echo " <input class='formfld' type='text' name='contact_name_prefix' placeholder='' maxlength='255' value='".escape($contact_name_prefix)."'>\n";
  1180. echo " </div>\n";
  1181. echo " <div class='label'>\n";
  1182. echo " ".$text['label-contact_name_given']."\n";
  1183. echo " </div>\n";
  1184. echo " <div class='field no-wrap'>\n";
  1185. echo " <input class='formfld' type='text' name='contact_name_given' placeholder='' maxlength='255' value='".escape($contact_name_given)."'>\n";
  1186. echo " </div>\n";
  1187. echo " <div class='label'>\n";
  1188. echo " ".$text['label-contact_name_middle']."\n";
  1189. echo " </div>\n";
  1190. echo " <div class='field no-wrap'>\n";
  1191. echo " <input class='formfld' type='text' name='contact_name_middle' placeholder='' maxlength='255' value='".escape($contact_name_middle)."'>\n";
  1192. echo " </div>\n";
  1193. echo " <div class='label'>\n";
  1194. echo " ".$text['label-contact_name_family']."\n";
  1195. echo " </div>\n";
  1196. echo " <div class='field no-wrap'>\n";
  1197. echo " <input class='formfld' type='text' name='contact_name_family' placeholder='' maxlength='255' value='".escape($contact_name_family)."'>\n";
  1198. echo " </div>\n";
  1199. echo " <div class='label'>\n";
  1200. echo " ".$text['label-contact_name_suffix']."\n";
  1201. echo " </div>\n";
  1202. echo " <div class='field no-wrap'>\n";
  1203. echo " <input class='formfld' type='text' name='contact_name_suffix' placeholder='' maxlength='255' value='".escape($contact_name_suffix)."'>\n";
  1204. echo " </div>\n";
  1205. echo " <div class='label'>\n";
  1206. echo " ".$text['label-contact_nickname']."\n";
  1207. echo " </div>\n";
  1208. echo " <div class='field no-wrap'>\n";
  1209. echo " <input class='formfld' type='text' name='contact_nickname' placeholder='' maxlength='255' value='".escape($contact_nickname)."'>\n";
  1210. echo " </div>\n";
  1211. echo " <div class='label empty_row' style='grid-row: 10 / span 99;'>\n";
  1212. echo " &nbsp;\n";
  1213. echo " </div>\n";
  1214. echo " <div class='field empty_row' style='grid-row: 10 / span 99;'>\n";
  1215. echo " &nbsp;\n";
  1216. echo " </div>\n";
  1217. echo " </div>\n";
  1218. echo " <div class='form_set card'>\n";
  1219. echo " <div class='heading'>\n";
  1220. echo " <b>".$text['option-other']."</b>\n";
  1221. echo " </div>\n";
  1222. echo " <div style='clear: both;'></div>\n";
  1223. echo " <div class='label'>\n";
  1224. echo " ".$text['label-contact_type']."\n";
  1225. echo " </div>\n";
  1226. echo " <div class='field no-wrap'>\n";
  1227. if (!empty($_SESSION["contact"]["type"])) {
  1228. sort($_SESSION["contact"]["type"]);
  1229. echo " <select class='formfld' name='contact_type'>\n";
  1230. echo " <option value=''></option>\n";
  1231. foreach($_SESSION["contact"]["type"] as $type) {
  1232. echo " <option value='".escape($type)."' ".(($type == $contact_type) ? "selected='selected'" : null).">".escape($type)."</option>\n";
  1233. }
  1234. echo " </select>\n";
  1235. }
  1236. else {
  1237. echo " <select class='formfld' name='contact_type'>\n";
  1238. echo " <option value=''></option>\n";
  1239. echo " <option value='customer' ".(!empty($contact_type) && $contact_type == "customer" ? "selected='selected'" : null).">".$text['option-contact_type_customer']."</option>\n";
  1240. echo " <option value='contractor' ".(!empty($contact_type) && $contact_type == "contractor" ? "selected='selected'" : null).">".$text['option-contact_type_contractor']."</option>\n";
  1241. echo " <option value='friend' ".(!empty($contact_type) && $contact_type == "friend" ? "selected='selected'" : null).">".$text['option-contact_type_friend']."</option>\n";
  1242. echo " <option value='lead' ".(!empty($contact_type) && $contact_type == "lead" ? "selected='selected'" : null).">".$text['option-contact_type_lead']."</option>\n";
  1243. echo " <option value='member' ".(!empty($contact_type) && $contact_type == "member" ? "selected='selected'" : null).">".$text['option-contact_type_member']."</option>\n";
  1244. echo " <option value='family' ".(!empty($contact_type) && $contact_type == "family" ? "selected='selected'" : null).">".$text['option-contact_type_family']."</option>\n";
  1245. echo " <option value='subscriber' ".(!empty($contact_type) && $contact_type == "subscriber" ? "selected='selected'" : null).">".$text['option-contact_type_subscriber']."</option>\n";
  1246. echo " <option value='supplier' ".(!empty($contact_type) && $contact_type == "supplier" ? "selected='selected'" : null).">".$text['option-contact_type_supplier']."</option>\n";
  1247. echo " <option value='provider' ".(!empty($contact_type) && $contact_type == "provider" ? "selected='selected'" : null).">".$text['option-contact_type_provider']."</option>\n";
  1248. echo " <option value='user' ".(!empty($contact_type) && $contact_type == "user" ? "selected='selected'" : null).">".$text['option-contact_type_user']."</option>\n";
  1249. echo " <option value='volunteer' ".(!empty($contact_type) && $contact_type == "volunteer" ? "selected='selected'" : null).">".$text['option-contact_type_volunteer']."</option>\n";
  1250. echo " </select>\n";
  1251. }
  1252. echo " </div>\n";
  1253. echo " <div class='label'>\n";
  1254. echo " ".$text['label-contact_title']."\n";
  1255. echo " </div>\n";
  1256. echo " <div class='field no-wrap'>\n";
  1257. if (!empty($_SESSION['contact']['contact_title'])) {
  1258. echo " <select class='formfld' name='contact_title'>\n";
  1259. echo " <option value=''></option>\n";
  1260. sort($_SESSION['contact']['contact_title']);
  1261. foreach($_SESSION['contact']['contact_title'] as $row) {
  1262. echo " <option value='".escape($row)."' ".(($row == $contact_title) ? "selected='selected'" : null).">".escape(ucwords($row))."</option>\n";
  1263. }
  1264. echo " </select>\n";
  1265. }
  1266. else {
  1267. echo " <input class='formfld' type='text' name='contact_title' placeholder='' maxlength='255' value='".escape($contact_title)."'>\n";
  1268. }
  1269. echo " </div>\n";
  1270. echo " <div class='label'>\n";
  1271. echo " ".$text['label-contact_role']."\n";
  1272. echo " </div>\n";
  1273. echo " <div class='field no-wrap'>\n";
  1274. if (!empty($_SESSION['contact']['contact_role'])) {
  1275. echo " <select class='formfld' name='contact_role'>\n";
  1276. echo " <option value=''>".$text['label-contact_category']."</option>\n";
  1277. sort($_SESSION['contact']['contact_role']);
  1278. foreach($_SESSION['contact']['contact_role'] as $row) {
  1279. echo " <option value='".escape($row)."' ".(($row == $contact_role) ? "selected='selected'" : null).">".escape(ucwords($row))."</option>\n";
  1280. }
  1281. echo " </select>\n";
  1282. }
  1283. else {
  1284. echo " <input class='formfld' type='text' name='contact_role' placeholder='' maxlength='255' value='".escape($contact_role)."'>\n";
  1285. }
  1286. echo " </div>\n";
  1287. echo " <div class='label'>\n";
  1288. echo " ".$text['label-contact_category']."\n";
  1289. echo " </div>\n";
  1290. echo " <div class='field no-wrap'>\n";
  1291. if (!empty($_SESSION['contact']['contact_category'])) {
  1292. echo " <select class='formfld' name='contact_category'>\n";
  1293. echo " <option value=''></option>\n";
  1294. sort($_SESSION['contact']['contact_category']);
  1295. foreach($_SESSION['contact']['contact_category'] as $row) {
  1296. echo " <option value='".escape($row)."' ".(($row == $contact_category) ? "selected='selected'" : null).">".escape(ucwords($row))."</option>\n";
  1297. }
  1298. echo " </select>\n";
  1299. }
  1300. else {
  1301. echo " <input class='formfld' type='text' name='contact_category' placeholder='' maxlength='255' value='".escape($contact_category)."'>\n";
  1302. }
  1303. echo " </div>\n";
  1304. echo " <div class='label'>\n";
  1305. echo " ".$text['label-contact_time_zone']."\n";
  1306. echo " </div>\n";
  1307. echo " <div class='field no-wrap'>\n";
  1308. echo " <select class='formfld' id='contact_time_zone' name='contact_time_zone' style=''>\n";
  1309. echo " <option value=''></option>\n";
  1310. //$list = DateTimeZone::listAbbreviations();
  1311. $time_zone_identifiers = DateTimeZone::listIdentifiers();
  1312. $previous_category = '';
  1313. $x = 0;
  1314. foreach ($time_zone_identifiers as $key => $val) {
  1315. $time_zone = explode("/", $val);
  1316. $category = $time_zone[0];
  1317. if ($category != $previous_category) {
  1318. if ($x > 0) {
  1319. echo " </optgroup>\n";
  1320. }
  1321. echo " <optgroup label='".$category."'>\n";
  1322. }
  1323. if (!empty($val)) {
  1324. $time_zone_offset = get_time_zone_offset($val)/3600;
  1325. $time_zone_offset_hours = floor($time_zone_offset);
  1326. $time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60;
  1327. $time_zone_offset_minutes = number_pad($time_zone_offset_minutes, 2);
  1328. if ($time_zone_offset > 0) {
  1329. $time_zone_offset_hours = number_pad($time_zone_offset_hours, 2);
  1330. $time_zone_offset_hours = "+".$time_zone_offset_hours;
  1331. }
  1332. else {
  1333. $time_zone_offset_hours = str_replace("-", "", $time_zone_offset_hours);
  1334. $time_zone_offset_hours = "-".number_pad($time_zone_offset_hours, 2);
  1335. }
  1336. }
  1337. echo " <option value='".$val."' ".(!empty($contact_time_zone) && $val == $contact_time_zone ? "selected='selected'" : null).">(UTC ".$time_zone_offset_hours.":".$time_zone_offset_minutes.") ".$val."</option>\n";
  1338. $previous_category = $category;
  1339. $x++;
  1340. }
  1341. echo " </select>\n";
  1342. echo " </div>\n";
  1343. echo " <div class='label'>\n";
  1344. echo " ".$text['label-contact_note']."\n";
  1345. echo " </div>\n";
  1346. echo " <div class='field no-wrap'>\n";
  1347. echo " <textarea class='formfld' style='width: 100%; height: 100%;' name='contact_note'>".$contact_note."</textarea>\n";
  1348. echo " </div>\n";
  1349. echo " <div class='label empty_row' style='grid-row: 8 / span 99;'>\n";
  1350. echo " &nbsp;\n";
  1351. echo " </div>\n";
  1352. echo " <div class='field empty_row' style='grid-row: 8 / span 99;'>\n";
  1353. echo " &nbsp;\n";
  1354. echo " </div>\n";
  1355. echo " </div>\n";
  1356. unset($contact_note);
  1357. if ($_SESSION['contact']['permissions']['boolean'] == "true") {
  1358. if (permission_exists('contact_user_view') || permission_exists('contact_group_view')) {
  1359. echo " <div class='form_set card'>\n";
  1360. echo " <div class='heading'>\n";
  1361. echo " <b>".$text['label-permissions']."</b>\n";
  1362. echo " </div>\n";
  1363. echo " <div style='clear: both;'></div>\n";
  1364. if (permission_exists('contact_user_edit')) {
  1365. echo " <div class='label' valign='top'>".$text['label-users']."</div>\n";
  1366. echo " <div class='field no-wrap' align='left'>";
  1367. if ($action == "update" && !empty($contact_users_assigned)) {
  1368. echo " <div class='vtable'>".$text['label-username']."\n";
  1369. if ($contact_users_assigned && permission_exists('contact_user_delete')) {
  1370. //echo " <div class='edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_users', 'delete_toggle_users');\" onmouseout=\"swap_display('delete_label_users', 'delete_toggle_users');\">\n";
  1371. echo " <div style='float: right;'\">\n";
  1372. echo " <span>".$text['label-delete']."</span>\n";
  1373. //echo " <span id='delete_label_users'>".$text['label-delete']."</span>\n";
  1374. //echo " <span id='delete_toggle_users'><input type='checkbox' id='checkbox_all_users' name='checkbox_all' onclick=\"edit_all_toggle('users');\"></span>\n";
  1375. echo " </div>\n";
  1376. }
  1377. echo " </div>\n";
  1378. foreach ($contact_users_assigned as $x => $field) {
  1379. echo " <div class='vtable'>".escape($field['username'])."\n";
  1380. if ($contact_users_assigned && permission_exists('contact_user_delete')) {
  1381. if (is_uuid($field['contact_user_uuid'])) {
  1382. echo " <div style='text-align: center; padding-bottom: 3px; float: right; margin-right: 10px;'>\n";
  1383. //echo " <input type='checkbox' name='contact_users_delete[".$x."][checked]' value='true' class='chk_delete checkbox_users' onclick=\"edit_delete_action('users');\">\n";
  1384. //echo " <input type='hidden' name='contact_users_delete[".$x."][uuid]' value='".escape($field['contact_user_uuid'])."' />\n";
  1385. echo " <input type='checkbox' name='contact_users[".$x."][checked]' value='true' class='chk_delete checkbox_users' onclick=\"edit_delete_action('users');\">\n";
  1386. echo " <input type='hidden' name='contact_users[".$x."][uuid]' value='".escape($field['contact_user_uuid'])."' />\n";
  1387. echo " <input type='hidden' name='contact_users[$x][domain_uuid]' value=\"".escape($_SESSION['domain_uuid'])."\">\n";
  1388. echo " <input type='hidden' name='contact_users[$x][contact_user_uuid]' value='".escape($field['contact_user_uuid'])."' />\n";
  1389. echo " <input type='hidden' name='contact_users[$x][contact_uuid]' value='".escape($field['contact_uuid'])."' />\n";
  1390. }
  1391. else {
  1392. echo " <div>\n";
  1393. }
  1394. echo " </div>\n";
  1395. }
  1396. echo " </div>\n";
  1397. }
  1398. }
  1399. if (permission_exists('contact_user_add')) {
  1400. echo " <div class='vtable' style='border-bottom: none;'>\n";
  1401. echo " <select name='contact_user_uuid' class='formfld' style='width: auto;'>\n";
  1402. echo " <option value=''></option>\n";
  1403. foreach ($users as $field) {
  1404. if (!empty($contact_users_assigned) && in_array($field['user_uuid'], array_column($contact_users_assigned, 'user_uuid'))) { continue; } //skip users already assigned
  1405. echo " <option value='".escape($field['user_uuid'])."'>".escape($field['username'])."</option>\n";
  1406. }
  1407. echo " </select>\n";
  1408. if ($action == "update") {
  1409. echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
  1410. }
  1411. unset($users);
  1412. echo " </div>\n";
  1413. }
  1414. echo " ".$text['description-users']."\n";
  1415. echo " </div>\n";
  1416. }
  1417. if (permission_exists('contact_group_view')) {
  1418. echo " <div class='label'>".$text['label-groups']."</div>";
  1419. echo " <div class='field no-wrap'>";
  1420. if (!empty($contact_groups_assigned)) {
  1421. echo " <div class='vtable'>".$text['label-group']."\n";
  1422. if ($contact_groups_assigned && permission_exists('contact_group_delete')) {
  1423. //echo " <div class='edit_delete_checkbox_all' style='float: right;' onmouseover=\"swap_display('delete_label_groups', 'delete_toggle_groups');\" onmouseout=\"swap_display('delete_label_groups', 'delete_toggle_groups');\">\n";
  1424. echo " <div style='float: right;'\">\n";
  1425. echo " <span>".$text['label-delete']."</span>\n";
  1426. //echo " <span id='delete_label_groups'>".$text['label-delete']."</span>\n";
  1427. //echo " <span id='delete_toggle_groups' style='margin-right: 10px;'><input type='checkbox' id='checkbox_all_groups' name='checkbox_all' onclick=\"edit_all_toggle('groups');\"></span>\n";
  1428. echo " </div>\n";
  1429. }
  1430. echo " </div>\n";
  1431. foreach ($contact_groups_assigned as $x => $field) {
  1432. if (!empty($field['group_name'])) {
  1433. echo " <div class='vtable'>".escape($field['group_name'])."\n";
  1434. if (permission_exists('contact_group_delete')) {
  1435. if (is_uuid($field['contact_group_uuid'])) {
  1436. echo " <div style='text-align: center; padding-bottom: 3px; float: right; margin-right: 10px;'>";
  1437. //echo " <input type='checkbox' name='contact_groups_delete[".$x."][checked]' value='true' class='chk_delete checkbox_groups' onclick=\"edit_delete_action('groups');\">\n";
  1438. //echo " <input type='hidden' name='contact_groups_delete[".$x."][uuid]' value='".escape($field['contact_group_uuid'])."' />\n";
  1439. echo " <input type='checkbox' name='contact_groups[".$x."][checked]' value='true' class='chk_delete checkbox_groups' onclick=\"edit_delete_action('groups');\">\n";
  1440. echo " <input type='hidden' name='contact_groups[".$x."][uuid]' value='".escape($field['contact_group_uuid'])."' />\n";
  1441. echo " <input type='hidden' name='contact_groups[$x][domain_uuid]' value=\"".escape($_SESSION['domain_uuid'])."\">\n";
  1442. echo " <input type='hidden' name='contact_groups[$x][contact_group_uuid]' value='".escape($field['contact_group_uuid'])."' />\n";
  1443. echo " <input type='hidden' name='contact_groups[$x][contact_uuid]' value='".escape($contact_uuid)."' />\n";
  1444. }
  1445. else {
  1446. echo " <div>";
  1447. }
  1448. echo " </div>\n";
  1449. }
  1450. echo " </div>\n";
  1451. }
  1452. }
  1453. }
  1454. if (permission_exists('contact_group_add')) {
  1455. if (!empty($contact_groups_available)) {
  1456. echo " <div class='vtable' style='border-bottom: none;'>\n";
  1457. echo " <select name='contact_group_uuid' class='formfld' style='width: auto; margin-right: 3px;'>\n";
  1458. echo " <option value=''></option>\n";
  1459. foreach ($contact_groups_available as $field) {
  1460. if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show superadmin group to superadmins
  1461. if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin"))) { continue; } //only show admin group to admins
  1462. echo " <option value='".escape($field['group_uuid'])."'>".escape($field['group_name'])."</option>\n";
  1463. }
  1464. echo " </select>";
  1465. if ($action == "update") {
  1466. echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
  1467. }
  1468. echo " </div>\n";
  1469. }
  1470. }
  1471. echo " ".$text['description-groups']."\n";
  1472. echo " </div>\n";
  1473. }
  1474. echo " <div class='label empty_row' style='grid-row: 4 / span 99;'>\n";
  1475. echo " &nbsp;\n";
  1476. echo " </div>\n";
  1477. echo " <div class='field empty_row' style='grid-row: 4 / span 99;'>\n";
  1478. echo " </div>\n";
  1479. echo " </div>\n";
  1480. }
  1481. }
  1482. if (permission_exists('contact_phone_view')) {
  1483. echo "<script type=\"text/javascript\">\n";
  1484. echo "function send_cmd(url) {\n";
  1485. echo " if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
  1486. echo " xmlhttp=new XMLHttpRequest();\n";
  1487. echo " }\n";
  1488. echo " else {// code for IE6, IE5\n";
  1489. echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
  1490. echo " }\n";
  1491. echo " xmlhttp.open(\"GET\",url,true);\n";
  1492. echo " xmlhttp.send(null);\n";
  1493. echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
  1494. echo "}\n";
  1495. echo "</script>\n";
  1496. $x = 0;
  1497. foreach($contact_phones as $row) {
  1498. echo " <div class='form_set card'>\n";
  1499. echo " <div class='heading'>\n";
  1500. echo " <b style='float: left;'>".$text['label-phone_numbers']."</b>\n";
  1501. if (permission_exists('contact_phone_delete')) {
  1502. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  1503. echo " <input type='checkbox' name='contact_phones[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_phones' value='true' onclick=\"edit_delete_action('phones');\">\n";
  1504. echo " <input type='hidden' name='contact_phones[$x][uuid]' value='".escape($row['contact_phone_uuid'])."' />\n";
  1505. echo " </div>\n";
  1506. }
  1507. echo " <div class='button no-link' style='float: left; margin-top: 1px; margin-left: 8px;'>\n";
  1508. echo " <a href='../xml_cdr/xml_cdr.php?caller_id_number=".urlencode($row['phone_number'] ?? '')."'>\n";
  1509. echo " <i class='fas fa-search fa-fw' style='color: ".$body_text_color."; float: left; margin-top: 7px; margin-left: 3px; margin-right: 3px;' title=\"".$text['button-cdr']."\"></i>\n";
  1510. echo " </a>\n";
  1511. $call = "send_cmd('";
  1512. $call .= PROJECT_PATH."/app/click_to_call/click_to_call.php";
  1513. $call .= "?src_cid_name=".urlencode($row['phone_number'] ?? '');
  1514. $call .= "&src_cid_number=".urlencode($row['phone_number'] ?? '');
  1515. $call .= "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'] ?? '');
  1516. $call .= "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? '');
  1517. $call .= "&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? '');
  1518. $call .= "&dest=".urlencode($row['phone_number'] ?? '');
  1519. $call .= "&rec=false";
  1520. $call .= "&ringback=us-ring";
  1521. $call .= "&auto_answer=true";
  1522. $call .= "');";
  1523. echo " <a href='' onclick=\"".$call."\">\n";
  1524. echo " <i class='fas fa-phone fa-fw' style='color: ".$body_text_color."; float: left; margin-top: 7px; margin-left: 7px;' title=\"".urlencode($row['phone_number'] ?? '')."\"></i>\n";
  1525. echo " </a>\n";
  1526. echo " </div>\n";
  1527. echo " </div>\n";
  1528. echo " <div style='clear: both;'>\n";
  1529. if ($row['phone_primary'] == "1") {
  1530. echo " <i class='fa-solid fa-star fa-sm' style='color: ".$body_text_color."; float: right; margin-top: 7px; margin-left: 8px;' title=\"".$text['label-primary']."\"></i>\n";
  1531. }
  1532. echo " </div>\n";
  1533. echo " <input type='hidden' name='contact_phones[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  1534. echo " <input type='hidden' name='contact_phones[$x][contact_uuid]' value=\"".escape($row["contact_uuid"])."\">\n";
  1535. echo " <input type='hidden' name='contact_phones[$x][contact_phone_uuid]' value=\"".escape($row["contact_phone_uuid"])."\">\n";
  1536. echo " <div class='label'>\n";
  1537. echo " ".$text['label-phone_label']."\n";
  1538. echo " </div>\n";
  1539. echo " <div class='field no-wrap'>\n";
  1540. echo " <select class='formfld' name='contact_phones[$x][phone_label]' style=''>\n";
  1541. echo " <option value=''></option>\n";
  1542. if ($row['phone_label'] == "work") {
  1543. echo " <option value='work' selected='selected'>".$text['option-work']."</option>\n";
  1544. }
  1545. else {
  1546. echo " <option value='work'>".$text['option-work']."</option>\n";
  1547. }
  1548. if ($row['phone_label'] == "home") {
  1549. echo " <option value='home' selected='selected'>".$text['option-home']."</option>\n";
  1550. }
  1551. else {
  1552. echo " <option value='home'>".$text['option-home']."</option>\n";
  1553. }
  1554. if ($row['phone_label'] == "mobile") {
  1555. echo " <option value='mobile' selected='selected'>".$text['option-mobile']."</option>\n";
  1556. }
  1557. else {
  1558. echo " <option value='mobile'>".$text['option-mobile']."</option>\n";
  1559. }
  1560. if ($row['phone_label'] == "main") {
  1561. echo " <option value='main' selected='selected'>".$text['option-main']."</option>\n";
  1562. }
  1563. else {
  1564. echo " <option value='main'>".$text['option-main']."</option>\n";
  1565. }
  1566. if ($row['phone_label'] == "billing") {
  1567. echo " <option value='billing' selected='selected'>".$text['option-billing']."</option>\n";
  1568. }
  1569. else {
  1570. echo " <option value='billing'>".$text['option-billing']."</option>\n";
  1571. }
  1572. if ($row['phone_label'] == "fax") {
  1573. echo " <option value='fax' selected='selected'>".$text['option-fax']."</option>\n";
  1574. }
  1575. else {
  1576. echo " <option value='fax'>".$text['option-fax']."</option>\n";
  1577. }
  1578. if ($row['phone_label'] == "voicemail") {
  1579. echo " <option value='voicemail' selected='selected'>".$text['option-voicemail']."</option>\n";
  1580. }
  1581. else {
  1582. echo " <option value='voicemail'>".$text['option-voicemail']."</option>\n";
  1583. }
  1584. if ($row['phone_label'] == "text") {
  1585. echo " <option value='text' selected='selected'>".$text['option-text']."</option>\n";
  1586. }
  1587. else {
  1588. echo " <option value='text'>".$text['option-text']."</option>\n";
  1589. }
  1590. if ($row['phone_label'] == "other") {
  1591. echo " <option value='other' selected='selected'>".$text['option-other']."</option>\n";
  1592. }
  1593. else {
  1594. echo " <option value='other'>".$text['option-other']."</option>\n";
  1595. }
  1596. echo " </select>\n";
  1597. //echo $text['description-phone_label']."\n";
  1598. echo " </div>\n";
  1599. echo " <div class='label'>\n";
  1600. echo " ".$text['label-phone_type']."\n";
  1601. echo " </div>\n";
  1602. echo " <div class='field no-wrap'>\n";
  1603. echo " <label style='padding-top: 2px; margin: 0;'><input type='checkbox' name='contact_phones[$x][phone_type_voice]' id='phone_type_voice' value='1' ".(($row['phone_type_voice']) ? "checked='checked'" : null)."> ".$text['label-voice']."</label>&nbsp;\n";
  1604. echo " <label style='padding-top: 2px; margin: 0;'><input type='checkbox' name='contact_phones[$x][phone_type_fax]' id='phone_type_fax' value='1' ".(($row['phone_type_fax']) ? "checked='checked'" : null)."> ".$text['label-fax']."</label>&nbsp;\n";
  1605. echo " <label style='padding-top: 2px; margin: 0;'><input type='checkbox' name='contact_phones[$x][phone_type_video]' id='phone_type_video' value='1' ".(($row['phone_type_video']) ? "checked='checked'" : null)."> ".$text['label-video']."</label>&nbsp;\n";
  1606. echo " <label style='padding-top: 2px; margin: 0;'><input type='checkbox' name='contact_phones[$x][phone_type_text]' id='phone_type_text' value='1' ".(($row['phone_type_text']) ? "checked='checked'" : null)."> ".$text['label-text']."</label>\n";
  1607. echo " <br />\n";
  1608. //echo $text['description-phone_type']."\n";
  1609. echo " </div>\n";
  1610. echo " <div class='label'>\n";
  1611. echo " ".$text['label-phone_speed_dial']."\n";
  1612. echo " </div>\n";
  1613. echo " <div class='field no-wrap'>\n";
  1614. echo " <input class='formfld' type='text' name='contact_phones[$x][phone_speed_dial]' placeholder='' maxlength='255' style='' value=\"".escape($row["phone_speed_dial"])."\">\n";
  1615. //echo $text['description-phone_extension']."\n";
  1616. echo " </div>\n";
  1617. echo " <div class='label'>\n";
  1618. echo " ".$text['label-phone_country_code']."\n";
  1619. echo " </div>\n";
  1620. echo " <div class='field no-wrap'>\n";
  1621. echo " <input class='formfld' type='text' name='contact_phones[$x][phone_country_code]' placeholder='' maxlength='6' style='' value=\"".escape($row["phone_country_code"])."\">\n";
  1622. //echo $text['description-phone_country_code']."\n";
  1623. echo " </div>\n";
  1624. echo " <div class='label required'>\n";
  1625. echo " ".$text['label-phone_number']."\n";
  1626. echo " </div>\n";
  1627. echo " <div class='field no-wrap'>\n";
  1628. echo " <input class='formfld' type='text' name='contact_phones[$x][phone_number]' placeholder='' style='' maxlength='255' style='max-width:90px;' value=\"".escape($row["phone_number"])."\">\n";
  1629. //echo $text['description-phone_speed_dial']."\n";
  1630. echo " </div>\n";
  1631. echo " <div class='label'>\n";
  1632. echo " ".$text['label-phone_extension']."\n";
  1633. echo " </div>\n";
  1634. echo " <div class='field no-wrap'>\n";
  1635. echo " <input class='formfld' type='text' name='contact_phones[$x][phone_extension]' placeholder='' style='' maxlength='255' value=\"".escape($row["phone_extension"])."\">\n";
  1636. //echo $text['description-phone_number']."\n";
  1637. echo " </div>\n";
  1638. echo " <div class='label'>\n";
  1639. echo " ".$text['label-primary']."\n";
  1640. echo " </div>\n";
  1641. echo " <div class='field no-wrap'>\n";
  1642. echo " <select class='formfld' name='contact_phones[$x][phone_primary]' style='width: auto;'>\n";
  1643. echo " <option value=''></option>\n";
  1644. if ($row['phone_primary'] == "1") {
  1645. echo " <option value='1' selected='selected'>".$text['label-true']."</option>\n";
  1646. }
  1647. else {
  1648. echo " <option value='1'>".$text['label-true']."</option>\n";
  1649. }
  1650. if ($row['phone_primary'] == "0") {
  1651. echo " <option value='0' selected='selected'>".$text['label-false']."</option>\n";
  1652. }
  1653. else {
  1654. echo " <option value='0'>".$text['label-false']."</option>\n";
  1655. }
  1656. echo " </select>\n";
  1657. //echo $text['description-phone_primary']."\n";
  1658. echo " </div>\n";
  1659. echo " <div class='label'>\n";
  1660. echo " ".$text['label-phone_description']."\n";
  1661. echo " </div>\n";
  1662. echo " <div class='field no-wrap'>\n";
  1663. echo " <input class='formfld' type='text' name='contact_phones[$x][phone_description]' placeholder='' maxlength='255' value=\"".escape($row["phone_description"])."\">\n";
  1664. //echo $text['description-phone_description']."\n";
  1665. echo " </div>\n";
  1666. echo " <div class='label empty_row' style='grid-row: 10 / span 99;'>\n";
  1667. echo " &nbsp;\n";
  1668. echo " </div>\n";
  1669. echo " <div class='field empty_row' style='grid-row: 10 / span 99;'>\n";
  1670. echo " &nbsp;\n";
  1671. echo " </div>\n";
  1672. //if (!empty($contact_phones) && @sizeof($contact_phones) > 1 && permission_exists('contact_phone_delete')) {
  1673. // echo " <div class='label'>\n";
  1674. // echo " ".$text['label-action']."\n";
  1675. // echo " </div>\n";
  1676. // echo " <div class='field no-wrap'>\n";
  1677. // //echo " <span id='delete_label_details'>".$text['label-action']."</span>\n";
  1678. // echo " <span id='delete_toggle_details'>\n";
  1679. // //echo " <input type='checkbox' name='contact_phones[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
  1680. // echo " <input type='checkbox' id='checkbox_all_details' name='checkbox_all' onclick=\"edit_all_toggle('details'); checkbox_on_change(this);\">\n";
  1681. // echo " </span>\n";
  1682. // echo " </div>\n";
  1683. //}
  1684. echo " </div>\n";
  1685. $x++;
  1686. }
  1687. }
  1688. if (permission_exists('contact_address_view')) {
  1689. $x = 0;
  1690. foreach($contact_addresses as $row) {
  1691. echo " <div class='form_set card'>\n";
  1692. echo " <div class='heading'>\n";
  1693. echo " <b style='float: left;'>".$text['label-addresses']."</b>\n";
  1694. if (permission_exists('contact_address_delete')) {
  1695. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  1696. echo " <input type='checkbox' name='contact_addresses[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_addresses' value='true' onclick=\"edit_delete_action('addresses');\">\n";
  1697. echo " <input type='hidden' name='contact_addresses[$x][uuid]' value='".escape($row['contact_address_uuid'])."' />\n";
  1698. echo " </div>\n";
  1699. }
  1700. echo " <div class='button no-link' style='float: left; margin-top: 1px; margin-left: 8px;'>\n";
  1701. $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code'];
  1702. echo " <a href=\"http://maps.google.com/maps?q=".urlencode($map_query)."&hl=en\" target=\"_blank\">";
  1703. echo " <img src='resources/images/icon_gmaps.png' style='width: 17px; height: 17px;' alt='".$text['label-google_map']."' title='".$text['label-google_map']."'>";
  1704. echo " </a>\n";
  1705. echo " </div>\n";
  1706. echo " </div>\n";
  1707. echo " <div style='clear: both;'>\n";
  1708. if ($row['address_primary'] == "1") {
  1709. echo " <i class='fa-solid fa-star fa-sm' style='color: ".$body_text_color."; float: right; margin-top: 7px; margin-left: 8px;' title=\"".$text['label-primary']."\"></i>\n";
  1710. }
  1711. echo " </div>\n";
  1712. echo " <input type='hidden' name='contact_addresses[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  1713. echo " <input type='hidden' name='contact_addresses[$x][contact_uuid]' value=\"".escape($row["contact_uuid"])."\">\n";
  1714. echo " <input type='hidden' name='contact_addresses[$x][contact_address_uuid]' value=\"".escape($row["contact_address_uuid"])."\">\n";
  1715. echo " <div class='label'>\n";
  1716. echo " ".$text['label-address_label']."\n";
  1717. echo " </div>\n";
  1718. echo " <div class='field no-wrap'>\n";
  1719. echo " <select class='formfld' name='contact_addresses[$x][address_label]'>\n";
  1720. echo " <option value=''></option>\n";
  1721. if ($row['address_label'] == "work") {
  1722. echo " <option value='work' selected='selected'>".$text['option-work']."</option>\n";
  1723. }
  1724. else {
  1725. echo " <option value='work'>".$text['option-work']."</option>\n";
  1726. }
  1727. if ($row['address_label'] == "home") {
  1728. echo " <option value='home' selected='selected'>".$text['option-home']."</option>\n";
  1729. }
  1730. else {
  1731. echo " <option value='home'>".$text['option-home']."</option>\n";
  1732. }
  1733. if ($row['address_label'] == "mobile") {
  1734. echo " <option value='mobile' selected='selected'>".$text['option-mobile']."</option>\n";
  1735. }
  1736. else {
  1737. echo " <option value='mobile'>".$text['option-mobile']."</option>\n";
  1738. }
  1739. if ($row['address_label'] == "main") {
  1740. echo " <option value='main' selected='selected'>".$text['option-main']."</option>\n";
  1741. }
  1742. else {
  1743. echo " <option value='main'>".$text['option-main']."</option>\n";
  1744. }
  1745. if ($row['address_label'] == "billing") {
  1746. echo " <option value='billing' selected='selected'>".$text['option-billing']."</option>\n";
  1747. }
  1748. else {
  1749. echo " <option value='billing'>".$text['option-billing']."</option>\n";
  1750. }
  1751. if ($row['address_label'] == "fax") {
  1752. echo " <option value='fax' selected='selected'>".$text['option-fax']."</option>\n";
  1753. }
  1754. else {
  1755. echo " <option value='fax'>".$text['option-fax']."</option>\n";
  1756. }
  1757. if ($row['address_label'] == "pager") {
  1758. echo " <option value='pager' selected='selected'>".$text['option-pager']."</option>\n";
  1759. }
  1760. else {
  1761. echo " <option value='pager'>".$text['option-pager']."</option>\n";
  1762. }
  1763. if ($row['address_label'] == "voicemail") {
  1764. echo " <option value='voicemail' selected='selected'>".$text['option-voicemail']."</option>\n";
  1765. }
  1766. else {
  1767. echo " <option value='voicemail'>".$text['option-voicemail']."</option>\n";
  1768. }
  1769. if ($row['address_label'] == "text") {
  1770. echo " <option value='text' selected='selected'>".$text['option-text']."</option>\n";
  1771. }
  1772. else {
  1773. echo " <option value='text'>".$text['option-text']."</option>\n";
  1774. }
  1775. echo " </select>\n";
  1776. echo " </div>\n";
  1777. echo " <div class='label'>\n";
  1778. echo " ".$text['label-address_type']."\n";
  1779. echo " </div>\n";
  1780. echo " <div class='field no-wrap'>\n";
  1781. echo " <select class='formfld' name='contact_addresses[$x][address_type]'>\n";
  1782. echo " <option value=''></option>\n";
  1783. if ($row['address_type'] == "work") {
  1784. echo " <option value='work' selected='selected'>".$text['option-work']."</option>\n";
  1785. }
  1786. else {
  1787. echo " <option value='work'>".$text['option-work']."</option>\n";
  1788. }
  1789. if ($row['address_type'] == "home") {
  1790. echo " <option value='home' selected='selected'>".$text['option-home']."</option>\n";
  1791. }
  1792. else {
  1793. echo " <option value='home'>".$text['option-home']."</option>\n";
  1794. }
  1795. if ($row['address_type'] == "domestic") {
  1796. echo " <option value='domestic' selected='selected'>".$text['option-dom']."</option>\n";
  1797. }
  1798. else {
  1799. echo " <option value='domestic'>".$text['option-dom']."</option>\n";
  1800. }
  1801. if ($row['address_type'] == "international") {
  1802. echo " <option value='international' selected='selected'>".$text['option-intl']."</option>\n";
  1803. }
  1804. else {
  1805. echo " <option value='international'>".$text['option-intl']."</option>\n";
  1806. }
  1807. if ($row['address_type'] == "postal") {
  1808. echo " <option value='postal' selected='selected'>".$text['option-postal']."</option>\n";
  1809. }
  1810. else {
  1811. echo " <option value='postal'>".$text['option-postal']."</option>\n";
  1812. }
  1813. if ($row['address_type'] == "parcel") {
  1814. echo " <option value='parcel' selected='selected'>".$text['option-parcel']."</option>\n";
  1815. }
  1816. else {
  1817. echo " <option value='parcel'>".$text['option-parcel']."</option>\n";
  1818. }
  1819. if ($row['address_type'] == "preferred") {
  1820. echo " <option value='preferred' selected='selected'>".$text['option-pref']."</option>\n";
  1821. }
  1822. else {
  1823. echo " <option value='preferred'>".$text['option-pref']."</option>\n";
  1824. }
  1825. echo " </select>\n";
  1826. echo " </div>\n";
  1827. echo " <div class='label required'>\n";
  1828. echo " ".$text['label-address_address']."\n";
  1829. echo " </div>\n";
  1830. echo " <div class='field no-wrap'>\n";
  1831. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_street]' placeholder='".$text['label-address_address']." 1' maxlength='255' value=\"".escape($row["address_street"])."\"><br />\n";
  1832. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_extended]' placeholder='".$text['label-address_address']." 2' maxlength='255' value=\"".escape($row["address_extended"])."\">\n";
  1833. echo " </div>\n";
  1834. if (permission_exists('address_community')) {
  1835. echo " <div class='label'>\n";
  1836. echo " ".$text['label-address_community']."\n";
  1837. echo " </div>\n";
  1838. echo " <div class='field no-wrap'>\n";
  1839. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_community]' placeholder='' maxlength='255' value=\"".escape($row["address_community"])."\">\n";
  1840. echo " </div>\n";
  1841. }
  1842. echo " <div class='label'>\n";
  1843. echo " ".$text['label-address_locality']."\n";
  1844. echo " </div>\n";
  1845. echo " <div class='field no-wrap'>\n";
  1846. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_locality]' placeholder='' maxlength='255' value=\"".escape($row["address_locality"])."\">\n";
  1847. echo " </div>\n";
  1848. echo " <div class='label'>\n";
  1849. echo " ".$text['label-address_region']."\n";
  1850. echo " </div>\n";
  1851. echo " <div class='field no-wrap'>\n";
  1852. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_region]' placeholder='' maxlength='255' value=\"".escape($row["address_region"])."\">\n";
  1853. echo " </div>\n";
  1854. echo " <div class='label'>\n";
  1855. echo " ".$text['label-address_postal_code']."\n";
  1856. echo " </div>\n";
  1857. echo " <div class='field no-wrap'>\n";
  1858. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_postal_code]' placeholder='' maxlength='255' value=\"".escape($row["address_postal_code"])."\">\n";
  1859. echo " </div>\n";
  1860. echo " <div class='label'>\n";
  1861. echo " ".$text['label-address_country']."\n";
  1862. echo " </div>\n";
  1863. echo " <div class='field no-wrap'>\n";
  1864. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_country]' placeholder='' maxlength='255' value=\"".escape($row["address_country"])."\">\n";
  1865. echo " </div>\n";
  1866. if (permission_exists('address_latitude')) {
  1867. echo " <div class='label'>\n";
  1868. echo " ".$text['label-address_latitude']."\n";
  1869. echo " </div>\n";
  1870. echo " <div class='field no-wrap'>\n";
  1871. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_latitude]' placeholder='".escape($text['label-address_latitude'])."' maxlength='255' value=\"".escape($row["address_latitude"])."\">\n";
  1872. echo " </div>\n";
  1873. }
  1874. if (permission_exists('address_longitude')) {
  1875. echo " <div class='label'>\n";
  1876. echo " ".$text['label-address_longitude']."\n";
  1877. echo " </div>\n";
  1878. echo " <div class='field no-wrap'>\n";
  1879. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_longitude]' placeholder='".escape($text['label-address_longitude'])."' maxlength='255' value=\"".escape($row["address_longitude"])."\">\n";
  1880. echo " </div>\n";
  1881. }
  1882. echo " <div class='label'>\n";
  1883. echo " ".$text['label-primary']."\n";
  1884. echo " </div>\n";
  1885. echo " <div class='field no-wrap'>\n";
  1886. echo " <select class='formfld' name='contact_addresses[$x][address_primary]' style='width: auto;'>\n";
  1887. echo " <option value=''>".escape($text['label-address_primary'] ?? '')."</option>\n";
  1888. if ($row['address_primary'] == "1") {
  1889. echo " <option value='1' selected='selected'>".$text['label-true']."</option>\n";
  1890. }
  1891. else {
  1892. echo " <option value='1'>".$text['label-true']."</option>\n";
  1893. }
  1894. if ($row['address_primary'] == "0") {
  1895. echo " <option value='0' selected='selected'>".$text['label-false']."</option>\n";
  1896. }
  1897. else {
  1898. echo " <option value='0'>".$text['label-false']."</option>\n";
  1899. }
  1900. echo " </select>\n";
  1901. echo " </div>\n";
  1902. echo " <div class='label'>\n";
  1903. echo " ".$text['label-address_description']."\n";
  1904. echo " </div>\n";
  1905. echo " <div class='field no-wrap'>\n";
  1906. echo " <input class='formfld' type='text' name='contact_addresses[$x][address_description]' placeholder='' maxlength='255' value=\"".escape($row["address_description"])."\">\n";
  1907. echo " </div>\n";
  1908. //if (!empty($contact_addresses) && @sizeof($contact_addresses) > 1 && permission_exists('contact_address_delete')) {
  1909. // if (is_uuid($row['contact_address_uuid'])) {
  1910. // echo " <div class='label'>\n";
  1911. // echo " ".$text['label-action']."\n";
  1912. // echo " </div>\n";
  1913. // echo " <div class='field no-wrap'>\n";
  1914. // echo " <input type='checkbox' name='contact_addresses[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
  1915. // echo " </div>\n";
  1916. // }
  1917. //}
  1918. echo " </div>\n";
  1919. $x++;
  1920. }
  1921. }
  1922. if (permission_exists('contact_email_view')) {
  1923. $x = 0;
  1924. foreach($contact_emails as $row) {
  1925. echo " <div class='form_set card'>\n";
  1926. echo " <div class='heading'>\n";
  1927. echo " <b style='float: left;'>".$text['label-emails']."</b>\n";
  1928. if (permission_exists('contact_email_delete')) {
  1929. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  1930. echo " <input type='checkbox' name='contact_emails[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_emails' value='true' onclick=\"edit_delete_action('emails');\">\n";
  1931. echo " <input type='hidden' name='contact_emails[$x][uuid]' value='".escape($row['contact_email_uuid'])."' />\n";
  1932. echo " </div>\n";
  1933. }
  1934. echo " <div class='button no-link' style='float: left; margin-top: 1px; margin-left: 8px;'>\n";
  1935. echo " <a href='mailto:".escape($row['email_address'])."'>\n";
  1936. echo " <i class='fas fa-envelope fa-fw' style='color: ".$body_text_color."; float: left; margin-top: 5px; margin-left: 3px;' title=\"".escape($row["email_label"])."\"></i>\n";
  1937. echo " </a>\n";
  1938. echo " </div>\n";
  1939. echo " </div>\n";
  1940. echo " <div style='clear: both;'>\n";
  1941. if ($row['email_primary'] == "1") {
  1942. echo " <i class='fa-solid fa-star fa-sm' style='color: ".$body_text_color."; float: right; margin-top: 7px; margin-left: 8px;' title=\"".$text['label-primary']."\"></i>\n";
  1943. }
  1944. echo " </div>\n";
  1945. echo " <input type='hidden' name='contact_emails[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  1946. echo " <input type='hidden' name='contact_emails[$x][contact_uuid]' value=\"".escape($row["contact_uuid"])."\">\n";
  1947. echo " <input type='hidden' name='contact_emails[$x][contact_email_uuid]' value=\"".escape($row["contact_email_uuid"])."\">\n";
  1948. echo " <div class='label'>\n";
  1949. echo " ".$text['label-email_label']."\n";
  1950. echo " </div>\n";
  1951. echo " <div class='field no-wrap'>\n";
  1952. echo " <input class='formfld' type='text' name='contact_emails[$x][email_label]' placeholder='".escape($text['label-email_label'])."' maxlength='255' value=\"".escape($row["email_label"])."\">\n";
  1953. echo " </div>\n";
  1954. echo " <div class='label required'>\n";
  1955. echo " ".$text['label-email_address']."\n";
  1956. echo " </div>\n";
  1957. echo " <div class='field no-wrap'>\n";
  1958. echo " <input class='formfld' type='text' name='contact_emails[$x][email_address]' placeholder='".escape($text['label-email_address'])."' maxlength='255' value=\"".escape($row["email_address"])."\">\n";
  1959. echo " </div>\n";
  1960. echo " <div class='label'>\n";
  1961. echo " ".$text['label-primary']."\n";
  1962. echo " </div>\n";
  1963. echo " <div class='field no-wrap'>\n";
  1964. echo " <select class='formfld' name='contact_emails[$x][email_primary]' style='width: auto;'>\n";
  1965. echo " <option value=''>".escape($text['label-contact_emails'] ?? '')."</option>\n";
  1966. if ($row['email_primary'] == "1") {
  1967. echo " <option value='1' selected='selected'>".$text['label-true']."</option>\n";
  1968. }
  1969. else {
  1970. echo " <option value='1'>".$text['label-true']."</option>\n";
  1971. }
  1972. if ($row['email_primary'] == "0") {
  1973. echo " <option value='0' selected='selected'>".$text['label-false']."</option>\n";
  1974. }
  1975. else {
  1976. echo " <option value='0'>".$text['label-false']."</option>\n";
  1977. }
  1978. echo " </select>\n";
  1979. //echo " <br />\n";
  1980. //echo $text['description-email_primary']."\n";
  1981. echo " </div>\n";
  1982. echo " <div class='label'>\n";
  1983. echo " ".$text['label-email_description']."\n";
  1984. echo " </div>\n";
  1985. echo " <div class='field no-wrap'>\n";
  1986. echo " <input class='formfld' type='text' name='contact_emails[$x][email_description]' placeholder='' maxlength='255' value=\"".escape($row["email_description"])."\">\n";
  1987. echo " </div>\n";
  1988. echo " <div class='label empty_row' style='grid-row: 6 / span 99;'>\n";
  1989. echo " &nbsp;\n";
  1990. echo " </div>\n";
  1991. echo " <div class='field empty_row' style='grid-row: 6 / span 99;'>\n";
  1992. echo " </div>\n";
  1993. //if (!empty($contact_emails) && @sizeof($contact_emails) > 1 && permission_exists('contact_email_delete')) {
  1994. // if (is_uuid($row['contact_email_uuid'])) {
  1995. // echo " <div class='label'>\n";
  1996. // echo " ".$text['label-action']."\n";
  1997. // echo " </div>\n";
  1998. // echo " <div class='field no-wrap'>\n";
  1999. // echo " <input type='checkbox' name='contact_emails[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
  2000. // echo " </div>\n";
  2001. // }
  2002. //}
  2003. echo " </div>\n";
  2004. $x++;
  2005. }
  2006. }
  2007. if (permission_exists('contact_url_view')) {
  2008. $x = 0;
  2009. foreach($contact_urls as $row) {
  2010. echo " <div class='form_set card'>\n";
  2011. echo " <div class='heading'>\n";
  2012. echo " <b style='float: left;'>".$text['label-contact_url']."</b>\n";
  2013. if (permission_exists('contact_url_delete')) {
  2014. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2015. echo " <input type='checkbox' name='contact_urls[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_urls' value='true' onclick=\"edit_delete_action('urls');\">\n";
  2016. echo " <input type='hidden' name='contact_urls[$x][uuid]' value='".escape($row['contact_url_uuid'])."' />\n";
  2017. echo " </div>\n";
  2018. }
  2019. echo " <div class='button no-link' style='float: left; margin-top: 1px; margin-left: 8px;'>\n";
  2020. echo " <a href='".escape($row['url_address'])."' target='_blank'>\n";
  2021. echo " <span class='fas fa-link fa-fw' style='color: ".$body_text_color."; float: left; margin-top: 7px; margin-left: 3px;' title=\"".str_replace("http://", "", str_replace("https://", "", escape($row['url_address'])))."\"></span>\n";
  2022. echo " </a>\n";
  2023. echo " </div>\n";
  2024. echo " </div>\n";
  2025. echo " <div style='clear: both;'>\n";
  2026. if ($row['url_primary'] == "1") {
  2027. echo " <i class='fa-solid fa-star fa-sm' style='color: ".$body_text_color."; float: right; margin-top: 7px; margin-left: 8px;' title=\"".$text['label-primary']."\"></i>\n";
  2028. }
  2029. echo " </div>\n";
  2030. echo " <input type='hidden' name='contact_urls[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  2031. echo " <input type='hidden' name='contact_urls[$x][contact_uuid]' value=\"".escape($row["contact_uuid"])."\">\n";
  2032. echo " <input type='hidden' name='contact_urls[$x][contact_url_uuid]' value=\"".escape($row["contact_url_uuid"])."\">\n";
  2033. //echo " <td class='formfld'>\n";
  2034. //echo " <div class='label'>\n";
  2035. //echo " ".$text['label-url_type']."\n";
  2036. //echo " </div>\n";
  2037. //echo " <div class='field no-wrap'>\n";
  2038. //echo " <input class='formfld' type='text' name='contact_urls[$x][url_type]' placeholder='".escape($text['label-url_type'])."' maxlength='255' value=\"".escape($row["url_type"])."\">\n";
  2039. //echo " </div>\n";
  2040. echo " <div class='label'>\n";
  2041. echo " ".$text['label-url_label']."\n";
  2042. echo " </div>\n";
  2043. echo " <div class='field no-wrap'>\n";;
  2044. //if there are no custom labels add defaults
  2045. if (!empty($_SESSION["contact"]["url_label"])) {
  2046. $contact_url_labels = $_SESSION["contact"]["url_label"];
  2047. }
  2048. else {
  2049. $contact_url_labels[] = $text['option-work'];
  2050. $contact_url_labels[] = $text['option-personal'];
  2051. $contact_url_labels[] = $text['option-other'];
  2052. }
  2053. sort($contact_url_labels);
  2054. foreach($contact_url_labels as $label) {
  2055. $url_label_options[] = "<option value='".$label."' ".(($label == $row['url_label']) ? "selected='selected'" : null).">".$label."</option>";
  2056. }
  2057. $url_label_found = (in_array($url_label, $contact_url_labels)) ? true : false;
  2058. echo " <select class='formfld' ".((!empty($url_label) && !$url_label_found) ? "style='display: none;'" : "style='width: auto;'")." name='contact_urls[$x][url_label]' id='url_label' onchange=\"getElementById('url_label_custom').value='';\">\n";
  2059. echo " <option value=''></option>\n";
  2060. echo (!empty($url_label_options)) ? implode("\n", $url_label_options) : null;
  2061. echo " </select>\n";
  2062. echo " <input type='text' class='formfld' ".((empty($url_label) || $url_label_found) ? "style='display: none;'" : null)." name='url_label_custom' id='url_label_custom' value=\"".((!$url_label_found) ? htmlentities($url_label ?? '') : null)."\">\n";
  2063. //echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('url_label');\">\n";
  2064. echo " </div>\n";
  2065. echo " <div class='label required'>\n";
  2066. echo " ".$text['label-url_address']."\n";
  2067. echo " </div>\n";
  2068. echo " <div class='field no-wrap'>\n";
  2069. echo " <input class='formfld' type='text' name='contact_urls[$x][url_address]' placeholder='http://...' maxlength='255' value=\"".escape($row["url_address"])."\">\n";
  2070. echo " </div>\n";
  2071. echo " <div class='label'>\n";
  2072. echo " ".$text['label-primary']."\n";
  2073. echo " </div>\n";
  2074. echo " <div class='field no-wrap'>\n";
  2075. echo " <select class='formfld' name='contact_urls[$x][url_primary]' style='width: auto;'>\n";
  2076. echo " <option value=''></option>\n";
  2077. if ($row['url_primary'] == "1") {
  2078. echo " <option value='1' selected='selected'>".$text['label-true']."</option>\n";
  2079. }
  2080. else {
  2081. echo " <option value='1'>".$text['label-true']."</option>\n";
  2082. }
  2083. if ($row['url_primary'] == "0") {
  2084. echo " <option value='0' selected='selected'>".$text['label-false']."</option>\n";
  2085. }
  2086. else {
  2087. echo " <option value='0'>".$text['label-false']."</option>\n";
  2088. }
  2089. echo " </select>\n";
  2090. echo " </div>\n";
  2091. echo " <div class='label'>\n";
  2092. echo " ".$text['label-url_description']."\n";
  2093. echo " </div>\n";
  2094. echo " <div class='field no-wrap'>\n";
  2095. echo " <input class='formfld' type='text' name='contact_urls[$x][url_description]' placeholder='' maxlength='255' value=\"".escape($row["url_description"])."\">\n";
  2096. echo " </div>\n";
  2097. if (!empty($contact_urls) && @sizeof($contact_urls) > 1 && permission_exists('contact_url_delete')) {
  2098. if (is_uuid($row['contact_url_uuid'])) {
  2099. echo " <input type='checkbox' name='contact_urls[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
  2100. }
  2101. }
  2102. //echo " <br />\n";
  2103. //echo " ".$text['description-contact_organization']."\n";
  2104. echo " <div class='label empty_row' style='grid-row: 6 / span 99;'>\n";
  2105. echo " &nbsp;\n";
  2106. echo " </div>\n";
  2107. echo " <div class='field empty_row' style='grid-row: 6 / span 99;'>\n";
  2108. echo " </div>\n";
  2109. echo " </div>\n";
  2110. $x++;
  2111. }
  2112. }
  2113. if (permission_exists('contact_relation_view')) {
  2114. if (!empty($contact_relations)) {
  2115. $x = 0;
  2116. foreach($contact_relations as $row) {
  2117. //get contact details and contact_name
  2118. $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname ";
  2119. $sql .= "from v_contacts ";
  2120. $sql .= "where domain_uuid = :domain_uuid ";
  2121. $sql .= "and contact_uuid <> :contact_uuid ";
  2122. $sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc ";
  2123. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  2124. $parameters['contact_uuid'] = $row['contact_uuid'];
  2125. $contacts = $database->select($sql, $parameters, 'all');
  2126. if (!empty($contacts) && is_uuid($row['relation_contact_uuid'])) {
  2127. foreach($contacts as $field) {
  2128. if ($field['contact_uuid'] == $row['relation_contact_uuid']) {
  2129. $name = array();
  2130. if (!empty($field['contact_organization'])) { $name[] = $field['contact_organization']; }
  2131. if (!empty($field['contact_name_family'])) { $name[] = $field['contact_name_family']; }
  2132. if (!empty($field['contact_name_given'])) { $name[] = $field['contact_name_given']; }
  2133. if (empty($field['contact_name_family']) && empty($field['contact_name_given']) && !empty($field['contact_nickname'])) { $name[] = $field['contact_nickname']; }
  2134. $contact_name = implode(', ', $name);
  2135. break;
  2136. }
  2137. }
  2138. }
  2139. echo " <div class='form_set card'>\n";
  2140. echo " <div class='heading'>\n";
  2141. echo " <b style='float: left;'>".$text['label-contact_relation_label']."</b>\n";
  2142. if (permission_exists('contact_relation_delete')) {
  2143. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2144. echo " <input type='checkbox' name='contact_relations[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_relations' value='true' onclick=\"edit_delete_action('relations');\">\n";
  2145. echo " <input type='hidden' name='contact_relations[$x][uuid]' value='".escape($row['contact_relation_uuid'])."' />\n";
  2146. echo " <input type='hidden' name='contact_relations[$x][contact_relation_uuid]' value='".escape($row['contact_relation_uuid'])."' />\n";
  2147. echo " <input type='hidden' name='contact_relations[$x][contact_uuid]' value='".escape($row['contact_uuid'])."' />\n";
  2148. echo " </div>\n";
  2149. }
  2150. echo " <div class='button no-link' style='float: left; margin-top: 1px; margin-left: 8px;'>\n";
  2151. echo " <a href='contact_edit.php?id=".escape($row['relation_contact_uuid'])."' target='_blank'>\n";
  2152. echo " <span class='fas fa-user-group' style='color: ".$body_text_color."; float: left; margin-top: 7px; margin-left: 3px;'></span>\n";
  2153. echo " </a>\n";
  2154. echo " </div>\n";
  2155. echo " </div>\n";
  2156. echo " <div style='clear: both;'></div>\n";
  2157. echo " <div class='label required'>\n";
  2158. echo " ".$text['label-contact_relation_label']."\n";
  2159. echo " </div>\n";
  2160. echo " <div class='field no-wrap'>\n";
  2161. //if there are no custom labels add defaults
  2162. if (!empty($_SESSION["contact"]["relation_label"])) {
  2163. $relation_labels = $_SESSION["contact"]["url_label"];
  2164. }
  2165. else {
  2166. $relation_labels[] = $text['label-contact_relation_option_parent'];
  2167. $relation_labels[] = $text['label-contact_relation_option_child'];
  2168. $relation_labels[] = $text['label-contact_relation_option_employee'];
  2169. $relation_labels[] = $text['label-contact_relation_option_member'];
  2170. $relation_labels[] = $text['label-contact_relation_option_associate'];
  2171. $relation_labels[] = $text['label-contact_relation_option_other'];
  2172. }
  2173. sort($relation_labels);
  2174. foreach($relation_labels as $label) {
  2175. $relation_label_options[] = "<option value='".escape($label)."' ".(($label == $row['relation_label']) ? "selected='selected'" : null).">".escape($label)."</option>";
  2176. }
  2177. $relation_label_found = (in_array($relation_label, $relation_labels)) ? true : false;
  2178. echo " <select class='formfld' ".((!empty($relation_label) && !$relation_label_found) ? "style='display: none;'" : "style='auto;'")." name='contact_relations[$x][relation_label]' id='relation_label' onchange=\"getElementById('relation_label_custom').value='';\">\n";
  2179. echo " <option value=''></option>\n";
  2180. echo (!empty($relation_label_options)) ? implode("\n", $relation_label_options) : null;
  2181. echo " </select>\n";
  2182. //echo " <input type='text' class='formfld' ".((empty($relation_label) || $relation_label_found) ? "style='display: none;'" : null)." name='contact_relations[$x][relation_label_custom]' id='relation_label_custom' value=\"".((!$relation_label_found) ? htmlentities($relation_label ?? '') : null)."\">\n";
  2183. //echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('relation_label');\">\n";
  2184. //echo " <br />\n";
  2185. //echo $text['description-relation_label']."\n";
  2186. echo " </div>\n";
  2187. echo " <div class='label required'>\n";
  2188. echo " ".$text['label-contact_relation_contact']."\n";
  2189. echo " </div>\n";
  2190. echo " <div class='field no-wrap'>\n";
  2191. echo " <div id='contacts' class='field no-wrap' style=\"width: auto; display: inline;\">\n";
  2192. echo " <input class=\"formfld\" type=\"text\" name=\"contact_search\" placeholder=\"".$text['label-search']."\" style=\"width: calc(30% - 5px);\" onkeyup=\"get_contacts('contact_select_".$x."', 'contact_uuid', this.value);\" maxlength=\"255\" value=\"\">\n";
  2193. echo " <select class='formfld' style=\"width: 70%;\" id=\"contact_select_".$x."\" name=\"contact_relations[".$x."][relation_contact_uuid]\" >\n";
  2194. echo " <option value='".escape($row['relation_contact_uuid'])."'>".escape($contact_name ?? '')."</option>\n";
  2195. echo " </select>\n";
  2196. echo " </div>\n";
  2197. echo " </div>\n";
  2198. echo " <div class='label empty_row' style='grid-row: 4 / span 99;'>\n";
  2199. echo " &nbsp;\n";
  2200. echo " </div>\n";
  2201. echo " <div class='field no-wrap empty_row' style='grid-row: 4 / span 99;'>\n";
  2202. echo " </div>\n";
  2203. echo " </div>\n";
  2204. $x++;
  2205. }
  2206. }
  2207. }
  2208. if (permission_exists('contact_setting_view')) {
  2209. $x = 0;
  2210. foreach($contact_settings as $row) {
  2211. echo " <div class='form_set card'>\n";
  2212. echo " <div class='heading'>\n";
  2213. echo " <b style='float: left;'>".$text['label-contact_settings']."</b>\n";
  2214. if (permission_exists('contact_setting_delete')) {
  2215. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2216. echo " <input type='checkbox' name='contact_settings[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_settings' value='true' onclick=\"edit_delete_action('settings');\">\n";
  2217. echo " <input type='hidden' name='contact_settings[$x][uuid]' value='".escape($row['contact_setting_uuid'])."' />\n";
  2218. echo " </div>\n";
  2219. }
  2220. echo " </div>\n";
  2221. echo " <div style='clear: both;'></div>\n";
  2222. echo " <input type='hidden' name='contact_settings[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  2223. echo " <input type='hidden' name='contact_settings[$x][contact_uuid]' value=\"".escape($row["contact_uuid"])."\">\n";
  2224. echo " <input type='hidden' name='contact_settings[$x][contact_setting_uuid]' value=\"".escape($row["contact_setting_uuid"])."\">\n";
  2225. echo " <div class='label required'>\n";
  2226. echo " ".$text['label-contact_setting_category']."\n";
  2227. echo " </div>\n";
  2228. echo " <div class='field no-wrap'>\n";
  2229. echo " <input class='formfld' type='text' name='contact_settings[$x][contact_setting_category]' placeholder='' maxlength='255' value=\"".escape($row["contact_setting_category"])."\">\n";
  2230. echo " </div>\n";
  2231. echo " <div class='label required'>\n";
  2232. echo " ".$text['label-contact_setting_subcategory']."\n";
  2233. echo " </div>\n";
  2234. echo " <div class='field no-wrap'>\n";
  2235. echo " <input class='formfld' type='text' name='contact_settings[$x][contact_setting_subcategory]' placeholder='' maxlength='255' value=\"".escape($row["contact_setting_subcategory"])."\">\n";
  2236. echo " </div>\n";
  2237. echo " <div class='label required'>\n";
  2238. echo " ".$text['label-name']."\n";
  2239. echo " </div>\n";
  2240. echo " <div class='field no-wrap'>\n";
  2241. echo " <input class='formfld' type='text' name='contact_settings[$x][contact_setting_name]' placeholder='' maxlength='255' value=\"".escape($row["contact_setting_name"])."\">\n";
  2242. echo " </div>\n";
  2243. echo " <div class='label'>\n";
  2244. echo " ".$text['label-contact_setting_value']."\n";
  2245. echo " </div>\n";
  2246. echo " <div class='field no-wrap'>\n";
  2247. echo " <input class='formfld' type='text' name='contact_settings[$x][contact_setting_value]' placeholder='' maxlength='255' value=\"".escape($row["contact_setting_value"])."\">\n";
  2248. echo " </div>\n";
  2249. echo " <div class='label'>\n";
  2250. echo " ".$text['label-order']."\n";
  2251. echo " </div>\n";
  2252. echo " <div class='field no-wrap'>\n";
  2253. echo " <select name='contact_settings[$x][contact_setting_order]' class='formfld'>\n";
  2254. echo " <option value=''></option>\n";
  2255. $i=0;
  2256. while ($i<=999) {
  2257. $selected = ($i == $row["contact_setting_order"]) ? "selected='selected'" : null;
  2258. if (strlen($i) == 1) {
  2259. echo " <option value='00$i' ".$selected.">00$i</option>\n";
  2260. }
  2261. if (strlen($i) == 2) {
  2262. echo " <option value='0$i' ".$selected.">0$i</option>\n";
  2263. }
  2264. if (strlen($i) == 3) {
  2265. echo " <option value='$i' ".$selected.">$i</option>\n";
  2266. }
  2267. $i++;
  2268. }
  2269. echo " </select>\n";
  2270. echo " </div>\n";
  2271. echo " <div class='label required'>\n";
  2272. echo " ".$text['label-enabled']."\n";
  2273. echo " </div>\n";
  2274. echo " <div class='field no-wrap'>\n";
  2275. echo " <select class='formfld' name='contact_settings[$x][contact_setting_enabled]' style='width: 5em;'>\n";
  2276. echo " <option value=''><b>".escape($text['label-contact_setting_enabled'] ?? '')."</b></option>\n";
  2277. if ($row['contact_setting_enabled'] == "true") {
  2278. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  2279. }
  2280. else {
  2281. echo " <option value='true'>".$text['label-true']."</option>\n";
  2282. }
  2283. if ($row['contact_setting_enabled'] == "false") {
  2284. echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
  2285. }
  2286. else {
  2287. echo " <option value='false'>".$text['label-false']."</option>\n";
  2288. }
  2289. echo " </select>\n";
  2290. echo " </div>\n";
  2291. echo " <div class='label'>\n";
  2292. echo " ".$text['label-description']."\n";
  2293. echo " </div>\n";
  2294. echo " <div class='field no-wrap'>\n";
  2295. echo " <input class='formfld' type='text' name='contact_settings[$x][contact_setting_description]' placeholder='".escape($text['label-contact_setting_description'] ?? '')."' maxlength='255' value=\"".escape($row["contact_setting_description"])."\">\n";
  2296. echo " </div>\n";
  2297. if (!empty($contact_settings) && @sizeof($contact_settings) > 1 && permission_exists('contact_setting_delete')) {
  2298. if (!empty($row['contact_setting_uuid']) && is_uuid($row['contact_setting_uuid'])) {
  2299. echo " <div class='label'>\n";
  2300. echo " ".$text['label-enabled']."\n";
  2301. echo " </div>\n";
  2302. echo " <div class='field no-wrap'>\n";
  2303. echo " <input type='checkbox' name='contact_settings[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
  2304. echo " </div>\n";
  2305. }
  2306. }
  2307. echo " <div class='label empty_row' style='grid-row: 9 / span 99;'>\n";
  2308. echo " &nbsp;\n";
  2309. echo " </div>\n";
  2310. echo " <div class='field no-wrap empty_row' style='grid-row: 9 / span 99;'>\n";
  2311. echo " </div>\n";
  2312. echo " </div>\n";
  2313. $x++;
  2314. }
  2315. }
  2316. if (permission_exists('contact_attachment_view')) {
  2317. $x = 0;
  2318. foreach($contact_attachments as $row) {
  2319. $attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION));
  2320. $attachment_type_label = $attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png' ? $text['label-image'] : $text['label-file'];
  2321. echo "<div class='form_set card'>\n";
  2322. echo " <div class='heading'>\n";
  2323. echo " <b style='float: left;'>".$text['label-attachments']."</b>\n";
  2324. if (permission_exists('contact_attachment_delete')) {
  2325. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2326. echo " <input type='checkbox' name='contact_attachments[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_attachments' value='true' onclick=\"edit_delete_action('attachments');\">\n";
  2327. echo " <input type='hidden' name='contact_attachments[$x][uuid]' value='".escape($row['contact_attachment_uuid'])."' />\n";
  2328. echo " <input type='hidden' name='contact_attachments[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  2329. echo " <input type='hidden' name='contact_attachments[$x][contact_attachment_uuid]' value='".escape($row['contact_attachment_uuid'])."' />\n";
  2330. echo " <input type='hidden' name='contact_attachments[$x][contact_uuid]' value='".escape($row['contact_uuid'])."' />\n";
  2331. echo " </div>\n";
  2332. }
  2333. echo " </div>\n";
  2334. echo " <div style='clear: both;'>\n";
  2335. if ($row['attachment_primary'] == "1") {
  2336. echo " <i class='fa-solid fa-star fa-sm' style='color: ".$body_text_color."; float: right; margin-top: 7px; margin-left: 8px;' title=\"".$text['label-primary']."\"></i>\n";
  2337. }
  2338. echo " </div>\n";
  2339. //script
  2340. echo "<script>\n";
  2341. echo " function display_attachment(id) {\n";
  2342. echo " $('#contact_attachment_layer').load('contact_attachment.php?id=' + id + '&action=display', function(){\n";
  2343. echo " $('#contact_attachment_layer').fadeIn(200);\n";
  2344. echo " });\n";
  2345. echo " }\n";
  2346. echo "</script>\n";
  2347. echo " <div class='label'>\n";
  2348. echo " ".$text['label-attachment']."\n";
  2349. echo " </div>\n";
  2350. echo " <div class='field no-wrap'>\n";
  2351. $attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION));
  2352. //if ($action == 'update') {
  2353. echo "<input type='hidden' name='attachment_filename' value=\"".escape($row['attachment_filename'])."\">\n";
  2354. if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') {
  2355. echo "<img src='data:image/".$attachment_type.";base64,".escape($row['attachment_content'])."' style='border: none; cursor: pointer; width: 100%; height: auto;' onclick=\"display_attachment('".escape($row['contact_attachment_uuid'])."');\">";
  2356. }
  2357. else {
  2358. echo "<a href='contact_attachment.php?id=".escape($row['contact_attachment_uuid'])."&action=download' style='font-size: 120%;'>".escape($row['attachment_filename'])."</a>";
  2359. }
  2360. //}
  2361. //else {
  2362. // $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true);
  2363. // echo " <input type='file' class='formfld' name='attachment' id='attachment' accept='.".implode(',.',array_keys($allowed_attachment_types))."'>\n";
  2364. // echo " <span style='display: inline-block; margin-top: 5px; font-size: 80%;'>".strtoupper(implode(', ', array_keys($allowed_attachment_types)))."</span>";
  2365. //}
  2366. echo " </div>\n";
  2367. echo " <div class='label'>\n";
  2368. echo " ".$text['label-attachment_filename']."\n";
  2369. echo " </div>\n";
  2370. echo " <div class='field no-wrap'>\n";
  2371. echo " <a href='contact_attachment.php?id=".escape($row['contact_attachment_uuid'])."&action=download' style='font-size: 120%;'>".escape($row['attachment_filename'])."</a>";
  2372. echo " </div>\n";
  2373. echo " <div class='label'>\n";
  2374. echo " ".$text['label-attachment_size']."\n";
  2375. echo " </div>\n";
  2376. echo " <div class='field no-wrap'>\n";
  2377. echo strtoupper(byte_convert($row['attachment_size']))."\n";
  2378. echo " </div>\n";
  2379. echo " <div class='label'>\n";
  2380. echo " ".$text['label-primary']."\n";
  2381. echo " </div>\n";
  2382. echo " <div class='field no-wrap'>\n";
  2383. echo " <select class='formfld' name='contact_attachments[$x][attachment_primary]' id='attachment_primary' style='width: auto;'>\n";
  2384. echo " <option value='0'>".$text['option-false']."</option>\n";
  2385. echo " <option value='1' ".(($row['attachment_primary']) ? "selected" : null).">".$text['option-true']."</option>\n";
  2386. echo " </select>\n";
  2387. echo " </div>\n";
  2388. echo " <div class='label'>\n";
  2389. echo " ".$text['label-description']."\n";
  2390. echo " </div>\n";
  2391. echo " <div class='field no-wrap'>\n";
  2392. echo " <input class='formfld' type='text' name='contact_attachments[$x][attachment_description]' maxlength='255' value=\"".escape($row['attachment_description'])."\">\n";
  2393. echo " </div>\n";
  2394. echo " <div class='label empty_row' style='grid-row: 9 / span 99;'>\n";
  2395. echo " &nbsp;\n";
  2396. echo " </div>\n";
  2397. echo " <div class='field no-wrap empty_row' style='grid-row: 9 / span 99;'>\n";
  2398. echo " </div>\n";
  2399. echo "</div>\n";
  2400. $x++;
  2401. }
  2402. }
  2403. if (permission_exists('contact_time_view')) {
  2404. $x = 0;
  2405. foreach ($contact_times as $row) {
  2406. echo "<div class='form_set card'>\n";
  2407. echo " <div class='heading'>\n";
  2408. echo " <b style='float: left;'>".$text['header_contact_times']."</b>\n";
  2409. if (permission_exists('contact_time_delete')) {
  2410. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2411. echo " <input type='checkbox' name='contact_times[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_times' value='true' onclick=\"edit_delete_action('times');\">\n";
  2412. echo " <input type='hidden' name='contact_times[$x][uuid]' value='".escape($row['contact_time_uuid'])."' />\n";
  2413. echo " <input type='hidden' name='contact_times[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  2414. echo " <input type='hidden' name='contact_times[$x][contact_time_uuid]' value='".escape($row['contact_time_uuid'])."' />\n";
  2415. echo " <input type='hidden' name='contact_times[$x][contact_uuid]' value='".escape($row['contact_uuid'])."' />\n";
  2416. echo " </div>\n";
  2417. }
  2418. echo " </div>\n";
  2419. echo " <div style='clear: both;'></div>\n";
  2420. echo " <div class='label required'>\n";
  2421. echo " ".$text['label-time_start']."\n";
  2422. echo " </div>\n";
  2423. echo " <div class='field no-wrap'>\n";
  2424. echo " <input class='formfld datetimesecpicker' data-toggle='datetimepicker' data-target='#time_start' type='text' name='contact_times[$x][time_start]' id='time_start' style='min-width: 135px; width: 135px;' value='".escape($row["time_start"])."' onblur=\"$(this).datetimepicker('hide');\">\n";
  2425. echo " </div>\n";
  2426. echo " <div class='label'>\n";
  2427. echo " ".$text['label-time_stop']."\n";
  2428. echo " </div>\n";
  2429. echo " <div class='field no-wrap'>\n";
  2430. echo " <input class='formfld datetimesecpicker' data-toggle='datetimepicker' data-target='#time_stop' type='text' name='contact_times[$x][time_stop]' id='time_stop' style='min-width: 135px; width: 135px;' value='".escape($row["time_stop"])."' onblur=\"$(this).datetimepicker('hide');\">\n";
  2431. echo " </div>\n";
  2432. echo " <div class='label'>\n";
  2433. echo " ".$text['label-time_description']."\n";
  2434. echo " </div>\n";
  2435. echo " <div class='field no-wrap'>\n";
  2436. echo " <textarea class='formfld' type='text' name='contact_times[$x][time_description]' id='time_description' style='width: 100%; height: 100%;'>".escape($row["time_description"])."</textarea>\n";
  2437. echo " </div>\n";
  2438. echo " <div class='label empty_row' style='grid-row: 5 / span 99;'>\n";
  2439. echo " &nbsp;\n";
  2440. echo " </div>\n";
  2441. echo " <div class='field empty_row' style='grid-row: 5 / span 99;'>\n";
  2442. echo " </div>\n";
  2443. echo "</div>\n";
  2444. $x++;
  2445. }
  2446. unset($contact_times);
  2447. }
  2448. if (permission_exists('contact_note_view')) {
  2449. $x = 0;
  2450. foreach($contact_notes as $row) {
  2451. $contact_note = $row['contact_note'];
  2452. $contact_note = escape($contact_note);
  2453. $contact_note = str_replace("\n","<br />",$contact_note);
  2454. if (permission_exists('contact_note_add')) {
  2455. $list_row_url = "contact_note_edit.php?contact_uuid=".escape($row['contact_uuid'])."&id=".escape($row['contact_note_uuid']);
  2456. }
  2457. echo "<div class='form_set card'>\n";
  2458. echo " <div class='heading'>\n";
  2459. echo " <b style='float: left;'>".$text['label-contact_notes']."</b>\n";
  2460. if (permission_exists('contact_note_delete')) {
  2461. echo " <div class='checkbox' style='float: left; margin-top: 3px; margin-left: 8px;'>\n";
  2462. echo " <input type='checkbox' name='contact_notes[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_notes' value='true' onclick=\"edit_delete_action('notes');\">\n";
  2463. echo " <input type='hidden' name='contact_notes[$x][uuid]' value='".escape($row['contact_note_uuid'])."' />\n";
  2464. echo " <input type='hidden' name='contact_notes[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
  2465. echo " <input type='hidden' name='contact_notes[$x][contact_note_uuid]' value='".escape($row['contact_note_uuid'])."' />\n";
  2466. echo " <input type='hidden' name='contact_notes[$x][contact_uuid]' value='".escape($row['contact_uuid'])."' />\n";
  2467. echo " </div>\n";
  2468. }
  2469. echo " </div>\n";
  2470. echo " <div style='clear: both;'></div>\n";
  2471. echo " <div class='label required'>\n";
  2472. echo " ".$text['label-contact_note']."\n";
  2473. echo " </div>\n";
  2474. echo " <div class='field no-wrap' style='float: left;'>\n";
  2475. echo " <textarea class='formfld' name=\"contact_notes[$x][contact_note]\" style='min-width: 100%; height: 275px;'>".$contact_note."</textarea>\n";
  2476. echo " </div>\n";
  2477. echo " <div class='label'>\n";
  2478. echo " ".$text['label-note_user']."\n";
  2479. echo " </div>\n";
  2480. echo " <div class='field no-wrap' style='margin-top: 2px;'>\n";
  2481. echo " <div class='description'><strong>".escape($row['last_mod_user'])."</strong>: ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."</div>\n";
  2482. echo " </div>\n";
  2483. echo " <div class='label empty_row' style='grid-row: 4 / span 99;'>\n";
  2484. echo " &nbsp;\n";
  2485. echo " </div>\n";
  2486. echo " <div class='field empty_row' style='grid-row: 4 / span 99;'>\n";
  2487. echo " </div>\n";
  2488. echo "</div>\n";
  2489. $x++;
  2490. }
  2491. unset($contact_notes);
  2492. }
  2493. //close the grid
  2494. echo "</div>\n";
  2495. echo "<br /><br />";
  2496. //end the form
  2497. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  2498. echo "</form>";
  2499. //include the footer
  2500. require_once "resources/footer.php";
  2501. ?>