예제 #1
1
 public static function GetRentNumbers()
 {
     $arResult = array();
     $viHttp = new CVoxImplantHttp();
     $result = $viHttp->GetPhoneNumbers();
     if ($result && !empty($result->result)) {
         foreach ($result->result as $value) {
             $renewalDate = $renewalDateTs = '';
             if ($value->phone_next_renewal) {
                 $data = new Bitrix\Main\Type\DateTime($value->phone_next_renewal . ' 00:00:00', 'Y-m-d H:i:s');
                 $renewalDate = $data->format(Bitrix\Main\Type\Date::getFormat());
                 $renewalDateTs = $data->getTimestamp();
             }
             $unverifiedHoldDate = $unverifiedHoldDateTs = '';
             if ($value->verification_status != 'VERIFIED' && $value->unverified_hold_until) {
                 $data = new Bitrix\Main\Type\DateTime($value->unverified_hold_until . ' 00:00:00', 'Y-m-d H:i:s');
                 $unverifiedHoldDate = $data->format(Bitrix\Main\Type\Date::getFormat());
                 $unverifiedHoldDateTs = $data->getTimestamp();
             }
             $arResult[$value->phone_number] = array('ACTIVE' => $value->deactivated ? 'N' : 'Y', 'NUMBER' => '+' . $value->phone_number, 'PAID_BEFORE' => $renewalDate, 'PAID_BEFORE_TS' => $renewalDateTs, 'PRICE' => $value->phone_price, 'VERIFY_STATUS' => $value->verification_status, 'VERIFY_STATUS_NAME' => CVoxImplantDocuments::GetStatusName($value->verification_status), 'VERIFY_BEFORE' => $unverifiedHoldDate, 'VERIFY_BEFORE_TS' => $unverifiedHoldDateTs);
         }
     }
     return $arResult;
 }
예제 #2
0
 public static function actualizeHandlers($chainId, array $fieldsNew = null, array $fieldsOld = null)
 {
     $settingsNew = null;
     $settingsOld = null;
     if ($fieldsNew) {
         $settingsNew = new TriggerSettings($fieldsNew);
     }
     if ($fieldsOld) {
         $settingsOld = new TriggerSettings($fieldsOld);
     }
     // if old item was closed trigger
     if ($settingsOld && $settingsOld->isClosedTrigger()) {
         // delete agent
         $agentName = TriggerManager::getClosedEventAgentName($settingsOld->getEventModuleId(), $settingsOld->getEventType(), $chainId);
         $agent = new \CAgent();
         $agentListDb = $agent->GetList(array(), array('MODULE_ID' => 'sender', 'NAME' => $agentName));
         while ($agentItem = $agentListDb->Fetch()) {
             $agent->Delete($agentItem['ID']);
         }
     }
     // if new item is closed trigger
     if ($settingsNew && $settingsNew->isClosedTrigger()) {
         // check active state of mailing
         $chainDb = MailingChainTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $chainId, '=MAILING.ACTIVE' => 'Y')));
         if (!$chainDb->fetch()) {
             return;
         }
         // add new agent
         $agentName = TriggerManager::getClosedEventAgentName($settingsNew->getEventModuleId(), $settingsNew->getEventType(), $chainId);
         // set date of next exec
         $agentTime = $settingsNew->getClosedTriggerTime();
         $agentInterval = $settingsNew->getClosedTriggerInterval();
         if ($agentInterval <= 0) {
             $agentInterval = 1440;
         }
         $agentTimeArray = explode(":", $agentTime);
         $agentDate = new \Bitrix\Main\Type\DateTime();
         $agentDate->setTime((int) $agentTimeArray[0], (int) $agentTimeArray[1]);
         // set next exec on next day if exec was today
         if ($agentDate->getTimestamp() < time()) {
             $agentDate->add("1 days");
         }
         // add agent
         $agent = new \CAgent();
         $agent->AddAgent($agentName, 'sender', 'N', $agentInterval * 60, '', 'Y', $agentDate->toString());
         return;
     }
     // actualize deleted/changed event
     if ($settingsOld && !$settingsOld->isClosedTrigger() && $settingsOld->getFullEventType()) {
         // if delete operation(no the NEW)
         // or change operation(the NEW is not equal to the OLD)
         if (!$settingsNew || $settingsOld->getFullEventType() != $settingsNew->getFullEventType()) {
             TriggerManager::actualizeHandler(array('MODULE_ID' => $settingsOld->getEventModuleId(), 'EVENT_TYPE' => $settingsOld->getEventType(), 'CALLED_BEFORE_CHANGE' => true));
         }
     }
     // actualize new event
     if ($settingsNew && $settingsNew->getFullEventType()) {
         $calledBeforeChange = $fieldsOld ? false : true;
         TriggerManager::actualizeHandler(array('MODULE_ID' => $settingsNew->getEventModuleId(), 'EVENT_TYPE' => $settingsNew->getEventType(), 'CALLED_BEFORE_CHANGE' => $calledBeforeChange));
     }
 }
예제 #3
0
 public static function RebuildStatistics(array $IDs)
 {
     $dbResult = self::GetListEx(array(), array('@ID' => $IDs, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'DATE_CREATE', 'DATE_MODIFY', 'STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE', 'CURRENCY_ID', 'OPPORTUNITY', 'UF_*'));
     if (!is_object($dbResult)) {
         return;
     }
     while ($fields = $dbResult->Fetch()) {
         $ID = (int) $fields['ID'];
         //--> History
         if (!Bitrix\Crm\History\DealStageHistoryEntry::isRegistered($ID)) {
             $created = isset($fields['DATE_CREATE']) ? $fields['DATE_CREATE'] : '';
             $createdTime = null;
             try {
                 $createdTime = new Bitrix\Main\Type\DateTime($created, Bitrix\Main\Type\DateTime::convertFormatToPhp(FORMAT_DATETIME));
             } catch (Bitrix\Main\ObjectException $e) {
             }
             $modified = isset($fields['DATE_MODIFY']) ? $fields['DATE_MODIFY'] : '';
             $modifiedTime = null;
             if ($modified !== '') {
                 try {
                     $modifiedTime = new Bitrix\Main\Type\DateTime($modified, Bitrix\Main\Type\DateTime::convertFormatToPhp(FORMAT_DATETIME));
                 } catch (Bitrix\Main\ObjectException $e) {
                 }
             }
             if ($createdTime && $modifiedTime && $createdTime->getTimestamp() !== $modifiedTime->getTimestamp()) {
                 Bitrix\Crm\History\DealStageHistoryEntry::register($ID, $fields, array('IS_NEW' => false, 'TIME' => $modifiedTime));
             } elseif ($createdTime) {
                 Bitrix\Crm\History\DealStageHistoryEntry::register($ID, $fields, array('IS_NEW' => true, 'TIME' => $createdTime));
             }
         }
         //<-- History
         //--> Statistics
         if (!Bitrix\Crm\Statistics\DealSumStatisticEntry::isRegistered($ID)) {
             Bitrix\Crm\Statistics\DealSumStatisticEntry::register($ID, $fields);
         }
         if (!Bitrix\Crm\Statistics\DealInvoiceStatisticEntry::isRegistered($ID)) {
             Bitrix\Crm\Statistics\DealInvoiceStatisticEntry::register($ID, $fields);
         }
         $timeline = Bitrix\Crm\Statistics\DealActivityStatisticEntry::prepareTimeline($ID);
         foreach ($timeline as $date) {
             Bitrix\Crm\Statistics\DealActivityStatisticEntry::register($ID, $fields, array('DATE' => $date));
         }
         //<-- Statistics
     }
 }
예제 #4
0
if (!CModule::IncludeModule('voximplant')) {
    return;
}
$arResult['NUMBERS'] = CVoxImplantPhone::GetRentNumbers();
$arResult['PAID_BEFORE'] = array('TS' => 0, 'DATE' => '', 'PRICE' => 0, 'NOTICE' => false);
foreach ($arResult['NUMBERS'] as $value) {
    if ($arResult['PAID_BEFORE']['TS'] > $value['PAID_BEFORE_TS'] || $arResult['PAID_BEFORE']['TS'] == 0) {
        $arResult['PAID_BEFORE']['TS'] = $value['PAID_BEFORE_TS'];
        $arResult['PAID_BEFORE']['DATE'] = $value['PAID_BEFORE'];
        $arResult['PAID_BEFORE']['PRICE'] = $value['PRICE'];
    } else {
        if ($arResult['PAID_BEFORE']['TS'] == $value['PAID_BEFORE_TS']) {
            $arResult['PAID_BEFORE']['PRICE'] += $value['PRICE'];
        }
    }
}
$ViAccount = new CVoxImplantAccount();
$arResult['BALANCE_CURRENCY'] = $ViAccount->GetAccountCurrency();
if ($arResult['PAID_BEFORE']['TS'] > 0) {
    $data = new Bitrix\Main\Type\DateTime();
    if ($arResult['PAID_BEFORE']['TS'] <= $data->getTimestamp() + 604800) {
        $arResult['BALANCE'] = $ViAccount->GetAccountBalance(true);
        if ($arResult['BALANCE'] < $arResult['PAID_BEFORE']['PRICE']) {
            $arResult['PAID_BEFORE']['NOTICE'] = 'Y';
        }
    }
}
if (count($arResult['NUMBERS']) > 0 && !(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) {
    $this->IncludeComponentTemplate();
}
return $arResult;
예제 #5
0
 public static function GetRentNumbers()
 {
     $arResult = array();
     $viHttp = new CVoxImplantHttp();
     $result = $viHttp->GetPhoneNumbers();
     if ($result && !empty($result->result)) {
         foreach ($result->result as $value) {
             $data = new Bitrix\Main\Type\DateTime($value->phone_next_renewal . ' 00:00:00', 'Y-m-d H:i:s');
             $arResult[$value->phone_number] = array('ACTIVE' => $value->deactivated ? 'N' : 'Y', 'NUMBER' => '+' . $value->phone_number, 'PAID_BEFORE' => $value->phone_next_renewal, 'PAID_BEFORE_TS' => $data->getTimestamp(), 'PRICE' => $value->phone_price);
         }
     }
     return $arResult;
 }