Last active
April 15, 2020 13:24
-
-
Save Feiron/136b0a5d145994ff0a8b9da1ce8b97d9 to your computer and use it in GitHub Desktop.
Переводит от менеджера, другому Компани, Лиды, Сделки, Контакты, Дела #utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
define('STOP_STATISTICS', true); | |
define('BX_SECURITY_SHOW_MESSAGE', true); | |
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); | |
use Bitrix\Disk\Configuration; | |
use Bitrix\Disk\Driver; | |
use Bitrix\Disk\ExternalLink; | |
use Bitrix\Disk\File; | |
use Bitrix\Disk\Folder; | |
use Bitrix\Disk\Internals\Error\Error; | |
use Bitrix\Disk\Internals\ExternalLinkTable; | |
use Bitrix\Disk\Internals\ObjectTable; | |
use Bitrix\Disk\Version; | |
use Bitrix\Main\EventResult; | |
use Bitrix\Main\Localization\Loc; | |
use Bitrix\Main\Loader; | |
CModule::IncludeModule('crm'); | |
CModule::IncludeModule('gpw.1cdb'); | |
CModule::IncludeModule('gpw.payments'); | |
CModule::IncludeModule('rest'); | |
\CModule::IncludeModule('intranet'); | |
$bDO = true; | |
$iUserID = 1876; | |
$iToUserID = 1413; | |
/** | |
* LEADS | |
*/ | |
$arParams = array('filter' => array('STATUS_SEMANTIC_ID' => 'P', 'ASSIGNED_BY_ID' => $iUserID)); | |
$dbResult = \Bitrix\Crm\LeadTable::getList($arParams); | |
$obLead = new CCrmLead(false); | |
echo '<pre>'; | |
var_dump($dbResult->getSelectedRowsCount()); | |
echo '</pre>'; | |
while ($arResult = $dbResult->fetch()) { | |
$arFields = array('ASSIGNED_BY_ID' => $iToUserID); | |
if ($bDO) { | |
$obLead->Update($arResult['ID'], $arFields); | |
} | |
echo "LEAD: {$arResult['ID']} {$bDO} <br>"; | |
} | |
echo '==============<br><br>'; | |
/** | |
* DEALS | |
*/ | |
$dbResult = \Bitrix\Crm\DealTable::getList(array('filter' => array('STAGE_SEMANTIC_ID' => 'P', 'ASSIGNED_BY_ID' => $iUserID))); | |
$obDeal = new CCrmDeal(false); | |
echo '<pre>'; | |
var_dump($dbResult->getSelectedRowsCount()); | |
echo '</pre>'; | |
while ($arResult = $dbResult->fetch()) { | |
$arFields = array('ASSIGNED_BY_ID' => $iToUserID); | |
if ($bDO) { | |
$obDeal->Update($arResult['ID'], $arFields); | |
} | |
echo "DEAL: {$arResult['ID']} {$bDO} <br>"; | |
} | |
echo '==============<br><br>'; | |
/** | |
* CONTACTS | |
*/ | |
$dbResult = \Bitrix\Crm\ContactTable::getList(array('filter' => array('ASSIGNED_BY_ID' => $iUserID))); | |
$obContact = new CCrmContact(false); | |
echo '<pre>'; | |
var_dump($dbResult->getSelectedRowsCount()); | |
echo '</pre>'; | |
while ($arResult = $dbResult->fetch()) { | |
$arFields = array('ASSIGNED_BY_ID' => $iToUserID); | |
if ($bDO) { | |
$obContact->Update($arResult['ID'], $arFields); | |
} | |
echo "CONTACT: {$arResult['ID']} {$bDO} <br>"; | |
} | |
echo '==============<br><br>'; | |
/** | |
* COMPANIES | |
*/ | |
$dbResult = \Bitrix\Crm\CompanyTable::getList(array('filter' => array('ASSIGNED_BY_ID' => $iUserID))); | |
$obCompany = new CCrmCompany(false); | |
echo '<pre>'; | |
var_dump($dbResult->getSelectedRowsCount()); | |
echo '</pre>'; | |
while ($arResult = $dbResult->fetch()) { | |
$arFields = array('ASSIGNED_BY_ID' => $iToUserID); | |
if ($bDO) { | |
$obCompany->Update($arResult['ID'], $arFields); | |
} | |
echo "COMPANY: {$arResult['ID']} {$bDO} <br>"; | |
} | |
echo '==============<br><br>'; | |
/** | |
* ACTIVITIES | |
*/ | |
$dbResult = \Bitrix\Crm\ActivityTable::getList(array('filter' => array('RESPONSIBLE_ID' => $iUserID, 'COMPLETED' => 'N'))); | |
$obActivity = new CCrmActivity(); | |
while ($arResult = $dbResult->fetch()) { | |
$arFields = array('RESPONSIBLE_ID' => $iToUserID); | |
if ($bDO) { | |
$obActivity->Update($arResult['ID'], $arFields); | |
} | |
echo "ACTIVITY: {$arResult['ID']} {$bDO} <br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment