重复现有联系人提醒

时间:2016-12-12 06:52:12

标签: vtiger

在Vtiger 6.5.0开源中,我想创建一个警报功能,警告用户该conact的移动设备是否存在?请你帮助我好吗。我比较新鲜。

谢谢, LOI

3 个答案:

答案 0 :(得分:1)

您可以参考帐户模块中存在的功能来检查重复的帐户名称。

请按照这些文件进行操作。

这是代码流如何在帐户模块中完成

Registring Pre Save Event http://code.vtiger.com/vtiger/vtigercrm/blob/master/layouts/vlayout/modules/Accounts/resources/Edit.js#L250

这个功能可以检查缓存中的Duplicate,如果没有调用Helper功能 http://code.vtiger.com/vtiger/vtigercrm/blob/master/layouts/vlayout/modules/Accounts/resources/Edit.js#L83

这是对服务器进行调用的Helper函数 http://code.vtiger.com/vtiger/vtigercrm/blob/master/resources/helper.js#L166

这是动作函数,负责提供来自Helper Function的请求 http://code.vtiger.com/vtiger/vtigercrm/blob/master/modules/Accounts/actions/CheckDuplicate.php#L30

这是检查Duplicate的函数 http://code.vtiger.com/vtiger/vtigercrm/blob/master/modules/Accounts/models/Record.php#L57

希望这有帮助。

答案 1 :(得分:1)

嗨,Victor请按照以下步骤操作

模块\信息\动作\ Checkprimaryemail.php

<?php

    class Leads_Checkprimaryemail_Action extends Vtiger_BasicAjax_Action {

        public function checkPermission(Vtiger_Request $request) {
            return;
        }

        public function process(Vtiger_Request $request) {
            global $adb;
            $moduleName = $request->get('module');
            $recordId = $request->get('recordId');
            $primary_email = $request->get('primary_email');

            /*Lead Details*/
            $lead_query = "select * from vtiger_leaddetails
                     inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid 
                     where vtiger_crmentity.deleted = 0 and vtiger_leaddetails.email='".$primary_email."'";
            $lead_result = $adb->query($lead_query);
            $lead_email = $adb->query_result($lead_result,0,'email');
            $lead_numrows = $adb->num_rows($lead_result);

            /*Contact Details*/
            $cont_query = "select * from vtiger_contactdetails
                     inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
                     where vtiger_crmentity.deleted = 0 and vtiger_contactdetails.email='".$primary_email."'";
            $cont_result = $adb->query($cont_query);
            $cont_email = $adb->query_result($cont_result,0,'email');
            $cont_numrows = $adb->num_rows($cont_result);

            if($recordId != '' ){
                if($primary_email == $lead_email && $lead_numrows == 1 ){
                    $emailtrue = 0;
                } elseif($primary_email == $cont_email && $cont_numrows >= 1 ) {
                    $emailtrue = 1;
                }
            } else {
                if(($lead_numrows >=1 || $cont_numrows >=1 ) ||  ($lead_numrows >=1 && $cont_numrows >= 1)  ){
                    $emailtrue = 1;
                } else {
                    $emailtrue = 0;
                }
            }

            $emailData = array($emailtrue);
            $response = new Vtiger_Response();
            $response->setResult($emailData);
            $response->emit();

        }
    }

    ?>

创建另一个文件后 布局\ vlayout \模块\信息\资源\ Edit.js

Vtiger_Edit_Js("Leads_Edit_Js", {
}, {
    changeEvent: function (container) {
        jQuery('input[name="email"]').on('focusout', function (e) {
            var email = jQuery('input[name="email"]').val();
            var recordId = jQuery('input[name="record"]').val();
            var email_length = email.length;
            if (email != '') {
                if (email_length > 100) {
                    var errorMessage = app.vtranslate('JS_EMAIL_LENGTH_VALIDATION');
                    params = {
                        text: errorMessage,
                        'type': 'error',
                    };
                    Vtiger_Helper_Js.showMessage(params);
                }

                var progressIndicatorElement = jQuery.progressIndicator({
                    'position': 'html',
                    'blockInfo': {
                        'enabled': true
                    }
                });
                var postData = {
                    "module": 'Leads',
                    "action": "Checkprimaryemail",
                    "primary_email": email,
                    "recordId": recordId
                }
                AppConnector.request(postData).then(
                        function (data) {
                            progressIndicatorElement.progressIndicator({'mode': 'hide'});
                            if (data['result'] == 1) {
                                jQuery('#emailalready_exists').val(1);
                                var errorMessage = app.vtranslate('JS_EMAIL_EXIST');
                                params = {
                                    text: errorMessage,
                                    'type': 'error',
                                };
                                Vtiger_Helper_Js.showMessage(params);
                            } else {
                                jQuery('#emailalready_exists').val(0);
                            }
                        },
                        function (error, err) {}
                );
                e.preventDefault();
            }
        });
    },
    registerBasicEvents: function (container) {
        this._super(container);
        this.changeEvent(container);
    }
});

答案 2 :(得分:0)

要检查vTiger中的重复记录,请按照以下步骤操作: 在checkDuplicate注册registerBasicEvents功能 1:\layouts\vlayout\modules\Contacts\resources\Edit.js

getmobile : function(container){
    return jQuery('input[name="mobile"]',container).val();
},
getRecordId : function(container){
    return jQuery('input[name="record"]',container).val();
},
DuplicateCheck : function(form) {
    var thisInstance = this;
    if(typeof form == 'undefined') {
        form = this.getForm();
    }
     jQuery( "#mobileFieldId" ).change(function() {
            var mobile = thisInstance.getmobile(form);

        var recordId = thisInstance.getRecordId(form);
        var params = {
            'module' : "Contacts",
            'action' : "CheckDuplicate",
            'mobile' : mobile,
            'record' : recordId
        }
        AppConnector.request(params).then(
            function(data) {
                var response = data['result'];
                var result = response['success'];
                if(result == true) {
                    var message_params = {
                        title : app.vtranslate('JS_MESSAGE'),
                        text: response['message'],
                        animation: 'show',
                        type: 'error'
                    };
                    Vtiger_Helper_Js.showPnotify(message_params);
                    jQuery(".btn-success").attr('disabled',true);
                    return false;
                } else {
                    jQuery(".btn-success").attr('disabled',false);
                }
            }
        );
     });
   },

2:在** \modules\Contacts\actions\CheckDuplicate.php中创建新文件 遵循\modules\Accounts\actions\CheckDuplicate.php

中给出的相同流程/代码

3:在checkDuplicate()

中添加新功能\modules\Contacts\models\Record.php

并按照\modules\Accounts\models\Record.php function checkDuplicate()

中的相同流程进行操作

注意:不要忘记更改db表名,类名模块。

希望这会对你有所帮助。谢谢。