softphonebar.js 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  1. holly.softphonebar = {
  2. _softphonebar_state: new Array(),
  3. _softphonebar_desc: new Array(),
  4. _softphonebar_countTimer: 0,
  5. _softphonebar_calculagraph: "",
  6. _softphonebar_otherstateref: "",
  7. _softphonebar_curstateref: "",
  8. _softphonebar_timestateref: "",
  9. _softphonebar_callstateref: "",
  10. _softphonebar_dialogBoxRemain: 40000,
  11. _softphonebar_notifyDialogInterval: "",
  12. softphonebar_count: 0,
  13. _softphonebar_monitorTimers: [],
  14. _softphoneBar_replaceAll: new RegExp("\\.", "g"),
  15. _softphoneBar_replaceAll_bak: new RegExp("\\_", "g"),
  16. _softphonebar_peer_index: 0,
  17. _softphonebar_queue_index: 0,
  18. _softphonebar_serviceNo_index: 0,
  19. softphonebar_init: function () {
  20. holly.softphonebar._softphonebar_timestateref = $("#softphone_timer");
  21. holly.softphonebar._softphonebar_otherstateref = $("#softphone_otherstate");
  22. holly.softphonebar._softphonebar_curstateref = $("#softphone_curstate");
  23. holly.softphonebar._softphonebar_callstateref = $("#softphone_phonestate");
  24. holly.softphonebar._softphonebar_desc["unregister"] = "失效";
  25. holly.softphonebar._softphonebar_desc["peerstate"] = "空闲";
  26. holly.softphonebar._softphonebar_desc["dialing"] = "呼叫中";
  27. holly.softphonebar._softphonebar_desc["innerDialing"] = "呼叫中";
  28. holly.softphonebar._softphonebar_desc["belling"] = "来电振铃";
  29. holly.softphonebar._softphonebar_desc["innerBelling"] = "来电振铃";
  30. holly.softphonebar._softphonebar_desc["listening"] = "监听振铃";
  31. holly.softphonebar._softphonebar_desc["talking"] = "普通通话";
  32. holly.softphonebar._softphonebar_desc["threeWayTalking"] = "三方通话";
  33. holly.softphonebar._softphonebar_desc["innerTalking"] = "内部通话";
  34. holly.softphonebar._softphonebar_desc["dialTalking"] = "外呼通话";
  35. holly.softphonebar._softphonebar_desc["listened"] = "监听中";
  36. holly.softphonebar._softphonebar_desc["hold"] = "保持";
  37. holly.softphonebar._softphonebar_desc["consultTalking"] = "普通通话";
  38. holly.softphonebar._softphonebar_desc["dialTransfer"] = "转接通话";
  39. holly.softphonebar._softphonebar_desc["transfer"] = "转接通话";
  40. holly.softphonebar._softphonebar_desc["offline"] = "离线接听";
  41. holly.softphonebar._softphonebar_desc["ready"] = "签出";
  42. holly.softphonebar._softphonebar_desc["transferBelling"] = "转接振铃";
  43. holly.softphonebar._softphonebar_desc["transferDialing"] = "转接振铃";
  44. holly.softphonebar._softphonebar_state["unregister"] = [];
  45. holly.softphonebar._softphonebar_state["peerstate"] = ["dialout_input", "DialEnable"];
  46. holly.softphonebar._softphonebar_state["dialing"] = ["dialout_input", "HangupEnable"];
  47. holly.softphonebar._softphonebar_state["innerDialing"] = ["dialout_input", "HangupEnable"];
  48. holly.softphonebar._softphonebar_state["belling"] = ["dialout_input"];
  49. holly.softphonebar._softphonebar_state["innerBelling"] = ["dialout_input"];
  50. holly.softphonebar._softphonebar_state["transferBelling"] = [];
  51. holly.softphonebar._softphonebar_state["transferDialing"] = [];
  52. holly.softphonebar._softphonebar_state["listening"] = ["HangupEnable"];
  53. holly.softphonebar._softphonebar_state["talking"] = ["HoldEnable", "TransferEnable", "ConsultEnable", "HangupEnable", "InvestigateEnable"];
  54. holly.softphonebar._softphonebar_state["transfer"] = ["HoldEnable", "TransferEnable", "ConsultEnable", "HangupEnable", "InvestigateEnable"];
  55. holly.softphonebar._softphonebar_state["dialTransfer"] = ["HoldEnable", "TransferEnable", "ConsultEnable", "HangupEnable", "InvestigateEnable"];
  56. holly.softphonebar._softphonebar_state["threeWayTalking"] = ["HangupEnable"];
  57. holly.softphonebar._softphonebar_state["innerTalking"] = ["HangupEnable"];
  58. holly.softphonebar._softphonebar_state["dialTalking"] = ["HoldEnable", "TransferEnable", "ConsultEnable", "HangupEnable", "InvestigateEnable"];
  59. holly.softphonebar._softphonebar_state["listened"] = ["TransferDisable", "HangupEnable"];
  60. holly.softphonebar._softphonebar_state["hold"] = ["HoldGetEnable"];
  61. holly.softphonebar._softphonebar_state["consultTalking"] = ["ConsultThreeWayCallEnable", "ConsultTransferEnable", "StopConsultEnable", "HangupEnable"];
  62. holly.phone.phone_registerEvent("toolbarupdate", holly.softphonebar._softphonebar_toolbarupdate);
  63. holly.phone.phone_registerEvent("barupdate", holly.softphonebar._softphonebar_barupdate);
  64. holly.phone.phone_registerEvent("transfering", holly.softphonebar._softphonebar_transfering);
  65. holly.phone.phone_registerEvent("ivrMenuTransfering", holly.softphonebar._softphonebar_ivrMenuTransfering);
  66. holly.phone.phone_registerEvent("EvtMonitorServiceNo", holly.softphonebar._softphonebar_onServiceNoChanged);
  67. holly.phone.phone_registerEvent("EvtMonitorQueue", holly.softphonebar._softphonebar_onQueueChanged);
  68. holly.phone.phone_registerEvent("EvtMonitorPeer", holly.softphonebar._softphonebar_onPeerChanged);
  69. holly.phone.phone_registerEvent("EvtEndListen", holly.softphonebar._softphonebar_onEndListen);
  70. holly.phone.phone_registerEvent("EvtAccountCalls", holly.softphonebar._softphonebar_onAccountCalls);
  71. holly.phone.phone_registerEvent("EvtRing", holly.softphonebar._softphonebar_evtRing);
  72. // holly.phone.phone_registerEvent("EvtTalking", holly.softphonebar._softphonebar_evtTalking);
  73. holly.phone.phone_registerEvent("EvtHangup", holly.softphonebar._softphonebar_evtHangup);
  74. holly.phone.phone_registerEvent("EvtDialinAgentBusyMessage", holly.softphonebar._softphonebar_ontDialinAgentBusy);
  75. if (!hollyglobal.isDisplayInvestigate) {
  76. holly.softphonebar._softphonebar_removeButton("InvestigateEnable");
  77. }
  78. if (!hollyglobal.isDisplayConsult) {
  79. holly.softphonebar._softphonebar_removeButton("ConsultEnable");
  80. }
  81. if (!hollyglobal.isDisplayTransfer) {
  82. holly.softphonebar._softphonebar_removeButton("TransferEnable");
  83. }
  84. },
  85. _softphonebar_removeButton: function (buttonId) {
  86. var state = holly.softphonebar._softphonebar_state;
  87. for (var i in state) {
  88. var softPhoneState = state[i];
  89. if (Array.indexOf(softPhoneState, buttonId) > -1) {
  90. for (var index in softPhoneState) {
  91. if (softPhoneState[index] === buttonId) {
  92. softPhoneState.splice(index, 1);
  93. break;
  94. }
  95. }
  96. }
  97. }
  98. },
  99. _softphonebar_toolbarupdate: function (event, state, timestamp) {
  100. console.info(state)
  101. //状态变更事件
  102. hollyglobal.actionEvent(state,event);
  103. $("#phone_bar :input").each(function () {
  104. var id = $(this).attr("id");
  105. if (holly.softphonebar._softphonebar_state[state]) {
  106. if (Array.indexOf(holly.softphonebar._softphonebar_state[state], id) < 0) {
  107. $(this).css('display', 'none');
  108. } else {
  109. $(this).css('display', 'inline-block');
  110. $(this).removeAttr('disabled');
  111. }
  112. }
  113. });
  114. holly.softphonebar._softphonebar_switchState(state, timestamp);
  115. },
  116. _softphonebar_barupdate: function (event, state, timestamp) {
  117. console.info(state)
  118. // $("#phone_bar :input").each(function () {
  119. // var id = $(this).attr("id");
  120. // if (holly.softphonebar._softphonebar_state[state]) {
  121. // if (Array.indexOf(holly.softphonebar._softphonebar_state[state], id) < 0) {
  122. // $(this).css('display', 'none');
  123. // } else {
  124. // $(this).css('display', 'inline-block');
  125. // $(this).removeAttr('disabled');
  126. // }
  127. // }
  128. // });
  129. //状态变更事件
  130. hollyglobal.actionEvent(state,event);
  131. if (state === "unregister") {
  132. holly.softphonebar._softphonebar_timestateref.css('display', 'none');
  133. } else {
  134. holly.softphonebar._softphonebar_timestateref.css('display', 'inline-block');
  135. }
  136. holly.softphonebar._softphonebar_callstateref.css("color", "#B30000");
  137. if (state === "peerstate") {
  138. if (holly.phone.phone_data.busyType == "99") {
  139. holly.softphonebar._softphonebar_systemBusy();
  140. } else if (holly.phone.phone_data.busyType == "0") {
  141. holly.softphonebar._softphonebar_callstateref.css("color", "#468847");
  142. }
  143. holly.softphonebar._softphonebar_updPeerState();
  144. $("#softphone-bar .state_dropdown").css('display', 'inline-block');
  145. $("#softphone-bar .state_line").css('display', 'inline-block');
  146. } else {
  147. holly.softphonebar._softphonebar_updCallState(state);
  148. $("#softphone-bar .state_dropdown").css('display', 'none');
  149. $("#softphone-bar .state_line").css('display', 'none');
  150. }
  151. },
  152. _softphonebar_switchState: function (state, timestamp) {
  153. //console.info('_softphonebar_switchState'+'->'+state)
  154. if (state === "unregister") {
  155. holly.softphonebar._softphonebar_timestateref.css('display', 'none');
  156. } else {
  157. holly.softphonebar._softphonebar_timestateref.css('display', 'inline-block');
  158. }
  159. holly.softphonebar._softphonebar_callstateref.css("color", "#B30000");
  160. if (state === "peerstate") {
  161. if (holly.phone.phone_data.busyType == "99") {
  162. holly.softphonebar._softphonebar_systemBusy();
  163. } else if (holly.phone.phone_data.busyType == "0") {
  164. holly.softphonebar._softphonebar_callstateref.css("color", "#468847");
  165. }
  166. holly.softphonebar._softphonebar_updPeerState();
  167. $("#softphone-bar .state_dropdown").css('visibility', 'visible');
  168. $("#softphone-bar .state_dropdown").css('display', 'inline-block');
  169. } else {
  170. holly.softphonebar._softphonebar_updCallState(state);
  171. $("#softphone-bar .state_dropdown").css('visibility', 'hidden');
  172. $("#softphone-bar .state_dropdown").css('display', 'none');
  173. }
  174. if ((state === "peerstate" && holly.phone.phone_data.busyType == "99") || timestamp === "continueTime")
  175. return;
  176. if (timestamp != "") {
  177. var date = new Date();
  178. var identity = date.valueOf();
  179. var oldTime = ((identity - holly.phone.phone_data.currentServerTime) - parseFloat(timestamp) * 1000) / 1000;
  180. if (oldTime < 0)
  181. holly.softphonebar._softphonebar_countTimer = 0;
  182. else
  183. holly.softphonebar._softphonebar_countTimer = oldTime;
  184. } else {
  185. holly.softphonebar._softphonebar_countTimer = 0;
  186. }
  187. if (holly.softphonebar._softphonebar_calculagraph != null)
  188. window.clearInterval(holly.softphonebar._softphonebar_calculagraph);
  189. holly.softphonebar._softphonebar_calculagraph = window.setInterval(function () {
  190. holly.softphonebar._softphonebar_doCallTimer();
  191. }, 1000);
  192. },
  193. _softphonebar_doCallTimer: function () {
  194. holly.softphonebar._softphonebar_timestateref.html(holly.softphonebar._softphonebar_getTimer(holly.softphonebar._softphonebar_countTimer));
  195. holly.softphonebar._softphonebar_countTimer++;
  196. },
  197. _softphonebar_getTimer: function (countTimer) {
  198. countTimer = parseInt(countTimer) + 1;
  199. var hour = parseInt(countTimer / 3600);
  200. var minute = parseInt((countTimer % 3600) / 60);
  201. var second = (countTimer % 3600) % 60;
  202. var mtime = (hour < 10) ? "0" + hour : "" + hour;
  203. mtime += ":";
  204. mtime += (minute < 10) ? "0" + minute : "" + minute;
  205. mtime += ":";
  206. mtime += (second < 10) ? "0" + second : "" + second;
  207. return mtime;
  208. },
  209. _softphonebar_setStatePadding: function (stateDes) {
  210. //$("#softphone_phonestate").css('padding-left', 16 / (stateDes.length));
  211. },
  212. _softphonebar_updPeerState: function () {
  213. var stateDes = holly.phone.phone_data.phonebarConfig[holly.phone.phone_data.busyType];
  214. holly.softphonebar._softphonebar_callstateref.html(stateDes);
  215. holly.softphonebar._softphonebar_setStatePadding(stateDes);
  216. var html = "";
  217. holly.softphonebar._softphonebar_otherstateref.find("li").remove();
  218. for (var i in holly.phone.phone_data.phonebarConfig) {
  219. if (i != "99" && i != holly.phone.phone_data.busyType) {
  220. var isBusy = true;
  221. var color = "#B30000";
  222. if (i == "0") {
  223. isBusy = false;
  224. color = "#468847";
  225. }
  226. html += "<div class='customer_div' style=\"color:" + color + ";font-weight:bold;\" onclick=\"holly.phone.phone_setBusy(" + isBusy + ", " + i + ")\">" + holly.phone.phone_data.phonebarConfig[i] + "</div><div class='customer_line'>|</div>";
  227. }
  228. }
  229. holly.softphonebar._softphonebar_otherstateref.html(html);
  230. // $('#softphone-bar .customer_db .customer_line').last().remove();
  231. },
  232. softphonebar_dialout: function (phoneNum, interfaceData) {
  233. if (holly.phone.phone_isAllowDialout()) {
  234. $('#DialEnable').attr("disabled", "true");
  235. holly.phone.phone_dialout(phoneNum, interfaceData);
  236. } else {
  237. holly.utils.showError("您已经在通话中,不能再次进行外呼", 'softphone_transfer');
  238. return true;
  239. }
  240. if (hollyglobal.isHiddenNumber) {
  241. phoneNum = holly.softphonebar.softphonebar_getHiddenNum(phoneNum);
  242. }
  243. $("#dialout_input").val(phoneNum);
  244. // holly.phone._phone_getUserStatusFromExten(phoneNum);
  245. },
  246. softphonebar_getHiddenNum: function (phoneNum) {
  247. var mask = '';
  248. if (phoneNum > 5) {
  249. mask = '****';
  250. } else if (phoneNum < 4) {
  251. mask = '*';
  252. } else {
  253. mask = '***';
  254. }
  255. return phoneNum.substring(0, phoneNum.length - 6) + mask + phoneNum.substring(phoneNum.length - 2);
  256. },
  257. softphonebar_hangup: function () {
  258. holly.phone.phone_hangup();
  259. },
  260. _softphonebar_updCallState: function (state) {
  261. holly.softphonebar._softphonebar_callstateref.html(holly.softphonebar._softphonebar_desc[state]);
  262. },
  263. _softphonebar_systemBusy: function () {
  264. var autoBusyTime = holly.phone.phone_data.autoBusyTime;
  265. if (autoBusyTime < 1)
  266. return;
  267. holly.softphonebar._softphonebar_callstateref.html(holly.phone.phone_data.phonebarConfig["99"]);
  268. if (holly.softphonebar._softphonebar_calculagraph != null) {
  269. window.clearInterval(holly.softphonebar._softphonebar_calculagraph);
  270. }
  271. holly.softphonebar._softphonebar_calculagraph = window.setInterval(function () {
  272. autoBusyTime--;
  273. holly.softphonebar._softphonebar_autoBusyTime(autoBusyTime);
  274. }, 1000);
  275. },
  276. _softphonebar_autoBusyTime: function (autoBusyTime) {
  277. var minute = "0";
  278. var second = "0";
  279. var hour = "0";
  280. if (autoBusyTime >= 60 * 60) {
  281. hour = parseInt(autoBusyTime / (60 * 60));
  282. minute = parseInt((autoBusyTime - hour * (60 * 60)) / (60));
  283. second = autoBusyTime - hour * (60 * 60) - minute * (60);
  284. } else if (autoBusyTime >= 60 && (autoBusyTime < 60 * 60)) {
  285. hour = "0";
  286. minute = parseInt(autoBusyTime / 60);
  287. second = autoBusyTime - minute * 60;
  288. } else if (0 < autoBusyTime < 60) {
  289. hour = "0";
  290. minute = "0";
  291. second = autoBusyTime;
  292. } else if (autoBusyTime <= 0) {
  293. hour = "0";
  294. minute = "0";
  295. second = "0";
  296. }
  297. if (hour < 0) {
  298. hour = 0;
  299. }
  300. if (minute < 0) {
  301. minute = 0;
  302. }
  303. if (second < 0) {
  304. second = 0;
  305. }
  306. holly.softphonebar._softphonebar_timestateref.html(((hour < 10) ? ("0" + hour) : hour) + ":" + ((minute < 10) ? ("0" + minute) : minute) + ":" + ((second < 10) ? ("0" + second) : second));
  307. },
  308. _softphonebar_showConsult: function (destExten) {
  309. holly.softphonebar._softphonebar_dialogBoxRemain = 40000;
  310. holly.softphonebar.softphonebar_count = 1;
  311. var bodyMsg = "<div style='height:20px;overflow:hidden;text-align:center'><img src='" + (hollyglobal.imgDir ? hollyglobal.imgDir : '.') + "/img/loading.gif' style='float:left;' />" +
  312. "<div id='holly.softphonebar.showMsg.id' style='float:left;color:#666666;padding-left:5px;'></div></div>";
  313. var bodyHtml = "<div class='modal-body' style='height:20px;padding-top:9px;' ><div style='float: left;position: relative;width: 325px;'>" + bodyMsg + "</div>" +
  314. "</div>";
  315. $('#softphone_consult').empty();
  316. $('#softphone_consult').html(bodyHtml);
  317. holly.softphonebar._softphonebar_notifyDialogInterval = setInterval(function () {
  318. holly.softphonebar._softphonebar_checkLoadingHide(destExten, "");
  319. }, 1000);
  320. },
  321. _softphonebar_showTranster: function (destExten) {
  322. holly.softphonebar._softphonebar_dialogBoxRemain = 40000;
  323. holly.softphonebar.softphonebar_count = 1;
  324. var bodyMsg = "<div style='height:20px;overflow:hidden;text-align:center'><img src='" + (hollyglobal.imgDir ? hollyglobal.imgDir : '.') + "/img/loading.gif' style='float:left;' />" +
  325. "<div id='holly.softphonebar.showMsg.id' style='float:left;color:#666666;padding-left:5px;'></div></div>";
  326. var bodyHtml = "<div class='modal-body' style='height:20px;padding-top:9px;' >" + bodyMsg + "</div>";
  327. $('#softphone_transfer').empty();
  328. $('#softphone_transfer').html(bodyHtml);
  329. holly.softphonebar._softphonebar_notifyDialogInterval = setInterval(function () {
  330. var cancelHtml = "<a href=\"javascript:holly.phone.phone_cancelTransfer();\" style='margin-left:5px;cursor:pointer;font-weight:bold;color:red;text-decoration:underline;'>取消</a>";
  331. holly.softphonebar._softphonebar_checkLoadingHide(destExten, cancelHtml);
  332. }, 1000);
  333. },
  334. _softphonebar_checkLoadingHide: function (destExten, cancelHtml) {
  335. var count = holly.softphonebar.softphonebar_count++;
  336. var html = "正在等待<span style='color:#3fb23f;font-weight:bold'>" + destExten + "</span>接听," + "请稍后<span style='font-weight:bold'>(00:" + (count < 10 ? ("0" + count) : count) + ")</span>" + cancelHtml;
  337. if (document.getElementById("holly.softphonebar.showMsg.id")) {
  338. document.getElementById("holly.softphonebar.showMsg.id").innerHTML = html;
  339. }
  340. if (holly.softphonebar._softphonebar_dialogBoxRemain <= 0) {
  341. holly.softphonebar.softphonebar_close();
  342. }
  343. holly.softphonebar._softphonebar_dialogBoxRemain -= 1000;
  344. },
  345. _softphonebar_showToMenu: function (displayname) {
  346. holly.softphonebar._softphonebar_dialogBoxRemain = 40000;
  347. holly.softphonebar.softphonebar_count = 1;
  348. var bodyMsg = "<div style='height:20px;overflow:hidden;text-align:center'>" +
  349. "<img src='" + (hollyglobal.imgDir ? hollyglobal.imgDir : '.') + "/img/loading.gif' style='float:left;margin-top:5px;' />" +
  350. "<div id='holly.softphonebar.showMsg.id' style='float:left;color:#666666;padding-left:5px;'></div>" +
  351. "<div style='clear:both;height:1px;overflow:hidden'>&nbsp;</div></div>";
  352. holly.utils.showBox(310, 40, bodyMsg);
  353. holly.softphonebar._softphonebar_notifyDialogInterval = setInterval(function () {
  354. holly.softphonebar._softphonebar_checkMenuLoadingHide(displayname, "");
  355. }, 1000);
  356. },
  357. _softphonebar_checkMenuLoadingHide: function (destExten, cancelHtml) {
  358. var count = holly.softphonebar.softphonebar_count++;
  359. var html = "正在等待转<span style='color:#3fb23f;font-weight:bold'>" + destExten + "</span>," + "请稍后<span style='font-weight:bold'>(00:" + (count < 10 ? ("0" + count) : count) + ")</span>" + cancelHtml;
  360. document.getElementById("holly.softphonebar.showMsg.id").innerHTML = html;
  361. if (holly.softphonebar._softphonebar_dialogBoxRemain <= 0) {
  362. holly.softphonebar.softphonebar_close();
  363. }
  364. holly.softphonebar._softphonebar_dialogBoxRemain -= 1000;
  365. },
  366. softphonebar_close: function () {
  367. if (holly.softphonebar._softphonebar_notifyDialogInterval)
  368. clearInterval(holly.softphonebar._softphonebar_notifyDialogInterval);
  369. },
  370. softphonebar_consult: function (phoneNum) {
  371. if (/^\d+$/.test(phoneNum)) {
  372. holly.phone.phone_consult("9" + phoneNum, "number");
  373. } else {
  374. alert('请输入工号或者手机号');
  375. }
  376. },
  377. softphonebar_closeModel: function () {
  378. if ($('#softphone_consult'))
  379. $('#softphone_consult').modal('hide');
  380. if ($('#softphone_transfer'))
  381. $('#softphone_transfer').modal('hide');
  382. if ($('#softphone_ivrMenu'))
  383. $('#softphone_ivrMenu').modal('hide');
  384. },
  385. softphonebar_transfer: function (phoneNum) {
  386. if (/^\d+$/.test(phoneNum)) {
  387. holly.phone.phone_transfer("9" + phoneNum, "number");
  388. } else {
  389. alert('请输入工号或者手机号');
  390. }
  391. },
  392. _softphonebar_transfering: function (event, json) {
  393. if (json.Event === "TransferSuccess") {
  394. holly.softphonebar.softphonebar_close();
  395. if (json.Type === "Investigate") {
  396. holly.utils.showSucc("转调查成功", "softphone_transfer");
  397. } else {
  398. if (json.Loot) {
  399. holly.utils.showTransferOrConsultSucc("抢接成功", "softphone_transfer");
  400. } else {
  401. holly.phone._phone_currentState = holly.phone._phone_peerstate;
  402. holly.phone.phone_publishEvent("toolbarupdate", [holly.phone._phone_stateDescription[holly.phone._phone_peerstate], ""]);
  403. holly.utils.showTransferOrConsultSucc("转接成功", "softphone_transfer");
  404. }
  405. }
  406. } else if (json.Event === "TransferFailed") {
  407. holly.softphonebar.softphonebar_close();
  408. if (json.Type === "Investigate") {
  409. holly.utils.showTransferOrConsultError("转调查失败", "softphone_transfer");
  410. } else {
  411. if (json.Loot) {
  412. holly.utils.showTransferOrConsultError("抢接失败", "softphone_transfer");
  413. } else {
  414. holly.utils.showTransferOrConsultError("转接失败", "softphone_transfer");
  415. }
  416. }
  417. }
  418. },
  419. _softphonebar_ivrMenuTransfering: function (event, json) {
  420. if (json.Event === "IvrMenuEnd") {
  421. holly.softphonebar.softphonebar_close();
  422. if (json.VAL_OF_IVR_MENU) {
  423. var outIvrRefused = json.VAL_OF_IVR_MENU;
  424. if (outIvrRefused === "DTSF") {
  425. outIvrRefused = "转第三方系统失败!";
  426. holly.utils.showError(outIvrRefused, 'softphone_transfer');
  427. } else {
  428. }
  429. }
  430. }
  431. },
  432. _softphonebar_onServiceNoChanged: function (event, monitorServiceNo) {
  433. if (!holly.phone.phone_data.monitor || !monitorServiceNo || !monitorServiceNo.serviceNo)
  434. return;
  435. var curRow = $("#monitor_serviceNo_" + monitorServiceNo.serviceNo);
  436. if (curRow.html() == null) {
  437. holly.softphonebar._softphonebar_createRow(monitorServiceNo, 'serviceNo');
  438. } else {
  439. holly.softphonebar._softphonebar_updateRow(monitorServiceNo, curRow, 'serviceNo')
  440. }
  441. holly.softphonebar._softphonebar_monitoringOnServiceNoChanged(monitorServiceNo);
  442. },
  443. _softphonebar_onQueueChanged: function (event, monitorQueue, type) {
  444. if (!monitorQueue || !monitorQueue.queueId)
  445. return;
  446. var curRow = $("#monitor_queue_" + monitorQueue.queueId);
  447. if (curRow.html() == null) {
  448. holly.softphonebar._softphonebar_createRow(monitorQueue, 'queueId');
  449. } else {
  450. holly.softphonebar._softphonebar_updateRow(monitorQueue, curRow, 'queueId')
  451. }
  452. // if(type == "needWaitCount") {
  453. // if(holly.phone.phone_queues) {
  454. // var totalQueueWait = 0;
  455. // var pbx;
  456. // for(var j in holly.phone.phone_queues) {
  457. // var item = holly.phone.phone_queues[j];
  458. // totalQueueWait = totalQueueWait + item.queueWaitCount;
  459. // pbx = item.pbx;
  460. // }
  461. // $("#monitor_waitCountTotal_" + pbx.replace(holly.softphonebar._softphoneBar_replaceAll, "_")).html(totalQueueWait);
  462. // }
  463. // }
  464. holly.softphonebar._softphonebar_queue(monitorQueue);
  465. },
  466. _softphonebar_onPeerChanged: function (event, monitorPeer) {
  467. if (!monitorPeer || !monitorPeer.userId)
  468. return;
  469. if (monitorPeer.user.indexOf("admin") != -1)
  470. return;
  471. if (!holly.phone.phone_data.monitor) {
  472. if (monitorPeer.userId != holly.session.user._id) {
  473. if (jQuery.inArray(monitorPeer.userId, holly.session.user.childs) == -1) {
  474. return;
  475. }
  476. }
  477. }
  478. var curRow = $("#monitor_peer_" + monitorPeer.userId);
  479. if (curRow.html() == null) {
  480. holly.softphonebar._softphonebar_createRow(monitorPeer, 'userId');
  481. } else {
  482. holly.softphonebar._softphonebar_updateRow(monitorPeer, curRow, 'userId')
  483. }
  484. // holly.softphonebar._softphonebar_info(monitorPeer);
  485. },
  486. _softphonebar_isCalling: function (userId) {
  487. var peer = holly.phone.phone_peers[userId];
  488. if (peer) {
  489. if (peer.callStatus == 'Ring'
  490. || peer.callStatus == 'Ringing' || peer.callStatus == 'inner'
  491. || peer.callStatus == 'normal' || peer.callStatus == 'dialout' || peer.callStatus == 'dialTransfer'
  492. || peer.callStatus == 'transfer' || peer.callStatus == 'listen') {
  493. return true;
  494. }
  495. }
  496. return false;
  497. },
  498. _softphonebar_info: function (obj) {
  499. // var userId = obj.userId;
  500. // if(userId != holly.session.user._id)
  501. // return;
  502. // var status = obj.status;
  503. // var inComplete = obj.InComplete;
  504. // var inCalls = obj.InCalls;
  505. // var outComplete = obj.OutComplete;
  506. //var TransferComplete = obj.TransferComplete
  507. // var outCalls = obj.OutCalls;
  508. // var dialoutTimeLength = holly.softphonebar._softphonebar_getDialoutTime(obj.DialoutTimeLength);
  509. },
  510. _softphonebar_getDialoutTime: function (dialoutLength) {
  511. var time = Math.ceil(dialoutLength / 1000);
  512. return holly.softphonebar._softphonebar_getTimer(time - 1);
  513. },
  514. _softphonebar_onEndListen: function (event) {
  515. for (var id in holly.phone.phone_peers) {
  516. if (holly.softphonebar._softphonebar_isCalling(id)) {
  517. $("#" + id + "_listen_disable").css("display", "none");
  518. $("#" + id + "_listen").css("display", "");
  519. $("#" + id + "_loot_disable").css("display", "none");
  520. $("#" + id + "_loot").css("display", "");
  521. } else {
  522. $("#" + id + "_listen_disable").css("display", "");
  523. $("#" + id + "_listen").css("display", "none");
  524. $("#" + id + "_loot_disable").css("display", "");
  525. $("#" + id + "_loot").css("display", "none");
  526. }
  527. $("#" + id + "_endlisten").css("display", "none");
  528. }
  529. },
  530. _softphonebar_monitoringInit: function () {
  531. for (var i in holly.phone.phone_pbxs) {
  532. var pbxid = i.replace(holly.softphonebar._softphoneBar_replaceAll, "_");
  533. holly.softphonebar._softphonebar_initInCallChart(pbxid);
  534. holly.softphonebar._softphonebar_initOutCallChart(pbxid);
  535. }
  536. if (holly.phone.phone_accountCalls) {
  537. for (var i in holly.phone.phone_accountCalls) {
  538. var accountCall = holly.phone.phone_accountCalls[i];
  539. if (accountCall) {
  540. var curPbxId = i.replace(holly.softphonebar._softphoneBar_replaceAll, "_");
  541. holly.softphonebar._softphonebar_toDrawingTodayPandectChart(accountCall.inCalls, accountCall.inComplete, accountCall.outCalls, accountCall.outComplete, curPbxId);
  542. holly.softphonebar._softphonebar_toDrawingInCallChart(accountCall.inCalls, accountCall.inCallsPerHour, accountCall.inCompletePerHour, curPbxId);
  543. holly.softphonebar._softphonebar_toShowInCallChart(curPbxId);
  544. holly.softphonebar._softphonebar_toDrawingOutCallChart(accountCall.outCalls, accountCall.outCallsPerHour, accountCall.outCompletePerHour, curPbxId);
  545. holly.softphonebar._softphonebar_toShowOutCallChart(curPbxId);
  546. }
  547. }
  548. }
  549. if (holly.phone.phone_serviceNos) {
  550. for (var i in holly.phone.phone_serviceNos) {
  551. var monitorServiceNo = holly.phone.phone_serviceNos[i];
  552. holly.softphonebar._softphonebar_toDrawingServiceNumberChart(monitorServiceNo.serviceNo, monitorServiceNo.inCalls, monitorServiceNo.inLost, monitorServiceNo.inComplete, (monitorServiceNo.pbx).replace(_softphoneBar_replaceAll, "_"));
  553. }
  554. }
  555. },
  556. _softphonebar_initOutCallChart: function (curPbx) {
  557. var ic = $("#" + curPbx + "_TwentyFourHourOutChart");
  558. var icArea = $("#" + curPbx + "_TwentyFourHourOutCallChartArea");
  559. for (var i = 0; i < 25; i++) {
  560. if (i === 24) {
  561. var timerow = document.createElement("div");
  562. timerow.id = curPbx + "_outCalltimerow_" + i;
  563. timerow.setAttribute("class", "callnum");
  564. timerow.style.left = (26 * i) + "px";
  565. timerow.style.width = "50px";
  566. timerow.style.position = "absolute";
  567. timerow.style.top = "205px";
  568. timerow.innerHTML = "时间/时";
  569. ic.append(timerow);
  570. } else {
  571. var sumrow = document.createElement("div");
  572. sumrow.id = curPbx + "_outCallsumrow_" + i;
  573. sumrow.setAttribute("class", "call");
  574. sumrow.setAttribute("call", 0);
  575. sumrow.setAttribute("showTip", true);
  576. sumrow.style.left = 26 * i + "px";
  577. sumrow.style.height = 0 + "px";
  578. sumrow.style.width = "10px";
  579. sumrow.style.border = "solid 0px #1280ef";
  580. sumrow.style.position = "absolute";
  581. sumrow.style.overflow = "hidden";
  582. sumrow.style.background = "none repeat scroll 0 0 #1280ef";
  583. sumrow.style.display = "block";
  584. sumrow.style.top = 200 + "px";
  585. sumrow.style.zIndex = "1";
  586. icArea.append(sumrow);
  587. var timerow = document.createElement("div");
  588. timerow.id = curPbx + "_outCalltimerow_" + i;
  589. timerow.setAttribute("class", "callnum");
  590. timerow.style.left = (26 * i) + 3 + "px";
  591. timerow.style.width = "10px";
  592. timerow.style.position = "absolute";
  593. timerow.style.top = "205px";
  594. timerow.style.textAlign = "center";
  595. timerow.innerHTML = i;
  596. ic.append(timerow);
  597. var cptrow = document.createElement("div");
  598. cptrow.id = curPbx + "_outCallcptrow_" + i;
  599. cptrow.setAttribute("class", "outcallchartcptrow");
  600. cptrow.setAttribute("call", 0);
  601. cptrow.setAttribute("showTip", true);
  602. cptrow.style.width = "10px";
  603. cptrow.style.height = 0 + "px";
  604. cptrow.style.border = "solid 0px #f8c713";
  605. cptrow.style.position = "absolute";
  606. cptrow.style.overflow = "hidden";
  607. cptrow.style.background = "none repeat scroll 0 0 #f8c713";
  608. cptrow.style.left = 10 + 26 * i + "px";
  609. cptrow.style.display = "block";
  610. cptrow.style.top = 200 + "px";
  611. cptrow.style.zIndex = "1";
  612. icArea.append(cptrow);
  613. }
  614. }
  615. for (var i = 0; i < 6; i++) {
  616. if (i === 0) {
  617. var tity = document.createElement("div");
  618. tity.id = curPbx + "_outCalltity_" + i;
  619. tity.setAttribute("class", "tity");
  620. tity.style.width = "50px";
  621. tity.style.position = "absolute";
  622. tity.style.top = (36 * i) - 5 + "px";
  623. tity.style.left = "-40px";
  624. tity.innerHTML = "数量/个";
  625. ic.append(tity);
  626. } else {
  627. var tity = document.createElement("div");
  628. tity.id = curPbx + "_outCalltity_" + i;
  629. tity.setAttribute("class", "tity");
  630. tity.style.width = "35px";
  631. tity.style.position = "absolute";
  632. tity.style.top = (36 * i) - 21 + "px";
  633. tity.style.left = "-18px";
  634. tity.innerHTML = 6 - i;
  635. ic.append(tity);
  636. var liney = document.createElement("div");
  637. liney.id = curPbx + "_outCallliney_" + i;
  638. liney.setAttribute("class", "liney");
  639. liney.style.width = "620px";
  640. liney.style.position = "absolute";
  641. liney.style.borderTop = "1px dotted #B9B9B9";
  642. liney.style.height = "1px";
  643. liney.style.overflow = "hidden";
  644. liney.style.top = (36 * i) - 16 + "px";
  645. liney.style.left = "0px";
  646. icArea.append(liney);
  647. }
  648. }
  649. },
  650. _softphonebar_initInCallChart: function (curPbx) {
  651. var ic = $("#" + curPbx + "_TwentyFourHourInChart");
  652. var icArea = $("#" + curPbx + "_TwentyFourHourInCallChartArea");
  653. for (var i = 0; i < 25; i++) {
  654. if (i === 24) {
  655. var timerow = document.createElement("div");
  656. timerow.id = curPbx + "_inCalltimerow_" + i;
  657. timerow.setAttribute("class", "callnum");
  658. timerow.style.left = (26 * i) + "px";
  659. timerow.style.width = "50px";
  660. timerow.style.position = "absolute";
  661. timerow.style.top = "205px";
  662. timerow.innerHTML = "时间/时";
  663. ic.append(timerow);
  664. } else {
  665. var sumrow = document.createElement("div");
  666. sumrow.id = curPbx + "_inCallsumrow_" + i;
  667. sumrow.setAttribute("class", "incallchartsumrow");
  668. sumrow.setAttribute("call", 0);
  669. sumrow.setAttribute("showTip", true);
  670. sumrow.style.left = (26 * i) + "px";
  671. sumrow.style.height = 0 + "px";
  672. sumrow.style.width = "10px";
  673. sumrow.style.border = "solid 0px #1280ef";
  674. sumrow.style.position = "absolute";
  675. sumrow.style.overflow = "hidden";
  676. sumrow.style.background = "none repeat scroll 0 0 #1280ef";
  677. sumrow.style.display = "block";
  678. sumrow.style.top = 200 + "px";
  679. sumrow.style.zIndex = "1";
  680. icArea.append(sumrow);
  681. var timerow = document.createElement("div");
  682. timerow.id = curPbx + "_inCalltimerow_" + i;
  683. timerow.setAttribute("class", "callnum");
  684. timerow.style.left = (26 * i) + 3 + "px";
  685. timerow.style.width = "10px";
  686. timerow.style.textAlign = "center";
  687. timerow.style.position = "absolute";
  688. timerow.style.top = "205px";
  689. timerow.innerHTML = i;
  690. ic.append(timerow);
  691. var cptrow = document.createElement("div");
  692. cptrow.id = curPbx + "_inCallcptrow_" + i;
  693. cptrow.setAttribute("class", "incallchartcptrow");
  694. cptrow.setAttribute("call", 0);
  695. cptrow.setAttribute("showTip", true);
  696. cptrow.style.width = "10px";
  697. cptrow.style.height = 0 + "px";
  698. cptrow.style.border = "solid 0px #92be0f";
  699. cptrow.style.position = "absolute";
  700. cptrow.style.overflow = "hidden";
  701. cptrow.style.background = "none repeat scroll 0 0 #92be0f";
  702. cptrow.style.left = (26 * i) + 10 + "px";
  703. cptrow.style.display = "block";
  704. cptrow.style.top = 200 + "px";
  705. cptrow.style.zIndex = "1";
  706. icArea.append(cptrow);
  707. }
  708. }
  709. for (var i = 0; i < 6; i++) {
  710. if (i === 0) {
  711. var tity = document.createElement("div");
  712. tity.id = curPbx + "_inCalltity_" + i;
  713. tity.setAttribute("class", "tity");
  714. tity.style.width = "50px";
  715. tity.style.position = "absolute";
  716. tity.style.top = (36 * i) - 5 + "px";
  717. tity.style.left = "-40px";
  718. tity.innerHTML = "数量/个";
  719. ic.append(tity);
  720. } else {
  721. var tity = document.createElement("div");
  722. tity.id = curPbx + "_inCalltity_" + i;
  723. tity.setAttribute("class", "tity");
  724. tity.style.width = "35px";
  725. tity.style.position = "absolute";
  726. tity.style.top = (36 * i) - 21 + "px";
  727. tity.style.left = "-18px";
  728. tity.style.right = "30px";
  729. tity.innerHTML = 6 - i;
  730. ic.append(tity);
  731. var liney = document.createElement("div");
  732. liney.id = curPbx + "_inCallliney_" + i;
  733. liney.style.width = "620px";
  734. liney.style.position = "absolute";
  735. liney.style.borderTop = "1px dotted #B9B9B9";
  736. liney.style.height = "1px";
  737. liney.style.overflow = "hidden";
  738. liney.style.top = (36 * i) - 16 + "px";
  739. liney.style.left = "0px";
  740. icArea.append(liney);
  741. }
  742. }
  743. },
  744. _softphonebar_toDrawingTodayPandectChart: function (inCalls, inComplete, outCalls, outComplete, curPbx) {
  745. $("#" + curPbx + "_today_call_sum").html("今日呼叫总量:" + (inCalls + outCalls));
  746. $("#" + curPbx + "_today_call_in_sum").html("呼入总量:" + inCalls);
  747. $("#" + curPbx + "_today_call_out_sum").html("呼出总量:" + outCalls);
  748. if (inCalls == 0) {
  749. $("#" + curPbx + "_todayChartInCallBox").html('<div class="callNullStyle" >呼入数据为空</div>');
  750. } else {
  751. var sinCallCpt, sinCallLst, inCallCpt, inCallLst;
  752. var perInComplete = Math.round((inComplete / inCalls) * 100);
  753. if (perInComplete < 15) {
  754. sinCallCpt = 15;
  755. sinCallLst = 85;
  756. } else if (perInComplete > 85) {
  757. sinCallCpt = 85;
  758. sinCallLst = 15;
  759. } else {
  760. sinCallCpt = perInComplete;
  761. sinCallLst = 100 - perInComplete;
  762. }
  763. inCallCpt = perInComplete.toString();
  764. inCallLst = (100 - perInComplete).toString();
  765. $("#" + curPbx + "_todayChartInCallBox").html('<div id="' + curPbx + '_today_call_in_success" class="todayCallInSuccess" style="width:' + sinCallCpt + '%;" >'
  766. + inComplete + '(' + inCallCpt + '%)' + '</div><div id="' + curPbx + '_today_call_in_failure" style="width:'
  767. + sinCallLst + '%;" class="todayCallInFailure" >' + (inCalls - inComplete) + '(' + inCallLst + '%)' + '</div>');
  768. }
  769. if (outCalls == 0) {
  770. $("#" + curPbx + "_todayChartOutCallBox").html('<div class="callNullStyle" >呼出数据为空</div>');
  771. } else {
  772. var soutCallCpt, soutCallLst, outCallCpt, outCallLst;
  773. var perOutComplete = Math.round((outComplete / outCalls) * 100);
  774. if (perOutComplete < 15) {
  775. soutCallCpt = 15;
  776. soutCallLst = 85;
  777. } else if (perOutComplete > 85) {
  778. soutCallCpt = 85;
  779. soutCallLst = 15;
  780. } else {
  781. soutCallCpt = perOutComplete;
  782. soutCallLst = 100 - perOutComplete;
  783. }
  784. outCallCpt = perOutComplete.toString();
  785. outCallLst = (100 - perOutComplete).toString();
  786. $("#" + curPbx + "_todayChartOutCallBox").html('<div id="' + curPbx + '_today_call_out_success" class="todayCallOutSuccess" style="width:' + soutCallCpt + '%;" >' + outComplete + '(' + outCallCpt + '%)' + '</div><div id="' + curPbx + '_today_call_out_failure" style="width:' + soutCallLst + '%;" class="todayCallOutFailure">' + (outCalls - outComplete) + '(' + outCallLst + '%)' + '</div>');
  787. }
  788. },
  789. _softphonebar_onAccountCalls: function (event, accountCall) {
  790. var curPbxId = (accountCall.pbx).replace(holly.softphonebar._softphoneBar_replaceAll, "_");
  791. holly.softphonebar._softphonebar_toDrawingTodayPandectChart(accountCall.inCalls, accountCall.inComplete, accountCall.outCalls, accountCall.outComplete, curPbxId);
  792. if ($("#" + curPbxId + "_TwentyFourHourInChart").html() == null) {
  793. return;
  794. }
  795. holly.softphonebar._softphonebar_toDrawingInCallChart(accountCall.inCalls, accountCall.inCallsPerHour, accountCall.inCompletePerHour, curPbxId);
  796. holly.softphonebar._softphonebar_toShowInCallChart(curPbxId);
  797. if ($("#" + curPbxId + "_TwentyFourHourOutChart").html() == null) {
  798. return;
  799. }
  800. holly.softphonebar._softphonebar_toDrawingOutCallChart(accountCall.outCalls, accountCall.outCallsPerHour, accountCall.outCompletePerHour, curPbxId);
  801. holly.softphonebar._softphonebar_toShowOutCallChart(curPbxId);
  802. },
  803. _softphonebar_toDrawingServiceNumberChart: function (serviceNo, inCalls, inLost, inComplete, curPbx) {
  804. var sn = $("#" + curPbx + "_ServiceNumberChart");
  805. if (serviceNo != undefined) {
  806. var snChart = document.createElement("div");
  807. if (inCalls == 0) {
  808. snChart.id = curPbx + "_snChart" + serviceNo;
  809. snChart.setAttribute("class", "snChartItem");
  810. snChart.style.background = "none repeat scroll 0 0 #ffffff";
  811. snChart.innerHTML = '<div class="snChartNumber">服务号:' + serviceNo + '</div> <div class="snChartDiagram" style="text-align:center; border:dashed 1px #ccc; background-color:#f2f6fb;" > 呼入数量为空 </div> <div class="snChartSum"> 总计:' + inCalls + '</div> <div class="clear"></div>';
  812. sn.append(snChart);
  813. } else if (inCalls == inComplete) {
  814. snChart.id = curPbx + "_snChart" + serviceNo;
  815. snChart.setAttribute("class", "snChartItem");
  816. snChart.style.background = "none repeat scroll 0 0 #ffffff";
  817. snChart.innerHTML = '<div class="snChartNumber">服务号:' + serviceNo + '</div> <div class="snChartDiagram" > <div style="width:100%; " class="snChartComplete">' + inComplete + " (100%)" + '</div> <div style="display:none; " class="snChartLost"></div> </div> <div class="snChartSum"> 总计:' + inCalls + '</div> <div class="clear"></div>';
  818. sn.append(snChart);
  819. } else if (inCalls == inLost) {
  820. snChart.id = curPbx + "_snChart" + serviceNo;
  821. snChart.setAttribute("class", "snChartItem");
  822. snChart.style.background = "none repeat scroll 0 0 #ffffff";
  823. snChart.innerHTML = '<div class="snChartNumber">服务号:' + serviceNo + '</div> <div class="snChartDiagram" > <div style=" display:none;" class="snChartComplete"></div> <div style="width:100%; " class="snChartLost">' + inLost + " (100%)" + '</div> </div> <div class="snChartSum"> 总计:' + inCalls + '</div> <div class="clear"></div>';
  824. sn.append(snChart);
  825. } else {
  826. var sinCallCpt, sinCallLst, inCallCpt, inCallLst;
  827. var perInComplete = Math.round((inComplete / inCalls) * 100);
  828. if (perInComplete < 15) {
  829. sinCallCpt = 15;
  830. sinCallLst = 85;
  831. } else if (perInComplete > 85) {
  832. sinCallCpt = 85;
  833. sinCallLst = 15;
  834. } else {
  835. sinCallCpt = perInComplete;
  836. sinCallLst = 100 - perInComplete;
  837. }
  838. inCallCpt = perInComplete.toString();
  839. inCallLst = (100 - perInComplete).toString();
  840. snChart.id = curPbx + "_snChart" + serviceNo;
  841. snChart.setAttribute("class", "snChartItem");
  842. snChart.style.background = "none repeat scroll 0 0 #ffffff";
  843. snChart.innerHTML = '<div class="snChartNumber">服务号:' + serviceNo
  844. + '</div> <div class="snChartDiagram" > <div style="width:' + sinCallCpt
  845. + '%; " class="snChartComplete">' + inComplete + " (" + inCallCpt + "%)"
  846. + '</div> <div style="width:' + sinCallLst + '%; " class="snChartLost">'
  847. + inLost + " (" + inCallLst + "%)" + '</div> </div> <div class="snChartSum"> 总计:'
  848. + inCalls + '</div> <div class="clear"></div>';
  849. sn.append(snChart);
  850. }
  851. }
  852. },
  853. _softphonebar_monitoringOnServiceNoChanged: function (serviceNos) {
  854. var serviceNo = serviceNos.serviceNo;
  855. var inCalls = serviceNos.inCalls;
  856. var inComplete = serviceNos.inComplete;
  857. var inLost = serviceNos.inLost;
  858. var outCalls = serviceNos.outCalls;
  859. var outComplete = serviceNos.outComplete;
  860. var pbxId = (serviceNos.pbx).replace(holly.softphonebar._softphoneBar_replaceAll, "_");
  861. var updateBox = $("#" + pbxId + "_snChart" + serviceNo);
  862. if (updateBox.html() == null) {
  863. holly.softphonebar._softphonebar_toDrawingServiceNumberChart(serviceNo, inCalls, inLost, inComplete, pbxId);
  864. return;
  865. }
  866. if (inCalls == 0) {
  867. updateBox.css("background", "none repeat scroll 0 0 #ffffff");
  868. updateBox.html('<div class="snChartNumber">服务号:' + serviceNo + '</div> <div class="snChartDiagram" style="text-align:center; border:dashed 1px #ccc; background-color:#f2f6fb;" > 呼入数量为空 </div> <div class="snChartSum"> 总计:' + inCalls + '</div> <div class="clear"></div>');
  869. } else {
  870. var sinCallCpt, sinCallLst, inCallCpt, inCallLst;
  871. var perInComplete = Math.round((inComplete / inCalls) * 100);
  872. if (perInComplete < 15) {
  873. sinCallCpt = 15;
  874. sinCallLst = 85;
  875. } else if (perInComplete > 85) {
  876. sinCallCpt = 85;
  877. sinCallLst = 15;
  878. } else {
  879. sinCallCpt = perInComplete;
  880. sinCallLst = 100 - perInComplete;
  881. }
  882. inCallCpt = perInComplete.toString();
  883. inCallLst = (100 - perInComplete).toString();
  884. updateBox.html('<div class="snChartNumber">服务号:' + serviceNo
  885. + '</div> <div class="snChartDiagram" > <div style="width:' + sinCallCpt
  886. + '%; " class="snChartComplete">' + inComplete + " (" + inCallCpt + "%)"
  887. + '</div> <div style="width:' + sinCallLst + '%; " class="snChartLost">'
  888. + inLost + " (" + inCallLst + "%)" + '</div> </div> <div class="snChartSum"> 总计:'
  889. + inCalls + '</div> <div class="clear"></div>');
  890. }
  891. },
  892. _softphonebar_toDrawingInCallChart: function (inCalls, inCallsPerHour, inCompletePerHour, curPbx) {
  893. if (inCalls != 0) {
  894. var inCallSumArray, inCallCptArray = [];
  895. inCallSumArray = inCallsPerHour.split(",");
  896. inCallCptArray = inCompletePerHour.split(",");
  897. var inCallMax = 0;
  898. for (var i = 0; i < 24; i++) {
  899. inCallMax = Math.max(inCallMax, inCallSumArray[i]);
  900. }
  901. var b = inCallMax % 5;
  902. var mainLength = inCallMax - b + 5;
  903. var offsetCall = mainLength / 5;
  904. var topOffsetPercent = 180 / mainLength;
  905. for (var i = 0; i < 24; i++) {
  906. var sumrow = document.getElementById(curPbx + "_inCallsumrow_" + i);
  907. sumrow.setAttribute("call", inCallSumArray[i]);
  908. sumrow.style.height = Math.round(topOffsetPercent * inCallSumArray[i]) + "px";
  909. sumrow.style.top = 200 - Math.round(topOffsetPercent * inCallSumArray[i]) + "px";
  910. var cptrow = document.getElementById(curPbx + "_inCallcptrow_" + i);
  911. cptrow.setAttribute("call", inCallCptArray[i]);
  912. cptrow.style.height = Math.round(topOffsetPercent * inCallCptArray[i]) + "px";
  913. cptrow.style.top = 200 - Math.round(topOffsetPercent * inCallCptArray[i]) + "px";
  914. }
  915. for (var i = 1; i < 6; i++) {
  916. var tity = document.getElementById(curPbx + "_inCalltity_" + i);
  917. var temp = offsetCall * ( 6 - i );
  918. tity.innerHTML = temp;
  919. }
  920. }
  921. },
  922. _softphonebar_toShowInCallChart: function (curPbx) {
  923. var incalls = $("#" + curPbx + "_TwentyFourHourInCallChartArea div");
  924. incalls.each(function (i, incall) {
  925. if (!incall.getAttribute("showTip"))
  926. return;
  927. incall.onmouseover = function () {
  928. var temp = this.id.split("_");
  929. var hour = temp[temp.length - 1];
  930. var type = temp[temp.length - 2];
  931. var pbx = this.id.substr(0, this.id.indexOf(type) - 1);
  932. var times = this.getAttribute("call");
  933. var tipMessage = "";
  934. if (type == "inCallsumrow") {
  935. tipMessage = "今日" + hour + "时呼入" + times;
  936. } else if (type == "inCallcptrow") {
  937. tipMessage = "今日" + hour + "时已接" + times;
  938. }
  939. var liney = document.getElementById(pbx + "_inCallMouseTip");
  940. if (!liney) {
  941. liney = document.createElement("div");
  942. liney.id = pbx + "_inCallMouseTip";
  943. liney.style.position = "absolute";
  944. liney.style.border = "1px dotted #FFFF99";
  945. liney.style.padding = "3px";
  946. liney.style.overflow = "hidden";
  947. liney.style.background = "none repeat scroll 0 0 #f8c713";
  948. liney.style.textAlign = "center";
  949. liney.style.zIndex = "2";
  950. var area = $("#" + pbx + "_TwentyFourHourInChart");
  951. area.append(liney);
  952. }
  953. liney.innerHTML = tipMessage;
  954. liney.style.top = $(this).position().top + "px";
  955. liney.style.left = $(this).position().left + 5 + "px";
  956. liney.style.visibility = "visible";
  957. var timeText = document.getElementById(pbx + "_inCalltimerow_" + hour);
  958. if (timeText) {
  959. timeText.style.background = "none repeat scroll 0 0 #f8c713";
  960. }
  961. };
  962. incall.onmouseout = function () {
  963. var temp = this.id.split("_");
  964. var type = temp[temp.length - 2];
  965. var hour = temp[temp.length - 1];
  966. var pbx = this.id.substr(0, this.id.indexOf(type) - 1);
  967. var liney = document.getElementById(pbx + "_inCallMouseTip");
  968. if (liney) {
  969. liney.style.visibility = "hidden";
  970. }
  971. var timeText = document.getElementById(pbx + "_inCalltimerow_" + hour);
  972. if (timeText) {
  973. timeText.style.background = "";
  974. }
  975. };
  976. });
  977. },
  978. _softphonebar_toDrawingOutCallChart: function (outCalls, outCallsPerHour, outCompletePerHour, curPbx) {
  979. if (outCalls != 0) {
  980. var outCallSumArray, outCallCptArray = [];
  981. outCallSumArray = outCallsPerHour.split(",");
  982. outCallCptArray = outCompletePerHour.split(",");
  983. var outCallMax = 0;
  984. for (var i = 0; i < 24; i++) {
  985. outCallMax = Math.max(outCallMax, outCallSumArray[i]);
  986. }
  987. var b = outCallMax % 5;
  988. var mainLength = outCallMax - b + 5;
  989. var offsetCall = mainLength / 5;
  990. var topOffsetPercent = 180 / mainLength;
  991. for (var i = 0; i < 24; i++) {
  992. var sumrow = document.getElementById(curPbx + "_outCallsumrow_" + i);
  993. sumrow.setAttribute("call", outCallSumArray[i]);
  994. sumrow.style.height = Math.round(topOffsetPercent * outCallSumArray[i]) + "px";
  995. sumrow.style.top = 200 - Math.round(topOffsetPercent * outCallSumArray[i]) + "px";
  996. var cptrow = document.getElementById(curPbx + "_outCallcptrow_" + i);
  997. cptrow.setAttribute("call", outCallCptArray[i]);
  998. cptrow.style.height = Math.round(topOffsetPercent * outCallCptArray[i]) + "px";
  999. cptrow.style.top = 200 - Math.round(topOffsetPercent * outCallCptArray[i]) + "px";
  1000. }
  1001. for (var i = 1; i < 6; i++) {
  1002. var tity = document.getElementById(curPbx + "_outCalltity_" + i);
  1003. var temp = offsetCall * ( 6 - i );
  1004. tity.innerHTML = temp;
  1005. }
  1006. }
  1007. },
  1008. _softphonebar_toShowOutCallChart: function (curPbx) {
  1009. var outcalls = $("#" + curPbx + "_TwentyFourHourOutCallChartArea div");
  1010. outcalls.each(function (i, outcall) {
  1011. if (!outcall.getAttribute("showTip"))
  1012. return;
  1013. outcall.onmouseover = function () {
  1014. var temp = this.id.split("_");
  1015. var hour = temp[temp.length - 1];
  1016. var type = temp[temp.length - 2];
  1017. var pbx = this.id.substr(0, this.id.indexOf(type) - 1);
  1018. var times = this.getAttribute("call");
  1019. var tipMessage = "";
  1020. if (type === "outCallsumrow") {
  1021. tipMessage = "今日" + hour + "时呼出" + times;
  1022. } else if (type === "outCallcptrow") {
  1023. tipMessage = "今日" + hour + "时呼通" + times;
  1024. }
  1025. var liney = document.getElementById(pbx + "_outCallMouseTip");
  1026. if (!liney) {
  1027. liney = document.createElement("div");
  1028. liney.id = curPbx + "_outCallMouseTip";
  1029. liney.style.position = "absolute";
  1030. liney.style.border = "1px dotted #FFFF99";
  1031. //liney.style.height = "18px";
  1032. liney.style.padding = "3px";
  1033. liney.style.overflow = "hidden";
  1034. liney.style.background = "none repeat scroll 0 0 #f8c713";
  1035. liney.style.textAlign = "center";
  1036. liney.style.zIndex = "2";
  1037. var area = $("#" + pbx + "_TwentyFourHourOutChart");
  1038. area.append(liney);
  1039. }
  1040. liney.innerHTML = tipMessage;
  1041. liney.style.top = $(this).position().top - 18 + "px";
  1042. liney.style.left = $(this).position().left + 5 + "px";
  1043. liney.style.visibility = "visible";
  1044. var timeText = document.getElementById(pbx + "_outCalltimerow_" + hour);
  1045. if (timeText) {
  1046. timeText.style.background = "none repeat scroll 0 0 #f8c713";
  1047. }
  1048. };
  1049. outcall.onmouseout = function () {
  1050. var temp = this.id.split("_");
  1051. var type = temp[temp.length - 2];
  1052. var hour = temp[temp.length - 1];
  1053. var pbx = this.id.substr(0, this.id.indexOf(type) - 1);
  1054. var liney = document.getElementById(pbx + "_outCallMouseTip");
  1055. if (liney) {
  1056. liney.style.visibility = "hidden";
  1057. }
  1058. var timeText = document.getElementById(pbx + "_outCalltimerow_" + hour);
  1059. if (timeText) {
  1060. timeText.style.background = "";
  1061. }
  1062. };
  1063. });
  1064. },
  1065. softphonebar_getpbxid: function (pbx) {
  1066. if (!pbx) {
  1067. pbx = holly.session.user.sipConfigId;
  1068. }
  1069. return pbx.replace(holly.softphonebar._softphoneBar_replaceAll, "_");
  1070. },
  1071. _softphonebar_queue: function (queue) {
  1072. if (queue.members[holly.phone.phone_data.sipNo] == undefined)
  1073. return;
  1074. var queueName = $("#icc_statistics_queue_" + queue.queueId);
  1075. if (queueName.length > 0) {
  1076. if ($("#icc_statistics_name_" + queue.queueId))
  1077. $("#icc_statistics_name_" + queue.queueId).html(queue.queueName);
  1078. if ($("#icc_statistics_idle_" + queue.queueId))
  1079. $("#icc_statistics_idle_" + queue.queueId).html(queue.idleAgentCount);
  1080. if ($("#icc_statistics_wait_" + queue.queueId))
  1081. $("#icc_statistics_wait_" + queue.queueId).html(queue.queueWaitCount);
  1082. } else {
  1083. var htmls = [];
  1084. htmls.push("<div>技能组名:<span id=\"icc_statistics_name_" + queue.queueId + "\">" + queue.queueName + "</span></div>");
  1085. htmls.push("<div>空闲座席数:<span id=\"icc_statistics_idle_" + queue.queueId + "\">" + queue.idleAgentCount + "</span></div>");
  1086. htmls.push("<div>排队数:<span id=\"icc_statistics_wait_" + queue.queueId + "\">" + queue.queueWaitCount + "</span></div>");
  1087. htmls.push("<div class=\"clear5\"></div>")
  1088. var elementDiv = document.createElement("div");
  1089. elementDiv.id = "icc_statistics_queue_" + queue.queueId;
  1090. elementDiv.innerHTML = htmls.join("");
  1091. $("#user_queue").append(elementDiv);
  1092. }
  1093. },
  1094. monitor_agent: function () {
  1095. var ul = "<ul class=\"nav nav-tabs\" id=\"monitor_ul\">";
  1096. var curpbxid = holly.softphonebar.softphonebar_getpbxid(holly.phone.phone_data.pbx_in_ip);
  1097. ul += "<li class=\"active\"><a href=\"#monitor_" + curpbxid + "\">" + holly.phone.phone_pbxs[holly.phone.phone_data.pbx_in_ip].pbxNick + "</a></li>";
  1098. for (var pbx in holly.phone.phone_pbxs) {
  1099. if (pbx != holly.phone.phone_data.pbx_in_ip) {
  1100. var pbxid = holly.softphonebar.softphonebar_getpbxid(pbx);
  1101. ul += "<li><a href=\"#monitor_" + pbxid + "\" >" + holly.phone.phone_pbxs[pbx].pbxNick + "</a></li>";
  1102. }
  1103. }
  1104. ul += "</ul>";
  1105. var content = "";
  1106. content += "<div class=\"tab-content\">";
  1107. for (var pbx in holly.phone.phone_pbxs) {
  1108. var agentItem = $("#monitor_allpbx").html();
  1109. var pbxid = holly.softphonebar.softphonebar_getpbxid(pbx);
  1110. agentItem = agentItem.replace("monitor_serviceNo", "monitor_serviceNo" + "_" + pbxid);
  1111. agentItem = agentItem.replace("monitor_queue", "monitor_queue" + "_" + pbxid);
  1112. agentItem = agentItem.replace(/monitor_peer/g, "monitor_peer" + "_" + pbxid);
  1113. agentItem = agentItem.replace("monitor_waitCountTotal", "monitor_waitCountTotal" + "_" + pbxid);
  1114. agentItem = agentItem.replace("monitor_countAll", "monitor_countAll" + "_" + pbxid);
  1115. agentItem = agentItem.replace(/__pbxid/g, pbxid);
  1116. agentItem = agentItem.replace("monitor_onlineCount", "monitor_onlineCount" + "_" + pbxid);
  1117. agentItem = agentItem.replace("monitor_idleCount", "monitor_idleCount" + "_" + pbxid);
  1118. if (pbx == holly.phone.phone_data.pbx_in_ip) {
  1119. content += "<div class=\"tab-pane active\" id=\"monitor_" + pbxid + "\">";
  1120. } else {
  1121. content += "<div class=\"tab-pane\" id=\"monitor_" + pbxid + "\">";
  1122. }
  1123. content += agentItem;
  1124. content += "</div>";
  1125. }
  1126. content += "</div>";
  1127. $("#monitor_allpbx").html(ul + content);
  1128. $('#monitor_ul a').click(function (e) {
  1129. e.preventDefault();
  1130. $(this).tab('show');
  1131. })
  1132. $('#monitor_ul a').on('shown', function (e) {
  1133. var value = e.target + "";
  1134. var pbxid = value.substr(value.indexOf("#monitor_") + 9, value.length);
  1135. var pbx = holly.softphonebar._softphonebar_getpbx(pbxid);
  1136. holly.phone.phone_pbxMonitor(pbx);
  1137. })
  1138. holly.softphonebar._softphonebar_monitorInit();
  1139. },
  1140. _softphonebar_getpbx: function (pbxid) {
  1141. return pbxid.replace(holly.softphonebar._softphoneBar_replaceAll_bak, ".");
  1142. },
  1143. _softphonebar_monitorInit: function () {
  1144. holly.softphonebar._softphonebar_peer_index = 0;
  1145. holly.softphonebar._softphonebar_queue_index = 0;
  1146. holly.softphonebar._softphonebar_serviceNo_index = 0;
  1147. if (holly.phone.phone_data.monitor) {
  1148. if (holly.phone.phone_serviceNos) {
  1149. for (var i in holly.phone.phone_serviceNos) {
  1150. var item = holly.phone.phone_serviceNos[i];
  1151. if (!item || !item.serviceNo)
  1152. continue;
  1153. var curRow = $("#monitor_serviceNo_" + item.serviceNo);
  1154. if (curRow.html() == null) {
  1155. holly.softphonebar._softphonebar_createRow(item, 'serviceNo');
  1156. } else {
  1157. holly.softphonebar._softphonebar_updateRow(item, curRow, 'serviceNo')
  1158. }
  1159. }
  1160. }
  1161. if (holly.phone.phone_queues) {
  1162. for (var i in holly.phone.phone_queues) {
  1163. var item = holly.phone.phone_queues[i];
  1164. if (!item || !item.queueId)
  1165. continue;
  1166. var curRow = $("#monitor_queue_" + item.queueId);
  1167. if (curRow.html() == null) {
  1168. holly.softphonebar._softphonebar_createRow(item, 'queueId');
  1169. } else {
  1170. holly.softphonebar._softphonebar_updateRow(item, curRow, 'queueId')
  1171. }
  1172. }
  1173. }
  1174. if (holly.phone.phone_peers) {
  1175. for (var i in holly.phone.phone_peers) {
  1176. var item = holly.phone.phone_peers[i];
  1177. if (!item || !item.userId)
  1178. continue;
  1179. if (item.user.indexOf("admin") != -1)
  1180. continue;
  1181. var curRow = $("#monitor_peer_" + item.userId);
  1182. if (curRow.html() == null) {
  1183. holly.softphonebar._softphonebar_createRow(item, 'userId');
  1184. } else {
  1185. holly.softphonebar._softphonebar_updateRow(item, curRow, 'userId')
  1186. }
  1187. }
  1188. }
  1189. holly.softphonebar._softphonebar_setInterval();
  1190. $(".monitor_department").css("display", "block");
  1191. holly.softphonebar._softphonebar_initDept();
  1192. } else {
  1193. if (holly.phone.phone_peers) {
  1194. for (var i in holly.phone.phone_peers) {
  1195. var item = holly.phone.phone_peers[i];
  1196. if (!item || !item.userId)
  1197. continue;
  1198. if (item.user.indexOf("admin") != -1)
  1199. continue;
  1200. if (item.userId != holly.session.user._id) {
  1201. if (jQuery.inArray(item.userId, holly.session.user.childs) == -1) {
  1202. continue;
  1203. }
  1204. }
  1205. var curRow = $("#monitor_peer_" + item.userId);
  1206. if (curRow.html() == null) {
  1207. holly.softphonebar._softphonebar_createRow(item, 'userId');
  1208. } else {
  1209. holly.softphonebar._softphonebar_updateRow(item, curRow, 'userId')
  1210. }
  1211. }
  1212. }
  1213. holly.softphonebar._softphonebar_setInterval();
  1214. $(".monitor_department").css("display", "none");
  1215. $(".monitor_list_serviceNo").css("display", "none");
  1216. $(".monitor_list_queue").css("display", "none");
  1217. }
  1218. holly.softphonebar._softphonebar_updatePeerNum(holly.phone.phone_data.pbx_in_ip);
  1219. },
  1220. _softphonebar_setInterval: function () {
  1221. if (holly.softphonebar._softphonebar_monitorTimersHandle) {
  1222. window.clearInterval(holly.softphonebar._softphonebar_monitorTimersHandle);
  1223. }
  1224. holly.softphonebar._softphonebar_monitorTimersHandle = window.setInterval("holly.softphonebar._softphonebar_monitorDoCallTimer()", 1000);
  1225. },
  1226. _softphonebar_initDept: function () {
  1227. for (var i in holly.phone.phone_pbxs) {
  1228. var obj = document.getElementById('monitor_department_options' + '_' + holly.softphonebar.softphonebar_getpbxid(i));
  1229. if (obj) {
  1230. obj.options.length = 0;
  1231. obj.options.add(new Option("全部", ""));
  1232. for (var i = 0; i < holly.phone.phone_data.depts.length; i++) {
  1233. obj.options.add(new Option(holly.phone.phone_data.depts[i].Name, holly.phone.phone_data.depts[i].ID));
  1234. }
  1235. }
  1236. }
  1237. },
  1238. _softphonebar_monitorDoCallTimer: function () {
  1239. if (holly.softphonebar._softphonebar_monitorTimers) {
  1240. for (var i in holly.softphonebar._softphonebar_monitorTimers) {
  1241. var timerTd = $("#" + i + "_timer");
  1242. if (timerTd != null) {
  1243. timerTd.text(holly.softphonebar._softphonebar_getTimer(holly.softphonebar._softphonebar_monitorTimers[i].count));
  1244. holly.softphonebar._softphonebar_monitorTimers[i].count++;
  1245. }
  1246. }
  1247. }
  1248. },
  1249. _softphonebar_deptChange: function (pbxId) {
  1250. var obj = document.getElementById('monitor_department_options_' + pbxId);
  1251. if (obj) {
  1252. var index = obj.selectedIndex;
  1253. var deptId = obj[index].value;
  1254. var trs = $("table[id=monitor_peer_" + pbxId + "] > tbody").children("tr");
  1255. for (var i = 0; i < trs.length; i++) {
  1256. var tr = trs[i];
  1257. if (deptId == "") {
  1258. $(tr).css("display", "");
  1259. } else {
  1260. var userid = trs[i].id.replace("monitor_peer_", "");
  1261. var peer = holly.phone.phone_peers[userid];
  1262. if (peer && peer.department && peer.department == deptId) {
  1263. $(tr).css("display", "");
  1264. } else {
  1265. $(tr).css("display", "none");
  1266. }
  1267. }
  1268. }
  1269. holly.softphonebar._softphonebar_updatePeerNum(holly.softphonebar._softphonebar_getpbx(pbxId));
  1270. }
  1271. },
  1272. _softphonebar_displayStatus: function (peer) {
  1273. var displayName = '';
  1274. if (peer.login && peer.extenType != 'none') {
  1275. if ((peer.extenType === 'sip' || peer.extenType === 'gateway') && peer.register == false) {
  1276. displayName = holly.softphonebar._softphonebar_desc["unregister"];
  1277. } else if (peer.callStatus === 'Idle') {
  1278. if (peer.busyType === "0")
  1279. displayName = holly.softphonebar._softphonebar_getColor(holly.phone.phone_data.phonebarConfig[peer.busyType], "0");
  1280. else
  1281. displayName = holly.softphonebar._softphonebar_getColor(holly.phone.phone_data.phonebarConfig[peer.busyType], "1");
  1282. } else if (peer.callStatus === 'Ring') {
  1283. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialing"], "2");
  1284. } else if (peer.callStatus === 'Ringing') {
  1285. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["belling"], "2");
  1286. } else if (peer.callStatus === 'inner') {
  1287. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["innerTalking"], "2");
  1288. } else if (peer.callStatus === 'normal') {
  1289. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["talking"], "2");
  1290. } else if (peer.callStatus === 'dialout') {
  1291. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialTalking"], "2");
  1292. } else if (peer.callStatus === 'dialTransfer') {
  1293. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialTransfer"], "2");
  1294. } else if (peer.callStatus === 'transfer') {
  1295. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["transfer"], "2");
  1296. } else if (peer.callStatus === 'listen') {
  1297. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["listened"], "2");
  1298. }
  1299. } else if (peer.login && peer.extenType == 'none') {
  1300. displayName = '';
  1301. } else {
  1302. if (peer.callStatus === 'Ring') {
  1303. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialing"], "2");
  1304. } else if (peer.callStatus === 'Ringing') {
  1305. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["belling"], "2");
  1306. } else if (peer.callStatus === 'inner') {
  1307. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["innerTalking"], "2");
  1308. } else if (peer.callStatus === 'normal') {
  1309. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["talking"], "2");
  1310. } else if (peer.callStatus === 'dialout') {
  1311. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialTalking"], "2");
  1312. } else if (peer.callStatus === 'dialTransfer') {
  1313. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["dialTransfer"], "2");
  1314. } else if (peer.callStatus === 'transfer') {
  1315. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["transfer"], "2");
  1316. } else if (peer.callStatus == '=listen') {
  1317. displayName = holly.softphonebar._softphonebar_getColor(holly.softphonebar._softphonebar_desc["listened"], "2");
  1318. } else {
  1319. if (!peer.login && (peer.extenType === 'gateway' || peer.extenType === 'Local')) {
  1320. displayName = holly.softphonebar._softphonebar_desc["offline"];
  1321. } else {
  1322. displayName = holly.softphonebar._softphonebar_desc["ready"];
  1323. }
  1324. }
  1325. }
  1326. return displayName;
  1327. },
  1328. _softphonebar_getColor: function (content, type) {
  1329. if (type == "0") {
  1330. return "<span style=\"color: green\">" + content + "</span>";
  1331. } else if (type == "1") {
  1332. return "<span style=\"color: red\">" + content + "</span>";
  1333. } else if (type == "2") {
  1334. return "<span style=\"color: #FF33FF\">" + content + "</span>";
  1335. } else {
  1336. return content;
  1337. }
  1338. },
  1339. _softphonebar_updatePeerNum: function (pbx) {
  1340. var idleNum = 0;
  1341. var totalNum = 0;
  1342. var onlineNum = 0;
  1343. var deptOptions = document.getElementById('monitor_department_options_' + holly.softphonebar.softphonebar_getpbxid(pbx));
  1344. var deptId = "";
  1345. if (deptOptions && deptOptions.selectedIndex && deptOptions.selectedIndex != -1) {
  1346. if (deptOptions[deptOptions.selectedIndex]) {
  1347. deptId = deptOptions[deptOptions.selectedIndex].value;
  1348. }
  1349. }
  1350. for (var i in holly.phone.phone_peers) {
  1351. var item = holly.phone.phone_peers[i];
  1352. if (item.pbx != pbx)
  1353. continue;
  1354. var peerState = holly.softphonebar._softphonebar_displayStatus(item);
  1355. if (item.user != null) {
  1356. if (item.user.indexOf('admin') != -1) {
  1357. continue;
  1358. }
  1359. }
  1360. if (holly.phone.phone_data.monitor) {
  1361. if (deptId == "" || item.department == deptId) {
  1362. totalNum++;
  1363. if (peerState != holly.softphonebar._softphonebar_desc["offline"]
  1364. && peerState != holly.softphonebar._softphonebar_desc["unregister"]
  1365. && peerState != holly.softphonebar._softphonebar_desc["ready"]) {
  1366. onlineNum++;
  1367. if (peerState.indexOf(holly.softphonebar._softphonebar_desc["peerstate"]) > 0) {
  1368. idleNum++;
  1369. }
  1370. }
  1371. }
  1372. } else {
  1373. if (item.userId != holly.session.user._id) {
  1374. if (jQuery.inArray(item.userId, holly.session.user.childs) == -1) {
  1375. continue;
  1376. }
  1377. }
  1378. totalNum++;
  1379. if (peerState != holly.softphonebar._softphonebar_desc["offline"]
  1380. && peerState != holly.softphonebar._softphonebar_desc["unregister"]
  1381. && peerState != holly.softphonebar._softphonebar_desc["ready"]) {
  1382. onlineNum++;
  1383. if (peerState.indexOf(holly.softphonebar._softphonebar_desc["peerstate"]) > 0) {
  1384. idleNum++;
  1385. }
  1386. }
  1387. }
  1388. }
  1389. $("#monitor_countAll_" + holly.softphonebar.softphonebar_getpbxid(pbx)).html(totalNum);
  1390. $("#monitor_onlineCount_" + holly.softphonebar.softphonebar_getpbxid(pbx)).html(onlineNum);
  1391. $("#monitor_idleCount_" + holly.softphonebar.softphonebar_getpbxid(pbx)).html(idleNum);
  1392. },
  1393. _softphonebar_createRow: function (item, key) {
  1394. if (key === 'serviceNo') {
  1395. var tdHtml = "";
  1396. if ((holly.softphonebar._softphonebar_serviceNo_index++) % 2 == 0) {
  1397. tdHtml = "<tr id=\"monitor_serviceNo_" + item.serviceNo + "\">";
  1398. } else {
  1399. tdHtml = "<tr id=\"monitor_serviceNo_" + item.serviceNo + "\" class=\"odd\">";
  1400. }
  1401. tdHtml += "<td>" + item.serviceNo + "</td><td>" + item.inCalls + "</td><td>" + item.inLost + "</td><td>" + item.inComplete + "</td><tr>";
  1402. $('#monitor_serviceNo_' + holly.softphonebar.softphonebar_getpbxid(item.pbx) + ' > tbody:last').append(tdHtml);
  1403. } else if (key == 'queueId') {
  1404. var tdHtml = "";
  1405. if ((holly.softphonebar._softphonebar_queue_index++) % 2 == 0) {
  1406. tdHtml = "<tr id=\"monitor_queue_" + item.queueId + "\">";
  1407. } else {
  1408. tdHtml = "<tr id=\"monitor_queue_" + item.queueId + "\" class=\"odd\">";
  1409. }
  1410. var waitCountTd = "";
  1411. if (item.queueWaitCount > 0) {
  1412. waitCountTd = "<td style='color:red;'>" + item.queueWaitCount + "</td>";
  1413. } else {
  1414. waitCountTd = "<td>" + item.queueWaitCount + "</td>";
  1415. }
  1416. tdHtml += "<td class=\"ellipsis\" title=\"" + item.queueName + "\">" + item.queueName + "</td><td>" + item.idleAgentCount + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_getQueuePeer(item) + "\">" + item.totalAgentCount + holly.softphonebar._softphonebar_getQueuePeer(item) + "</td>" +
  1417. waitCountTd + "<td>" + (item.totalCalls - item.abadonedCalls) + "</td><tr>";
  1418. $('#monitor_queue_' + holly.softphonebar.softphonebar_getpbxid(item.pbx) + ' > tbody:last').append(tdHtml);
  1419. } else if (key == 'userId') {
  1420. var tdHtml = "";
  1421. if ((holly.softphonebar._softphonebar_peer_index++) % 2 == 0) {
  1422. tdHtml = "<tr id=\"monitor_peer_" + item.userId + "\">";
  1423. } else {
  1424. tdHtml = "<tr id=\"monitor_peer_" + item.userId + "\" class=\"odd\">";
  1425. }
  1426. tdHtml += "<td class=\"ellipsis\" title='" + item.DisplayName + "' style=\"height:20px;overflow: hidden\">" + item.DisplayName + "</td><td>" + item.exten + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_getInComCount(item) + "\">" + (item.InComplete + item.TransferComplete) + "(" + holly.softphonebar._softphonebar_getInComCount(item) + ")</td>" +
  1427. "<td>" + item.OutComplete + "</td><td>" + item.callNo + "</td><td>" + holly.softphonebar._softphonebar_displayExtenType(item) + "</td>" +
  1428. "<td>" + holly.softphonebar._softphonebar_displayStatus(item) + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_displayQueueName(item.queueName) + "\">" + holly.softphonebar._softphonebar_displayQueueName(item.queueName) + "</td><td id=\"" + item.userId + "_timer\"></td>" +
  1429. "<td>" + holly.softphonebar._softphonebar_getDialoutTime(item.DialoutTimeLength) + "</td><td>" + holly.softphonebar._softphonebar_getStatus(item) + "</td>" +
  1430. "<td><button id=\"" + item.userId + "_listen_disable\" class=\"btn btn-mini disabled\" >监听</button>" +
  1431. "<button id=\"" + item.userId + "_listen\" class=\"btn btn-mini btn-warning\" style=\"display:none;\" onclick=\"holly.softphonebar._softphonebar_listen('" + item.channel + "', '" + item.userId + "')\">监听</button>" +
  1432. "<button id=\"" + item.userId + "_endlisten\" class=\"btn btn-mini btn-warning\" style=\"display:none;\" onclick=\"holly.softphonebar._softphonebar_endListen()\">结束监听</button>" +
  1433. "<button id=\"" + item.userId + "_forceHangup_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">强拆</button>" +
  1434. "<button id=\"" + item.userId + "_forceHangup\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_forceHangup('" + item.channel + "', '" + item.pbx + "')\">强拆</button>" +
  1435. "<button id=\"" + item.userId + "_loot_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">抢接</button>" +
  1436. "<button id=\"" + item.userId + "_loot\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_loot('" + item.linkedChannel + "')\">抢接</button>" +
  1437. "<button id=\"" + item.userId + "_kick_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">签出</button>" +
  1438. "<button id=\"" + item.userId + "_kick\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_kick('" + item.userId + "', '" + item.pbx + "')\">签出</button>" +
  1439. "<button id=\"" + item.userId + "_pick_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">签入</button>" +
  1440. "<button id=\"" + item.userId + "_pick\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_pick('" + item.userId + "', '" + item.pbx + "')\">签入</button>" +
  1441. "</td></tr>";
  1442. var currentPbxId = holly.softphonebar.softphonebar_getpbxid(item.pbx);
  1443. var currentTbody = $('#monitor_peer_' + currentPbxId + ' > tbody:last');
  1444. currentTbody.append(tdHtml);
  1445. if (item.login && item.timestamp) {
  1446. var date = new Date();
  1447. var identity = date.valueOf();
  1448. var oldTime = ((identity - holly.phone.phone_data.currentServerTime) - parseFloat(item.timestamp) * 1000) / 1000;
  1449. if (oldTime < 0) {
  1450. oldTime = 0;
  1451. }
  1452. var countTimer = {
  1453. count: oldTime
  1454. };
  1455. holly.softphonebar._softphonebar_monitorTimers[item.userId] = countTimer;
  1456. }
  1457. holly.softphonebar._softphonebar_controlMonitor(item);
  1458. holly.softphonebar._softphonebar_updatePeerNum(item.pbx);
  1459. }
  1460. },
  1461. _softphonebar_getStatus: function (peer) {
  1462. if (!peer.login && !(peer.extenType == 'gateway' || peer.extenType == 'Local')) {
  1463. return "";
  1464. } else {
  1465. return peer.status;
  1466. }
  1467. },
  1468. _softphonebar_controlMonitor: function (peer) {
  1469. if(!holly.phone.phone_data.userId){
  1470. holly.phone.phone_data.userId = window.localStorage.getItem('currentLoginAgent');
  1471. }
  1472. if (peer.userId == holly.phone.phone_data.userId
  1473. || (!peer.login && peer.extenType != 'Local' && peer.extenType != 'gateway')) {
  1474. $("#" + peer.userId + "_kick_disable").css("display", "");
  1475. $("#" + peer.userId + "_kick").css("display", "none");
  1476. } else {
  1477. $("#" + peer.userId + "_kick_disable").css("display", "none");
  1478. $("#" + peer.userId + "_kick").css("display", "");
  1479. }
  1480. if (peer.userId == holly.phone.phone_data.userId
  1481. || peer.login || (!peer.login && peer.extenType == "Local") || (!peer.login && peer.extenType == "gateway")) {
  1482. $("#" + peer.userId + "_pick_disable").css("display", "");
  1483. $("#" + peer.userId + "_pick").css("display", "none");
  1484. } else {
  1485. $("#" + peer.userId + "_pick_disable").css("display", "none");
  1486. $("#" + peer.userId + "_pick").css("display", "");
  1487. }
  1488. if (peer.callStatus != "listen" && peer.callStatus != "Idle") {
  1489. $("#" + peer.userId + "_forceHangup_disable").css("display", "none");
  1490. $("#" + peer.userId + "_forceHangup").css("display", "");
  1491. } else {
  1492. $("#" + peer.userId + "_forceHangup_disable").css("display", "");
  1493. $("#" + peer.userId + "_forceHangup").css("display", "none");
  1494. }
  1495. if (holly.phone.phone_data.extenType == "none"
  1496. || peer.userId == holly.phone.phone_data.userId || holly.softphonebar._softphonebar_isCalling(holly.phone.phone_data.userId) || !holly.softphonebar._softphonebar_isCalling(peer.userId)) {
  1497. $("#" + peer.userId + "_loot_disable").css("display", "");
  1498. $("#" + peer.userId + "_loot").css("display", "none");
  1499. } else {
  1500. $("#" + peer.userId + "_loot_disable").css("display", "none");
  1501. $("#" + peer.userId + "_loot").css("display", "");
  1502. }
  1503. if (holly.phone.phone_data.extenType != "none" && peer.userId != holly.phone.phone_data.userId
  1504. && !holly.softphonebar._softphonebar_isCalling(holly.phone.phone_data.userId)
  1505. && (peer.callStatus == "webcall" || peer.callStatus == "inner" || peer.callStatus == "normal" || peer.callStatus == "dialout" || peer.callStatus == "dialTransfer" || peer.callStatus == "transfer")) {
  1506. $("#" + peer.userId + "_listen_disable").css("display", "none");
  1507. $("#" + peer.userId + "_listen").css("display", "");
  1508. } else {
  1509. $("#" + peer.userId + "_listen_disable").css("display", "");
  1510. $("#" + peer.userId + "_listen").css("display", "none");
  1511. }
  1512. if (peer.pbx != holly.phone.phone_data.pbx_in_ip) {
  1513. $("#" + peer.userId + "_loot_disable").css("display", "none");
  1514. $("#" + peer.userId + "_loot").css("display", "none");
  1515. $("#" + peer.userId + "_listen_disable").css("display", "none");
  1516. $("#" + peer.userId + "_listen").css("display", "none");
  1517. }
  1518. },
  1519. _softphonebar_displayExtenType: function (peer) {
  1520. var displayExtenType = "";
  1521. if (peer.extenType === 'sip') {
  1522. displayExtenType = "云通信客户端";
  1523. } else if (peer.extenType === 'gateway') {
  1524. displayExtenType = "SIP话机/网关";
  1525. } else if (peer.extenType === 'Local') {
  1526. displayExtenType = peer.localNo;
  1527. } else if (peer.extenType === 'none') {
  1528. displayExtenType = "无电话接入";
  1529. }
  1530. return displayExtenType;
  1531. },
  1532. _softphonebar_updateRow: function (item, curRow, key) {
  1533. if (key == 'serviceNo') {
  1534. var tdHtml = "<td>" + item.serviceNo + "</td><td>" + item.inCalls + "</td><td>" + item.inLost + "</td><td>" + item.inComplete + "</td>";
  1535. curRow.html(tdHtml);
  1536. } else if (key === 'queueId') {
  1537. var waitCountTd = "";
  1538. if (item.queueWaitCount > 0) {
  1539. waitCountTd = "<td style='color:red;'>" + item.queueWaitCount + "</td>";
  1540. } else {
  1541. waitCountTd = "<td>" + item.queueWaitCount + "</td>";
  1542. }
  1543. var tdHtml = "<td class=\"ellipsis\" title=\"" + item.queueName + "\">" + item.queueName + "</td><td>" + item.idleAgentCount + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_getQueuePeer(item) + "\">" + item.totalAgentCount + holly.softphonebar._softphonebar_getQueuePeer(item) + "</td>" + waitCountTd + "<td>" + (item.totalCalls - item.abadonedCalls) + "</td>";
  1544. curRow.html(tdHtml);
  1545. } else if (key === 'userId') {
  1546. var tdHtml = "<td class=\"ellipsis\" title='" + item.DisplayName + "' style=\"height:20px;overflow: hidden\">" + item.DisplayName + "</td><td>" + item.exten + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_getInComCount(item) + "\">" + (item.InComplete + item.TransferComplete) + "(" + holly.softphonebar._softphonebar_getInComCount(item) + ")</td><td>" + item.OutComplete + "</td><td>" + item.callNo + "</td>" +
  1547. "<td>" + holly.softphonebar._softphonebar_displayExtenType(item) + "</td><td>" + holly.softphonebar._softphonebar_displayStatus(item) + "</td><td class=\"ellipsis\" title=\"" + holly.softphonebar._softphonebar_displayQueueName(item.queueName) + "\">" + holly.softphonebar._softphonebar_displayQueueName(item.queueName) + "</td>" +
  1548. "<td id=\"" + item.userId + "_timer\"></td><td>" + holly.softphonebar._softphonebar_getDialoutTime(item.DialoutTimeLength) + "</td><td>" + holly.softphonebar._softphonebar_getStatus(item) + "</td>" +
  1549. "<td><button id=\"" + item.userId + "_listen_disable\" class=\"btn btn-mini disabled\" >监听</button>" +
  1550. "<button id=\"" + item.userId + "_listen\" class=\"btn btn-mini btn-warning\" style=\"display:none;\" onclick=\"holly.softphonebar._softphonebar_listen('" + item.channel + "', '" + item.userId + "')\">监听</button>" +
  1551. "<button id=\"" + item.userId + "_endlisten\" class=\"btn btn-mini btn-warning\" style=\"display:none;\" onclick=\"holly.softphonebar._softphonebar_endListen('" + item.channel + "')\">结束监听</button>" +
  1552. "<button id=\"" + item.userId + "_forceHangup_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">强拆</button>" +
  1553. "<button id=\"" + item.userId + "_forceHangup\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_forceHangup('" + item.channel + "', '" + item.pbx + "')\">强拆</button>" +
  1554. "<button id=\"" + item.userId + "_loot_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">抢接</button>" +
  1555. "<button id=\"" + item.userId + "_loot\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_loot('" + item.linkedChannel + "')\">抢接</button>" +
  1556. "<button id=\"" + item.userId + "_kick_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">签出</button>" +
  1557. "<button id=\"" + item.userId + "_kick\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_kick('" + item.userId + "', '" + item.pbx + "')\">签出</button>" +
  1558. "<button id=\"" + item.userId + "_pick_disable\" class=\"btn btn-mini disabled\" style=\"margin-left: 2px;\">签入</button>" +
  1559. "<button id=\"" + item.userId + "_pick\" class=\"btn btn-mini btn-warning\" style=\"margin-left: 2px;display:none;\" onclick=\"holly.softphonebar._softphonebar_pick('" + item.userId + "', '" + item.pbx + "')\">签入</button>" +
  1560. "</td>";
  1561. curRow.html(tdHtml);
  1562. if (item.login && item.timestamp) {
  1563. var date = new Date();
  1564. var identity = date.valueOf();
  1565. var oldTime = ((identity - holly.phone.phone_data.currentServerTime) - parseFloat(item.timestamp) * 1000) / 1000;
  1566. if (oldTime < 0) {
  1567. oldTime = 0;
  1568. }
  1569. var countTimer = {
  1570. count: oldTime
  1571. }
  1572. holly.softphonebar._softphonebar_monitorTimers[item.userId] = countTimer;
  1573. } else {
  1574. delete holly.softphonebar._softphonebar_monitorTimers[item.userId];
  1575. $("#" + item.userId + "_timer").text("");
  1576. }
  1577. holly.softphonebar._softphonebar_controlMonitor(item);
  1578. holly.softphonebar._softphonebar_updatePeerNum(item.pbx);
  1579. }
  1580. },
  1581. _softphonebar_listen: function (curChannel, userId) {
  1582. var peer = holly.phone.phone_peers[userId];
  1583. var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
  1584. if (peer == null) {
  1585. holly.utils.showError("监听失败!", "softphone_transfer");
  1586. return;
  1587. }
  1588. if (currentPeer.busyType == "0") {
  1589. holly.utils.showError("请先将电话置为忙碌", "softphone_transfer");
  1590. return;
  1591. }
  1592. if (currentPeer.extenType == "none") {
  1593. holly.utils.showError("执行该操作必须以电话方式登录", "softphone_transfer");
  1594. return;
  1595. }
  1596. if (peer.userId == currentPeer.userId) {
  1597. holly.utils.showError("不允许对自身进行操作", "softphone_transfer");
  1598. return;
  1599. }
  1600. if (peer.callStatus != "webcall"
  1601. && peer.callStatus != "inner"
  1602. && peer.callStatus != "normal"
  1603. && peer.callStatus != "dialout"
  1604. && peer.callStatus != "dialTransfer"
  1605. && peer.callStatus != "transfer") {
  1606. holly.utils.showError("该状态不允许监听", "softphone_transfer");
  1607. return;
  1608. }
  1609. var listen = holly.phone.phone_listen(curChannel,currentPeer);
  1610. if (listen) {
  1611. $("#" + userId + "_listen").css("display", "none");
  1612. $("#" + userId + "_endlisten").css("display", "");
  1613. }
  1614. },
  1615. _softphonebar_getQueuePeer: function (item) {
  1616. var queue = holly.phone.phone_queues[item.queueId];
  1617. var members;
  1618. var curPeer;
  1619. var tipTitle = "";
  1620. if (queue) {
  1621. members = queue.members;
  1622. for (var j in members) {
  1623. curPeer = holly.phone.phone_peers_sip[j];
  1624. if (curPeer)
  1625. tipTitle += (curPeer.DisplayName + ",");
  1626. }
  1627. if (tipTitle != "") {
  1628. tipTitle = "(" + tipTitle.substring(0, tipTitle.lastIndexOf(",")) + ")";
  1629. }
  1630. }
  1631. return tipTitle;
  1632. },
  1633. _softphonebar_getInComCount: function (item) {
  1634. return "普通来电数:" + item.InComplete + "\r\n" + "转接来电数:" + item.TransferComplete;
  1635. },
  1636. _softphonebar_endListen: function () {
  1637. holly.phone.phone_hangup();
  1638. },
  1639. _softphonebar_forceHangup: function (curChannel, pbx) {
  1640. if (pbx === holly.phone.phone_data.pbx_in_ip)
  1641. holly.phone.phone_hangupChannel(curChannel);
  1642. else
  1643. holly.phone.phone_hangupChannelFromPbx(curChannel, pbx);
  1644. },
  1645. _softphonebar_loot: function (linkedChannel) {
  1646. holly.phone.phone_loot(linkedChannel);
  1647. },
  1648. _softphonebar_kick: function (userId, pbx) {
  1649. if (pbx === holly.phone.phone_data.pbx_in_ip)
  1650. holly.phone.phone_kick(userId);
  1651. else
  1652. holly.phone.phone_kickFromPbx(userId, pbx);
  1653. },
  1654. _softphonebar_pick: function (userId, pbx) {
  1655. if (pbx === holly.phone.phone_data.pbx_in_ip)
  1656. holly.phone.phone_pick(userId);
  1657. else
  1658. holly.phone.phone_pickFromPbx(userId, pbx);
  1659. },
  1660. _softphonebar_evtRing: function (event, callObject) {
  1661. var dialoutInput = $("#dialout_input");
  1662. if (dialoutInput) {
  1663. var phoneNum = '';
  1664. if (callObject) {
  1665. if (callObject.ChannelType === 'dialout') {
  1666. phoneNum = callObject.FromDid;
  1667. } else if (callObject.ChannelType === 'normal') {
  1668. phoneNum = callObject.FromCid;
  1669. }
  1670. if (hollyglobal.isHiddenNumber) {
  1671. phoneNum = holly.softphonebar.softphonebar_getHiddenNum(phoneNum);
  1672. }
  1673. }
  1674. $("#dialout_input").val(phoneNum);
  1675. }
  1676. if (!hollyglobal.isMonitorPage && hollyglobal.ringEvent && typeof hollyglobal.ringEvent == 'function') {
  1677. hollyglobal.ringEvent(callObject);
  1678. }
  1679. },
  1680. _softphonebar_evtTalking: function (callObject) {
  1681. if (!hollyglobal.isMonitorPage && hollyglobal.talkingEvent && typeof hollyglobal.talkingEvent == 'function') {
  1682. hollyglobal.talkingEvent(callObject);
  1683. }
  1684. },
  1685. _softphonebar_evtHangup: function (event, callObject) {
  1686. if (!hollyglobal.isMonitorPage && hollyglobal.hangupEvent && typeof hollyglobal.hangupEvent == 'function') {
  1687. hollyglobal.hangupEvent(callObject);
  1688. }
  1689. },
  1690. _softphonebar_displayQueueName: function (queueName) {
  1691. if (!queueName)
  1692. queueName = "";
  1693. return queueName;
  1694. },
  1695. _softphonebar_ontDialinAgentBusy: function (event, callObject) {
  1696. // Account: "N000000007121"
  1697. // Command: "Event"
  1698. // Event: "DialinAgentBusyMessage"
  1699. // FromCid: "0105004"
  1700. // PBX: "2.3.1.100"
  1701. // UserID: "82dc2510-bef4-11e3-9327-9b83bd1d8356"
  1702. holly.utils.showError("您有新来电,来电号码:" + callObject.FromCid, "softphone_transfer");
  1703. }
  1704. }