当前位置: 首页>>代码示例>>PHP>>正文


PHP CCrmDeal::SaveProductRows方法代码示例

本文整理汇总了PHP中CCrmDeal::SaveProductRows方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmDeal::SaveProductRows方法的具体用法?PHP CCrmDeal::SaveProductRows怎么用?PHP CCrmDeal::SaveProductRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCrmDeal的用法示例。


在下文中一共展示了CCrmDeal::SaveProductRows方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unset

     $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']);
 $CCrmLead->Update($arLeads['57']['ID'], $arParams);
 // Add activity
 require_once "activity.demo.php";
 $CCrmActivity = new CCrmActivity();
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:index.php

示例2: isset

     if (isset($productID[0])) {
         $arProductRows = CCrmDeal::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($arDeal['OPPORTUNITY']) ? doubleval($arDeal['OPPORTUNITY']) : 0.0, 'QUANTITY' => 1));
         CCrmDeal::SaveProductRows($ID, $arProductRows);
     }
 }
 $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;
         }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:include.php

示例3: CCrmDeal

 }
 $fields['ASSIGNED_BY_ID'] = $assignedByID;
 $entity = new CCrmDeal(false);
 if (!$entity->CheckFields($fields, !$isNew ? $ID : false, array('DISABLE_USER_FIELD_CHECK' => true))) {
     __CrmMobileDealEditEndResonse(array('ERROR' => strip_tags(preg_replace("/<br[^>]*>/", "\n", $entity->LAST_ERROR))));
 } else {
     //$DB->StartTransaction();
     $successed = false;
     if ($isNew) {
         $ID = $entity->Add($fields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
         $successed = $ID !== false;
     } else {
         $successed = $entity->Update($ID, $fields, true, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
     }
     if ($successed && $processProductRows && (!$isNew || !empty($productRows))) {
         $successed = CCrmDeal::SaveProductRows($ID, $productRows, false, true, false);
         if (!$successed) {
             $fields['RESULT_MESSAGE'] = 'Could not save product rows.';
         }
     }
     if ($successed) {
         //$DB->Commit();
         $errors = array();
         CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $ID, $isNew ? CCrmBizProcEventType::Create : CCrmBizProcEventType::Edit, $errors);
         $dbRes = CCrmDeal::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
         $currentItem = $dbRes->GetNext();
         $formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
         CCrmMobileHelper::PrepareDealItem($currentItem, $formatParams);
         __CrmMobileDealEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareDealData($currentItem)));
     } else {
         //$DB->Rollback();
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:ajax.php

示例4: executePhase


//.........这里部分代码省略.........
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::NOT_SYNCHRONIZED);
         }
         if (!ConversionSettings::getCurrent()->isAutocreationEnabled()) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::AUTOCREATION_DISABLED);
         }
         if (\CCrmBizProcHelper::HasAutoWorkflows($entityTypeID, \CCrmBizProcEventType::Create)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::HAS_WORKFLOWS);
         }
         /** @var LeadConversionMapper $mapper */
         $mapper = $this->getMapper();
         $map = self::prepareMap($entityTypeID);
         $fields = $mapper->map($map);
         if (empty($fields)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::EMPTY_FIELDS);
         }
         if ($entityTypeID === \CCrmOwnerType::Company) {
             $entity = new \CCrmCompany(false);
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Company, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             //region BizProcess
             $arErrors = array();
             \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Company, $entityID, \CCrmBizProcEventType::Create, $arErrors);
             //endregion
             $this->resultData[\CCrmOwnerType::CompanyName] = $entityID;
         } elseif ($entityTypeID === \CCrmOwnerType::Contact) {
             if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
                 $fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
             }
             $entity = new \CCrmContact(false);
             if (!$entity->CheckFields($fields)) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::INVALID_FIELDS, $entity->LAST_ERROR);
             }
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Contact, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             //region BizProcess
             $arErrors = array();
             \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Contact, $entityID, \CCrmBizProcEventType::Create, $arErrors);
             //endregion
             $this->resultData[\CCrmOwnerType::ContactName] = $entityID;
         } else {
             if (isset($this->resultData[\CCrmOwnerType::ContactName])) {
                 $fields['CONTACT_ID'] = $this->resultData[\CCrmOwnerType::ContactName];
             }
             if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
                 $fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
             }
             $productRows = isset($fields['PRODUCT_ROWS']) && is_array($fields['PRODUCT_ROWS']) ? $fields['PRODUCT_ROWS'] : array();
             if (!empty($productRows)) {
                 $result = \CCrmProductRow::CalculateTotalInfo('D', 0, false, $fields, $productRows);
                 $fields['OPPORTUNITY'] = isset($result['OPPORTUNITY']) ? $result['OPPORTUNITY'] : 1.0;
                 $fields['TAX_VALUE'] = isset($result['TAX_VALUE']) ? $result['TAX_VALUE'] : 0.0;
             }
             $entity = new \CCrmDeal(false);
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             if (!empty($productRows)) {
                 \CCrmDeal::SaveProductRows($entityID, $productRows, false, false, false);
             }
             //region BizProcess
             $arErrors = array();
             \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Deal, $entityID, \CCrmBizProcEventType::Create, $arErrors);
             //endregion
             $this->resultData[\CCrmOwnerType::DealName] = $entityID;
         }
         return true;
     } elseif ($this->currentPhase === LeadConversionPhase::FINALIZATION) {
         $result = \CCrmLead::GetListEx(array(), array('=ID' => $this->entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('STATUS_ID'));
         $presentFields = is_object($result) ? $result->Fetch() : null;
         if (is_array($presentFields)) {
             $fields = array();
             $statusID = isset($presentFields['STATUS_ID']) ? $presentFields['STATUS_ID'] : '';
             if ($statusID !== 'CONVERTED') {
                 $fields['STATUS_ID'] = 'CONVERTED';
             }
             if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
                 $fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
             }
             if (isset($this->resultData[\CCrmOwnerType::ContactName])) {
                 $fields['CONTACT_ID'] = $this->resultData[\CCrmOwnerType::ContactName];
             }
             if (!empty($fields)) {
                 $entity = new \CCrmLead(false);
                 if ($entity->Update($this->entityID, $fields)) {
                     //region BizProcess
                     $arErrors = array();
                     \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Lead, $this->entityID, \CCrmBizProcEventType::Edit, $arErrors);
                     //endregion
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:leadconverter.php

示例5: executePhase

 public function executePhase()
 {
     if ($this->currentPhase === QuoteConversionPhase::DEAL_CREATION || $this->currentPhase === QuoteConversionPhase::INVOICE_CREATION) {
         if ($this->currentPhase === QuoteConversionPhase::DEAL_CREATION) {
             $entityTypeID = \CCrmOwnerType::Deal;
         } else {
             $entityTypeID = \CCrmOwnerType::Invoice;
         }
         $entityTypeName = \CCrmOwnerType::ResolveName($entityTypeID);
         $config = $this->config->getItem($entityTypeID);
         if (!$config->isActive()) {
             return false;
         }
         /** @var \CCrmPerms $permissions */
         $permissions = $this->getUserPermissions();
         $entityID = isset($this->contextData[$entityTypeName]) ? $this->contextData[$entityTypeName] : 0;
         if ($entityID > 0) {
             if ($entityTypeID === \CCrmOwnerType::Deal) {
                 if (!\CCrmDeal::Exists($entityID)) {
                     throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
                 }
                 $this->resultData[$entityTypeName] = $entityID;
             } else {
                 if (!\CCrmInvoice::Exists($entityID)) {
                     throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Invoice, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
                 }
                 if (!\CCrmInvoice::CheckUpdatePermission($entityID, $permissions)) {
                     throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Invoice, EntityConversionException::TARG_DST, EntityConversionException::UPDATE_DENIED);
                 }
                 $entity = new \CCrmInvoice(false);
                 $fields = array('UF_QUOTE_ID' => $this->entityID);
                 try {
                     $entity->Update($entityID, $fields);
                 } catch (Main\DB\SqlQueryException $e) {
                 }
                 $this->resultData[$entityTypeName] = $entityID;
             }
             return true;
         }
         if (!\CCrmAuthorizationHelper::CheckCreatePermission($entityTypeName, $permissions)) {
             throw new EntityConversionException(\CCrmOwnerType::Quote, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::CREATE_DENIED);
         }
         if (UserFieldSynchronizer::needForSynchronization(\CCrmOwnerType::Quote, $entityTypeID)) {
             throw new EntityConversionException(\CCrmOwnerType::Quote, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::NOT_SYNCHRONIZED);
         }
         if (!ConversionSettings::getCurrent()->isAutocreationEnabled()) {
             throw new EntityConversionException(\CCrmOwnerType::Quote, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::AUTOCREATION_DISABLED);
         }
         if ($entityTypeID === \CCrmOwnerType::Deal && \CCrmBizProcHelper::HasAutoWorkflows($entityTypeID, \CCrmBizProcEventType::Create)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::HAS_WORKFLOWS);
         }
         /** @var QuoteConversionMapper $mapper */
         $mapper = $this->getMapper();
         $map = self::prepareMap($entityTypeID);
         $fields = $mapper->map($map);
         if (empty($fields)) {
             throw new EntityConversionException(\CCrmOwnerType::Quote, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::EMPTY_FIELDS);
         }
         if ($entityTypeID === \CCrmOwnerType::Deal) {
             $entity = new \CCrmDeal(false);
             if (!$entity->CheckFields($fields)) {
                 throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::INVALID_FIELDS, $entity->LAST_ERROR);
             }
             $productRows = isset($fields['PRODUCT_ROWS']) && is_array($fields['PRODUCT_ROWS']) ? $fields['PRODUCT_ROWS'] : array();
             if (!empty($productRows)) {
                 $result = \CCrmProductRow::CalculateTotalInfo('D', 0, false, $fields, $productRows);
                 $fields['OPPORTUNITY'] = isset($result['OPPORTUNITY']) ? $result['OPPORTUNITY'] : 1.0;
                 $fields['TAX_VALUE'] = isset($result['TAX_VALUE']) ? $result['TAX_VALUE'] : 0.0;
             }
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             if (!empty($productRows)) {
                 \CCrmDeal::SaveProductRows($entityID, $productRows, false, false, false);
             }
             $this->resultData[\CCrmOwnerType::DealName] = $entityID;
         } else {
             $entity = new \CCrmInvoice(false);
             if (!$entity->CheckFields($fields)) {
                 throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Invoice, EntityConversionException::TARG_DST, EntityConversionException::INVALID_FIELDS, $entity->LAST_ERROR);
             }
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Quote, \CCrmOwnerType::Invoice, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             $this->resultData[\CCrmOwnerType::InvoiceName] = $entityID;
         }
         return true;
     } elseif ($this->currentPhase === DealConversionPhase::FINALIZATION) {
         $fields = array();
         if (isset($this->resultData[\CCrmOwnerType::DealName])) {
             $fields['DEAL_ID'] = $this->resultData[\CCrmOwnerType::DealName];
         }
         if (!empty($fields)) {
             $entity = new \CCrmQuote(false);
             $entity->Update($this->entityID, $fields);
         }
         return true;
     }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:quoteconverter.php

示例6: setProductRows

 public function setProductRows($ID, $rows)
 {
     $ID = intval($ID);
     if ($ID <= 0) {
         throw new RestException('The parameter id is invalid or not defined.');
     }
     if (!is_array($rows)) {
         throw new RestException('The parameter rows must be array.');
     }
     if (!CCrmDeal::CheckUpdatePermission($ID)) {
         throw new RestException('Access denied.');
     }
     if (!CCrmDeal::Exists($ID)) {
         throw new RestException('Not found.');
     }
     $proxy = new CCrmProductRowRestProxy();
     $actualRows = array();
     $qty = count($rows);
     for ($i = 0; $i < $qty; $i++) {
         $row = $rows[$i];
         if (!is_array($row)) {
             continue;
         }
         $proxy->prepareForSave($row);
         if (isset($row['OWNER_TYPE'])) {
             unset($row['OWNER_TYPE']);
         }
         if (isset($row['OWNER_ID'])) {
             unset($row['OWNER_ID']);
         }
         $actualRows[] = $row;
     }
     return CCrmDeal::SaveProductRows($ID, $actualRows, true, true, true);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:34,代码来源:restservice.php

示例7: foreach

            }
            if ($canBreak && count($arDeals) >= 20) {
                break;
            }
            $arDeals[$dealID] = $arDeal;
            $filePos = $csvFile->GetPos();
        }
        foreach ($arDeals as $arDeal) {
            $arDeal['PERMISSION'] = 'IMPORT';
            if (!$CCrmDeal->Add($arDeal)) {
                $arResult['error']++;
                $arResult['error_data'][] = array('message' => $arDeal['RESULT_MESSAGE'], 'data' => $arDeal['__CSV_DATA__']);
            } else {
                if (!empty($arDeal)) {
                    if (isset($arDeal['PRODUCT_ROWS']) && count($arDeal['PRODUCT_ROWS']) > 0) {
                        if (!CCrmDeal::SaveProductRows($arDeal['ID'], $arDeal['PRODUCT_ROWS'])) {
                            $arResult['error']++;
                            $arResult['error_data'][] = array('message' => CCrmProductRow::GetLastError(), 'data' => $arDeal['__CSV_DATA__']);
                        }
                    }
                    $arResult['import']++;
                }
            }
        }
        $_SESSION['CRM_IMPORT_FILE_POS'] = $filePos;
        $_SESSION['CRM_IMPORT_FILE_FIRST_HEADER'] = false;
        Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
        echo CUtil::PhpToJsObject($arResult);
        die;
    }
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例8: array

         $CCrmEvent->Share(array('ENTITY_TYPE' => 'LEAD', 'ENTITY_ID' => $arParams['ELEMENT_ID']), array(array('ENTITY_TYPE' => 'CONTACT', 'ENTITY_ID' => $iContactId)), 'MESSAGE');
         $CCrmContactBizProc = new CCrmBizProc('CONTACT');
         $arContactBizProcParams = $CCrmContactBizProc->CheckFields(false, false, $arFields['CONTACT']['ASSIGNED_BY_ID'], null);
         if ($arContactBizProcParams !== false) {
             $CCrmContactBizProc->StartWorkflow($iContactId, $arContactBizProcParams);
         }
     }
 }
 $arFields['DEAL']['CONTACT_ID'] = $iContactId;
 if (!$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE, 'ADD')) {
     if ($bConvertDeal) {
         $arDealFields = $arFields['DEAL'];
         $iDealId = $CCrmDeal->Add($arDealFields, true, array('REGISTER_SONET_EVENT' => true));
         if ($iDealId > 0) {
             if (!empty($arDealFields['PRODUCT_ROWS'])) {
                 CCrmDeal::SaveProductRows($iDealId, $arDealFields['PRODUCT_ROWS']);
             }
             $CCrmDealBizProc = new CCrmBizProc('DEAL');
             $arDealBizProcParams = $CCrmDealBizProc->CheckFields(false, false, $arDealFields['ASSIGNED_BY_ID'], null);
             if ($arDealBizProcParams !== false) {
                 $CCrmDealBizProc->StartWorkflow($iDealId, $arDealBizProcParams);
             }
         }
     }
 }
 $CCrmLead = new CCrmLead();
 $arFields['LEAD'] = array('STATUS_ID' => 'CONVERTED', 'CONTACT_ID' => $iContactId, 'COMPANY_ID' => $iCompanyId);
 if ($CCrmLead->Update($arParams['ELEMENT_ID'], $arFields['LEAD'], true, true, array('REGISTER_SONET_EVENT' => true))) {
     $arErrors = array();
     CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Lead, $arParams['ELEMENT_ID'], CCrmBizProcEventType::Edit, $arErrors);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php


注:本文中的CCrmDeal::SaveProductRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。