Ejemplo n.º 1
0
function goCreateContacts()
{
    $trainees = db::runQuery("select * from process_trainee where processed = '0'  and inerror = '0'");
    if ($trainees) {
        foreach ($trainees as $trains) {
            $traineeBatchID = db::esc($trains['ID']);
            $processgroup = db::esc($trains['processgroupID']);
            //check to make sure this item has been procesed in another thread.
            $dupcheck = db::runQuery("select * from process_trainee where processed = '0' and ID = '{$traineeBatchID}'");
            if (!$dupcheck) {
                //do nothing for now, later date we will add some extra processing steps here when volumes increas heavily.
            } else {
                $contactVars = array('givenName' => $trains['firstname'], 'surname' => $trains['lastname'], 'title' => '', 'emailAddress' => $trains['email'], 'mobilephone' => $trains['mobile'], 'organisation' => $trains['workplace'], 'address1' => $trains['address'], 'city' => $trains['suburb'], 'postcode' => $trains['postcode'], 'USI' => $trains['usi'], 'customField_additionalinfo' => $trains['additionalinfo'], 'customField_processingGroupID' => $trains['processgroupID']);
                db::insertQuery("update process_trainee set processed = '2' where ID = '{$traineeBatchID}'");
                $enroll = axcelerate_save_contact($contactVars);
                ob_start();
                echo "Axcelerate Create Contact\n";
                var_dump($enroll);
                echo "\n\nvars:\n\n";
                var_dump($contactVars);
                $extrans_dump = ob_get_clean();
                dlog($extrans_dump, false, $processgroup);
                dlog("is Error: " . $enroll->ERROR, false, $processgroup);
                dlog("Error Message: : " . $enroll->DETAILS, false, $processgroup);
                if ($enroll->ERROR == 1 || $enroll->ERROR == "1" || $enroll->ERROR == true) {
                    $errorMessage = $enroll->DETAILS;
                    db::insertQuery("update process_trainee set processed = '0', inerror = '1' where ID = '{$traineeBatchID}'");
                    $errorMessage = db::esc($errorMessage);
                    db::insertQuery("update process_group set process_status = '99' and errorMessage = '{$errormessage}' where processgroupID = '{$processgroup}'");
                    markGroupError($processgroup, $errorMessage);
                } else {
                    $contactID = db::esc($enroll->CONTACTID);
                    db::insertQuery("update process_trainee set processed = '1', contactID = '{$contactID}' where ID = '{$traineeBatchID}'");
                    checkEnrolmentsComplete();
                }
            }
        }
    }
    return true;
}
function goCreateContacts()
{
    $trainees = db::runQuery("select * from process_trainee where processed = '0'");
    if ($trainees) {
        foreach ($trainees as $trains) {
            $traineeBatchID = db::esc($trains['ID']);
            //check to make sure this item has been procesed in another thread.
            $dupcheck = db::runQuery("select * from process_trainee where processed = '0' and ID = '{$traineeBatchID}'");
            if (!$dupcheck) {
                //do nothing for now, later date we will add some extra processing steps here when volumes increas heavily.
            } else {
                $contactVars = array('givenName' => $trains['firstname'], 'surname' => $trains['lastname'], 'title' => '', 'emailAddress' => $trains['email'], 'mobilephone' => $trains['mobile'], 'organisation' => $trains['workplace'], 'address1' => $trains['address'], 'city' => $trains['suburb'], 'postcode' => $trains['postcode'], 'USI' => $trains['usi'], 'customField_additionalinfo' => $trains['additionalinfo'], 'customField_processingGroupID' => $trains['processgroupID']);
                $enroll = axcelerate_save_contact($contactVars);
                $contactID = db::esc($enroll->CONTACTID);
                db::insertQuery("update process_trainee set processed = '1', contactID = '{$contactID}' where ID = '{$traineeBatchID}'");
                checkEnrolmentsComplete();
            }
        }
    }
    return true;
}