| | 963 | $context = 'macro-dialout-trunk'; |
|---|
| | 964 | $exten = 's'; |
|---|
| | 965 | |
|---|
| | 966 | /* |
|---|
| | 967 | * dialout using a trunk, using pattern matching (don't strip any prefix) |
|---|
| | 968 | * arg1 = trunk number, arg2 = number, arg3 = route password |
|---|
| | 969 | * |
|---|
| | 970 | * MODIFIED (PL) |
|---|
| | 971 | * |
|---|
| | 972 | * Modified both Dial() commands to include the new TRUNK_OPTIONS from the general |
|---|
| | 973 | * screen of AMP |
|---|
| | 974 | */ |
|---|
| | 975 | $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK', '${ARG1}')); |
|---|
| | 976 | $ext->add($context, $exten, '', new ext_execif('$[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]', 'Authenticate', '${ARG3}')); |
|---|
| | 977 | $ext->add($context, $exten, '', new ext_gotoif('$["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]', 'disabletrunk,1')); |
|---|
| | 978 | $ext->add($context, $exten, '', new ext_set('DIAL_NUMBER', '${ARG2}')); // fixlocalprefix depends on this |
|---|
| | 979 | $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', '${DIAL_OPTIONS}')); // will be reset to TRUNK_OPTIONS if not intra-company |
|---|
| | 980 | $ext->add($context, $exten, '', new ext_set('GROUP()', 'OUT_${DIAL_TRUNK}')); |
|---|
| | 981 | $ext->add($context, $exten, '', new ext_gotoif('$["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]', 'nomax')); |
|---|
| | 982 | $ext->add($context, $exten, '', new ext_gotoif('$[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]', 'chanfull')); |
|---|
| | 983 | $ext->add($context, $exten, 'nomax', new ext_gotoif('$["${INTRACOMPANYROUTE}" = "YES"]', 'skipoutcid')); // Set to YES if treated like internal |
|---|
| | 984 | $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', '${TRUNK_OPTIONS}')); |
|---|
| | 985 | $ext->add($context, $exten, '', new ext_macro('outbound-callerid', '${DIAL_TRUNK}')); |
|---|
| | 986 | $ext->add($context, $exten, 'skipoutcid', new ext_agi('fixlocalprefix')); // this sets DIAL_NUMBER to the proper dial string for this trunk |
|---|
| | 987 | $ext->add($context, $exten, '', new ext_set('OUTNUM', '${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER}')); // OUTNUM is the final dial number |
|---|
| | 988 | $ext->add($context, $exten, '', new ext_set('custom', '${CUT(OUT_${DIAL_TRUNK},:,1)}')); // Custom trunks are prefixed with "AMP:" |
|---|
| | 989 | |
|---|
| | 990 | // Back to normal processing, whether intracompany or not. |
|---|
| | 991 | // But add the macro-setmusic if we don't want music on this outbound call |
|---|
| | 992 | $ext->add($context, $exten, '', new ext_gotoif('$[$["${MOHCLASS}" = "default"] | $["foo${MOHCLASS}" = "foo"]]', 'gocall')); // Set to YES if we should pump silence |
|---|
| | 993 | $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', 'M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS}')); // set MoH or off |
|---|
| | 994 | |
|---|
| | 995 | // This macro call will always be blank and is provided as a hook for customization required prior to making a call |
|---|
| | 996 | // such as adding SIP header information or other requirements. All the channel variables from above are present |
|---|
| | 997 | |
|---|
| | 998 | $ext->add($context, $exten, 'gocall', new ext_macro('dialout-trunk-predial-hook')); |
|---|
| | 999 | $ext->add($context, $exten, '', new ext_gotoif('$["${PREDIAL_HOOK_RET}" = "BYPASS"]', 'bypass,1')); |
|---|
| | 1000 | |
|---|
| | 1001 | $ext->add($context, $exten, '', new ext_gotoif('$["${custom}" = "AMP"]', 'customtrunk')); |
|---|
| | 1002 | $ext->add($context, $exten, '', new ext_dial('${OUT_${DIAL_TRUNK}}/${OUTNUM}', '300,${DIAL_TRUNK_OPTIONS}')); // Regular Trunk Dial |
|---|
| | 1003 | $ext->add($context, $exten, '', new ext_goto(1, 's-${DIALSTATUS}')); |
|---|
| | 1004 | |
|---|
| | 1005 | $ext->add($context, $exten, 'customtrunk', new ext_set('pre_num', '${CUT(OUT_${DIAL_TRUNK},$,1)}')); |
|---|
| | 1006 | $ext->add($context, $exten, '', new ext_set('the_num', '${CUT(OUT_${DIAL_TRUNK},$,2)}')); // this is where we expect to find string OUTNUM |
|---|
| | 1007 | $ext->add($context, $exten, '', new ext_set('post_num', '${CUT(OUT_${DIAL_TRUNK},$,3)}')); |
|---|
| | 1008 | $ext->add($context, $exten, '', new ext_gotoif('$["${the_num}" = "OUTNUM"]', 'outnum', 'skipoutnum')); // if we didn't find "OUTNUM", then skip to Dial |
|---|
| | 1009 | $ext->add($context, $exten, 'outnum', new ext_set('the_num', '${OUTNUM}')); // replace "OUTNUM" with the actual number to dial |
|---|
| | 1010 | $ext->add($context, $exten, 'skipoutnum', new ext_dial('${pre_num:4}${the_num}${post_num}', '300,${DIAL_TRUNK_OPTIONS}')); |
|---|
| | 1011 | $ext->add($context, $exten, '', new ext_goto(1, 's-${DIALSTATUS}')); |
|---|
| | 1012 | |
|---|
| | 1013 | $ext->add($context, $exten, 'chanfull', new ext_noop('max channels used up')); |
|---|
| | 1014 | |
|---|
| | 1015 | $exten = 's-BUSY'; |
|---|
| | 1016 | $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting BUSY - giving up')); |
|---|
| | 1017 | $ext->add($context, $exten, '', new ext_playtones('busy')); |
|---|
| | 1018 | $ext->add($context, $exten, '', new ext_busy(20)); |
|---|
| | 1019 | |
|---|
| | 1020 | $exten = 's-NOANSWER'; |
|---|
| | 1021 | $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting NOANSWER - giving up')); |
|---|
| | 1022 | $ext->add($context, $exten, '', new ext_playtones('congestion')); |
|---|
| | 1023 | $ext->add($context, $exten, '', new ext_congestion(20)); |
|---|
| | 1024 | |
|---|
| | 1025 | $exten = 's-CANCEL'; |
|---|
| | 1026 | $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting CANCEL - giving up')); |
|---|
| | 1027 | $ext->add($context, $exten, '', new ext_playtones('congestion')); |
|---|
| | 1028 | $ext->add($context, $exten, '', new ext_congestion(20)); |
|---|
| | 1029 | |
|---|
| | 1030 | $exten = '_s-.'; |
|---|
| | 1031 | $ext->add($context, $exten, '', new ext_gotoif('$["x${OUTFAIL_${ARG1}}" = "x"]', 'noreport')); |
|---|
| | 1032 | $ext->add($context, $exten, '', new ext_agi('${OUTFAIL_${ARG1}}')); |
|---|
| | 1033 | $ext->add($context, $exten, 'noreport', new ext_noop('TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks')); |
|---|
| | 1034 | |
|---|
| | 1035 | $ext->add($context, 'disabletrunk', '', new ext_noop('TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk')); |
|---|
| | 1036 | $ext->add($context, 'bypass', '', new ext_noop('TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook')); |
|---|
| | 1037 | |
|---|
| | 1038 | $ext->add($context, 'h', '', new ext_macro('hangupcall')); |
|---|
| | 1039 | |
|---|
| | 1040 | |
|---|
| | 1041 | /* |
|---|
| | 1042 | * sets the callerid of the device to that of the logged in user |
|---|
| | 1043 | * |
|---|
| | 1044 | * ${AMPUSER} is set upon return to the real user despite any aliasing that may |
|---|
| | 1045 | * have been set as a result of the AMPUSER/<nnn>/cidnum field. This is used by |
|---|
| | 1046 | * features like DND, CF, etc. to set the proper structure on aliased instructions |
|---|
| | 1047 | */ |
|---|
| | 1048 | $context = 'macro-user-callerid'; |
|---|
| | 1049 | $exten = 's'; |
|---|
| | 1050 | |
|---|
| | 1051 | $ext->add($context, $exten, '', new ext_noop('user-callerid: ${CALLERID(name)} ${CALLERID(number)}')); |
|---|
| | 1052 | |
|---|
| | 1053 | // make sure AMPUSER is set if it doesn't get set below |
|---|
| | 1054 | $ext->add($context, $exten, '', new ext_set('AMPUSER', '${IF($["foo${AMPUSER}" = "foo"]?${CALLERID(number)}:${AMPUSER})}')); |
|---|
| | 1055 | $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:5}" = "Local"]', 'report')); |
|---|
| | 1056 | $ext->add($context, $exten, '', new ext_execif('$["${REALCALLERIDNUM:1:2}" = ""]', 'Set', 'REALCALLERIDNUM=${CALLERID(number)}')); |
|---|
| | 1057 | $ext->add($context, $exten, 'start', new ext_noop('REALCALLERIDNUM is ${REALCALLERIDNUM}')); |
|---|
| | 1058 | $ext->add($context, $exten, '', new ext_set('AMPUSER', '${DB(DEVICE/${REALCALLERIDNUM}/user)}')); |
|---|
| | 1059 | $ext->add($context, $exten, '', new ext_set('AMPUSERCIDNAME', '${DB(AMPUSER/${AMPUSER}/cidname)}')); |
|---|
| | 1060 | $ext->add($context, $exten, '', new ext_gotoif('$["x${AMPUSERCIDNAME:1:2}" = "x"]', 'report')); |
|---|
| | 1061 | |
|---|
| | 1062 | // user may masquerade as a different user internally, so set the internal cid as indicated |
|---|
| | 1063 | // but keep the REALCALLERID which is used to determine their true identify and lookup info |
|---|
| | 1064 | // during outbound calls. |
|---|
| | 1065 | $ext->add($context, $exten, '', new ext_set('AMPUSERCID', '${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})}')); |
|---|
| | 1066 | $ext->add($context, $exten, '', new ext_set('CALLERID(all)', '"${AMPUSERCIDNAME}" <${AMPUSERCID}>')); |
|---|
| | 1067 | $ext->add($context, $exten, '', new ext_set('REALCALLERIDNUM', '${DB(DEVICE/${REALCALLERIDNUM}/user)}')); |
|---|
| | 1068 | $ext->add($context, $exten, '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/language)}" != ""]', 'Set', 'LANGUAGE()=${DB(AMPUSER/${AMPUSER}/language)}')); |
|---|
| | 1069 | $ext->add($context, $exten, 'report', new ext_noop('TTL: ${TTL} ARG1: ${ARG1}')); |
|---|
| | 1070 | $ext->add($context, $exten, '', new ext_gotoif('$[ "${ARG1}" = "SKIPTTL" ]', 'continue')); |
|---|
| | 1071 | $ext->add($context, $exten, 'report2', new ext_set('__TTL', '${IF($["foo${TTL}" = "foo"]?64:$[ ${TTL} - 1 ])}')); |
|---|
| | 1072 | $ext->add($context, $exten, '', new ext_gotoif('$[ ${TTL} > 0 ]', 'continue')); |
|---|
| | 1073 | $ext->add($context, $exten, '', new ext_wait('${RINGTIMER}')); // wait for a while, to give it a chance to be picked up by voicemail |
|---|
| | 1074 | $ext->add($context, $exten, '', new ext_answer()); |
|---|
| | 1075 | $ext->add($context, $exten, '', new ext_wait('2')); |
|---|
| | 1076 | $ext->add($context, $exten, '', new ext_playback('im-sorry&an-error-has-occured&with&call-forwarding')); |
|---|
| | 1077 | $ext->add($context, $exten, '', new ext_macro('hangupcall')); |
|---|
| | 1078 | $ext->add($context, $exten, '', new ext_congestion(20)); |
|---|
| | 1079 | $ext->add($context, $exten, 'continue', new ext_noop('Using CallerID ${CALLERID(all)}')); |
|---|
| | 1080 | $ext->add($context, 'h', '', new ext_macro('hangupcall')); |
|---|
| | 1081 | |
|---|
| | 1082 | /* |
|---|
| | 1083 | * arg1 = trunk number, arg2 = number |
|---|
| | 1084 | * |
|---|
| | 1085 | * Re-written to use enumlookup.agi |
|---|
| | 1086 | */ |
|---|
| | 1087 | |
|---|
| | 1088 | $context = 'macro-dialout-enum'; |
|---|
| | 1089 | $exten = 's'; |
|---|
| | 1090 | |
|---|
| | 1091 | $ext->add($context, $exten, '', new ext_execif('$[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]', 'Authenticate', '${ARG3}')); |
|---|
| | 1092 | $ext->add($context, $exten, '', new ext_macro('outbound-callerid', '${ARG1}')); |
|---|
| | 1093 | $ext->add($context, $exten, '', new ext_set('GROUP()', 'OUT_${ARG1}')); |
|---|
| | 1094 | $ext->add($context, $exten, '', new ext_gotoif('$["${OUTMAXCHANS_${ARG1}}foo" = "foo"]', 'nomax')); |
|---|
| | 1095 | $ext->add($context, $exten, '', new ext_gotoif('$[ ${GROUP_COUNT(OUT_${ARG1})} > ${OUTMAXCHANS_${ARG1}} ]', 'nochans')); |
|---|
| | 1096 | $ext->add($context, $exten, 'nomax', new ext_set('DIAL_NUMBER', '${ARG2}')); |
|---|
| | 1097 | $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK', '${ARG1}')); |
|---|
| | 1098 | $ext->add($context, $exten, '', new ext_agi('fixlocalprefix')); // this sets DIAL_NUMBER to the proper dial string for this trunk |
|---|
| | 1099 | // Replacement for asterisk's ENUMLOOKUP function |
|---|
| | 1100 | $ext->add($context, $exten, '', new ext_agi('enumlookup.agi')); |
|---|
| | 1101 | // Now we have the variable DIALARR set to a list of URI's that can be called, in order of priority |
|---|
| | 1102 | // Loop through them trying them in order. |
|---|
| | 1103 | $ext->add($context, $exten, 'dialloop', new ext_gotoif('$["foo${DIALARR}"="foo"]', 'end')); |
|---|
| | 1104 | $ext->add($context, $exten, '', new ext_set('TRYDIAL', '${CUT(DIALARR,%,1)}')); |
|---|
| | 1105 | $ext->add($context, $exten, '', new ext_set('DIALARR', '${CUT(DIALARR,%,2-)}')); |
|---|
| | 1106 | $ext->add($context, $exten, '', new ext_dial('${TRYDIAL}', '')); |
|---|
| | 1107 | $ext->add($context, $exten, '', new ext_noop('Dial exited in macro-enum-dialout with ${DIALSTATUS}')); |
|---|
| | 1108 | // Now, if we're still here, that means the Dial failed for some reason. |
|---|
| | 1109 | // If it's CONGESTION or CHANUNAVAIL we want to try again on a different |
|---|
| | 1110 | // different channel. If there's no more left, the dialloop tag will exit. |
|---|
| | 1111 | $ext->add($context, $exten, '', new ext_gotoif('$[ $[ "${DIALSTATUS}" = "CHANUNAVAIL" ] | $[ "${DIALSTATUS}" = "CONGESTION" ] ]', 'dialloop')); |
|---|
| | 1112 | // If we're here, then it's BUSY or NOANSWER or something and well, deal with it. |
|---|
| | 1113 | $ext->add($context, $exten, 'dialfailed', new ext_goto(1, 's-${DIALSTATUS}')); |
|---|
| | 1114 | // Here are the exit points for the macro. |
|---|
| | 1115 | $ext->add($context, $exten, 'nochans', new ext_noop('max channels used up')); |
|---|
| | 1116 | $ext->add($context, $exten, 'end', new ext_noop('Exiting macro-dialout-enum')); |
|---|
| | 1117 | $ext->add($context, 's-BUSY', '', new ext_noop('Trunk is reporting BUSY')); |
|---|
| | 1118 | $ext->add($context, 's-BUSY', '', new ext_busy(20)); |
|---|
| | 1119 | $ext->add($context, '_s-.', '', new ext_noop('Dial failed due to ${DIALSTATUS}')); |
|---|
| | 1120 | |
|---|
| | 1121 | /* |
|---|
| | 1122 | * overrides callerid out trunks |
|---|
| | 1123 | * arg1 is trunk |
|---|
| | 1124 | * macro-user-callerid should be called _before_ using this macro |
|---|
| | 1125 | */ |
|---|
| | 1126 | |
|---|
| | 1127 | $context = 'macro-outbound-callerid'; |
|---|
| | 1128 | $exten = 's'; |
|---|
| | 1129 | |
|---|
| | 1130 | // Keep the original CallerID number, for failover to the next trunk. |
|---|
| | 1131 | $ext->add($context, $exten, '', new ext_gotoif('$["${REALCALLERIDNUM:1:2}" != ""]', 'start')); |
|---|
| | 1132 | $ext->add($context, $exten, '', new ext_set('REALCALLERIDNUM', '${CALLERID(number)}')); |
|---|
| | 1133 | $ext->add($context, $exten, 'start', new ext_noop('REALCALLERIDNUM is ${REALCALLERIDNUM}')); |
|---|
| | 1134 | |
|---|
| | 1135 | // If this came through a ringgroup or CF, then we want to retain original CID unless |
|---|
| | 1136 | // OUTKEEPCID_${trunknum} is set. |
|---|
| | 1137 | // Save then CIDNAME while it is still intact in case we end up sending out this same CID |
|---|
| | 1138 | $ext->add($context, $exten, '', new ext_gotoif('$["${KEEPCID}" != "TRUE"]', 'normcid')); // Set to TRUE if coming from ringgroups, CF, etc. |
|---|
| | 1139 | $ext->add($context, $exten, '', new ext_gotoif('$["x${OUTKEEPCID_${ARG1}}" = "xon"]', 'normcid')); |
|---|
| | 1140 | $ext->add($context, $exten, '', new ext_gotoif('$["foo${REALCALLERIDNUM}" = "foo"]', 'normcid')); // if not set to anything, go through normal processing |
|---|
| | 1141 | $ext->add($context, $exten, '', new ext_set('USEROUTCID', '${REALCALLERIDNUM}')); |
|---|
| | 1142 | $ext->add($context, $exten, '', new ext_set('REALCALLERIDNAME', '${CALLERID(name)}')); |
|---|
| | 1143 | |
|---|
| | 1144 | // We now have to make sure the CID is valid. If we find an AMPUSER with the same CID, we assume it is an internal |
|---|
| | 1145 | // call (would be quite a conincidence if not) and go through the normal processing to get that CID. If a device |
|---|
| | 1146 | // is set for this CID, then it must be internal |
|---|
| | 1147 | // If we end up using USEROUTCID at the end, it may still be the REALCALLERIDNUM we saved above. That is determined |
|---|
| | 1148 | // if the two are equal, AND there is no CALLERID(name) present since it has been removed by the CALLERID(all)=${USEROUTCID} |
|---|
| | 1149 | // setting. If this is the case, then we put the orignal name back in to send out. Although the CNAME is not honored by most |
|---|
| | 1150 | // carriers, there are cases where it is so this preserves that information to be used by those carriers who do honor it. |
|---|
| | 1151 | $ext->add($context, $exten, '', new ext_gotoif('$["foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = "foo"]', 'bypass', 'normcid')); |
|---|
| | 1152 | |
|---|
| | 1153 | $ext->add($context, $exten, 'normcid', new ext_set('USEROUTCID', '${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)}')); |
|---|
| | 1154 | $ext->add($context, $exten, 'bypass', new ext_set('EMERGENCYCID', '${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)}')); |
|---|
| | 1155 | $ext->add($context, $exten, '', new ext_set('TRUNKOUTCID', '${OUTCID_${ARG1}}')); |
|---|
| | 1156 | $ext->add($context, $exten, '', new ext_gotoif('$["${EMERGENCYROUTE:1:2}" = ""]', 'trunkcid')); // check EMERGENCY ROUTE |
|---|
| | 1157 | $ext->add($context, $exten, '', new ext_gotoif('$["${EMERGENCYCID:1:2}" = ""]', 'trunkcid')); // empty EMERGENCY CID, so default back to trunk |
|---|
| | 1158 | $ext->add($context, $exten, '', new ext_set('CALLERID(all)', '${EMERGENCYCID}')); // emergency cid for device |
|---|
| | 1159 | $ext->add($context, $exten, '', new ext_goto('report')); |
|---|
| | 1160 | $ext->add($context, $exten, 'trunkcid', new ext_gotoif('$["${TRUNKOUTCID:1:2}" = ""]', 'usercid')); // check for CID override for trunk (global var) |
|---|
| | 1161 | $ext->add($context, $exten, '', new ext_set('CALLERID(all)', '${TRUNKOUTCID}')); |
|---|
| | 1162 | $ext->add($context, $exten, 'usercid', new ext_gotoif('$["${USEROUTCID:1:2}" = ""]', 'report')); // check CID override for extension |
|---|
| | 1163 | $ext->add($context, $exten, '', new ext_set('CALLERID(all)', '${USEROUTCID}')); |
|---|
| | 1164 | $ext->add($context, $exten, '', new ext_gotoif('$["x${CALLERID(name)}"!="xhidden"]', 'checkname', 'hidecid')); // check CID blocking for extension |
|---|
| | 1165 | $ext->add($context, $exten, 'hidecid', new ext_setcallerpres('prohib_passed_screen')); // Only works with ISDN (T1/E1/BRI) |
|---|
| | 1166 | $ext->add($context, $exten, 'checkname', new ext_execif('$[ $[ "${CALLERID(number)}" = "${REALCALLERIDNUM}" ] & $[ "${CALLERID(name)}" = "" ] ]', 'Set', 'CALLERID(name)=${REALCALLERIDNAME}')); |
|---|
| | 1167 | $ext->add($context, $exten, 'report', new ext_noop('CallerID set to ${CALLERID(all)}')); |
|---|
| | 1168 | |
|---|
| | 1169 | |
|---|
| | 1170 | /* |
|---|
| | 1171 | * Adds a dynamic agent/member to a Queue |
|---|
| | 1172 | * Prompts for call-back number - in not entered, uses CIDNum |
|---|
| | 1173 | */ |
|---|
| | 1174 | |
|---|
| | 1175 | $context = 'macro-agent-add'; |
|---|
| | 1176 | $exten = 's'; |
|---|
| | 1177 | |
|---|
| | 1178 | $ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| | 1179 | $ext->add($context, $exten, '', new ext_macro('user-callerid', 'SKIPTTL')); |
|---|
| | 1180 | $ext->add($context, $exten, 'a3', new ext_read('CALLBACKNUM', 'agent-user')); // get callback number from user |
|---|
| | 1181 | $ext->add($context, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" != ""]', 'a7')); // if user just pressed # or timed out, use cidnum |
|---|
| | 1182 | $ext->add($context, $exten, 'a5', new ext_set('CALLBACKNUM', '${AMPUSER}')); |
|---|
| | 1183 | $ext->add($context, $exten, '', new ext_execif('$["${CALLBACKNUM}" = ""]', 'Set', 'CALLBACKNUM=${CALLERID(number)}')); |
|---|
| | 1184 | $ext->add($context, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" = ""]', 'a3')); // if still no number, start over |
|---|
| | 1185 | $ext->add($context, $exten, 'a7', new ext_gotoif('$["${CALLBACKNUM}" = "${ARG1}"]', 'invalid')); // Error, they put in the queue number |
|---|
| | 1186 | $ext->add($context, $exten, '', new ext_execif('$["${ARG2}" != ""]', 'Authenticate', '${ARG2}')); |
|---|
| | 1187 | $ext->add($context, $exten, 'a9', new ext_addqueuemember('${ARG1}', 'Local/${CALLBACKNUM}@from-internal/n')); // using chan_local allows us to have agents over trunks |
|---|
| | 1188 | $ext->add($context, $exten, '', new ext_userevent('Agentlogin', 'Agent: ${CALLBACKNUM}')); |
|---|
| | 1189 | $ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| | 1190 | $ext->add($context, $exten, '', new ext_playback('agent-loginok&with&extension')); |
|---|
| | 1191 | $ext->add($context, $exten, '', new ext_saydigits('${CALLBACKNUM}')); |
|---|
| | 1192 | $ext->add($context, $exten, '', new ext_hangup()); |
|---|
| | 1193 | $ext->add($context, $exten, '', new ext_macroexit()); |
|---|
| | 1194 | $ext->add($context, $exten, 'invalid', new ext_playback('pbx-invalid')); |
|---|
| | 1195 | $ext->add($context, $exten, '', new ext_goto('a3')); |
|---|
| | 1196 | |
|---|
| | 1197 | /* |
|---|
| | 1198 | * Removes a dynamic agent/member from a Queue |
|---|
| | 1199 | * Prompts for call-back number - in not entered, uses CIDNum |
|---|
| | 1200 | */ |
|---|
| | 1201 | |
|---|
| | 1202 | $context = 'macro-agent-del'; |
|---|
| | 1203 | |
|---|
| | 1204 | $ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| | 1205 | $ext->add($context, $exten, '', new ext_macro('user-callerid', 'SKIPTTL')); |
|---|
| | 1206 | $ext->add($context, $exten, 'a3', new ext_read('CALLBACKNUM', 'agent-user')); // get callback number from user |
|---|
| | 1207 | $ext->add($context, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" = ""]', 'a5', 'a7')); // if user just pressed # or timed out, use cidnum |
|---|
| | 1208 | $ext->add($context, $exten, 'a5', new ext_set('CALLBACKNUM', '${AMPUSER}')); |
|---|
| | 1209 | $ext->add($context, $exten, '', new ext_execif('$["${CALLBACKNUM}" = ""]', 'Set', 'CALLBACKNUM=${CALLERID(number)}')); |
|---|
| | 1210 | $ext->add($context, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" = ""]', 'a3')); // if still no number, start over |
|---|
| | 1211 | $ext->add($context, $exten, 'a7', new ext_removequeuemember('${ARG1}', 'Local/${CALLBACKNUM}@from-internal/n')); |
|---|
| | 1212 | $ext->add($context, $exten, '', new ext_userevent('RefreshQueue')); |
|---|
| | 1213 | $ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| | 1214 | $ext->add($context, $exten, '', new ext_playback('agent-loggedoff')); |
|---|
| | 1215 | $ext->add($context, $exten, '', new ext_hangup()); |
|---|
| | 1216 | |
|---|