$todaysDate = date('Y-m-d\\TH:i:s');
$currentDate = date('Y-m-d H:i:s');
$yestDate = date('Y-m-d H:i:s', strtotime($currentDate . ' - 1 days'));
$sourceFrom = date('Y-m-d', strtotime($currentDate . ' - 1 days'));
$result = $client->call($session, 'customer.list', array(array('created_at' => array('from' => "{$sourceFrom}"))));
if (isset($result)) {
    /*var_dump($result); exit;*/
    $domtree = new DOMDocument('1.0', 'UTF-8');
    $xmlRoot = $domtree->createElement('DOCUMENT');
    $xmlRoot = $domtree->appendChild($xmlRoot);
    $customersNode = $domtree->createElement('CUSTOMERS');
    $customersNode = $xmlRoot->appendChild($customersNode);
    $count = 0;
    /*while ($customerData = mysql_fetch_array($result))*/
    foreach ($result as $customerData) {
        $generatedId = addCustomerToIndex($customerData['customer_id']);
        $customerNode = createNode($domtree, $customersNode, 'CUSTOMER');
        $customerAddsNode = createNode($domtree, $customerNode, 'CUST_ADDRESSS');
        $customerAddNode = createNode($domtree, $customerAddsNode, 'CUST_ADDRESS');
        $customerSupplsNode = createNode($domtree, $customerNode, 'CUST_SUPPLS');
        for ($i = 1; $i <= 20; $i++) {
            $customerSupplNode = createNode($domtree, $customerSupplsNode, 'CUST_SUPPL');
            $udf_no = $domtree->createAttribute('udf_no');
            $customerSupplNode->appendChild($udf_no);
            $udf_noValue = $domtree->createTextNode($i);
            $udf_no->appendChild($udf_noValue);
            $udf_value = $domtree->createAttribute('udf_value');
            $customerSupplNode->appendChild($udf_value);
            $udf_valueValue = $domtree->createTextNode('');
            $udf_value->appendChild($udf_valueValue);
        }
     foreach ($xmlDoc->CUSTOMERS->CUSTOMER as $customer) {
         $email = $customer['email_addr'];
         if (isset($email) && strlen($email) > 0) {
             //build the customer object
             $firstName = $customer['first_name'];
             $lastName = $customer['last_name'];
             $magentoCustomer = array('email' => "{$email}", 'firstname' => "{$firstName}", 'lastname' => "{$lastName}", 'password' => '%hj88256jkl', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1);
             //push the customer via the API
             try {
                 $result = $client->call($session, 'customer.create', array($magentoCustomer));
                 $result = intval($result);
                 //if result is an Integer i.e ID
                 if ($result != 0) {
                     $count++;
                     logMessage($count . ' customers imported');
                     addCustomerToIndex($result, $customer['cust_sid']);
                 }
             } catch (Exception $e) {
                 logMessage('Error: ' . $e->getMessage());
             }
         } else {
             logMessage('Customer ' . $customer['first_name'] . ' has no email address, cannot import');
         }
     }
 }
 try {
     $hasMoved = rename('customer-uploads/' . $sourceFile, 'backups/' . $sourceFile);
     if ($hasMoved) {
         logMessage($sourceFile . ' processed and moved to the backups folder');
     } else {
         logMessage($sourceFile . ' File could not be moved');