Beispiel #1
0
    def agent_add(self):
        schema = AgentForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent()
            cca.extension = form_result.get('extension')
            endpoint = PbxEndpoint.query.filter_by(user_context=session['context'])\
                        .filter(PbxEndpoint.auth_id==cca.extension).first()
            cca.context = session['context']
            cca.domain = session['context']
            cca.type = 'callback'
            cca.system = 'single_box'
            cca.name = cca.extension+"@"+session['context']
            cca.timeout = form_result.get('timeout', 30)
            cca.contact = "[call_timeout="+cca.timeout+"]user/"+cca.name
            cca.max_no_answer = form_result.get('max_no_answer', 3)
            cca.wrap_up_time = form_result.get('wrap_up_time', 30)
            cca.reject_delay_time = form_result.get('reject_delay_time', 30)
            cca.busy_delay_time = form_result.get('busy_delay_time', 0)
            cca.no_answer_delay_time = form_result.get('no_answer_delay_time', 5)
            cca.record_calls = form_result.get('record_calls', 0)
            cca.status = 'Available'
            cca.state = 'Waiting'
            cca.user_id = endpoint.user_id
            cca.pbx_endpoint_id = endpoint.id

            db.add(cca)
            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #2
0
    def tier_add(self):
        schema = TierForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent.query.filter_by(extension=form_result.get('agent_extension', None))\
                    .filter_by(context=session['context']).first()
            cur_cct = CallCenterTier.query.filter_by(agent=cca.name).first()
            ccq = CallCenterQueue.query.filter_by(name=form_result.get('queue_name', None)).first()

            if cur_cct:
                return "Agent in tier already exists!"

            cct = CallCenterTier()
            cct.extension = cca.extension
            cct.queue_id = ccq.id
            cct.agent_id = cca.id
            cct.queue = str(ccq.name)+"@"+session['context']
            cct.agent = str(cca.extension)+"@"+session['context']
            cct.level = form_result.get('level', 1)
            cct.state = 'Ready'
            cct.position = form_result.get('position', 1)
            cct.context = session['context']
            cct.domain = session['context']

            db.add(cct)
            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #3
0
    def agent_edit(self):
        schema = AgentEditForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent.query.filter_by(context=session['context'])\
                    .filter(CallCenterAgent.id==form_result.get('agent_id')).first()
            cca.extension = form_result.get('extension')
            endpoint = PbxEndpoint.query.filter_by(user_context=session['context'])\
                    .filter(PbxEndpoint.auth_id==cca.extension).first()
            cca.context = session['context']
            cca.domain = session['context']
            cca.type = 'callback'
            cca.record_calls = form_result.get('record_calls', 0)
            cca.timeout = form_result.get('timeout', 30)
            cca.max_no_answer = form_result.get('max_no_answer', 3)
            cca.wrap_up_time = form_result.get('wrap_up_time', 30)
            cca.reject_delay_time = form_result.get('reject_delay_time', 30)
            cca.busy_delay_time = form_result.get('busy_delay_time', 0)
            cca.no_answer_delay_time = form_result.get('no_answer_delay_time', 5)
            cca.user_id = endpoint.user_id
            cca.pbx_endpoint_id = endpoint.id

            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #4
0
    def ccq_edit(self):
        schema = QueueEditForm()
        try:
            form_result = schema.to_python(request.params)
            ccq =  CallCenterQueue.query.filter_by(context=session['context']).filter_by(id=form_result.get('ccq_id')).first()
            ccq.context = session['context']
            ccq.domain = session['context']
            ccq.audio_type = form_result.get('audio_name').split(",")[0]
            ccq.audio_name = form_result.get('audio_name').split(",")[1]
            ccq.moh_sound = form_result.get('moh_sound', 'local_stream://moh')
            ccq.time_base_score = form_result.get('time_base_score', 'system')
            ccq.max_wait_time = form_result.get('max_wait_time', 0)
            ccq.max_wait_time_with_no_agent = form_result.get('max_wait_time_with_no_agent', 0)
            ccq.max_wait_time_with_no_agent_reached = form_result.get('max_wait_time_with_no_agent_reached', 5)
            ccq.tier_rules_apply = form_result.get('tier_rules_apply', False)
            ccq.tier_rule_wait_second = form_result.get('tier_rule_wait_second', 300)
            ccq.tier_rule_wait_multiply_level = form_result.get('tier_rule_wait_multiply_level', False)
            ccq.tier_rule_agent_no_wait = form_result.get('tier_rule_agent_no_wait', False)
            ccq.discard_abandoned_after = form_result.get('discard_abandoned_after', 1800)
            ccq.abandoned_resume_allowed = form_result.get('abandoned_resume_allowed', False)
            ccq.strategy = form_result.get('strategy')
            ccq.failed_route_id = form_result.get('failed_route_id', 0)
            ccq.record_calls = form_result.get('record_calls', False)
            ccq.announce_position = form_result.get('announce_position', False)
            ccq.announce_sound = form_result.get('announce_sound').split(",")[1]
            ccq.announce_frequency = form_result.get('announce_frequency')

            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #5
0
    def agent_add(self):
        schema = AgentForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent()
            cca.extension = form_result.get('extension')
            endpoint = PbxEndpoint.query.filter_by(user_context=session['context'])\
                        .filter(PbxEndpoint.auth_id==cca.extension).first()
            cca.context = session['context']
            cca.domain = session['context']
            cca.type = 'callback'
            cca.system = 'single_box'
            cca.name = cca.extension + "@" + session['context']
            cca.timeout = form_result.get('timeout', 30)
            cca.contact = "[call_timeout=" + cca.timeout + "]user/" + cca.name
            cca.max_no_answer = form_result.get('max_no_answer', 3)
            cca.wrap_up_time = form_result.get('wrap_up_time', 30)
            cca.reject_delay_time = form_result.get('reject_delay_time', 30)
            cca.busy_delay_time = form_result.get('busy_delay_time', 0)
            cca.no_answer_delay_time = form_result.get('no_answer_delay_time',
                                                       5)
            cca.record_calls = form_result.get('record_calls', 0)
            cca.status = 'Available'
            cca.state = 'Waiting'
            cca.user_id = endpoint.user_id
            cca.pbx_endpoint_id = endpoint.id

            db.add(cca)
            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #6
0
    def agent_edit(self):
        schema = AgentEditForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent.query.filter_by(context=session['context'])\
                    .filter(CallCenterAgent.id==form_result.get('agent_id')).first()
            cca.extension = form_result.get('extension')
            endpoint = PbxEndpoint.query.filter_by(user_context=session['context'])\
                    .filter(PbxEndpoint.auth_id==cca.extension).first()
            cca.context = session['context']
            cca.domain = session['context']
            cca.type = 'callback'
            cca.record_calls = form_result.get('record_calls', 0)
            cca.timeout = form_result.get('timeout', 30)
            cca.max_no_answer = form_result.get('max_no_answer', 3)
            cca.wrap_up_time = form_result.get('wrap_up_time', 30)
            cca.reject_delay_time = form_result.get('reject_delay_time', 30)
            cca.busy_delay_time = form_result.get('busy_delay_time', 0)
            cca.no_answer_delay_time = form_result.get('no_answer_delay_time',
                                                       5)
            cca.user_id = endpoint.user_id
            cca.pbx_endpoint_id = endpoint.id

            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #7
0
    def tier_add(self):
        schema = TierForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent.query.filter_by(extension=form_result.get('agent_extension', None))\
                    .filter_by(context=session['context']).first()
            cur_cct = CallCenterTier.query.filter_by(agent=cca.name).first()
            ccq = CallCenterQueue.query.filter_by(
                name=form_result.get('queue_name', None)).first()

            if cur_cct:
                return "Agent in tier already exists!"

            cct = CallCenterTier()
            cct.extension = cca.extension
            cct.queue_id = ccq.id
            cct.agent_id = cca.id
            cct.queue = str(ccq.name) + "@" + session['context']
            cct.agent = str(cca.extension) + "@" + session['context']
            cct.level = form_result.get('level', 1)
            cct.state = 'Ready'
            cct.position = form_result.get('position', 1)
            cct.context = session['context']
            cct.domain = session['context']

            db.add(cct)
            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #8
0
    def edit_crm_account(self, **kw):
        schema = CrmAccountForm()
        try:
            form_result = schema.to_python(request.params)
            crm_account = CrmAccount.query.filter(id=form_result['id']).filter(customer_id=session['customer_id']).first()
            crm_account.first_name = form_result.get("first_name", "Unknown")
            crm_account.last_name = form_result.get("last_name", "Unknown")
            crm_account.customer = form_result.get("customer")
            crm_account.title = form_result.get("title")
            crm_account.email = form_result.get("email")
            crm_account.address = form_result.get("address")
            crm_account.address_2 = form_result.get("address_2")
            crm_account.city = form_result.get("city")
            crm_account.state = form_result.get("state")
            crm_account.zip = form_result.get("zip")
            crm_account.tel = form_result.get("tel")
            crm_account.tel_ext = form_result.get("tel_ext")
            crm_account.mobile = form_result.get("mobile")
            crm_account.active = True if form_result.get('active')=="true" else False
            crm_account.customer_id = session["customer_id"]
            crm_account.user_id = session["user_id"]
            crm_account.crm_campaign_id = form_result.get("crm_campaign_name")
            crm_account.crm_account_status_type_id = form_result.get("status_type_name")
            crm_account.crm_lead_type_id = form_result.get("crm_lead_type_name")
            
            db.add(crm_account)
            db.commit()

        except validators.Invalid, error:
             return 'Error: %s' % error
Beispiel #9
0
    def update_campaign_grid(self, **kw):

        w = loads(urllib.unquote_plus(request.params.get("data")))

        try:
            for data in w['modified']:
                crm_campaign_group = CrmCampaignGroup.query.filter(CrmCampaignGroup.crm_campaign_id==data['id'])\
                        .filter(CrmCampaignGroup.context==session['context']).first()
                CrmGroupMember.query.filter(CrmGroupMember.crm_group_id==crm_campaign_group.crm_group_id).delete()

                for member in data['members'].split(","):
                    if not member.strip().isdigit():
                        continue
                    crm_group_member = CrmGroupMember()
                    crm_group_member.crm_group_id = crm_campaign_group.crm_group_id
                    crm_group_member.extension = member.strip()
                    crm_group_member.context = session['context']

                    db.add(crm_group_member)
                    db.commit()
        except:
            db.rollback()
            return "Error updating campaign."

        return "Successfully updated campaign."
Beispiel #10
0
 def register_login(class_, username, session, request):
     user = User.query.filter_by(username=username).first()
     if user:
         now = datetime.now()
         user.last_login = now
         user.session_id = session.id
         user.remote_addr = request.environ["HTTP_REMOTE_EU"]
         db.commit()
Beispiel #11
0
 def register_login(class_, username, session, request):
     user = db.query(AdminUser).filter(AdminUser.username==username).first()
     if user:
         now = datetime.now()
         user.last_login = now
         user.session_id = session.id
         user.remote_addr = request.environ["HTTP_REMOTE_EU"]
         db.commit()
Beispiel #12
0
    def del_tier(self, **kw):

        try:
            CallCenterTier.query.filter_by(id=request.params.get('id', 0)).delete()
            db.commit()

        except:
            db.rollback()
            return "Error deleting tier agent."

        return  "Successfully deleted tier agent."
Beispiel #13
0
    def del_tier(self, **kw):

        try:
            CallCenterTier.query.filter_by(
                id=request.params.get('id', 0)).delete()
            db.commit()

        except:
            db.rollback()
            return "Error deleting tier agent."

        return "Successfully deleted tier agent."
Beispiel #14
0
    def add_crm_account_note(self, **kw):
        try:
            crm_note = CrmNote()
            crm_note.note = request.params.get('crm_note')
            crm_note.crm_account_id = request.params.get('crm_acct_id')
            crm_note.created = datetime.now()

            db.add(crm_note)
            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #15
0
    def update_agent_grid(self):

        try:
            w = loads(urllib.unquote_plus(request.params.get("data")))

            for i in w['modified']:
                log.debug(w['modified'])
                fsa = CallCenterAgent.query.filter(CallCenterAgent.name==str(i['extension'])+"@"+str(session['context'])).first()
                fsa.status = i['status']

                db.commit()

        except DataInputError, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #16
0
    def update_agent_grid(self):

        try:
            w = loads(urllib.unquote_plus(request.params.get("data")))

            for i in w['modified']:
                log.debug(w['modified'])
                fsa = CallCenterAgent.query.filter(
                    CallCenterAgent.name == str(i['extension']) + "@" +
                    str(session['context'])).first()
                fsa.status = i['status']

                db.commit()

        except DataInputError, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #17
0
    def delete_queue(self, **kw):

        try:
            id = request.params.get('id', None)
            q = CallCenterQueue.query.filter(CallCenterQueue.id==id).filter(CallCenterQueue.context==session['context']).first()

            queue = CallCenterQueue.query.filter(CallCenterQueue.id==q.id).first()
            CallCenterTier.query.filter(CallCenterTier.queue_id==queue.id).delete()
            CallCenterQueue.query.filter(CallCenterQueue.id==q.id).delete()

            db.commit()

            return "Successfully removed queue."

        except Exception, e:
            db.rollback()
            return "Error: %s" % e
Beispiel #18
0
    def update_tier_grid(self):

        try:
            w = loads(urllib.unquote_plus(request.params.get("data")))

            for i in w['modified']:
                log.debug(w['modified'])
                tier = CallCenterTier.query.filter_by(id=i['id']).first()

                tier.state = i['state']
                tier.level = i['level']
                tier.position = i['position']

                db.commit()

        except DataInputError, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #19
0
    def update_tier_grid(self):

        try:
            w = loads(urllib.unquote_plus(request.params.get("data")))

            for i in w['modified']:
                log.debug(w['modified'])
                tier = CallCenterTier.query.filter_by(id=i['id']).first()

                tier.state = i['state']
                tier.level = i['level']
                tier.position = i['position']

                db.commit()

        except DataInputError, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #20
0
    def ccq_edit(self):
        schema = QueueEditForm()
        try:
            form_result = schema.to_python(request.params)
            ccq = CallCenterQueue.query.filter_by(
                context=session['context']).filter_by(
                    id=form_result.get('ccq_id')).first()
            ccq.context = session['context']
            ccq.domain = session['context']
            ccq.audio_type = form_result.get('audio_name').split(",")[0]
            ccq.audio_name = form_result.get('audio_name').split(",")[1]
            ccq.moh_sound = form_result.get('moh_sound', 'local_stream://moh')
            ccq.time_base_score = form_result.get('time_base_score', 'system')
            ccq.max_wait_time = form_result.get('max_wait_time', 0)
            ccq.max_wait_time_with_no_agent = form_result.get(
                'max_wait_time_with_no_agent', 0)
            ccq.max_wait_time_with_no_agent_reached = form_result.get(
                'max_wait_time_with_no_agent_reached', 5)
            ccq.tier_rules_apply = form_result.get('tier_rules_apply', False)
            ccq.tier_rule_wait_second = form_result.get(
                'tier_rule_wait_second', 300)
            ccq.tier_rule_wait_multiply_level = form_result.get(
                'tier_rule_wait_multiply_level', False)
            ccq.tier_rule_agent_no_wait = form_result.get(
                'tier_rule_agent_no_wait', False)
            ccq.discard_abandoned_after = form_result.get(
                'discard_abandoned_after', 1800)
            ccq.abandoned_resume_allowed = form_result.get(
                'abandoned_resume_allowed', False)
            ccq.strategy = form_result.get('strategy')
            ccq.failed_route_id = form_result.get('failed_route_id', 0)
            ccq.record_calls = form_result.get('record_calls', False)
            ccq.announce_position = form_result.get('announce_position', False)
            ccq.announce_sound = form_result.get('announce_sound').split(
                ",")[1]
            ccq.announce_frequency = form_result.get('announce_frequency')

            db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error
Beispiel #21
0
    def delete_queue(self, **kw):

        try:
            id = request.params.get('id', None)
            q = CallCenterQueue.query.filter(CallCenterQueue.id == id).filter(
                CallCenterQueue.context == session['context']).first()

            queue = CallCenterQueue.query.filter(
                CallCenterQueue.id == q.id).first()
            CallCenterTier.query.filter(
                CallCenterTier.queue_id == queue.id).delete()
            CallCenterQueue.query.filter(CallCenterQueue.id == q.id).delete()

            db.commit()

            return "Successfully removed queue."

        except Exception, e:
            db.rollback()
            return "Error: %s" % e
Beispiel #22
0
    def campaign_add(self, **kw):
        schema = CrmCampaignForm()
        try:
            form_result = schema.to_python(request.params)
            crm_campaign = CrmCampaign()
            crm_campaign.name = form_result.get('campaign_name')
            crm_campaign.context = session['context']

            db.add(crm_campaign)
            db.flush()

            crm_group = CrmGroup()
            group.name = form_result.get('campaign_name')
            db.add(crm_group)
            db.flush()

            crm_campaign_group = CrmCampaignGroup()
            crm_campaign_group.name = form_result.get('campaign_name')
            crm_campaign_group.crm_group_id = crm_group.id
            crm_campaign_group.crm_campaign_id = crm_campaign.id
            crm_campaign_group.context = session['context']
            db.add(crm_campaign_group)
            db.flush()

            for extension in form_result.get('campaign_extensions').split(","):
                if not extension.isdigit():
                    continue
                crm_group_member = CrmGroupMember()
                crm_group_member.crm_group_id = crm_group.id
                crm_group_member.context = session['context']
                crm_group_member.extension = extension

                db.add(crm_group_member)
                db.commit()

        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s' % error
Beispiel #23
0
        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error

        route = PbxRoute()
        route.context = session['context']
        route.domain = session['context']
        route.name = form_result['name']
        route.continue_route = True
        route.voicemail_enable = True
        route.voicemail_ext = form_result['name']
        route.pbx_route_type_id = 10
        route.pbx_to_id = ccq.id

        db.add(route)
        db.commit()

        return "Successfully added Call Center queue "+form_result['name']+"."

    @authorize(logged_in)
    def ccq_edit(self):
        schema = QueueEditForm()
        try:
            form_result = schema.to_python(request.params)
            ccq =  CallCenterQueue.query.filter_by(context=session['context']).filter_by(id=form_result.get('ccq_id')).first()
            ccq.context = session['context']
            ccq.domain = session['context']
            ccq.audio_type = form_result.get('audio_name').split(",")[0]
            ccq.audio_name = form_result.get('audio_name').split(",")[1]
            ccq.moh_sound = form_result.get('moh_sound', 'local_stream://moh')
            ccq.time_base_score = form_result.get('time_base_score', 'system')
Beispiel #24
0
        except validators.Invalid, error:
            db.rollback()
            return 'Error: %s.' % error

        route = PbxRoute()
        route.context = session['context']
        route.domain = session['context']
        route.name = form_result['name']
        route.continue_route = True
        route.voicemail_enable = True
        route.voicemail_ext = form_result['name']
        route.pbx_route_type_id = 10
        route.pbx_to_id = ccq.id

        db.add(route)
        db.commit()

        return "Successfully added Call Center queue " + form_result[
            'name'] + "."

    @authorize(logged_in)
    def ccq_edit(self):
        schema = QueueEditForm()
        try:
            form_result = schema.to_python(request.params)
            ccq = CallCenterQueue.query.filter_by(
                context=session['context']).filter_by(
                    id=form_result.get('ccq_id')).first()
            ccq.context = session['context']
            ccq.domain = session['context']
            ccq.audio_type = form_result.get('audio_name').split(",")[0]