예제 #1
0
         }
     }
     $rsLeads = CCrmLead::GetListEx(array('ID' => 'ASC'), array("CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'PRODUCT_ID', 'OPPORTUNITY', 'CURRENCY_ID'));
     while ($arLead = $rsLeads->Fetch()) {
         $ID = isset($arLead['ID']) ? intval($arLead['ID']) : 0;
         if ($ID <= 0) {
             continue;
         }
         $productID = isset($arLead['PRODUCT_ID']) ? $arLead['PRODUCT_ID'] : '';
         if (isset($productID[0])) {
             $arProductRows = CCrmLead::LoadProductRows($ID);
             if (count($arProductRows) > 0) {
                 // already converted
                 continue;
             }
             $arProduct = CCrmProduct::GetByOriginID('CRM_PROD_' . $productID);
             if (!is_array($arProduct)) {
                 continue;
             }
             $productID = isset($arProduct['ID']) ? $arProduct['ID'] : 0;
             if ($productID <= 0) {
                 continue;
             }
             $arProductRows = array(array('PRODUCT_ID' => $productID, 'PRICE' => isset($arLead['OPPORTUNITY']) ? doubleval($arLead['OPPORTUNITY']) : 0.0, 'QUANTITY' => 1));
             CCrmLead::SaveProductRows($ID, $arProductRows);
         }
     }
     COption::SetOptionString('crm', '~crm_11_0_6_convertion', 'Y');
 }
 // <-- Convert LEAD CURRENCY and PRODUCT
 // Convert DEAL EVENTS -->
예제 #2
0
 // Add Deal
 require_once "deal.demo.php";
 $CCrmDeal = new CCrmDeal();
 foreach ($arDeals as $ID => &$arParams) {
     $arProductRows = null;
     if (isset($arParams['PRODUCT_ROWS'])) {
         $arProductRows = $arParams['PRODUCT_ROWS'];
         unset($arParams['PRODUCT_ROWS']);
     }
     $arParams['CURRENCY_ID'] = $currencyID;
     $dealID = $CCrmDeal->Add($arParams);
     $arDeals[$ID]['ID'] = $dealID;
     if (is_array($arProductRows)) {
         foreach ($arProductRows as &$arProductRow) {
             $originID = $arProductRow['ORIGIN_ID'];
             $arProduct = CCrmProduct::GetByOriginID($originID, $catalogID);
             if (!is_array($arProduct)) {
                 continue;
             }
             CCrmDeal::SaveProductRows($dealID, array(array('PRODUCT_ID' => intval($arProduct['ID']), 'PRICE' => doubleval($arProduct['PRICE']), 'QUANTITY' => 1)));
         }
     }
 }
 // Add event
 require_once "event.demo.php";
 $CCrmEvent = new CCrmEvent();
 foreach ($arEvents as $ID => $arParams) {
     $arEvents[$ID]['ID'] = $CCrmEvent->Add($arParams);
 }
 // Add relation
 $arParams = array('COMPANY_ID' => $arCompany['39']['ID'], 'CONTACT_ID' => $arContacts['51']['ID']);
예제 #3
0
     if (isset($arStatus['SOURCE_LIST'][$data])) {
         // 1. Try to interpret value as ID
         $arLead[$currentKey] = $data;
     } else {
         $result = array_search($data, $arStatus['SOURCE_LIST']);
         $arLead[$currentKey] = $result !== false ? $result : $data;
     }
 } elseif ($currentKey == 'CURRENCY_ID') {
     $currency = CCrmCurrency::GetByName($data);
     if (!$currency) {
         $currency = CCrmCurrency::GetByID($data);
     }
     $arLead[$currentKey] = $currency ? $currency['CURRENCY'] : CCrmCurrency::GetBaseCurrencyID();
 } elseif ($currentKey == 'PRODUCT_ID') {
     // For compatibility
     $arProduct = CCrmProduct::GetByOriginID('CRM_PROD_' . $data);
     if (is_array($arProduct)) {
         $arProductRow = array('PRODUCT_ID' => $arProduct['ID'], 'QUANTITY' => 1);
         // PRICE equals to OPPORTUNITY. We will set PRICE latter
     } else {
         $arProduct = CCrmProduct::GetByName($data);
         if ($arProduct) {
             $arProductRow['PRODUCT_ID'] = $arProduct['ID'];
         } else {
             $arProductRow['PRODUCT_ID'] = 0;
         }
         $arProductRow['PRODUCT_NAME'] = $data;
     }
 } elseif ($currentKey == 'PRODUCT_PRICE') {
     // Process price only if product has been resolved
     if (isset($arProductRow['PRODUCT_ID'])) {