Esempio n. 1
0
function getCalls()
{
    //Realiza el query en la base de datos
    $mysqli = makeSqlConnection();
    $sql = "SELECT * FROM calls a LEFT JOIN calls_cstm ac ON a.id = ac.id_c ";
    $sql .= "WHERE a.parent_type IN('Accounts', 'Opportunities','Tasks') AND deleted = '0' ORDER BY name ASC";
    $res = $mysqli->query($sql);
    $rows = array();
    while ($r = mysqli_fetch_assoc($res)) {
        $obj = (object) $r;
        $obj->created_by_name = getNombreUsuario($obj->created_by);
        $obj->assigned_user_name = getNombreUsuario($obj->assigned_user_id);
        $obj->parent_name = getParentName($obj->parent_id, $obj->parent_type);
        $obj->campaign_name = getCampaignName($obj->id);
        $obj->campaign_id = getCampaignId($obj->id);
        $a = (array) $obj;
        $rows[] = $a;
    }
    if (empty($rows)) {
        return '{"results" :[]}';
    } else {
        //Convierte el arreglo en json y lo retorna
        $temp = json_encode(utf8ize($rows));
        return '{"results" :' . $temp . '}';
    }
}
Esempio n. 2
0
function getGenericCall($sql)
{
    //Realiza el query en la base de datos
    $mysqli = makeSqlConnection();
    $res = $mysqli->query($sql);
    $rows = array();
    while ($r = mysqli_fetch_assoc($res)) {
        $obj = (object) $r;
        $obj->created_by_name = getNombreUsuario($obj->created_by);
        $obj->assigned_user_name = getNombreUsuario($obj->assigned_user_id);
        $obj->parent_name = getParentName($obj->parent_id, $obj->parent_type);
        $obj->campaign_name = getCampaignName($obj->id);
        $obj->campaign_id = getCampaignId($obj->id);
        $a = (array) $obj;
        $rows[] = $a;
    }
    if (empty($rows)) {
        return '{"results" :[]}';
    } else {
        //Convierte el arreglo en json y lo retorna
        $temp = json_encode(utf8ize($rows));
        return '{"results" :' . $temp . '}';
    }
}
Esempio n. 3
0
function loadLeadList($baseURL, $userId, $password, $filename, $logLevel)
{
    // Open the CSV file
    $header = NULL;
    $leadDetails = array();
    $loopFlag = TRUE;
    // Loop until the end of the file, or a fatal error occurs
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        // Read in a line, and parse it into an array, using commas as delimiters
        while (($row = fgetcsv($handle, 1000, ',')) !== FALSE && $loopFlag !== FALSE) {
            unset($leadDetails);
            unset($rawLeadDetails);
            // If this is the first row, it must be the header row
            if (!$header) {
                $header = $row;
                // Convert all the field names to lower case, to simplify future comparisons
                for ($i = 0; $i < count($header); $i++) {
                    $header[$i] = strtolower($header[$i]);
                }
            } else {
                // This is a data row. Check whether it's complete. If it isn't, ignore it
                if (count($row) !== count($header)) {
                    if ($logLevel >= 1) {
                        echo "loadLeadList: ERROR - Input row doesn't have the correct number of data fields\n";
                    }
                } else {
                    // This is a complete data row, so put it into an array with the field names as keys
                    $leadDetails = array_combine($header, $row);
                    // If a Campaign Id has been given, use it. If not, look it up from the Campaign Title.
                    $campaignId = 0;
                    if (array_key_exists('campaignid', $leadDetails) && $leadDetails['campaignid'] > 0) {
                        // Pick up the campaign id directly from the input data
                        $campaignId = $leadDetails['campaignid'];
                    } else {
                        // We don't have the Campaign Id, but do we have a Campaign Title?
                        if (array_key_exists('campaigntitle', $leadDetails)) {
                            // We have the Campaign Title, so look up the Campaign Id
                            $campaignId = getCampaignId($baseURL, $userId, $password, $leadDetails['campaigntitle'], $logLevel);
                        } else {
                            // We don't have either the Campaign Id or the Campaign Title, so we can't proceed
                            if ($logLevel >= 1) {
                                echo "loadLeadList: ERROR - Neither Campaign Title nor Campaign Id were provided.\n";
                            }
                        }
                    }
                    // If a List Id has been given, use it. If not, look it up from the List Title.
                    $listId = 0;
                    if ($campaignId != 0) {
                        if (array_key_exists('listid', $leadDetails) && $leadDetails['listid'] > 0) {
                            // Pick up the list id directly from the input data
                            $listId = $leadDetails['listid'];
                        } else {
                            // We don't have the List Id, but do we have a List Title?
                            if (array_key_exists('listtitle', $leadDetails)) {
                                // We have the List Title, so look up the List Id
                                $leadDetails['listid'] = getListId($baseURL, $userId, $password, $campaignId, $leadDetails['listtitle'], $logLevel);
                            } else {
                                // We don't have either the List Id or the List Title, so we can't proceed
                                if ($logLevel >= 1) {
                                    echo "loadLeadList: ERROR - Neither List Title nor List Id were provided.\n";
                                }
                            }
                        }
                    }
                    // If we have both the Campaign Id and the List Id, attempt to load this lead's details
                    if ($campaignId != 0 && $listId != 0) {
                        // If a Campaign or List Title is present, then remove it, otherwise we'll try and load this data into a custom data field
                        if (array_key_exists('campaigntitle', $leadDetails)) {
                            unset($leadDetails['campaigntitle']);
                        }
                        if (array_key_exists('listtitle', $leadDetails)) {
                            unset($leadDetails['listtitle']);
                        }
                        // Set up the Camapign and List Ids, then try and load this lead
                        $leadDetails['campaignid'] = $campaignId;
                        $leadDetails['listid'] = $listId;
                        loadLead($baseURL, $userId, $password, $leadDetails, $logLevel);
                    }
                }
            }
        }
        // Close the input file prior to exit
        fclose($handle);
    } else {
        // Failed to open input file
        if ($logLevel >= 1) {
            echo "loadLeadList: ERROR - Failed to open input file: " . $filename . "\n";
        }
    }
}