Ejemplo n.º 1
0
/**
 * Function used to transfer all the lead related records to given Entity(Contact/Account) record
 * @param $leadid - leadid
 * @param $relatedid - related entity id (contactid/accountid)
 * @param $setype - related module(Accounts/Contacts)
 */
function vtws_transferLeadRelatedRecords($leadId, $relatedId, $seType)
{
    global $adb;
    if (empty($leadId) || empty($relatedId) || empty($seType)) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Records");
    }
    $status = vtws_getRelatedNotesAttachments($leadId, $relatedId);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Documents to the " . $seType);
    }
    //Retrieve the lead related products and relate them with this new account
    $status = vtws_saveLeadRelatedProducts($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Products to the " . $seType);
    }
    $status = vtws_saveLeadRelations($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move Records to the " . $seType);
    }
    $status = vtws_saveLeadRelatedCampaigns($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move Records to the " . $seType);
    }
    vtws_transferComments($leadId, $relatedId);
    // Tags
    $adb->pquery('update vtiger_freetagged_objects set object_id=?,module=? where object_id=?', array($relatedId, $seType, $leadId));
}
Ejemplo n.º 2
0
/**
 * Function used to transfer all the lead related records to given Entity(Contact/Account) record
 * @param $leadid - leadid
 * @param $relatedid - related entity id (contactid/accountid)
 * @param $setype - related module(Accounts/Contacts)
 */
function vtws_transferLeadRelatedRecords($leadId, $relatedId, $seType)
{
    if (empty($leadId) || empty($relatedId) || empty($seType)) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Records");
    }
    $status = vtws_getRelatedNotesAttachments($leadId, $relatedId);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Documents to the " . $seType);
    }
    //Retrieve the lead related products and relate them with this new account
    $status = vtws_saveLeadRelatedProducts($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Products to the " . $seType);
    }
    $status = vtws_saveLeadRelations($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move Records to the " . $seType);
    }
    $status = vtws_saveLeadRelatedCampaigns($leadId, $relatedId, $seType);
    if ($status === false) {
        throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move Records to the " . $seType);
    }
    vtws_transferComments($leadId, $relatedId);
}