JFIF  H H (ICC_PROFILE   0 mntrRGB XYZ acsp   - desc trXYZ d gXYZ x bXYZ  rTRC  (gTRC  (bTRC  (wtpt  cprt  بV7eudakt!Q ,*RGPQNČzŬb 5666p z"c83''Mq6Gitql@90.ۚAcN|li:9蠃p/^ZnLx84v;[#$ nh'c32o8Ɛ5KAv*_?nX?pyֆ̈́#z23F0Oe> {Gu.V (C'h/o%>x1X r:(>}{ycX8b]U:dOMsVAp'Z3'3E-ybj:>jOvUw#2cl~@gFCjțbz ^:-tdfj{XTh8aUM^+dAl"(KK m1$$ XKKqržoqg V FF#pG~:]֦!!Ң:pC+ AzӬ].t`='h_/} @L\,x㌼z԰+J-v+Y['8' % X q=[4Sj~4ݢ#dʂēRL5kX؊>l:t\baBA\Q38( ө:&$ 'L#d{qH>*5;jDo ˷YmԈ*[9*5tUf%3= GUW\'AR_W4_P պ -|4RFJZv0d[ˠzJ|PU8;鯌 'VcL,κ>*eb)f,0"j1 1v՘;bJ++COz7%>NU,=z\cEVK>Ic7} .jHn;^觱GHI HVǂO:ߊ{mSV?K|@ AiAT`2j 1~K8’$ ~]=9ឦG *9EMּm5Xf9Qĸ}i D%+t+;F: v:-&h_rD|! Ә;Zl븂':C&ҀaeKkm6 uT".}J&\ hciB2B+T7t?EPþЌmAF\lc2ЊABmE,cն\QJ]d5 `O Y@8?lx#KiI&Ri1fR2f1N%_g*TӨ??N:}+לɀh٭qL,ʈBrcuBmz ̢TV^ 뙏8' ufUX3㓏>NG:/;Hp饕B1K /%iɫ VQ%:_ -1oL?Roa\i^F|W*Na)P X#y㯨z+Cح\вjirm*dWҡQbBȨi'%NEb?'[h=`OiU϶u nR}GW4fVJmiR~J|l%m'%"LW V27NsXb?_={s}ij4Ý=SNjxFV"ԎI(E)]ӝЖm[4 m`5-7Wf󪥎bZKa#Vb%KY5T$y`46̼p C7HM'l{Oi +Pw~j,S5T4(FԨ;A`*HJTPgt(6/cg5U1@Qb8Y!rBzOQKF+6v%=~XDPpWc_-:߈#c坣CW1:^Q 06Ӭq@ Dj$ UW$?9F\cSM5=2>hב\,()JBk; J#j徻W(p=oQD #UMhU*Fc ?N=nF5Ӑ12w05Z뀩4ڣ霅uC1y%nJ8Ԑ*crR 9W=H9,A׻,.ZFb QEGVNs, q';OMmbtNVqOw*֙kPѬ؈XJIӯEWok+R{%j; Yx 7&&,LԜYbw"lI(*`۹F AS- #$413)Qpڤ3RxOJ$cP]viuq {kyN.- B,@󪳪ڸAor%X0UNb9 򍕑7)*233|Rnb@q|EUý$!7&["XOy ~ƓtADhP]mG파9p=ԜZ]ӭሎOeyq !bI GU:5~FoL ST[е$]$g*w]!;m@ޠ&IUڬ{҄բ-.SmҒ` vU"oL;'5s"W)@äL1i}^Y5$+Pv0o HU @ȓsQM)?M\4Q $2;g WJ/NwFJGD: y όMfW!QUZ%azҳDK_XhM^rԝ^!d'<#ﴛO{/F?+$ Y' wg'$ljGAH7l4xѶc}I*esg~;ͤt@B2iB'9C a8fTR: %NO@ m3sv w .@濾 ,FYrT0mUW_v>>d[A6ڊx:YTLHvӺ!nSD}>[mET0_,'C]pjVᅷPDZ[-V0`>}ܟpmֻ2O6O*ݹXHSN(J /+1՟#(P*gEO#w&j6?;ڡ)+U]l\/{莄*I/9<'$'#'yt/&-\\WPL`/p9qa'e¨E] fAAEYnGtm,ϮwXT>AaN#FjŵjQFdq^<H?yJ܃2*3 T4ЧH**W;(ꭽ¾Pf=eyA4FJ6{e]JqOCf#3SJf iMM\ iT$rG8$9>2:M)Q#NKe&"E8.z<mHk?#t˒A]; G0H:f!i! j{1m}o7u;$99Ӱ\ncz:zALq޶wyKT<4X,'!Y;Ͱ6q GM~_~܂}t>(zl}:r L9 fe}.-R*<`c6oܛ=prҽGB)nQ%)s*&i΍%—Zb{m[NNkbwBw Q*dF HP iܛ; aV68j}\eIGI'͔B;yA :^bn-m#@S6ˎr ;~cmƻgU:X6G%[gc{]c4)fpsgY˅>*"1}2<175)]V5)kdkM~`΂:{4nGPTTb   뎱϶w FFᓂG8>zF_H9_rDl:ҶH5Z!Bj.yk}erb:SOT]!ǎ?n:HεZsyztn[7NZ#UQO$.J#]Cr#YX9c<'$z 9 .$$PnDSn 2u5X g\ ?|Aᬰⶵ >>bE)Cb-ruMc׺*,\)`^m ge\k.۫8گoK1gWMpU޻zI=EErz:#6--/Wm\z8מ0x tA_c?Ծc^MژIMyO>l0ċ}t7[\ʲ9̜m_a[姯rְjP\kx1'CdmvF70e+m-]a?ݝKuSMUm 8f Yb!)2Z.UD \~:ܽ8zR̪Kcbs&ߦ1$, w\gc3F$iU#<`:I4{w.2aQ$EXNo?Gm NN rE$#Jn҉!AH'zePzRog8u(tJP߁Z.pÐ͢Aռ65Xsyvm 6RW7W;|0 >OүG@ٳ<>omԼ()kZJlK,F 4)snOQ{u㌏= Ao,ծ?eKBzG 6e6 f|CU _4C[j͕M8,%emM8\ cv COwTGi _94BDf%'ns8MPc&-y"8R_j 3a+z+N 9QlDQ40E VۋrH2I_YO',:뿉WNHvﵐ0B}na*E zUbN#0e"f.Q H5"-HVn=+ # Eiy- v8=g`o[ 鼛2.D^QeB ؅qϿRC~ B+Jۍ8 4*ӖΝ1R BI\ 1[0 I9y)Y " 7]6qg\ vP  s= Ѭ֕)פE< c`ϷU9W,: ?y1hsU(T ge/룮JA]|4aZVAIeIhBI!l$3![qHnw\7R{oM/ִ>5& gwjFE dc@K:V&W/k+=Yk[ @fU5zzmFȖH,[ n-dc wd[z"g4ϘRr0`B8_; #$^Zo5KZYKj GY%s"!a[9I2TF-w#a]˒Itٮei_FpVЧ૱W3eCi7 "}HApG>h֝5i T٧- '`dX1AF$$ޙ_Z]ڷTC Uy JGO} >A"5a> ZUR -Z\9 jrWݖQRݳ*ļ]$ڵXq=/w z\II#{ӭl^;F_R쵎[ָ[gKKͰoQ )W녕іs*kuzŨQde`WU_KLE~"g r<2GyއL(-VY -Z(IU0 |\;8C mhl:̄DkYHOk|:*DY tsس |zrO;񍃌sT31=jwyШ^nZHm_G̮0W󿓹S;_$mٛIDV=f-H}U]HA*vԶ3\Wh*I#$@6x^OZC&JU 16 XD*if&BDGFYYP[KLX uX .Z hq Ghb8M#Mqt\c> aT 00=㎨ʕGQԪR,ĜI9zӦJO3Rn`C5܊@QO1N.ؔ"I\YÖĐHdL\}IP~jm$ y; :ZGZVJv =&*UF#``R`*S+p\=) ҭ9k̮Ršx0'**ԑLkɺk+zJb#:|MZ ?j$ݼ &X)$6FY6ѕ/; J*nlC*ų_ ԕ{_6:\47ڷs4RmĊ=z *ʪXT[]5Bl#a-˙bv8@H|Rwe9A%5&M%Z02TN)&&GfM 儀oŒM;=.//k~ E"a9/3y,>lj>ZXy&εYP&h gec<``]!}i'c KQulFIʓ_\T58(+cJq~ [dgmm/`Xڙhtkq ו$"c[PVY[uɜ&#몵"ȾqC"ÜȔ!<Mj8u-dx*gϫtTLdKlaWڭ\~|7u`h(w֋cL=˼=FvcGs}зUBSМ;FI;Q$8+V|[CS쮙1%YP Q% LVVK+&,cIb]Vyi ~h?yF4"5As-F ݆x55P&E:W@f;}Gy^]U ITki 1 d﫠*cNh' cؗYnsL:b?H :kM~@8#Iqɔ~:f]P*i]H'fjhxTҗ1O:^t$1]UXz&tODT>(^s&3#N_/x-䬦? ~vU-W$4'ӎvRG|jySW?u4(1 G[ِ22jʎhrmoյشgRͮ%ϟѬ9 oR  n-&F-@hgY_qN;"2 !KJ  šA^, "aG8`=14=5Mqk>U@UT :RgjrKF.O$I9'=i}._ One Hat Cyber Team
  • Your IP: 216.73.216.182
  • Server IP: 172.67.131.134
  • Server: Linux vmi1569040.contaboserver.net 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
  • Server Software: LiteSpeed
  • PHP Version: 8.1.28
  • Buat File | Buat Folder
View File Name : main.min.js
',s.content+="
",s.content+="",s.message=app.lang.task_stop_timer,system_popup(s).attr("id","timer-select-task"),init_ajax_search("tasks","#timer_add_task_id",void 0,admin_url+"tasks/ajax_search_assign_task_to_timer"),!1}$(e).addClass("disabled");var o={};o.task_id=t,o.timer_id=a,o.note=$("body").find("#timesheet_note").val(),o.note||(o.note="");var l=$("#task-modal").is(":visible"),d=admin_url+"tasks/timer_tracking?single_task="+l;i&&(d+="&admin_stop="+i),$.post(d,o).done((function(e){e=JSON.parse(e),$("body").hasClass("member")&&window.location.reload(),l&&_task_append_html(e.taskHtml),n.is(":visible")&&n.find(".system-popup-close").click(),_init_timers_top_html(JSON.parse(e.timers)),$(".popover-top-timer-note").popover("hide"),reload_tasks_tables()}))}}function init_task_modal(e,t){var a="",i=$("#lead-modal"),n=$("#_task_modal");i.is(":visible")?(a+="?opened_from_lead_id="+i.find('input[name="leadid"]').val(),i.modal("hide")):null!=n.attr("data-lead-id")&&(a+="?opened_from_lead_id="+n.attr("data-lead-id")),requestGet("tasks/get_task_data/"+e+a).done((function(e){_task_append_html(e),void 0!==t&&setTimeout((function(){$('[data-task-comment-href-id="'+t+'"]').click()}),1e3)})).fail((function(e){$("#task-modal").modal("hide"),alert_float("danger",e.responseText)}))}function _task_append_html(e){var t=$("#task-modal");t.find(".data").html(e),recalculate_checklist_items_progress(),do_task_checklist_items_height(),setTimeout((function(){t.modal("show"),t.is(":visible")&&init_tags_inputs(),init_form_reminder("task"),fix_task_modal_left_col_height(),is_mobile()&&init_new_task_comment(!0)}),150)}function task_tracking_stats(e){requestGet("tasks/task_tracking_stats/"+e).done((function(e){$("
",{id:"tracking-stats"}).appendTo("body").html(e),$("#task-tracking-stats-modal").modal("toggle")}))}function init_timers(){requestGetJSON("tasks/get_staff_started_timers").done((function(e){_init_timers_top_html(e)}))}function _init_timers_top_html(e){$("#top-timers");var t=$("#top-timers").find(".icon-started-timers");e.total_timers>0?t.removeClass("hide").html(e.total_timers):t.addClass("hide"),e.total_timers>0?$("#top-timers").find("svg").addClass("tw-animate-spin"):$("#top-timers").find("svg").removeClass("tw-animate-spin"),$("#started-timers-top").html(e.html)}function edit_task_comment(e){var t=$('[data-edit-comment="'+e+'"]');t.next().addClass("hide"),t.removeClass("hide"),tinymce.remove("#task_comment_"+e);var a=_simple_editor_config();a.auto_focus="task_comment_"+e,a.toolbar_sticky=!0,init_editor("#task_comment_"+e,a),tinymce.triggerSave()}function cancel_edit_comment(e){var t=$('[data-edit-comment="'+e+'"]');tinymce.remove('[data-edit-comment="'+e+'"] textarea'),t.addClass("hide"),t.next().removeClass("hide")}function save_edited_comment(e,t){tinymce.triggerSave();var a={};a.id=e,a.task_id=t,a.content=$('[data-edit-comment="'+e+'"]').find("textarea").val(),is_ios()&&(a.no_editor=!0),$.post(admin_url+"tasks/edit_comment",a).done((function(t){!0===(t=JSON.parse(t)).success||"true"==t.success?(alert_float("success",t.message),_task_append_html(t.taskHtml)):cancel_edit_comment(e),tinymce.remove('[data-edit-comment="'+e+'"] textarea')}))}function fix_task_modal_left_col_height(){is_mobile()||$("body").find(".task-single-col-left").css("min-height",$("body").find(".task-single-col-right").outerHeight(!0)+"px")}function tasks_kanban_update(e,t){if(t===e.item.parent()[0]){var a=$(e.item.parent()[0]).attr("data-task-status-id"),i={order:[],status:a};$.each($(e.item.parent()[0]).find("[data-task-id]"),(function(e,t){var a=$(t).attr("data-task-id");a&&i.order.push([a,e+1])})),task_mark_as(a,$(e.item).attr("data-task-id")),check_kanban_empty_col("[data-task-id]"),setTimeout((function(){$.post(admin_url+"tasks/update_order",i).done((function(t){update_kan_ban_total_when_moving(e,i.status),tasks_kanban()}))}),200)}}function tasks_kanban(){init_kanban("tasks/kanban",tasks_kanban_update,".tasks-status",240,360)}function edit_task_inline_description(e,t){tinyMCE.remove("#task_view_description"),$(e).hasClass("editor-initiated")?$(e).removeClass("editor-initiated"):($(e).addClass("editor-initiated"),$.Shortcuts.stop(),tinymce.init({branding:!1,toolbar:!1,menubar:!1,inline:!0,cache_suffix:"?v="+app.version,selector:"#task_view_description",theme:"silver",directionality:"true"==isRTL?"rtl":"",auto_focus:"task_view_description",plugins:["quickbars","link","table","true"==isRTL?" directionality":""],contextmenu:"link table paste pastetext",quickbars_insert_toolbar:"quicktable",quickbars_selection_toolbar:"bold italic | quicklink h2 h3 blockquote",table_default_styles:{width:"100%"},setup:function(e){e.on("blur",(function(a){e.isDirty()&&$.post(admin_url+"tasks/update_task_description/"+t,{description:e.getContent()}),setTimeout((function(){e.remove(),$.Shortcuts.start()}),500)}))}}))}function tasks_bulk_action(e){if(confirm_delete()){var t=[],a={},i=$("#mass_delete").prop("checked");if(0==i||void 0===i){a.status=$("#move_to_status_tasks_bulk_action").val();var n=$("#task_bulk_assignees");a.assignees=n.length?n.selectpicker("val"):"";var s=$("#tags_bulk");a.tags=s.length?s.tagit("assignedTags"):"";var o=$("#task_bulk_milestone");if(a.milestone=o.length?o.selectpicker("val"):"",a.billable=$("#task_bulk_billable").val(),a.billable=void 0===a.billable?"":a.billable,a.priority=$("#task_bulk_priority").val(),a.priority=void 0===a.priority?"":a.priority,""===a.status&&""===a.priority&&""===a.tags&&""===a.assignees&&""===a.milestone&&""===a.billable)return}else a.mass_delete=!0;var l=$($("#tasks_bulk_actions").attr("data-table")).find("tbody tr");$.each(l,(function(){var e=$($(this).find("td").eq(0)).find("input");!0===e.prop("checked")&&t.push(e.val())})),a.ids=t,$(e).addClass("disabled"),setTimeout((function(){$.post(admin_url+"tasks/bulk_action",a).done((function(){window.location.reload()}))}),200)}}function load_small_table_item(e,t,a,i,n){var s=$('input[name="'+a+'"]').val();""===s||window.location.hash?window.location.hash&&!e&&(e=window.location.hash.substring(1)):(e=s,$('input[name="'+a+'"]').val("")),void 0!==e&&""!==e&&(destroy_dynamic_scripts_in_element($(t)),$("body").hasClass("small-table")||toggle_small_view(n,t),$('input[name="'+a+'"]').val(e),do_hash_helper(e),$(t).load(admin_url+i+"/"+e),$("html, body").animate({scrollTop:$(t).offset().top+(is_mobile()?150:0)},600))}function init_invoice(e){load_small_table_item(e,"#invoice","invoiceid","invoices/get_invoice_data_ajax",".table-invoices")}function init_credit_note(e){load_small_table_item(e,"#credit_note","credit_note_id","credit_notes/get_credit_note_data_ajax",".table-credit-notes")}function init_estimate(e){load_small_table_item(e,"#estimate","estimateid","estimates/get_estimate_data_ajax",".table-estimates")}function init_proposal(e){load_small_table_item(e,"#proposal","proposal_id","proposals/get_proposal_data_ajax",".table-proposals")}function init_expense(e){load_small_table_item(e,"#expense","expenseid","expenses/get_expense_data_ajax",".table-expenses")}function clear_billing_and_shipping_details(){for(var e in billingAndShippingFields)billingAndShippingFields[e].indexOf("country")>-1?$('select[name="'+billingAndShippingFields[e]+'"]').selectpicker("val",""):($('input[name="'+billingAndShippingFields[e]+'"]').val(""),$('textarea[name="'+billingAndShippingFields[e]+'"]').val("")),"billing_country"==billingAndShippingFields[e]&&($('input[name="include_shipping"]').prop("checked",!1),$('input[name="include_shipping"]').change());init_billing_and_shipping_details()}function init_billing_and_shipping_details(){var e,t=$('input[name="include_shipping"]').prop("checked");for(var a in billingAndShippingFields)e="",billingAndShippingFields[a].indexOf("country")>-1?e=$("#"+billingAndShippingFields[a]+" option:selected").data("subtext"):billingAndShippingFields[a].indexOf("shipping_street")>-1||billingAndShippingFields[a].indexOf("billing_street")>-1?$('textarea[name="'+billingAndShippingFields[a]+'"]').length&&(e=$('textarea[name="'+billingAndShippingFields[a]+'"]').val().replace(/(?:\r\n|\r|\n)/g,"
")):e=$('input[name="'+billingAndShippingFields[a]+'"]').val(),billingAndShippingFields[a].indexOf("shipping")>-1&&(t||(e="")),void 0===e&&(e=""),e=""!==e?e:"--",$("."+billingAndShippingFields[a]).html(e);$("#billing_and_shipping_details").modal("hide")}function record_payment(e){void 0!==e&&""!==e&&$("#invoice").load(admin_url+"invoices/record_invoice_payment_ajax/"+e)}function schedule_invoice_send(e){$("#invoice").load(admin_url+"email_schedule_invoice/create/"+e)}function schedule_estimate_send(e){$("#estimate").load(admin_url+"email_schedule_estimate/create/"+e)}function edit_invoice_scheduled_email(e){$("#invoice").load(admin_url+"email_schedule_invoice/edit/"+e)}function edit_estimate_scheduled_email(e){$("#estimate").load(admin_url+"email_schedule_estimate/edit/"+e)}function add_item_to_preview(e){requestGetJSON("invoice_items/get_item_by_id/"+e).done((function(e){clear_item_preview_values(),$('.main textarea[name="description"]').val(e.description),$('.main textarea[name="long_description"]').val(e.long_description.replace(/(<|<)br\s*\/*(>|>)/g," ")),_set_item_preview_custom_fields_array(e.custom_fields),$('.main input[name="quantity"]').val(1);var t=[];e.taxname&&e.taxrate&&t.push(e.taxname+"|"+e.taxrate),e.taxname_2&&e.taxrate_2&&t.push(e.taxname_2+"|"+e.taxrate_2),$(".main select.tax").selectpicker("val",t),$('.main input[name="unit"]').val(e.unit);var a=$("body").find('.accounting-template select[name="currency"]'),i=a.attr("data-base"),n=a.find("option:selected").val(),s=$('.main input[name="rate"]');if(i==n)s.val(e.rate);else{var o=e["rate_currency_"+n];o&&0!==parseFloat(o)?s.val(o):s.val(e.rate)}$(document).trigger({type:"item-added-to-preview",item:e,item_type:"item"})}))}function _set_item_preview_custom_fields_array(e){for(var t=["input","number","date_picker","date_picker_time","colorpicker"],a=0;a-1)$('tr.main td[data-id="'+i.id+'"] input').val(i.value).trigger("change");else if("textarea"==i.type)$('tr.main td[data-id="'+i.id+'"] textarea').val(i.value);else if("select"==i.type||"multiselect"==i.type){if(!empty(i.value))n=(n=i.value.split(",")).map((function(e){return e.trim()})),$('tr.main td[data-id="'+i.id+'"] select').selectpicker("val",n)}else if("checkbox"==i.type){var n;if(!empty(i.value))n=(n=i.value.split(",")).map((function(e){return e.trim()})),$.each(n,(function(e,t){$('tr.main td[data-id="'+i.id+'"] input[type="checkbox"][value="'+t+'"]').prop("checked",!0)}))}}}function add_task_to_preview_as_item(e){requestGetJSON("tasks/get_billable_task_data/"+e).done((function(t){t.taxname=$("select.main-tax").selectpicker("val");var a=$(".main");a.find('textarea[name="description"]').val(t.name),a.find('textarea[name="long_description"]').val(t.description),a.find('input[name="quantity"]').val(t.total_hours),a.find('input[name="rate"]').val(t.hourly_rate),a.find('input[name="unit"]').val(""),$('input[name="task_id"]').val(e),$(document).trigger({type:"item-added-to-preview",item:t,item_type:"task"})}))}function clear_item_preview_values(e){var t=$("table.items tbody").find("tr:last-child").find("select").selectpicker("val"),a=$(".main");a.find("textarea").val(""),a.find('td.custom_field input[type="checkbox"]').prop("checked",!1),a.find("td.custom_field input:not(:checkbox):not(:hidden)").val(""),a.find("td.custom_field select").selectpicker("val",""),a.find('input[name="quantity"]').val(1),a.find("select.tax").selectpicker("val",t),a.find('input[name="rate"]').val(""),a.find('input[name="unit"]').val(""),$('input[name="task_id"]').val(""),$('input[name="expense_id"]').val("")}function add_item_to_table(e,t,a,i){if(""!==(e=void 0===e||"undefined"==e?get_item_preview_values():e).description||""!==e.long_description||""!==e.rate){var n="",s=lastAddedItemKey?lastAddedItemKey+=1:$("body").find("tbody .item").length+1;lastAddedItemKey=s,n+='',n+='',isNaN(e.qty)&&(e.qty=1),(""===e.rate||isNaN(e.rate))&&(e.rate=0);var o=e.rate*e.qty,l="newitems["+s+"][taxname][]";$("body").append('
');var d=/]*>/gi;return get_taxes_dropdown_template(l,e.taxname).done((function(a){n+='',n+="",n+='",n+='";var l=$("tr.main td.custom_field"),r=!1;l.length>0&&$.each(l,(function(){var e=$(this).clone(),t="",a=$(this).find("[data-fieldid]"),i="newitems["+s+"][custom_fields][items]["+a.attr("data-fieldid")+"]";if(a.is(":checkbox")){var o=$(this).find('input[type="checkbox"]:checked'),l=e.find('input[type="checkbox"]');$.each(l,(function(e,t){var a=Math.random().toString(20).slice(2);$(this).attr("id",a).attr("name",i).next("label").attr("for",a),"1"==$(this).attr("data-custom-field-required")&&(r=!0)})),$.each(o,(function(t,a){e.find('input[value="'+$(a).val()+'"]').attr("checked",!0)})),t=e.html()}else if(a.is("input")||a.is("textarea"))a.is("input")?e.find("[data-fieldid]").attr("value",a.val()):e.find("[data-fieldid]").html(a.val()),e.find("[data-fieldid]").attr("name",i),"1"==e.find("[data-fieldid]").attr("data-custom-field-required")&&(r=!0),t=e.html();else if(a.is("select")){"1"==$(this).attr("data-custom-field-required")&&(r=!0);var d=$(this).find("select[data-fieldid]").selectpicker("val");d=(d=new Array(d))[0].constructor===Array?d[0]:d;var c=e.find("select"),p=$("
");c.attr("name",i);var _=c.clone();p.append(_),$.each(d,(function(e,t){p.find('select option[value="'+t+'"]').attr("selected",!0)})),t=p.html()}n+=''+t+""})),n+='',e.unit&&void 0!==e.unit||(e.unit=""),n+='',n+="",n+='',n+=''+a+"",n+=''+format_money(o,!0)+"",n+='',n+="",$("table.items tbody").append(n),$(document).trigger({type:"item-added-to-table",data:e,row:n}),setTimeout((function(){calculate_total()}),15);var c=$('input[name="task_id"]').val(),p=$('input[name="expense_id"]').val();return""!==c&&void 0!==c&&(billed_tasks=c.split(","),$.each(billed_tasks,(function(e,t){$("#billed-tasks").append(hidden_input("billed_tasks["+s+"][]",t))}))),""!==p&&void 0!==p&&(billed_expenses=p.split(","),$.each(billed_expenses,(function(e,t){$("#billed-expenses").append(hidden_input("billed_expenses["+s+"][]",t))}))),$("#item_select").hasClass("ajax-search")&&""!==$("#item_select").selectpicker("val")&&$("#item_select").prepend(""),init_selectpicker(),init_datepicker(),init_color_pickers(),clear_item_preview_values(),reorder_items(),$("body").find("#items-warning").remove(),$("body").find(".dt-loader").remove(),$("#item_select").selectpicker("val",""),r&&$(".invoice-form").length?validate_invoice_form():r&&$(".estimate-form").length?validate_estimate_form():r&&$(".proposal-form").length?validate_proposal_form():r&&$(".credit-note-form").length&&validate_credit_note_form(),"undefined"!=i&&i||($('select[name="task_select"]').find('[value="'+c+'"]').remove(),$('select[name="task_select"]').selectpicker("refresh")),!0})),!1}}function get_taxes_dropdown_template(e,t){return $.post(admin_url+"misc/get_taxes_dropdown_template",{name:e,taxname:t})}function deselect_ajax_search(e){var t=$("select#"+$(e).attr("data-id"));t.data("AjaxBootstrapSelect").list.cache={};var a=t.parents(".bootstrap-select");t.html("").append('').selectpicker("val","multiple"==t.attr("multiple")?[]:""),a.removeClass("ajax-remove-values-option").find(".ajax-clear-values").remove(),setTimeout((function(){t.trigger("selected.cleared.ajax.bootstrap.select",e),t.trigger("change").data("AjaxBootstrapSelect").list.cache={}}),50)}function init_ajax_project_search_by_customer_id(e){init_ajax_search("project",e=void 0===e?"#project_id.ajax-search":e,{customer_id:function(){return $("#clientid").val()}})}function init_ajax_projects_search(e){init_ajax_search("project",e=void 0===e?"#project_id.ajax-search":e)}function init_items_sortable(e){var t=$("#wrapper").find(".items tbody");0!==t.length&&t.sortable({helper:fixHelperTableHelperSortable,handle:".dragger",placeholder:"ui-placeholder",itemPath:"> tbody",itemSelector:"tr.sortable",items:"tr.sortable",update:function(){void 0===e?reorder_items():save_ei_items_order()},sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var i=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:i+"px"})}}})}function save_ei_items_order(){var e=$(".table.items-preview"),t=e.find("tbody tr"),a=1,i=e.attr("data-type"),n=[];if(!i)return!1;$.each(t,(function(){n.push([$(this).data("item-id"),a]),$(this).find("td.item_no").html(a),a++})),setTimeout((function(){$.post(admin_url+"misc/update_ei_items_order/"+i,{data:n})}),200)}function reorder_items(){var e=$(".table.has-calculations tbody tr.item"),t=1;$.each(e,(function(){$(this).find("input.order").val(t),t++}))}function get_item_preview_values(){var e={};return e.description=$('.main textarea[name="description"]').val(),e.long_description=$('.main textarea[name="long_description"]').val(),e.qty=$('.main input[name="quantity"]').val(),e.taxname=$(".main select.tax").selectpicker("val"),e.rate=$('.main input[name="rate"]').val(),e.unit=$('.main input[name="unit"]').val(),e}function calculate_total(){if($("body").hasClass("no-calculate-total"))return!1;var e,t,a,i,n,s,o={},l=0,d=0,r=1,c=0,p=$(".table.has-calculations tbody tr.item"),_=$("#discount_area"),m=$('input[name="adjustment"]').val(),u=$('input[name="discount_percent"]').val(),f=$('input[name="discount_total"]').val(),h=$(".discount-total-type.selected"),v=$('select[name="discount_type"]').val();$(".tax-area").remove(),$.each(p,(function(){""===(r=$(this).find("[data-quantity]").val())&&(r=1,$(this).find("[data-quantity]").val(1)),n=accounting.toFixed($(this).find("td.rate input").val()*r,app.options.decimal_places),n=parseFloat(n),$(this).find("td.amount").html(format_money(n,!0)),l+=n,i=$(this),(a=$(this).find("select.tax").selectpicker("val"))&&$.each(a,(function(a,l){t=i.find('select.tax [value="'+l+'"]').data("taxrate"),e=n/100*t,o.hasOwnProperty(l)?o[l]=o[l]+=e:0!=t&&(s=l.split("|"),tax_row=''+s[0]+"("+t+'%)',$(_).after(tax_row),o[l]=e)}))})),""!==u&&0!=u&&"before_tax"==v&&h.hasClass("discount-type-percent")?c=l*u/100:""!==f&&0!=f&&"before_tax"==v&&h.hasClass("discount-type-fixed")&&(c=f),$.each(o,(function(e,t){if(""!==u&&0!=u&&"before_tax"==v&&h.hasClass("discount-type-percent"))total_tax_calculated=t*u/100,t-=total_tax_calculated;else if(""!==f&&0!=f&&"before_tax"==v&&h.hasClass("discount-type-fixed")){t-=t*(f/l*100)/100}d+=t,t=format_money(t),$("#tax_id_"+slugify(e)).html(t)})),d+=l,""!==u&&0!=u&&"after_tax"==v&&h.hasClass("discount-type-percent")?c=d*u/100:""!==f&&0!=f&&"after_tax"==v&&h.hasClass("discount-type-fixed")&&(c=f),d-=c,m=parseFloat(m),isNaN(m)||(d+=m);var b="-"+format_money(c);$('input[name="discount_total"]').val(accounting.toFixed(c,app.options.decimal_places)),$(".discount-total").html(b),$(".adjustment").html(format_money(m)),$(".subtotal").html(format_money(l)+hidden_input("subtotal",accounting.toFixed(l,app.options.decimal_places))),$(".total").html(format_money(d)+hidden_input("total",accounting.toFixed(d,app.options.decimal_places))),$(document).trigger("sales-total-calculated")}function exclude_tax_from_amount(e,t){return totalTax=accounting.toFixed(t*e/(100+e),app.options.decimal_places),accounting.toFixed(t-totalTax,app.options.decimal_places)}function delete_item(e,t){$(e).parents("tr").addClass("animated fadeOut",(function(){setTimeout((function(){$(e).parents("tr").remove(),calculate_total()}),50)})),t&&$('input[name="isedit"]').length>0&&$("#removed-items").append(hidden_input("removed_items[]",t))}function format_money(e,t){return void 0!==t&&t?accounting.formatMoney(e,{symbol:""}):accounting.formatMoney(e)}function init_currency(e,t){var a=$("body").find(".accounting-template");(a.length||e)&&requestGetJSON("misc/get_currency/"+(e||a.find('select[name="currency"]').val())).done((function(e){accounting.settings.currency.decimal=e.decimal_separator,accounting.settings.currency.thousand=e.thousand_separator,accounting.settings.currency.symbol=e.symbol,accounting.settings.currency.format="after"==e.placement?"%v %s":"%s%v",calculate_total(),t&&t()}))}function delete_invoice_attachment(e){confirm_delete()&&requestGet("invoices/delete_attachment/"+e).done((function(t){1==t&&($("body").find('[data-attachment-id="'+e+'"]').remove(),init_invoice($("body").find('input[name="_attachment_sale_id"]').val()))})).fail((function(e){alert_float("danger",e.responseText)}))}function delete_credit_note_attachment(e){confirm_delete()&&requestGet("credit_notes/delete_attachment/"+e).done((function(t){1==t&&($("body").find('[data-attachment-id="'+e+'"]').remove(),init_credit_note($("body").find('input[name="_attachment_sale_id"]').val()))})).fail((function(e){alert_float("danger",e.responseText)}))}function delete_estimate_attachment(e){confirm_delete()&&requestGet("estimates/delete_attachment/"+e).done((function(t){if(1==t){$("body").find('[data-attachment-id="'+e+'"]').remove();var a=$("body").find('input[name="_attachment_sale_id"]').val();$("body").hasClass("estimates-pipeline")?estimate_pipeline_open(a):init_estimate(a)}})).fail((function(e){alert_float("danger",e.responseText)}))}function delete_proposal_attachment(e){confirm_delete()&&requestGet("proposals/delete_attachment/"+e).done((function(t){if(1==t){var a=$("body").find('input[name="_attachment_sale_id"]').val();$("body").find('[data-attachment-id="'+e+'"]').remove(),$("body").hasClass("proposals-pipeline")?proposal_pipeline_open(a):init_proposal(a)}})).fail((function(e){alert_float("danger",e.responseText)}))}function init_invoices_total(e){if(0!==$("#invoices_total").length){var t=$(".invoices-total-inline"),a=$(".invoices-total");if(!$("body").hasClass("invoices-total-manual")||void 0!==e||a.hasClass("initialized"))if(t.length>0&&a.hasClass("initialized"))t.removeClass("invoices-total-inline");else{a.addClass("initialized");var i=$("body").find('select[name="invoices_total_years"]').selectpicker("val"),n=[];$.each(i,(function(e,t){""!==t&&n.push(t)}));var s={currency:$("body").find('select[name="total_currency"]').val(),years:n,init_total:!0},o=$('input[name="project_id"]').val(),l=$('.customer_profile input[name="userid"]').val();void 0!==o?s.project_id=o:void 0!==l&&(s.customer_id=l),$.post(admin_url+"invoices/get_invoices_total",s).done((function(e){$("#invoices_total").html(e)}))}}}function init_estimates_total(e){if(0!==$("#estimates_total").length){var t=$(".estimates-total");if(!$("body").hasClass("estimates-total-manual")||void 0!==e||t.hasClass("initialized")){t.addClass("initialized");var a=$("body").find('select[name="total_currency"]').val(),i=$("body").find('select[name="estimates_total_years"]').selectpicker("val"),n=[];$.each(i,(function(e,t){""!==t&&n.push(t)}));var s="",o="",l=$('.customer_profile input[name="userid"]').val(),d=$('input[name="project_id"]').val();void 0!==l?s=l:void 0!==d&&(o=d),$.post(admin_url+"estimates/get_estimates_total",{currency:a,init_total:!0,years:n,customer_id:s,project_id:o}).done((function(e){$("#estimates_total").html(e)}))}}}function init_expenses_total(){if(0!==$("#expenses_total").length){var e=$("body").find('select[name="expenses_total_currency"]').val(),t=$("body").find('select[name="expenses_total_years"]').selectpicker("val"),a=[];$.each(t,(function(e,t){""!==t&&a.push(t)}));var i="",n=$('.customer_profile input[name="userid"]').val();void 0!==i&&(i=n);var s="",o=$('input[name="project_id"]').val();void 0!==s&&(s=o),$.post(admin_url+"expenses/get_expenses_total",{currency:e,init_total:!0,years:a,customer_id:i,project_id:s}).done((function(e){$("#expenses_total").html(e)}))}}function validate_invoice_form(e){e=void 0===e?"#invoice-form":e,appValidateForm($(e),{clientid:{required:{depends:function(){return!$("select#clientid").hasClass("customer-removed")}}},date:"required",currency:"required",repeat_every_custom:{min:1},number:{required:!0}}),$("body").find('input[name="number"]').rules("add",{remote:{url:admin_url+"invoices/validate_invoice_number",type:"post",data:{number:function(){return $('input[name="number"]').val()},isedit:function(){return $('input[name="number"]').data("isedit")},original_number:function(){return $('input[name="number"]').data("original-number")},date:function(){return $('input[name="date"]').val()}}},messages:{remote:app.lang.invoice_number_exists}})}function validate_credit_note_form(e){e=void 0===e?"#credit-note-form":e,appValidateForm($(e),{clientid:{required:{depends:function(){return!$("select#clientid").hasClass("customer-removed")}}},date:"required",currency:"required",number:{required:!0}}),$("body").find('input[name="number"]').rules("add",{remote:{url:admin_url+"credit_notes/validate_number",type:"post",data:{number:function(){return $('input[name="number"]').val()},isedit:function(){return $('input[name="number"]').data("isedit")},original_number:function(){return $('input[name="number"]').data("original-number")},date:function(){return $(".credit_note input[name='date']").val()}}},messages:{remote:app.lang.credit_note_number_exists}})}function validate_estimate_form(e){e=void 0===e?"#estimate-form":e,appValidateForm($(e),{clientid:{required:{depends:function(){return!$("select#clientid").hasClass("customer-removed")}}},date:"required",currency:"required",number:{required:!0}}),$("body").find('input[name="number"]').rules("add",{remote:{url:admin_url+"estimates/validate_estimate_number",type:"post",data:{number:function(){return $('input[name="number"]').val()},isedit:function(){return $('input[name="number"]').data("isedit")},original_number:function(){return $('input[name="number"]').data("original-number")},date:function(){return $("body").find('.estimate input[name="date"]').val()}}},messages:{remote:app.lang.estimate_number_exists}})}function estimates_pipeline_sort(e){kan_ban_sort(e,estimate_pipeline)}function proposal_pipeline_sort(e){kan_ban_sort(e,proposals_pipeline)}function estimate_pipeline(){init_kanban("estimates/get_pipeline",estimates_pipeline_update,".pipeline-status",290,360)}function estimates_pipeline_update(e,t){if(t===e.item.parent()[0]){var a={estimateid:$(e.item).attr("data-estimate-id"),status:$(e.item.parent()[0]).attr("data-status-id"),order:[]};$.each($(e.item).parents(".pipeline-status").find("li"),(function(e,t){var i=$(t).attr("data-estimate-id");i&&a.order.push([i,e+1])})),check_kanban_empty_col("[data-estimate-id]"),setTimeout((function(){$.post(admin_url+"estimates/update_pipeline",a).done((function(t){update_kan_ban_total_when_moving(e,a.status),estimate_pipeline()}))}),200)}}function proposals_pipeline_update(e,t){if(t===e.item.parent()[0]){var a={order:[],status:$(e.item.parent()[0]).attr("data-status-id"),proposalid:$(e.item).attr("data-proposal-id")};$.each($(e.item).parents(".pipeline-status").find("li"),(function(e,t){var i=$(t).attr("data-proposal-id");i&&a.order.push([i,e+1])})),check_kanban_empty_col("[data-proposal-id]"),setTimeout((function(){$.post(admin_url+"proposals/update_pipeline",a).done((function(t){update_kan_ban_total_when_moving(e,a.status),proposals_pipeline()}))}),200)}}function proposals_pipeline(){init_kanban("proposals/get_pipeline",proposals_pipeline_update,".pipeline-status",290,360)}function proposal_pipeline_open(e){""!==e&&requestGet("proposals/pipeline_open/"+e).done((function(e){var t=$(".proposal-pipeline-modal:visible").length>0;$("#proposal").html(e),t?$("#proposal").find(".modal.proposal-pipeline-modal").removeClass("fade").addClass("in").css("display","block"):$(".proposal-pipeline-modal").modal({show:!0,backdrop:"static",keyboard:!1})}))}function estimate_pipeline_open(e){""!==e&&requestGet("estimates/pipeline_open/"+e).done((function(e){var t=$(".estimate-pipeline:visible").length>0;$("#estimate").html(e),t?$("#estimate").find(".modal.estimate-pipeline").removeClass("fade").addClass("in").css("display","block"):$(".estimate-pipeline").modal({show:!0,backdrop:"static",keyboard:!1})}))}function delete_sales_note(e,t){confirm_delete()&&requestGetJSON("misc/delete_note/"+t).done((function(t){if(!0===t.success||"true"==t.success){$(e).parents(".sales-note-wrapper").remove();var a=$("#sales-notes-wrapper"),i=a.attr("data-total")-1,n=$(".notes-total");a.attr("data-total",i),i<=0?n.addClass("hide"):n.html(''+i+"")}}))}function get_sales_notes(e,t){requestGet(t+"/get_notes/"+e).done((function(e){$("#sales_notes_area").html(e);var t=$("#sales-notes-wrapper").attr("data-total");t>0&&$(".notes-total").html(''+t+"").removeClass("hide")}))}function insert_proposal_merge_field(e){tinymce.activeEditor.execCommand("mceInsertContent",!1,$(e).text())}function small_table_full_view(){$("#small-table").toggleClass("hide"),$(".small-table-right-col").toggleClass("col-md-12 col-md-7"),$(window).trigger("resize")}function save_sales_number_settings(e){var t={};t.prefix=$("body").find('input[name="s_prefix"]').val(),$.post($(e).data("url"),t).done((function(e){(e=JSON.parse(e)).success&&e.message&&(alert_float("success",e.message),$("#prefix").html(t.prefix))}))}function do_prefix_year(e){var t=_split_formatted_date_by_separator(e);void 0!==t&&$.each(t,(function(e,a){if(4==a.length){var i=$("#prefix_year");if(i.hasClass("format-n-yy"))a=a.substr(-2);else if(i.hasClass("format-mm-yyyy")){var n;"d-m-Y"==app.options.date_format||"d/m/Y"==app.options.date_format||"Y-m-d"==app.options.date_format||"d.m.Y"==app.options.date_format?n=1:"m-d-Y"!=app.options.date_format&&"m.d.Y"!=app.options.date_format&&"m/d/Y"!=app.options.date_format||(n=0),$("#prefix_month").html(t[n])}i.html(a)}}))}function unformat_date(e){var t=_split_formatted_date_by_separator(e),a=1,i=0,n=2;return"d-m-Y"==app.options.date_format||"d/m/Y"==app.options.date_format||"d.m.Y"==app.options.date_format?(n=0,a=1,i=2):"m-d-Y"!=app.options.date_format&&"m.d.Y"!=app.options.date_format&&"m/d/Y"!=app.options.date_format||(n=1,a=0,i=2),t[i]+"-"+t[a]+"-"+t[n]}function _split_formatted_date_by_separator(e){var t;return e.indexOf(".")>-1?t=e.split("."):e.indexOf("-")>-1?t=e.split("-"):e.indexOf("/")>-1&&(t=e.split("/")),t}function init_tabs_scrollable(){"true"!=isRTL?($(window).width()<=768&&$("body").find(".toggle_view").remove(),$(".horizontal-scrollable-tabs").horizontalTabs()):($(".arrow-left, .arrow-right").css("display","none"),$(".horizontal-scrollable-tabs").removeClass("horizontal-scrollable-tabs"),$(".nav-tabs-horizontal").removeClass("nav-tabs-horizontal"))}function view_contact_consent(e){requestGet("clients/consents/"+e).done((function(e){$("#consent_data").html(e),initDataTableInline($("#consentHistoryTable")),$("#consentModal").modal("show")}))}function view_lead_consent(e){window.location.hash="gdpr",init_lead(e)}function set_notification_read_inline(e){requestGet("misc/set_notification_read_inline/"+e).done((function(){var t=$("body").find('.notification-wrapper[data-notification-id="'+e+'"]');t.find(".notification-handler").removeClass("unread-notification"),t.find(".not-mark-as-read-inline").tooltip("destroy").remove()}))}function mark_all_notifications_as_read_inline(){requestGet("misc/mark_all_notifications_as_read_inline/").done((function(){var e=$("body").find(".notification-wrapper");e.find(".notification-handler").removeClass("unread-notification"),e.find(".not-mark-as-read-inline").tooltip("destroy").remove()}))}function delete_sale_activity(e){confirm_delete()&&requestGet("misc/delete_sale_activity/"+e).done((function(){$("body").find('[data-sale-activity-id="'+e+'"]').remove()}))}function view_event(e){void 0!==e&&$.post(admin_url+"utilities/view_event/"+e).done((function(e){$("#event").html(e),$("#viewEvent").modal("show"),init_datepicker(),init_selectpicker(),validate_calendar_form()}))}function delete_event(e){confirm_delete()&&requestGetJSON("utilities/delete_event/"+e).done((function(e){!0!==e.success&&"true"!=e.success||window.location.reload()}))}function validate_calendar_form(){appValidateForm($("body").find("._event form"),{title:"required",start:"required",reminder_before:"required"},calendar_form_handler),appValidateForm($("body").find("#viewEvent form"),{title:"required",start:"required",reminder_before:"required"},calendar_form_handler)}function calendar_form_handler(e){return $.post(e.action,$(e).serialize()).done((function(e){!0!==(e=JSON.parse(e)).success&&"true"!=e.success||(alert_float("success",e.message),setTimeout((function(){var e=window.location.href;e=e.split("?"),window.location.href=e[0]}),500))})),!1}function fetch_notifications(e){requestGetJSON("misc/notifications_check").done((function(e){var t=notifications_wrapper;t.html(e.html);var a=t.find("ul.notifications").attr("data-total-unread");document.title=a>0?"("+a+") "+doc_initial_title:doc_initial_title;var i=e.notificationsIds;if("firefox"==app.browser&&i.length>1){var n=i[0];(i=[]).push(n)}setTimeout((function(){i.length>0&&$.each(i,(function(e,a){var i='li[data-notification-id="'+a+'"]',n=t.find(i);$.notify("",{title:app.lang.new_notification,body:n.find(".notification-title").text(),requireInteraction:!0,icon:n.find(".notification-image").attr("src"),tag:a,closeTime:"0"!=app.options.dismiss_desktop_not_after?1e3*app.options.dismiss_desktop_not_after:null}).close((function(){requestGet("misc/set_desktop_notification_read/"+a).done((function(e){var i=t.find(".icon-total-indicator");t.find('li[data-notification-id="'+a+'"] .notification-box').removeClass("unread");var n=i.text();n=n.trim(),(n-=1)>0?(document.title="("+n+") "+doc_initial_title,i.html(n)):(document.title=doc_initial_title,i.addClass("hide"))}))})).click((function(e){parent.focus(),window.focus(),setTimeout((function(){t.find(i+" .notification-link").addClass("desktopClick").click(),e.target.close()}),70)}))}))}),10)}))}function init_new_task_comment(e){tinymce.get("task_comment")&&tinymce.remove("#task_comment"),"undefined"!=typeof taskCommentAttachmentDropzone&&taskCommentAttachmentDropzone.destroy(),$("#dropzoneTaskComment").removeClass("hide"),$("#addTaskCommentBtn").removeClass("hide"),taskCommentAttachmentDropzone=new Dropzone("#task-comment-form",appCreateDropzoneOptions({uploadMultiple:!0,clickable:"#dropzoneTaskComment",previewsContainer:".dropzone-task-comment-previews",autoProcessQueue:!1,addRemoveLinks:!0,parallelUploads:20,maxFiles:20,paramName:"file",sending:function(e,t,a){a.append("taskid",$("#addTaskCommentBtn").attr("data-comment-task-id")),tinyMCE.activeEditor?a.append("content",tinyMCE.activeEditor.getContent()):a.append("content",$("#task_comment").val())},success:function(e,t){t=JSON.parse(t),0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&(_task_append_html(t.taskHtml),tinymce.remove("#task_comment"))}}));var t=_simple_editor_config();t.toolbar_sticky=!0,void 0!==e&&!1!==e||(t.auto_focus=!0);var a=$("#task-modal #taskid").val();t.content_style="span.mention { background-color: #eeeeee; padding: 3px; }",t.setup=function(e){initializeTinyMceMentions(e,(function(){return $.getJSON(admin_url+"tasks/get_staff_names_for_mentions/"+a)}))},init_editor("#task_comment",t)}function initializeTinyMceMentions(e,t){Object.hasOwn(e,"perfexCommands")||(e.perfexCommands={});let a=null;e.perfexCommands.getUsersForMention=async function(){if(Array.isArray(a))return a;let e=await t();return a=e.map((e=>({value:e.id.toString(),text:e.name}))),a},e.perfexCommands.insertMentionUser=function(t,a,i){e.selection.setRng(i||0),e.insertContent('@'+a+" ")},e.ui.registry.addAutocompleter("mentions",{trigger:"@",minChars:0,columns:1,fetch:function(t){return new Promise((t=>t(e.perfexCommands.getUsersForMention())))},onAction:function(t,a,i){e.perfexCommands.getUsersForMention().then((n=>{let s=n.find((e=>e.value==i));e.perfexCommands.insertMentionUser(i,s.text,a),t.hide()}))}})}function init_ajax_search(e,t,a,i){var n=$("body").find(t);if(n.length){var s={ajax:{url:void 0===i?admin_url+"misc/get_relation_data":i,data:function(){var t={};return t.type=e,t.rel_id="",t.q="{{{q}}}",void 0!==a&&jQuery.extend(t,a),t}},locale:{emptyTitle:app.lang.search_ajax_empty,statusInitialized:app.lang.search_ajax_initialized,statusSearching:app.lang.search_ajax_searching,statusNoResults:app.lang.not_results_found,searchPlaceholder:app.lang.search_ajax_placeholder,currentlySelected:app.lang.currently_selected},requestDelay:500,cache:!1,preprocessData:function(e){for(var t=[],a=e.length,i=0;i-1&&e.indexOf("%7D")>-1&&(e=e.replaceAll("%7B","{").replaceAll("%7D","}")),e}function salesGoogleDriveSave(e){salesExtenalFileUpload(e,"gdrive")}function leadExternalFileUpload(e,t,a){$.post(admin_url+"leads/add_external_attachment",{files:e,lead_id:a,external:t}).done((function(){init_lead_modal_data(a)}))}function taskExternalFileUpload(e,t,a){$.post(admin_url+"tasks/add_external_attachment",{files:e,task_id:a,external:t}).done((function(){init_task_modal(a)}))}function salesExtenalFileUpload(e,t){var a={};a.rel_id=$("body").find('input[name="_attachment_sale_id"]').val(),a.type=$("body").find('input[name="_attachment_sale_type"]').val(),a.files=e,a.external=t,$.post(admin_url+"misc/add_sales_external_attachment",a).done((function(){"estimate"==a.type?$("body").hasClass("estimates-pipeline")?estimate_pipeline_open(a.rel_id):init_estimate(a.rel_id):"proposal"==a.type?$("body").hasClass("proposals-pipeline")?proposal_pipeline_open(a.rel_id):init_proposal(a.rel_id):"function"==typeof window["init_"+a.type]&&window["init_"+a.type](a.rel_id),$("#sales_attach_file").modal("hide")}))}function set_search_history(e){for(var t=$("#search-history"),a="",i=0;i'+e[i]+' ';t.html(a)}function requestGet(e,t){t=void 0===t?{}:t;var a={type:"GET",url:e.indexOf(admin_url)>-1?e:admin_url+e};return $.ajax($.extend({},a,t))}function requestGetJSON(e,t){return(t=void 0===t?{}:t).dataType="json",requestGet(e,t)}function update_templates_count(e){var t=$(".templates-wrapper").length;$(".total_templates").text(t),0===t?$(".total_templates").addClass("hide"):$(".total_templates").removeClass("hide")}function get_templates(e,t){"proposals"===e?$("#proposal-templates").load(admin_url+"templates",{rel_type:e,rel_id:t},(function(){update_templates_count()})):"contracts"===e&&$("#contract-templates").load(admin_url+"templates",{rel_type:e,rel_id:t},(function(){update_templates_count()}))}function add_template(e,t){$("#modal-wrapper").load(admin_url+"templates/modal",{slug:"new",rel_type:e,rel_id:t},(function(){$("#TemplateModal").is(":hidden")&&$("#TemplateModal").modal({backdrop:"static",show:!0}),appValidateForm($("#template-form"),{name:"required"}),tinymce.remove("#content"),init_editor("#content",{pagebreak_split_block:!0,contextmenu:"link image inserttable | cell row column deletetable | paste copy | pagebreak",append_plugins:"pagebreak"})}))}function edit_template(e,t,a){$("#modal-wrapper").load(admin_url+"templates/modal",{slug:"edit",id:t,rel_type:e,rel_id:a},(function(){$("#TemplateModal").is(":hidden")&&$("#TemplateModal").modal({backdrop:"static",show:!0}),appValidateForm($("#template-form"),{name:"required"}),tinymce.remove("#content"),init_editor("#content",{pagebreak_split_block:!0,contextmenu:"link image inserttable | cell row column deletetable | paste copy | pagebreak",append_plugins:"pagebreak"})}))}function delete_template(e,t,a){confirm_delete()&&$.post(admin_url+"templates/delete/"+a).done((function(a){!0!==(a=JSON.parse(a)).success&&"true"!=a.success||("proposals"===t?$(e).parents(".proposal-templates-wrapper").html(""):"contracts"===t&&$(e).parents(".contract-templates-wrapper").html(""),get_templates(t))}))}function insert_template(e,t,a){requestGetJSON(admin_url+"templates/index/"+a).done((function(e){var a=e.data;tinymce.activeEditor.execCommand("mceInsertContent",!1,a.content),"proposals"==t?$('a[aria-controls="tab_proposal"]').click():"contracts"==t&&$('a[aria-controls="tab_content"]').click(),tinymce.activeEditor.focus()}))}function retrieve_imap_folders(e,t){var a=$.Deferred();return $("#folders-loader").addClass("spinning").removeClass("hidden"),$.post(e,t).done((function(e){if((e=JSON.parse(e)).hasOwnProperty("alert_type"))alert_float(e.alert_type,e.message);else{var t="",i=$("#folder"),n=i.selectpicker("val");e.forEach((function(e){t+='"})),i.html(t),i.selectpicker("refresh"),n||i.selectpicker("val",i.find("option:eq(0)")[0].value)}a.resolve(e)})).fail((function(e){a.reject(e)})).always((function(){$("#folders-loader").removeClass("spinning").addClass("hidden")})),a.promise()}function add_batch_payment(){$("#modal-wrapper").load(admin_url+"payments/batch_payment_modal",(function(){$("#batch-payment-modal").is(":hidden")&&$("#batch-payment-modal").modal({backdrop:"static",show:!0}),init_selectpicker(),init_datepicker();var e=$("#batch-payment-filter");e.on("changed.bs.select",(function(){""!==e.val()?$(".batch_payment_item").each((function(){$(this).data("clientid")==e.val()?($(this).find("input, select").prop("disabled",!1),$(this).removeClass("hide")):($(this).addClass("hide"),$(this).find("input, select").prop("disabled",!0))})):$(".batch_payment_item").each((function(){$(this).removeClass("hide"),$(this).find("input, select").prop("disabled",!1)}))})),appValidateForm($("#batch-payment-form"),{}),$(".batch_payment_item").each((function(){$(this).find('[name^="invoice"]').filter('select[name$="[paymentmode]"],input[name$="[amount]"]').each((function(){var e=$(this);e.rules("add",{required:function(){var t=!1;return e.closest(".batch_payment_item").find("input, select").filter('select[name$="[paymentmode]"],input[name$="[transactionid]"],input[name$="[amount]"]').each((function(){""!=$(this).val()&&(t=!0),$(this).hasClass("selectpicker")&&t&&(e.prop("required",!0),$(this).selectpicker("refresh"))})),t}})}))}))}))}function initDatatableOffline(e){console.warn('"initDatatableOffline" is deprecated, use "initDataTableInline" instead.'),initDataTableInline(e)}function init_currency_symbol(){console.warn('"init_currency_symbol" is deprecated, use "init_currency" instead'),init_currency()}$("body").on("loaded.bs.select change","select.ajax-search",(function(e){var t=$(this).selectpicker("val");if((!Array.isArray(t)||0!=t.length)&&t&&!$(this).is(":disabled")){var a=$(this).parents(".bootstrap-select.ajax-search");if(0===a.find(".ajax-clear-values").length){var i=$(this).attr("id");a.addClass("ajax-remove-values-option").find("button.dropdown-toggle").after('')}}})),$("body").on("rendered.bs.select","select",(function(){$(this).parents().removeClass("select-placeholder"),$(this).parents(".form-group").find(".select-placeholder").removeClass("select-placeholder")})),$("body").on("loaded.bs.select","select",(function(){1==$(this).data("toggle")&&$(this).selectpicker("toggle")})),$("body").on("loaded.bs.select","._select_input_group",(function(e){$(this).parents(".form-group").find(".input-group-select .input-group-addon").css("opacity","1")})),$(window).on("load resize",(function(e){$("body").hasClass("page-small")||set_body_small(),setTimeout((function(){mainWrapperHeightFix()}),"load"==e.type?150:0)})),$(document).on("mousemove",(function(e){!is_mobile()&&$("body").hasClass("hide-sidebar")&&("true"==isRTL&&$(window).width()-e.pageX<=10||"false"==isRTL&&e.pageX<=10)&&$(".hide-menu").click()})),$((function(){var e,t;totalUnreadNotifications>0&&(document.title="("+totalUnreadNotifications+") "+doc_initial_title),$(".screen-options-btn").on("click",(function(){$(".screen-options-area").slideToggle()})),$("body").hasClass("has-deprecated-errors")&&(e=$("div:contains('A PHP Error was encountered')"),t=0,$.each(e,(function(){t+=$(this).outerHeight(),$(this).css("background","#fff")})),t>0&&$("#menu, #setup-menu-wrapper").css("top",t+70+"px")),$("form").has('[data-entities-encode="true"]').on("submit.app.entity",(function(e){$(this).validate().checkForm()&&$.each($('[data-entities-encode="true"]'),(function(){$(this).hasClass("_entities-processed")||($(this).val(htmlEntities($(this).val())),$(this).addClass("_entities-processed"))}))})),add_hotkey("Shift+C",(function(){var e=$("#lead-modal"),t=$("#task-modal");if(e.is(":visible"))convert_lead_to_customer(e.find('input[name="leadid"]').val());else if(t.is(":visible")){var a=t.find(".tasks-comments");a.is(":visible")||a.css("display","block"),init_new_task_comment()}else window.location.href=admin_url+"clients/client"})),add_hotkey("Shift+I",(function(){window.location.href=admin_url+"invoices/invoice"})),add_hotkey("Shift+E",(function(){var e=$("#lead-modal"),t=$("#task-modal");e.is(":visible")||t.is(":visible")?e.is(":visible")?$("a[lead-edit]").click():t.is(":visible")&&edit_task(t.find("[data-task-single-id]").attr("data-task-single-id")):window.location.href=admin_url+"estimates/estimate"})),add_hotkey("Shift+F",(function(){var e=$("#task-modal");if(e.is(":visible")){var t=e.find("[data-task-single-id]");5!=t.attr("data-status")&&mark_complete(t.attr("data-task-single-id"))}})),add_hotkey("Ctrl+Shift+P",(function(){window.location.href=admin_url+"proposals/proposal"})),add_hotkey("Ctrl+Shift+E",(function(){window.location.href=admin_url+"expenses/expense"})),add_hotkey("Shift+L",(function(){init_lead()})),add_hotkey("Shift+T",(function(){var e=$(".new-task-relation");e.length>0?new_task(admin_url+"tasks/task?rel_id="+e.attr("data-rel-id")+"&rel_type="+e.attr("data-rel-type")):$("body").hasClass("project")?new_task(admin_url+"tasks/task?rel_id="+project_id+"&rel_type=project"):new_task()})),add_hotkey("Shift+P",(function(){window.location.href=admin_url+"projects/project"})),add_hotkey("Shift+S",(function(){window.location.href=admin_url+"tickets/add"})),add_hotkey("Ctrl+Shift+S",(function(){window.location.href=admin_url+"staff/member"})),add_hotkey("Ctrl+Shift+L",(function(){logout()})),add_hotkey("Alt+D",(function(){window.location.href=admin_url})),add_hotkey("Alt+C",(function(){window.location.href=admin_url+"clients"})),add_hotkey("Alt+T",(function(){window.location.href=admin_url+"tasks/list_tasks"})),add_hotkey("Alt+I",(function(){window.location.href=admin_url+"invoices/list_invoices"})),add_hotkey("Alt+E",(function(){window.location.href=admin_url+"estimates/list_estimates"})),add_hotkey("Alt+P",(function(){window.location.href=admin_url+"projects"})),add_hotkey("Alt+L",(function(){window.location.href=admin_url+"leads"})),add_hotkey("Ctrl+Alt+T",(function(){window.location.href=admin_url+"tickets"})),add_hotkey("Ctrl+Alt+E",(function(){window.location.href=admin_url+"expenses/list_expenses"})),add_hotkey("Alt+R",(function(){window.location.href=admin_url+"reports/sales"})),add_hotkey("Alt+S",(function(){window.location.href=admin_url+"settings"})),add_hotkey("Shift+K",(function(){$("#search_input").focus()})),add_hotkey("Shift+D",(function(){$("body .dataTables_wrapper").eq(0).find(".dataTables_filter input").focus()})),add_hotkey("Shift+F",(function(){$(".hide-menu").click()})),$.Shortcuts.start(),$(document).on("focusin",(function(e){$(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length&&e.stopImmediatePropagation()})),1!=app.options.show_setup_menu_item_only_on_hover||is_mobile()||side_bar.hover((function(){setTimeout((function(){setup_menu_item.css("display","block")}),200)}),(function(){setTimeout((function(){setup_menu_item.css("display","none")}),1e3)}));var a=$("body").find("ul.nav-tabs");tab_active&&a.find('[href="#'+tab_active+'"]').click(),tab_group&&(a.find("li").not('[role="presentation"]').removeClass("active"),a.find('[data-group="'+tab_group+'"]').parents("li").addClass("active")),moment.locale(app.locale),moment().tz(app.options.timezone).format(),init_editor(),$("body").on("click","#started-timers-top,.popover-top-timer-note",(function(e){e.stopPropagation()})),init_tags_inputs(),init_color_pickers(),initDataTableInline(),$("body").on("change",".onoffswitch input",(function(e,t){$(this).data("switch-url")&&switch_field(this)})),custom_fields_hyperlink(),init_lightbox(),init_progress_bars(),init_datepicker(),$(document).on("app.form-validate",(function(e,t){if(!0===select_picker_validated_event)return!0;select_picker_validated_event=!0,$(t).on("change","select.ajax-search, select.selectpicker",(function(e){if($(this).selectpicker("val")&&!$(this).is(":disabled")&&void 0!==$(this).rules()&&1===Object.keys($(this).rules()).length&&$(this).rules().hasOwnProperty("required")){var t=$(this).parents(".form-group");t.find("#"+$(this).attr("name")+"-error").remove(),t.removeClass("has-error")}}))})),init_selectpicker(),set_body_small(),init_form_reminder(),init_ajax_search("customer","#clientid.ajax-search");var i=side_bar.find('li > a[href="'+location+'"]');if(i.length&&(i.parents("li").not(".quick-links").addClass("active"),i.prop("aria-expanded",!0),i.parents("ul.nav-second-level").prop("aria-expanded",!0),i.parents("li").find("a:first-child").prop("aria-expanded",!0)),setup_menu.hasClass("display-block")){var n=setup_menu.find('li > a[href="'+location+'"]');n.length&&(n.parents("li").addClass("active"),n.prev("active"),n.parents("ul.nav-second-level").prop("aria-expanded",!0),n.parents("li").find("a:first-child").prop("aria-expanded",!0))}side_bar.metisMenu(),setup_menu.metisMenu(),$(".hide-menu").click((function(e){e.preventDefault(),$("body").hasClass("hide-sidebar")?$("body").removeClass("hide-sidebar").addClass("show-sidebar"):$("body").removeClass("show-sidebar").addClass("hide-sidebar"),setup_menu.hasClass("display-block")&&$(".close-customizer").click()})),is_mobile()&&content_wrapper.on("click",(function(){$("body").hasClass("show-sidebar")&&$(".hide-menu").click(),setup_menu.hasClass("display-block")&&$(".close-customizer").click()})),"safari"==app.browser&&$("body").on("input",".bootstrap-select .bs-searchbox input",(function(){$(this).trigger("keyup")})),mainWrapperHeightFix(),init_tabs_scrollable(),$("#top-timers").on("click",(function(){init_timers()})),set_search_history(app.user_recent_searches),$("#search-history").on("click",".remove-history",(function(e){e.stopImmediatePropagation(),e.preventDefault();var t=$(this).parents("li").index();requestGet("misc/remove_recent_search/"+t).done((function(e){var a=$("#search-history");a.find("li:eq("+t+")").remove(),0==a.find("li").length&&a.removeClass("display-block")}))})),$("#search_input").on("click focus",(function(){if(""==$(this).val()){var e=$("#search-history");e.find("li").length>0&&(e.css("width",$(this).outerWidth()+"px"),e.addClass("display-block"))}})),$("#search-history").on("click","a.history",(function(e){e.preventDefault();var t=$(this).text().trim();$("#search_input").val(t),$("#search_input").trigger("paste")})),$("#search_input").on("keyup paste"+("safari"==app.browser?" input":""),(function(){var e=$("#search-history");e.removeClass("display-block");var t=$(this).val().trim(),a=$("#search_results"),i=$("#top_search_button button");if(""===t)return content_wrapper.unhighlight(),a.html(""),original_top_search_val="",i.html('').removeClass("search_remove"),void e.addClass("display-block");t.length<2&&-1===app.user_language.indexOf("chinese")&&-1===app.user_language.indexOf("japanese")||(i.html('').addClass("search_remove"),delay((function(){t!=original_top_search_val&&$.post(admin_url+"misc/search",{q:t}).done((function(e){e=JSON.parse(e),content_wrapper.unhighlight(),a.html(e.results),content_wrapper.highlight(t),original_top_search_val=t,set_search_history(e.history)}))}),700))}));var s=get_url_param("q");if(s&&$("#search_input").val(s).trigger("keyup"),$("body").on("blur","#timesheet_duration",(function(){var e=$(this),t=$(this).val();if((t=t.replace(/[^0-9:]/gi,"")).indexOf(":")>-1){var a=t.split(":");if(0===a[0].length&&(a[0]="00"),a[1]>=60){var i=Math.floor(parseInt(a[1]/60));a[0]=i+parseInt(a[0]),a[1]=a[1]-60*i}1===a[0].toString().length&&(a[0]="0"+a[0]),1===a[1].toString().length?a[1]="0"+a[1]:0===a[1].toString().length&&(a[1]="00"),t=a[0]+":"+a[1]}else 1===t.length&&-1===t.indexOf(":")?t="0"+t+":00":t.length>=2&&-1===t.indexOf(":")&&(t+=":00");t="00:00"==t?"":t,e.val(t)})),$("body").on("click",".timesheet-toggle-enter-type",(function(e){e.preventDefault();var t=$(this).find("span.switch-to").removeClass("switch-to").addClass("hide");$(this).find("span").not(t).removeClass("hide").addClass("switch-to"),$(".timesheet-start-end-time, .timesheet-duration").toggleClass("hide"),$(".timesheet-start-end-time input").val(""),$(".timesheet-duration input").val("")})),$("body").on("hidden.bs.modal",".modal-reminder",(function(e){var t=$(this),a=t.find('input[name="rel_id"]').val(),i=t.find('input[name="rel_type"]').val();t.find("form").attr("action",admin_url+"misc/add_reminder/"+a+"/"+i),t.find("form").removeAttr("data-edit"),t.find(":input:not([type=hidden]), textarea").val(""),t.find('input[type="checkbox"]').prop("checked",!1),t.find("select").selectpicker("val","")})),$("body").on("shown.bs.modal",".modal-reminder",(function(e){0==$(this).find('form[data-edit="true"]').length&&$(this).find("#date").focus()})),$("body").on("click",".delete-reminder",(function(){return confirm_delete()&&requestGetJSON($(this).attr("href")).done((function(e){alert_float(e.alert_type,e.message),$("#task-modal").is(":visible")&&_task_append_html(e.taskHtml),reload_reminders_tables()})),!1})),$("body").on("keypress",'textarea[name="checklist-description"]',(function(e){if("13"==e.which){var t=$(this);return update_task_checklist_item(t).done((function(){add_task_checklist_item(t.attr("data-taskid"))})),!1}})),$("body").on("blur paste",'textarea[name="checklist-description"]',(function(){update_task_checklist_item($(this))})),$("body").on("show.bs.select","select.checklist-items-template-select",_make_task_checklist_items_deletable),$("body").on("refreshed.bs.select","select.checklist-items-template-select",_make_task_checklist_items_deletable),$("body").on("changed.bs.select","select",(function(e){$(e.currentTarget).trigger("keyup.validate")})),$("body").on("changed.bs.select","select.custom-field-multi-select",(function(e){var t=$(this).val();$(this).find('option[value=""]').prop("selected",0===t.length),$(this).selectpicker("refresh")})),$("body").on("change",".task-single-inline-field",(function(){var e=$("body").find(".task-single-inline-field"),t={};$.each(e,(function(){var e=$(this).attr("name"),a=$(this).val(),i=$(this).parents(".task-single-inline-wrap");"startdate"==e&&""===a?i.addClass("text-danger"):"startdate"==e&&""!==a&&i.removeClass("text-danger"),("startdate"==e&&""!==a||"startdate"!=e)&&(t[$(this).attr("name")]=a,"startdate"!=e&&""===a?i.css("opacity",.5):i.css("opacity",1))}));var a=$("#task-modal").find("[data-task-single-id]").attr("data-task-single-id");$.post(admin_url+"tasks/task_single_inline_update/"+a,t)})),$("body").on("change","#task-modal #checklist_items_templates",(function(){var e=$(this).val(),t=$(this).find('option[value="'+e+'"]').html().trim();""!==t&&(add_task_checklist_item($("#task-modal").find("[data-task-single-id]").attr("data-task-single-id"),t),$(this).selectpicker("val",""))})),$("body").on("click",".task-date-as-comment-id",(function(e){e.preventDefault();var t=$(this).attr("href").split("#"),a=$("#"+t[t.length-1]).position();$("#task-modal").scrollTop(a.top)})),$("body").on("click","table.dataTable tbody .tags-labels .label-tag",(function(){$(this).parents("table").DataTable().search($(this).find(".tag").text()).draw(),$("div.dataTables_filter input").focus()})),$("body").on("click","table.dataTable tbody .customer-group-list",(function(){$(this).parents("table").DataTable().search($(this).text()).draw(),$("div.dataTables_filter input").focus()})),$("[data-can-view-own], [data-can-view]").on("change",(function(){var e=$(this).attr("data-can-view-own");view_chk_selector=$(this).parents("tr").find("td input["+(void 0!==e&&!1!==e?"data-can-view":"data-can-view-own")+"]"),1!=view_chk_selector.data("not-applicable")&&(view_chk_selector.prop("checked",!1),view_chk_selector.prop("disabled",!0===$(this).prop("checked")))})),"undefined"!=typeof taskid&&""!==taskid&&init_task_modal(taskid),$("body").on("change",'input[name="checklist-box"]',(function(){requestGet(admin_url+"tasks/checkbox_action/"+$(this).parents(".checklist").data("checklist-id")+"/"+(!0===$(this).prop("checked")?1:0)),recalculate_checklist_items_progress(),$(this).prop("checked")&&$('button[data-hide="1"]').hasClass("hide")&&$(this).closest(".checklist ").addClass("hide")})),$("body").on("keyup paste click","textarea[name='checklist-description']",(function(e){do_task_checklist_items_height($(this))})),$("body").on("click focus","#task_comment",(function(e){init_new_task_comment()})),$("body").on("click",".task-single-delete-timesheet",(function(e){if(e.preventDefault(),confirm_delete()){var t=$(this).data("task-id");requestGet($(this).attr("href")).done((function(e){init_task_modal(t),setTimeout((function(){reload_tasks_tables(),init_timers()}),20)}))}})),$("#task-modal").on("change",'input[name="timesheet_start_time"], input[name="timesheet_end_time"], input[name="timesheet_duration"]',(function(){$(this).val()&&$(this).parents(".form-group").hasClass("has-error")&&$(this).parents(".form-group").removeClass("has-error")})),$("body").on("click",".task-single-add-timesheet",(function(e){e.preventDefault();var t=$("body").find('#task-modal input[name="timesheet_start_time"]'),a=$("body").find('#task-modal input[name="timesheet_end_time"]'),i=$("body").find('#task-modal input[name="timesheet_duration"]'),n=t.val(),s=a.val(),o=i.val();if(""===n&&t.parents(".form-group").addClass("has-error"),""===s&&a.parents(".form-group").addClass("has-error"),""===o&&i.parents(".form-group").addClass("has-error"),""!==n&&""!==s||""!==o){var l={};l.timesheet_duration=o,l.start_time=n,l.end_time=s,l.timesheet_task_id=$(this).data("task-id"),l.note=$("body").find("#task_single_timesheet_note").val(),l.timesheet_staff_id=$("body").find('#task-modal select[name="single_timesheet_staff_id"]').val(),$.post(admin_url+"tasks/log_time",l).done((function(e){!0===(e=JSON.parse(e)).success||"true"==e.success?(init_task_modal(l.timesheet_task_id),alert_float("success",e.message),setTimeout((function(){reload_tasks_tables()}),20)):alert_float("warning",e.message)}))}})),$("body").on("click",".copy_task_action",(function(){var e={};return $(this).prop("disabled",!0),e.copy_from=$(this).data("task-copy-from"),e.copy_task_assignees=$("body").find("#copy_task_assignees").prop("checked"),e.copy_task_followers=$("body").find("#copy_task_followers").prop("checked"),e.copy_task_checklist_items=$("body").find("#copy_task_checklist_items").prop("checked"),e.copy_task_attachments=$("body").find("#copy_task_attachments").prop("checked"),e.copy_task_status=$("body").find('input[name="copy_task_status"]:checked').val(),$.post(admin_url+"tasks/copy",e).done((function(e){if(!0===(e=JSON.parse(e)).success||"true"==e.success){var t=$("#_task_modal");t.is(":visible")&&t.modal("hide"),init_task_modal(e.new_task_id),reload_tasks_tables()}alert_float(e.alert_type,e.message)})),!1})),$("body").on("click",".new-task-to-milestone",(function(e){e.preventDefault();var t=$(this).parents(".milestone-column").data("col-status-id");new_task(admin_url+"tasks/task?rel_type=project&rel_id="+project_id+"&milestone_id="+t),$('body [data-toggle="popover"]').popover("hide")})),$("body").on("shown.bs.modal","#_task_modal",(function(e){$(e.currentTarget).hasClass("edit")?""!==$(this).find(".tinymce-task").val().trim()&&init_editor(".tinymce-task",{height:200}):$("body").find("#_task_modal #name").focus(),init_tags_inputs()})),$("body").on("hidden.bs.modal","#_task_modal",(function(){tinyMCE.remove(".tinymce-task"),"undefined"!=typeof _ticket_message&&(_ticket_message=void 0),null==$(this).attr("data-lead-id")||$(this).attr("data-task-created")||init_lead($(this).attr("data-lead-id")),destroy_dynamic_scripts_in_element($("body #_task_modal")),$("#_task").empty()})),$("body").on("hide.bs.modal","#task-modal",(function(){if(1==$("#lightbox").is(":visible"))return!1;"undefined"!=typeof taskAttachmentDropzone&&taskAttachmentDropzone.destroy();var e=tinyMCE.get("#task_view_description");e&&(e.blur(),tinyMCE.remove("#task_view_description"))})),$("body").on("hide.bs.modal","#task-modal",(function(e){tinymce.get().forEach((function(t){t.id.includes("task_comment")&&""!==t.getContent()&&$(t.editorContainer).is(":visible")&&e.preventDefault()}))})),$("body").on("hide.bs.modal","#task-modal",(function(e){var t=$("#task-modal");if(t.find(".timesheet-edit").is(":visible")&&e.preventDefault(),t.find(".add-timesheet").is(":visible")){var a=t.find("#timesheet_start_time").val(),i=t.find("#timesheet_end_time").val(),n=t.find("#timesheet_duration").val(),s=t.find("#task_single_timesheet_note").val();""===a&&""===i&&""===n&&""===s||e.preventDefault()}})),$("body").on("hidden.bs.modal","#task-modal",(function(){destroy_dynamic_scripts_in_element($(this)),$(this).find(".data").empty()})),$("body").on("shown.bs.modal","#task-modal",(function(){do_task_checklist_items_height(),init_tags_inputs(),fix_task_modal_left_col_height(),$(document).off("focusin.modal");var e=window.location.href;if(e.indexOf("#comment_")>-1){var t=e.split("#comment_");t=t[t.length-1],$('[data-task-comment-href-id="'+t+'"]').click()}})),$("body").on("blur","#task-modal ul.tagit li.tagit-new input",(function(){setTimeout((function(){task_single_update_tags()}),100)})),$("body").on("change",'select[name="select-assignees"]',(function(){$("body").append('
');var e={};e.assignee=$('select[name="select-assignees"]').val(),""!==e.assignee&&(e.taskid=$(this).attr("data-task-id"),$.post(admin_url+"tasks/add_task_assignees",e).done((function(e){$("body").find(".dt-loader").remove(),e=JSON.parse(e),reload_tasks_tables(),_task_append_html(e.taskHtml)})))})),$("body").on("change",'select[name="select-followers"]',(function(){var e={};e.follower=$('select[name="select-followers"]').val(),""!==e.follower&&(e.taskid=$(this).attr("data-task-id"),$("body").append('
'),$.post(admin_url+"tasks/add_task_followers",e).done((function(e){e=JSON.parse(e),$("body").find(".dt-loader").remove(),_task_append_html(e.taskHtml)})))})),$("body").on("click",".close-task-stats",(function(){$("#task-tracking-stats-modal").modal("hide")})),$("body").on("hidden.bs.modal","#task-tracking-stats-modal",(function(){$("#tracking-stats").remove()})),$("body").on("show.bs.modal","#task-tracking-stats-modal",(function(){var e=$("body").find("#task-tracking-stats-chart");setTimeout((function(){"undefined"!=typeof taskTrackingChart&&taskTrackingChart.destroy(),taskTrackingChart=new Chart(e,{type:"line",data:taskTrackingStatsData,options:{legend:{display:!1},responsive:!0,maintainAspectRatio:!1,tooltips:{enabled:!0,mode:"single",callbacks:{label:function(e,t){return decimalToHM(e.yLabel)}}},scales:{yAxes:[{ticks:{beginAtZero:!0,min:0,userCallback:function(e,t,a){return decimalToHM(e)}}}]}}})}),800)})),$("body").on("shown.bs.modal","#sync_data_proposal_data",(function(){"lead"==$("#sync_data_proposal_data").data("rel-type")&&$("#lead-modal .data").eq(0).css("height",$("#sync_data_proposal_data .modal-content").height()+80+"px").css("overflow-x","hidden")})),$("body").on("hidden.bs.modal","#sync_data_proposal_data",(function(){"lead"==$("#sync_data_proposal_data").data("rel-type")&&$("#lead-modal .data").prop("style","")})),"undefined"!=typeof openLeadID&&""!==openLeadID&&init_lead(openLeadID,!!get_url_param("edit")),$("body").on("click",".leads-kan-ban .cpicker",(function(){var e=$(this).data("color"),t=$(this).parents(".panel-heading").data("status-id");$.post(admin_url+"leads/change_status_color",{color:e,status_id:t})})),$("body").on("click","[lead-edit]",(function(e){e.preventDefault();var t=$("body .lead-edit");if($("body .lead-view").toggleClass("hide"),t.toggleClass("hide"),!t.hasClass("hide")){var a=$("#lead-modal").find("#address"),i=a[0].scrollHeight;a.is("textarea")&&(a.height(0).height(i-15),a.css("padding-top","9px"))}})),$("body").on("click",".new-lead-from-status",(function(e){e.preventDefault();var t=$(this).parents(".kan-ban-col").data("col-status-id");init_lead_modal_data(void 0,admin_url+"leads/lead?status_id="+t),$('body [data-toggle="popover"]').popover("hide")})),$("body").on("change","input.include_leads_custom_fields",(function(){var e=$(this).val(),t=$(this).data("field-id");2==e?$("#merge_db_field_"+t).removeClass("hide"):$("#merge_db_field_"+t).addClass("hide"),3==e?$("#merge_db_contact_field_"+t):$("#merge_db_contact_field_"+t).addClass("hide")})),calendar_selector.length>0){validate_calendar_form();var o={customButtons:{},locale:app.locale,headerToolbar:{left:"prev,next today",center:"title",right:"dayGridMonth,timeGridWeek,timeGridDay"},editable:!1,dayMaxEventRows:parseInt(app.options.calendar_events_limit)+1,views:{day:{dayMaxEventRows:!1}},direction:"true"==isRTL?"rtl":"ltr",eventStartEditable:!1,firstDay:parseInt(app.options.calendar_first_day),initialView:app.options.default_view_calendar,timeZone:app.options.timezone,loading:function(e,t){e?$(".dt-loader").removeClass("hide"):$(".dt-loader").addClass("hide")},eventSources:[function(e,t,a){var i={};return $("#calendar_filters").find("input:checkbox:checked").map((function(){i[$(this).attr("name")]=!0})).get(),jQuery.isEmptyObject(i)||(i.calendar_filters=!0),$.getJSON(admin_url+"utilities/get_calendar_data",$.extend({},i,{start:e.startStr,end:e.endStr})).then((function(e){t(e.map((function(e){return $.extend({},e,{start:e.start||e.date,end:e.end||e.date})})))}))}],moreLinkClick:function(e){r.gotoDate(e.date),r.changeView("dayGridDay"),setTimeout((function(){$(".fc-popover-close").click()}),250)},eventDidMount:function(e){var t=$(e.el);t.attr("title",e.event.extendedProps._tooltip),t.attr("onclick",e.event.extendedProps.onclick),t.attr("data-toggle","tooltip"),e.event.extendedProps.url||t.on("click",(function(){view_event(e.event.extendedProps.eventid)}))},dateClick:function(e){e.dateStr.length<=10&&(e.dateStr+="T00:00:00");var t=(new DateFormatter).formatDate(new Date(e.dateStr),vformat=24==app.options.time_format?app.options.date_format+" H:i":app.options.date_format+" g:i A");return $("input[name='start'].datetimepicker").val(t),$("#newEventModal").modal("show"),!1}};if($("body").hasClass("dashboard")&&(o.customButtons.viewFullCalendar={text:app.lang.calendar_expand,click:function(){window.location.href=admin_url+"utilities/calendar"}},o.headerToolbar.left+=",viewFullCalendar"),o.customButtons.calendarFilter={text:app.lang.filter_by.toLowerCase(),click:function(){slideToggle("#calendar_filters")}},o.headerToolbar.right+=",calendarFilter",1==app.user_is_staff_member&&(""!==app.options.google_api&&(o.googleCalendarApiKey=app.options.google_api),""!==app.calendarIDs&&(app.calendarIDs=JSON.parse(app.calendarIDs),0!=app.calendarIDs.length)))if(""!==app.options.google_api)for(var l=0;lSettings->Google");var r=new FullCalendar.Calendar(calendar_selector[0],o);r.render(),get_url_param("new_event")&&($("input[name='start'].datetimepicker").val(get_url_param("date")),$("#newEventModal").modal("show"))}$("body").on("change",'select[name="tax"]',(function(){var e=$("body").find('select[name="tax2"]'),t=$(this);""!==t.val()?e.prop("disabled",!1):(e.prop("disabled",!0),""!==e.val()&&(t.selectpicker("val",e.val()),e.val(""),t.selectpicker("refresh"))),e.selectpicker("refresh")})),$("body").on("click","#invoice_create_credit_note",(function(e){if(2==$(this).attr("data-status"))return!0;var t=$("#confirm_credit_note_create_from_invoice");t.modal("show"),t.find("#confirm-invoice-credit-note").attr("href",$(this).attr("href")),e.preventDefault()})),$("body").on("change blur",".apply-credits-to-invoice .apply-credits-field",(function(){var e=$("#apply_credits"),t=e.find("input.apply-credits-field"),a=0,i=e.attr("data-credits-remaining");$.each(t,(function(){if(!0===$(this).valid()){var e=$(this).val();e=parseFloat(e),isNaN(e)?$(this).val(0):a+=e}})),e.find("#credits-alert").remove(),e.find(".amount-to-credit").html(format_money(a)),i",{id:"credits-alert",class:"alert alert-danger"}).html(app.lang.credit_amount_bigger_then_credit_note_remaining_credits)),e.find('[type="submit"]').prop("disabled",!0)):(e.find(".credit-note-balance-due").html(format_money(i-a)),e.find('[type="submit"]').prop("disabled",!1))})),$("body").on("change blur",".apply-credits-from-invoice .apply-credits-field",(function(){var e=$("#apply_credits"),t=e.find("input.apply-credits-field"),a=0,i=e.attr("data-balance-due");$.each(t,(function(){if(!0===$(this).valid()){var e=$(this).val();e=parseFloat(e),isNaN(e)?$(this).val(0):a+=e}})),e.find("#credits-alert").remove(),e.find(".amount-to-credit").html(format_money(a)),a>i?($(".credits-table").before($("
",{id:"credits-alert",class:"alert alert-danger"}).html(app.lang.credit_amount_bigger_then_invoice_balance)),e.find('[type="submit"]').prop("disabled",!0)):(e.find(".invoice-balance-due").html(format_money(i-a)),e.find('[type="submit"]').prop("disabled",!1))})),$('input[name="notify_type"]').on("change",(function(){var e=$('input[name="notify_type"]:checked').val(),t=$("#specific_staff_notify"),a=$("#role_notify");"specific_staff"==e?(t.removeClass("hide"),a.addClass("hide")):"roles"==e?(t.addClass("hide"),a.removeClass("hide")):"assigned"==e&&(t.addClass("hide"),a.addClass("hide"))})),$("body").on("shown.bs.modal","#lead-modal",(function(e){custom_fields_hyperlink(),0===$("body").find('#lead-modal input[name="leadid"]').length&&$("body").find('#lead-modal input[name="name"]').focus(),init_tabs_scrollable(),$("body").find(".lead-wrapper").hasClass("open-edit")&&$("body").find("a[lead-edit]").click()})),$("body").on("show.bs.modal","#lead-modal",(function(e){0==$("#lead-more-dropdown").find("li").length&&$("#lead-more-btn").css("display","none").css("pointer-events","none")})),$("#lead-modal").on("hidden.bs.modal",(function(e){destroy_dynamic_scripts_in_element($(this)),$(this).data("bs.modal",null),$("#lead_reminder_modal").html(""),$("#lead-modal").is(":visible")||history.pushState("",document.title,window.location.pathname+window.location.search),$("body #lead-modal .datetimepicker").datetimepicker("destroy"),"undefined"!=typeof leadAttachmentsDropzone&&leadAttachmentsDropzone.destroy()})),$("body").on("submit","#lead-modal .consent-form",(function(){var e=$(this).serialize();return $.post($(this).attr("action"),e).done((function(e){init_lead_modal_data((e=JSON.parse(e)).lead_id)})),!1})),$("body").on("click",'#lead-modal a[data-toggle="tab"]',(function(){"#tab_lead_profile"==this.hash||"#attachments"==this.hash||"#lead_notes"==this.hash||"#gdpr"==this.hash||"#lead_activity"==this.hash?window.location.hash=this.hash:history.pushState("",document.title,window.location.pathname+window.location.search),$(document).resize()})),$("body").on("click","#lead_enter_activity",(function(){var e=$("#lead_activity_textarea").val(),t=$("#lead-modal").find('input[name="leadid"]').val();""!==e&&$.post(admin_url+"leads/add_activity",{leadid:t,activity:e}).done((function(e){_lead_init_data(e=JSON.parse(e),e.id)})).fail((function(e){alert_float("danger",e.responseText)}))})),$("body").on("submit","#lead-modal #lead-notes",(function(){var e=$(this),t=$(e).serialize();return $.post(e.attr("action"),t).done((function(e){_lead_init_data(e=JSON.parse(e),e.id)})).fail((function(e){alert_float("danger",e.responseText)})),!1}));var c={custom_view:"[name='custom_view']",assigned:"[name='view_assigned']",status:"[name='view_status[]']",source:"[name='view_source']"};if((table_leads=$("table.table-leads")).length){var p=table_leads.find("#th-consent"),_=[0],m=[0,table_leads.find("#th-assigned").index()];p.length>0&&(_.push(p.index()),m.push(p.index())),_table_api=initDataTable(table_leads,admin_url+"leads/table",m,_,c,[table_leads.find("th.date-created").index(),"desc"]),_table_api&&p.length>0&&_table_api.on("draw",(function(){var e=table_leads.find("tbody tr");$.each(e,(function(){$(this).find("td:eq(3)").addClass("bg-neutral")}))})),$.each(c,(function(e,t){$("select"+t).on("change",(function(){$("[name='view_status[]']").prop("disabled","lost"==$(this).val()||"junk"==$(this).val()).selectpicker("refresh"),table_leads.DataTable().ajax.reload()}))}))}if($("body").on("change",'input[name="contacted_today"]',(function(){var e=$(this).prop("checked"),t=$(".lead-select-date-contacted");0==e?t.removeClass("hide"):t.addClass("hide")})),$("body").on("change",'input[name="contacted_indicator"]',(function(){var e=$(".lead-select-date-contacted");"yes"==$(this).val()?e.removeClass("hide"):e.addClass("hide")})),$("body").on("click",".close-reminder-modal",(function(){$(".reminder-modal-"+$(this).data("rel-type")+"-"+$(this).data("rel-id")).modal("hide")})),$("form").not("#single-ticket-form,#calendar-event-form,#proposal-form, #department-form").areYouSure(),$("body").on("click",".editor-add-content-notice",(function(){var e=$(this);setTimeout((function(){e.remove(),tinymce.triggerSave()}),500)})),$(".bulk_actions").on("change",'input[name="mass_delete"]',(function(){var e=$("#bulk_change");!0===$(this).prop("checked")?(e.find("select").selectpicker("val",""),e.addClass("hide"),$(".mass_delete_separator, merge_tickets_checkbox").addClass("hide"),$("#merge_tickets").prop("checked",!1)):(e.removeClass("hide"),$(".mass_delete_separator, merge_tickets_checkbox").removeClass("hide"))})),$("body").on("change loaded.bs.select","#item_select",(function(){var e=$(".items-wrapper .items-select-wrapper");$(".items-wrapper .bootstrap-select").css("max-width",e.width()+"px"),$(".items-wrapper .bootstrap-select").css("width","100%")})),$(".send-test-sms").on("click",(function(){var e=$(this).data("id"),t=$('#sms_test_response[data-id="'+e+'"]'),a=$('textarea[data-id="'+e+'"]').val(),i=$('input.test-phone[data-id="'+e+'"]').val(),n=$(this);t.empty(),""!=(a=a.trim())&&""!=i&&(n.prop("disabled",!0),$.post(window.location.href,{message:a,number:i,id:e,sms_gateway_test:!0}).done((function(e){1==(e=JSON.parse(e)).success?t.html('
SMS Sent Successfully!
'):t.html('
'+e.error+"
")})).always((function(){n.prop("disabled",!1)})))})),$("body").on("hidden.bs.modal","#__todo",(function(){var e=$("#__todo");e.find('input[name="todoid"]').val(""),e.find('textarea[name="description"]').val(""),e.find(".add-title").addClass("hide"),e.find(".edit-title").addClass("hide")})),$("body").on("shown.bs.modal","#__todo",(function(){var e=$("#__todo");e.find('textarea[name="description"]').focus(),""!==e.find('input[name="todoid"]').val()?(e.find(".add-title").addClass("hide"),e.find(".edit-title").removeClass("hide")):(e.find(".add-title").removeClass("hide"),e.find(".edit-title").addClass("hide"))})),$("#top_search_button button").on("click",(function(){var e=$("#search_input");$(this).hasClass("search_remove")&&($(this).html('').removeClass("search_remove"),original_top_search_val="",$("#search_results").html(""),e.val("")),e.focus()})),$("body").click((function(e){$(e.target).parents("#top_search_dropdown").hasClass("search-results")||$("#top_search_dropdown").remove()})),$("body").tooltip({selector:'[data-toggle="tooltip"]'}),$("body").popover({selector:'[data-toggle="popover"]'}),$("body").on("click","._filter_data ul.dropdown-menu li a,.not-mark-as-read-inline,.not_mark_all_as_read a",(function(e){e.stopPropagation(),e.preventDefault()})),$("body").on("shown.bs.modal",".modal",(function(){$("body").addClass("modal-open"),$("body").find("#started-timers-top").parents("li").removeClass("open")})),$("body").on("hidden.bs.modal",".modal",(function(e){$(".modal:visible").length&&$(document.body).addClass("modal-open"),$(this).data("bs.modal",null)})),$(".datepicker.activity-log-date").on("change",(function(){table_activity_log.DataTable().ajax.reload()})),$(".btn-import-submit").on("click",(function(){$(this).hasClass("simulate")&&$("#import_form").append(hidden_input("simulate",!0)),$("#import_form").submit()})),$("body").on("change","#unlimited_cycles",(function(){$(this).parents(".recurring-cycles").find("#cycles").prop("disabled",$(this).prop("checked"))})),$("body").on("change",'[name="repeat_every"], [name="recurring"]',(function(){var e=$(this).val();"custom"==e?$(".recurring_custom").removeClass("hide"):$(".recurring_custom").addClass("hide"),""!==e&&0!=e?$("body").find("#cycles_wrapper").removeClass("hide"):($("body").find("#cycles_wrapper").addClass("hide"),$("body").find("#cycles_wrapper #cycles").val(0),$("#unlimited_cycles").prop("checked",!0).change())})),$("body").on("change","#mass_select_all",(function(){var e,t,a;e=$(this).data("to-table"),t=$(".table-"+e).find("tbody tr"),a=$(this).prop("checked"),$.each(t,(function(){$($(this).find("td").eq(0)).find("input").prop("checked",a)}))})),$("body").on("show.bs.modal",".modal.email-template",(function(){init_editor($(this).data("editor-id"),{urlconverter_callback:merge_field_format_url})})),$("body").on("hidden.bs.modal",".modal.email-template",(function(){tinymce.remove($(this).data("editor-id"))})),$(".close-customizer").on("click",(function(e){e.preventDefault(),setup_menu.addClass("true"==isRTL?"fadeOutRight":"fadeOutLeft"),requestGet("misc/set_setup_menu_closed")})),$(".open-customizer").on("click",(function(e){e.preventDefault(),setup_menu.hasClass("true"==isRTL?"fadeOutRight":"fadeOutLeft")&&setup_menu.removeClass("true"==isRTL?"fadeOutRight":"fadeOutLeft"),setup_menu.addClass("display-block "+("true"==isRTL?"fadeInRight":"fadeInLeft")),is_mobile()||requestGet("misc/set_setup_menu_open"),mainWrapperHeightFix()})),$("body").on("click",".cpicker",(function(){var e=$(this).data("color");if($(this).hasClass("cpicker-big"))return!1;$(this).parents(".cpicker-wrapper").find(".cpicker-big").removeClass("cpicker-big").addClass("cpicker-small"),$(this).removeClass("cpicker-small","fast").addClass("cpicker-big","fast"),$(this).hasClass("kanban-cpicker")?($(this).parents(".panel-heading").css("background",e),$(this).parents(".panel-heading").css("border","1px solid "+e)):$(this).hasClass("calendar-cpicker")&&$("body").find('._event input[name="color"]').val(e)})),$("body").on("click",".notification_link",(function(){var e=$(this).data("link");e.split("#")[1]||(window.location.href=e)})),$("body").on("click"+("ontouchstart"in window?" touchstart":""),".notifications a.notification-top, .notification_link",(function(e){e.preventDefault();var t,a=$(this),i=a.hasClass("notification_link")?a.data("link"):e.currentTarget.href,n=i.split("#"),s=!0;if(n[1]&&n[1].indexOf("=")>-1)if(s=!1,t=n[1].split("=")[1],n[1].indexOf("postid")>-1)postid=t,$(window).width()>769?$(".open_newsfeed.desktop").click():$(".open_newsfeed.mobile").click();else if(n[1].indexOf("taskid")>-1){var o=void 0;if(i.indexOf("#comment_")>-1){var l=i.split("#comment_");o=l[l.length-1]}init_task_modal(t,o)}else n[1].indexOf("leadid")>-1?init_lead(t):n[1].indexOf("eventid")>-1&&view_event(t);a.hasClass("desktopClick")||a.parent("li").find(".not-mark-as-read-inline").click(),s&&setTimeout((function(){window.location.href=n}),50)})),$(".notifications-wrapper").on("show.bs.dropdown",(function(){notifications_wrapper.find(".notifications").attr("data-total-unread")>0&&$.post(admin_url+"misc/set_notifications_read").done((function(e){!0!==(e=JSON.parse(e)).success&&"true"!=e.success||(document.title=doc_initial_title,$(".icon-notifications").addClass("hide"))}))})),init_table_tickets(),init_table_announcements(),init_table_staff_projects(),(table_activity_log=$("table.table-activity-log")).length){var u=[];u.activity_log_date='[name="activity_log_date"]',initDataTable(table_activity_log,window.location.href,"undefined","undefined",u,[1,"desc"])}if(table_invoices=$("table.table-invoices"),table_estimates=$("table.table-estimates"),table_invoices.length>0||table_estimates.length>0){var f={},h=$("._hidden_inputs._filters input");$.each(h,(function(){f[$(this).attr("name")]='[name="'+$(this).attr("name")+'"]'})),table_invoices.length&&initDataTable(table_invoices,admin_url+"invoices/table"+($("body").hasClass("recurring")?"?recurring=1":""),"undefined","undefined",f,$("body").hasClass("recurring")?[table_invoices.find("th.next-recurring-date").index(),"asc"]:[[3,"desc"],[0,"desc"]]),table_estimates.length&&initDataTable(table_estimates,admin_url+"estimates/table","undefined","undefined",f,[[3,"desc"],[0,"desc"]])}if((table_tasks=$(".table-tasks")).length){var v,b={};v=$("._hidden_inputs._filters._tasks_filters input"),$.each(v,(function(){b[$(this).attr("name")]='[name="'+$(this).attr("name")+'"]'}));var g=[0],k=admin_url+"tasks/table";$("body").hasClass("tasks-page")&&(k+="?bulk_actions=true"),_table_api=initDataTable(table_tasks,k,g,g,b,[table_tasks.find("th.duedate").index(),"asc"]),_table_api&&$("body").hasClass("dashboard")&&_table_api.column(5).visible(!1,!1).column(6).visible(!1,!1).columns.adjust()}$("#send_file").on("show.bs.modal",(function(e){var t=$("#send_file");t.find('input[name="filetype"]').val($($(e.relatedTarget)).data("filetype")),t.find('input[name="file_path"]').val($($(e.relatedTarget)).data("path")),t.find('input[name="file_name"]').val($($(e.relatedTarget)).data("file-name")),$('input[name="email"]').length>0&&t.find('input[name="send_file_email"]').val($('input[name="email"]').val())})),$("#send_file form").on("submit",(function(){$(this).find('button[type="submit"]').prop("disabled",!0)})),$("body").on("change",'input[name="send_set_password_email"]',(function(){$("body").find(".client_password_set_wrapper").toggleClass("hide")})),$("body").on("change",'.todo input[type="checkbox"]',(function(){var e=!0===$(this).prop("checked")?1:0,t=$(this).val();window.location.href=admin_url+"todo/change_todo_status/"+t+"/"+e}));var y=$(".todos-sortable");(y.length>0&&(y=y.sortable({connectWith:".todo",items:"li",handle:".dragger",appendTo:"body",update:function(e,t){this===t.item.parent()[0]&&update_todo_items()}})),$("body").on("click",".open_newsfeed, .close_newsfeed",(function(e){e.preventDefault(),void 0===$(this).data("close")?requestGet("newsfeed/get_data").done((function(e){$("#newsfeed").html(e),load_newsfeed(postid),init_newsfeed_form(),init_selectpicker(),init_lightbox()})):!0===$(this).data("close")&&(newsFeedDropzone.destroy(),$("#newsfeed").html(""),newsfeed_posts_page=0,track_load_post_likes=0,track_load_comment_likes=0,postid=void 0),$("#newsfeed").toggleClass("hide"),$("body").toggleClass("noscroll")})),$("[data-newsfeed-auto]").length>0&&($(window).width()>769?$(".open_newsfeed.desktop").click():$(".open_newsfeed.mobile").click()),$("body").on("keyup",".comment-input input",(function(e){13==e.keyCode&&add_comment(this)})),$("#modal_post_likes").on("show.bs.modal",(function(e){track_load_post_likes=0,$("#modal_post_likes_wrapper").empty(),$(".likes_modal .modal-footer").removeClass("hide");var t=$(e.relatedTarget),a=$(t).data("postid");post_likes_total_pages=$(t).data("total-pages"),$(".load_more_post_likes").attr("data-postid",a),load_post_likes(a)})),$("#modal_post_comment_likes").on("show.bs.modal",(function(e){$("#modal_comment_likes_wrapper").empty(),track_load_comment_likes=0,$(".likes_modal .modal-footer").removeClass("hide");var t=$(e.relatedTarget),a=$(t).data("commentid");comment_likes_total_pages=$(t).data("total-pages"),$(".load_more_post_comment_likes").attr("data-commentid",a),load_comment_likes(a)})),$(".load_more_post_likes").on("click",(function(e){e.preventDefault(),load_post_likes($(this).data("postid"))})),$(".load_more_post_comment_likes").on("click",(function(e){e.preventDefault(),load_comment_likes($(this).data("commentid"))})),$(".add-attachments").on("click",(function(e){e.preventDefault(),$("#post-attachments").toggleClass("hide")})),init_invoices_total(),init_expenses_total(),init_estimates_total(),init_items_sortable(),$(".settings-textarea-merge-field").on("click",(function(e){e.preventDefault();var t=$(this).text().trim(),a=$('textarea[name="settings['+$(this).data("to")+']"]');a.val(a.val()+"\n"+t)})),$("body").hasClass("estimates-pipeline"))&&estimate_pipeline_open($('input[name="estimateid"]').val());$("body").hasClass("proposals-pipeline")&&proposal_pipeline_open($('input[name="proposalid"]').val());$("body").on("submit","._transaction_form",(function(){calculate_total(),$("body").find("#items-warning").remove();var e=$(this).find("table.items"),t=e.find(".main");return t.find('[name="description"]').length&&t.find('[name="description"]').val().trim().length>0&&t.find('[name="rate"]').val().trim().length>0?(e.before('
'+app.lang.item_forgotten_in_preview+'
'),$("html,body").animate({scrollTop:$("#items-warning").offset().top}),!1):e.length&&0===e.find(".item").length?(e.before('
'+app.lang.no_items_warning+"
"),$("html,body").animate({scrollTop:$("#items-warning").offset().top}),!1):(reorder_items(),$('select[name="currency"]').prop("disabled",!1),$('select[name="project_id"]').prop("disabled",!1),$('input[name="date"]').prop("disabled",!1),$(this).find(".transaction-submit").prop("disabled",!0),!0)})),$("body").on("click",".transaction-submit",(function(){var e=$(this),t=e.parents("form._transaction_form");t.valid()&&(e.hasClass("save-as-draft")?t.append(hidden_input("save_as_draft","true")):e.hasClass("save-and-send")?t.append(hidden_input("save_and_send","true")):e.hasClass("save-and-record-payment")?t.append(hidden_input("save_and_record_payment","true")):e.hasClass("save-and-send-later")&&t.append(hidden_input("save_and_send_later","true"))),t.submit()})),$("body").on("submit","#sales-notes",(function(){var e=$(this);if(""!==e.find('textarea[name="description"]').val())return $.post(e.attr("action"),$(e).serialize()).done((function(t){e.find('textarea[name="description"]').val(""),e.hasClass("estimate-notes-form")?get_sales_notes(t,"estimates"):e.hasClass("invoice-notes-form")?get_sales_notes(t,"invoices"):e.hasClass("proposal-notes-form")?get_sales_notes(t,"proposals"):e.hasClass("contract-notes-form")&&get_sales_notes(t,"contracts")})),!1})),$("body").on("change",'input[name="show_quantity_as"]',(function(){$("body").find("th.qty").html($(this).data("text"))})),$("body").on("change",'div.credit_note input[name="date"]',(function(){do_prefix_year($(this).val())})),$("body").on("change",'div.invoice input[name="date"], div.estimate input[name="date"], div.proposal input[name="date"]',(function(){var e=$(this).val();if(do_prefix_year(e),!($('input[name="isedit"]').length>0)){var t="duedate",a=admin_url+"invoices/get_due_date";$("body").find("div.estimate").length>0?(a=admin_url+"estimates/get_due_date",t="expirydate"):$("body").find("div.proposal").length>0&&(a=admin_url+"proposals/get_due_date",t="open_till"),""===e&&$('input[name="'+t+'"]').val(""),""!==e&&$.post(a,{date:e}).done((function(e){e&&$('input[name="'+t+'"]').val(e)}))}})),$("#sales_attach_file").on("hidden.bs.modal",(function(e){$("#sales_uploaded_files_preview").empty(),$(".dz-file-preview").empty()})),"undefined"!=typeof Dropbox&&$("#dropbox-chooser-sales").length>0&&document.getElementById("dropbox-chooser-sales").appendChild(Dropbox.createChooseButton({success:function(e){salesExtenalFileUpload(e,"dropbox")},linkType:"preview",extensions:app.options.allowed_files.split(",")})),$("#sales-upload").length>0&&new Dropzone("#sales-upload",appCreateDropzoneOptions({sending:function(e,t,a){a.append("rel_id",$("body").find('input[name="_attachment_sale_id"]').val()),a.append("type",$("body").find('input[name="_attachment_sale_type"]').val())},success:function(e,t){t=JSON.parse(t);var a,i=$("body").find('input[name="_attachment_sale_type"]').val();a="delete_"+i+"_attachment","estimate"==i?$("body").hasClass("estimates-pipeline")?estimate_pipeline_open(t.rel_id):init_estimate(t.rel_id):"proposal"==i?$("body").hasClass("proposals-pipeline")?proposal_pipeline_open(t.rel_id):init_proposal(t.rel_id):"function"==typeof window["init_"+i]&&window["init_"+i](t.rel_id);var n="";!0!==t.success&&"true"!=t.success||(n+='
',n+='
',n+='
',n+=''+t.file_name+"",n+='

'+t.filetype+"

",n+="
",n+='
',n+='',n+="
",n+='

',n+="
",$("#sales_uploaded_files_preview").append(n))}})),$("body").on("click",".invoice-send-to-client",(function(e){e.preventDefault(),$("#invoice_send_to_client_modal").modal("show")})),$("body").on("click",".estimate-send-to-client",(function(e){e.preventDefault(),$("#estimate_send_to_client_modal").modal("show")})),$("body").on("click",".close-send-template-modal",(function(){$("#estimate_send_to_client_modal").modal("hide"),$("#proposal_send_to_customer").modal("hide")})),$("body").on("change","#include_shipping",(function(){var e=$("#shipping_details");!0===$(this).prop("checked")?e.removeClass("hide"):e.addClass("hide")})),$("body").on("click",".save-shipping-billing",(function(e){init_billing_and_shipping_details()})),$("body").on("change",'select[name="currency"]',(function(){init_currency()})),$("body").on("change",'input[name="adjustment"],select.tax',(function(){calculate_total()})),$("body").on("click",".discount-total-type",(function(e){e.preventDefault(),$("#discount-total-type-dropdown").find(".discount-total-type").removeClass("selected"),$(this).addClass("selected"),$(".discount-total-type-selected").html($(this).text()),$(this).hasClass("discount-type-percent")?($(".input-discount-fixed").addClass("hide").val(0),$(".input-discount-percent").removeClass("hide")):($(".input-discount-fixed").removeClass("hide"),$(".input-discount-percent").addClass("hide").val(0),$("#discount_percent-error").remove()),calculate_total()})),$("body").on("change",'select[name="discount_type"]',(function(){""===$(this).val()&&$('input[name="discount_percent"]').val(0),calculate_total()})),$("body").on("change",'input[name="discount_percent"],input[name="discount_total"]',(function(){if(""===$('select[name="discount_type"]').val()&&0!=$(this).val()){if(0===$("td[id^='tax_id_']").length)return;return alert("You need to select discount type"),$("html,body").animate({scrollTop:0},"slow"),$("#wrapper").highlight($('label[for="discount_type"]').text()),setTimeout((function(){$("#wrapper").unhighlight()}),3e3),!1}!0===$(this).valid()&&calculate_total()})),$("body").on("change",".invoice #project_id",(function(){var e=$(this).selectpicker("val");if(""!==e)requestGetJSON("tasks/get_billable_tasks_by_project/"+e).done((function(t){_init_tasks_billable_select(t,e)}));else{var t=$("#clientid").selectpicker("val");""!==t?requestGetJSON("tasks/get_billable_tasks_by_customer_id/"+t).done((function(e){_init_tasks_billable_select(e)})):_init_tasks_billable_select([],"")}})),$("body").on("change",'select[name="task_select"]',(function(){""!==$(this).selectpicker("val")&&add_task_to_preview_as_item($(this).selectpicker("val"))})),$("body").on("change",'select[name="paymentmode"]',(function(){var e=$(".do_not_redirect");$.isNumeric($(this).val())?e.addClass("hide"):e.removeClass("hide")})),$("body").on("change",".f_client_id #clientid",(function(){var e=$(this).val(),t=$('select[name="project_id"]'),a=t.html("").clone(),i=$(".projects-wrapper");if(t.selectpicker("destroy").remove(),t=a,$("#project_ajax_search_wrapper").append(a),init_ajax_project_search_by_customer_id(),clear_billing_and_shipping_details(),!e)return $("#merge").empty(),$("#expenses_to_bill").empty(),$("#invoice_top_info").addClass("hide"),i.addClass("hide"),!1;var n=$("body").find('input[name="merge_current_invoice"]').val();requestGetJSON("invoices/client_change_data/"+e+"/"+(n=void 0===n?"":n)).done((function(e){$("#merge").html(e.merge_info);var a=$("#expenses_to_bill");for(var n in 0===a.length?e.expenses_bill_info="":a.html(e.expenses_bill_info),""!==e.merge_info||""!==e.expenses_bill_info?$("#invoice_top_info").removeClass("hide"):$("#invoice_top_info").addClass("hide"),billingAndShippingFields)billingAndShippingFields[n].indexOf("billing")>-1&&(billingAndShippingFields[n].indexOf("country")>-1?$('select[name="'+billingAndShippingFields[n]+'"]').selectpicker("val",e.billing_shipping[0][billingAndShippingFields[n]]):billingAndShippingFields[n].indexOf("billing_street")>-1?$('textarea[name="'+billingAndShippingFields[n]+'"]').val(e.billing_shipping[0][billingAndShippingFields[n]]):$('input[name="'+billingAndShippingFields[n]+'"]').val(e.billing_shipping[0][billingAndShippingFields[n]]));for(var s in empty(e.billing_shipping[0].shipping_street)||$('input[name="include_shipping"]').prop("checked",!0).change(),billingAndShippingFields)billingAndShippingFields[s].indexOf("shipping")>-1&&(billingAndShippingFields[s].indexOf("country")>-1?$('select[name="'+billingAndShippingFields[s]+'"]').selectpicker("val",e.billing_shipping[0][billingAndShippingFields[s]]):billingAndShippingFields[s].indexOf("shipping_street")>-1?$('textarea[name="'+billingAndShippingFields[s]+'"]').val(e.billing_shipping[0][billingAndShippingFields[s]]):$('input[name="'+billingAndShippingFields[s]+'"]').val(e.billing_shipping[0][billingAndShippingFields[s]]));init_billing_and_shipping_details();var o=e.client_currency,l=$("body").find('.accounting-template select[name="currency"]');0!=(o=parseInt(o))?l.val(o):l.val(l.data("base")),_init_tasks_billable_select(e.billable_tasks,t.selectpicker("val")),!0===e.customer_has_projects?i.removeClass("hide"):i.addClass("hide"),l.selectpicker("refresh"),init_currency()}))})),0===$("body").find('input[name="isedit"]').length&&$('.f_client_id select[name="clientid"]').change(),$("body").on("click","#get_shipping_from_customer_profile",(function(e){e.preventDefault();var t=$("#include_shipping");!1===t.prop("checked")&&(t.prop("checked",!0),$("#shipping_details").removeClass("hide"));var a=$("#clientid").val();""!==a&&requestGetJSON("clients/get_customer_billing_and_shipping_details/"+a).done((function(e){$('textarea[name="shipping_street"]').val(e[0].shipping_street),$('input[name="shipping_city"]').val(e[0].shipping_city),$('input[name="shipping_state"]').val(e[0].shipping_state),$('input[name="shipping_zip"]').val(e[0].shipping_zip),$('select[name="shipping_country"]').selectpicker("val",e[0].shipping_country)}))})),"undefined"!=typeof accounting&&(accounting.settings.currency.precision=app.options.decimal_places,accounting.settings.number.thousand=app.options.thousand_separator,accounting.settings.number.decimal=app.options.decimal_separator,accounting.settings.number.precision=app.options.decimal_places,calculate_total()),$("body").on("change",'input[name="invoices_to_merge[]"]',(function(){var e=$(this).prop("checked"),t=$(this).val();!0===e?requestGetJSON("invoices/get_merge_data/"+t).done((function(e){$.each(e.items,(function(e,a){""!==a.rel_type&&("task"==a.rel_type?$('input[name="task_id"]').val(a.item_related_formatted_for_input):"expense"==a.rel_type&&$('input[name="expense_id"]').val(a.item_related_formatted_for_input)),_set_item_preview_custom_fields_array(a.custom_fields),add_item_to_table(a,"undefined",t)}))})):$("body").find('[data-merge-invoice="'+t+'"]').remove()})),$("body").on("change",'input[name="bill_expenses[]"]',(function(){var e=$(this).prop("checked"),t=$(this).val();!0===e?requestGetJSON("invoices/get_bill_expense_data/"+t).done((function(e){$('input[name="expense_id"]').val(t),add_item_to_table(e,"undefined","undefined",t)})):($("body").find('[data-bill-expense="'+t+'"]').remove(),$("body").find('#billed-expenses input[value="'+t+'"]').remove())})),$("body").on("change",".invoice_inc_expense_additional_info input",(function(){var e,t=$(this).attr("data-content"),a=$("[data-bill-expense="+$(this).attr("data-id")+"] .item_long_description");current_desc_val=a.val(),current_desc_val=current_desc_val.trim(),""!==t&&(!0===$(this).prop("checked")?(e=current_desc_val+"\n"+t,a.val(e.trim())):(a.val(current_desc_val.replace("\n"+t,"")),a.val(current_desc_val.replace(t,""))))}))})),$(document).keyup((function(e){27==e.keyCode&&($(".popup-wrapper").is(":visible")&&$(".popup-wrapper").find(".system-popup-close").click(),$("#search-history").is(":visible")&&$("#search-history").removeClass("display-block"))})),$("#newsfeed").scroll((function(e){var t=$(e.currentTarget);t[0].scrollHeight-t.scrollTop()==t.outerHeight()&&load_newsfeed(),$("#newsfeed .close_newsfeed").css("top",$(this).scrollTop()+20+"px")}));