예제 #1
0
         if ($enableDupFile) {
             __CrmImportWriteDataToFile($duplicateFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arLead['__CSV_DATA__']);
         }
     } else {
         $arLead['PERMISSION'] = 'IMPORT';
         if (!$CCrmLead->Add($arLead)) {
             $arResult['error']++;
             $arResult['error_data'][] = array('message' => $arLead['RESULT_MESSAGE'], 'data' => $arLead['__CSV_DATA__']);
             __CrmImportWriteDataToFile($errataFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arLead['__CSV_DATA__']);
         } else {
             if (!empty($arLead)) {
                 if (isset($arLead['PRODUCT_ROWS']) && count($arLead['PRODUCT_ROWS']) > 0) {
                     if (!CCrmLead::SaveProductRows($arLead['ID'], $arLead['PRODUCT_ROWS'])) {
                         $arResult['error']++;
                         $arResult['error_data'][] = array('message' => CCrmProductRow::GetLastError(), 'data' => $arLead['__CSV_DATA__']);
                         __CrmImportWriteDataToFile($errataFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arLead['__CSV_DATA__']);
                     }
                 }
                 $arResult['import']++;
             }
         }
     }
 }
 $_SESSION['CRM_IMPORT_FILE_POS'] = $filePos;
 $_SESSION['CRM_IMPORT_FILE_FIRST_HEADER'] = false;
 if ($arResult['error'] > 0) {
     $arResult['errata_url'] = SITE_DIR . 'bitrix/components/bitrix/crm.lead.import/show_file.php?name=errata';
 }
 if ($enableDupFile && $arResult['duplicate'] > 0) {
     $arResult['duplicate_url'] = SITE_DIR . 'bitrix/components/bitrix/crm.lead.import/show_file.php?name=duplicate';
 }
예제 #2
0
                 }
                 unset($item);
             }
         }
     }
     if ($isDuplicate) {
         $arResult['duplicate']++;
         if ($enableDupFile) {
             __CrmImportWriteDataToFile($duplicateFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arData);
         }
     } else {
         $arCompany['PERMISSION'] = 'IMPORT';
         if (!$CCrmCompany->Add($arCompany)) {
             $arResult['error']++;
             $arResult['error_data'][] = array('message' => $arCompany['RESULT_MESSAGE'], 'data' => $arData);
             __CrmImportWriteDataToFile($errataFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arData);
         } else {
             if (!empty($arCompany)) {
                 $arResult['import']++;
             }
         }
     }
     $processedQty++;
     if ($processedQty == 20) {
         break;
     }
 }
 $_SESSION['CRM_IMPORT_FILE_POS'] = $csvFile->GetPos();
 $_SESSION['CRM_IMPORT_FILE_FIRST_HEADER'] = false;
 $csvFile->CloseFile();
 if ($arResult['error'] > 0) {