function getSenderItemContainer($id, array $chain = array())
{
    $i = '%SENDER_LETTER_TEMPLATE_BODY_NUM%';
    ob_start();
    ?>
	<div class="sender-trigger-chain-container-letter">
		<div class="sender-trigger-status-mailing-time">
			<?php 
    echo GetMessage("sender_chain_edit_field_time_thr");
    ?>
 <span class="sender_letter_container_time_text">*</span> <?php 
    echo GetMessage("sender_chain_edit_field_time_after");
    ?>
			<span class="sender_letter_container_time_text_first">&nbsp;<?php 
    echo GetMessage("sender_chain_edit_field_time_event");
    ?>
</span>
			<span style="display: none;" class="sender_letter_container_time_text_nonfirst">&nbsp;<?php 
    echo GetMessage("sender_chain_edit_field_time_letter");
    ?>
</span>
			&nbsp;&nbsp;
			<a id="SENDER_TRIGGER_CHAIN_TIME_BNT_<?php 
    echo $i;
    ?>
" href="javascript: void(0);" class="sender_letter_container_time_button sender-link-email"><?php 
    echo GetMessage("sender_chain_edit_field_time_change");
    ?>
</a>
		</div>
		<div class="sender_letter_container" id="SENDER_TRIGGER_CHAIN_<?php 
    echo $i;
    ?>
">
			<input type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][ID]" value="<?php 
    echo htmlspecialcharsbx($chain['ID']);
    ?>
">
			<input class="sender_letter_container_sorter" type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][ITEM_SORT]" value="<?php 
    echo $i;
    ?>
">
			<input class="sender_letter_container_time" type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][TIME_SHIFT]" value="<?php 
    echo intval($chain['TIME_SHIFT']);
    ?>
">

			<div class="sender_letter_container_head">
				<div class="sender_letter_container_move"><div class="sender_letter_container_burger"></div></div>
				<div class="sender_letter_container_sorter_view">
					<span class="sender_letter_container_sorter_icon">
						<span class="sender_letter_container_sorter_text"><?php 
    echo $i;
    ?>
</span>
					</span>
				</div>
				<h3><span class="sender_letter_container_caption"><?php 
    echo htmlspecialcharsbx($chain['SUBJECT']);
    ?>
</span></h3>
				<span class="sender_letter_container-info">
					<?php 
    if (!empty($chain['ID']) && empty($chain['DATE_INSERT'])) {
        ?>
						<span><?php 
        echo GetMessage("sender_chain_edit_field_created_exists_but_not_save");
        ?>
</span>
					<?php 
    } elseif (!empty($chain['ID'])) {
        ?>
						<span class="sender_letter_container-create"><?php 
        echo GetMessage("sender_chain_edit_field_created");
        ?>
</span>
						<span>
							<?php 
        echo GetMessage("sender_chain_edit_field_created_text", array('%DATE_CREATE%' => htmlspecialcharsbx(is_object($chain['DATE_INSERT']) ? \Bitrix\Main\Type\Date::createFromTimestamp($chain['DATE_INSERT']->getTimestamp()) : $chain['DATE_INSERT']), '%AUTHOR%' => '<a class="sender_letter_container-author" href="/bitrix/admin/user_edit.php?ID=' . htmlspecialcharsbx($chain['CREATED_BY']) . '&lang=' . LANGUAGE_ID . '">' . htmlspecialcharsbx($chain['CREATED_BY_NAME']) . ' ' . htmlspecialcharsbx($chain['CREATED_BY_LAST_NAME']) . '</a>'));
        ?>
						</span>
					<?php 
    } else {
        ?>
						<span><?php 
        echo GetMessage("sender_chain_edit_field_created_new");
        ?>
</span>
					<?php 
    }
    ?>
				</span>
				<a class="sender_letter_container_button_delete" href="javascript: void(0);" title="<?php 
    echo GetMessage("sender_chain_edit_field_delete");
    ?>
"></a>
				<?php 
    if (strlen($chain['SUBJECT']) > 0 && strlen($chain['MESSAGE']) > 0) {
        ?>
					<a class="sender_letter_container_button_show" href="javascript: void(0);">
						<?php 
        echo GetMessage('SENDER_MAILING_TRIG_LETTER_MESSAGE_SHOW');
        ?>
					</a>
				<?php 
    } else {
        ?>
					<a class="sender_letter_container_button_show sender_letter_container_button_hide" href="javascript: void(0);">
						<?php 
        echo GetMessage('SENDER_MAILING_TRIG_LETTER_MESSAGE_HIDE');
        ?>
					</a>
				<?php 
    }
    ?>
			</div>
			<div class="sender_letter_container_body" <?php 
    echo strlen($chain['SUBJECT']) > 0 && strlen($chain['MESSAGE']) > 0 ? 'style="display:none;"' : '';
    ?>
>
				<div class="sender_letter_container_body_tmpl" id="CHAIN_TEMPLATE_NUM_<?php 
    echo $i;
    ?>
" <?php 
    echo strlen($chain['MESSAGE']) > 0 ? 'style="display:none;"' : '';
    ?>
>
					<?php 
    echo \Bitrix\Sender\Preset\Template::getTemplateListHtml('SENDER_TRIGGER_CHAIN_' . $i);
    ?>
				</div>
				<div class="sender_letter_container_body_fields" <?php 
    echo strlen($chain['MESSAGE']) > 0 ? '' : 'style="display:none;"';
    ?>
>
					<table class="trigger_chain_item">
						<tr>
							<td><?php 
    echo GetMessage("sender_chain_edit_field_sel_templ");
    ?>
</td>
							<td>
								<span class="sender-template-message-caption-container"></span>
								&nbsp;
								<a href="javascript:void(0);" class="sender-template-message-caption-container-btn sender-link-email">
									<?php 
    echo GetMessage("sender_chain_edit_field_sel_templ_another");
    ?>
								</a>
							</td>
						</tr>
						<tr>
							<td><?php 
    echo GetMessage("sender_chain_edit_field_subject");
    ?>
</td>
							<td>
								<input class="sender_letter_container_subject" type="text" id="CHAIN_<?php 
    echo $i;
    ?>
_SUBJECT" name="CHAIN[<?php 
    echo $i;
    ?>
][SUBJECT]" value="<?php 
    echo htmlspecialcharsbx($chain['SUBJECT']);
    ?>
">
							</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>
								<?php 
    $arPersonalizeList = \Bitrix\Sender\PostingRecipientTable::getPersonalizeList();
    ?>
								<?php 
    echo GetMessage("sender_chain_edit_field_subject_personalize");
    ?>
								<?php 
    foreach ($arPersonalizeList as $arPersonalize) {
        ?>
								<a class="sender-link-email" onclick="SetAddressToControl('CHAIN_<?php 
        echo $i;
        ?>
_SUBJECT', ' #<?php 
        echo htmlspecialcharsbx($arPersonalize['CODE']);
        ?>
#', true)" title="#<?php 
        echo htmlspecialcharsbx($arPersonalize['CODE']);
        ?>
# - <?php 
        echo htmlspecialcharsbx($arPersonalize['DESC']);
        ?>
">
									<?php 
        echo htmlspecialcharsbx($arPersonalize['NAME']);
        ?>
									</a><?php 
        echo end($arPersonalizeList) === $arPersonalize ? '' : ',';
        ?>
								<?php 
    }
    ?>
								<span style="cursor: pointer;" class="hidden-when-show-template-list-info" onclick="ShowPersonalizeDescDialog(this);">&nbsp;</span>
							</td>
						</tr>
						<tr>
							<td colspan="2">
								<b><?php 
    echo GetMessage("sender_chain_edit_field_message");
    ?>
</b>
								<br>
								<br>
								%SENDER_LETTER_TEMPLATE_MESSAGE%
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</div>
	<?php 
    return ob_get_clean();
}
 public static function register($ownerID, array $entityFields = null, array $options = null)
 {
     if (!is_int($ownerID)) {
         $ownerID = (int) $ownerID;
     }
     if ($ownerID <= 0) {
         throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
     }
     if (!is_array($options)) {
         $options = array();
     }
     if (!is_array($entityFields)) {
         $dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE'));
         $entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
         if (!is_array($entityFields)) {
             return false;
         }
     }
     $stageID = isset($entityFields['STAGE_ID']) ? $entityFields['STAGE_ID'] : '';
     if ($stageID === '') {
         return false;
     }
     $responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int) $entityFields['ASSIGNED_BY_ID'] : 0;
     $startDate = self::parseDateString(isset($entityFields['BEGINDATE']) ? $entityFields['BEGINDATE'] : '');
     if ($startDate === null) {
         $startDate = new Date();
     }
     $endDate = self::parseDateString(isset($entityFields['CLOSEDATE']) ? $entityFields['CLOSEDATE'] : '');
     if ($endDate === null) {
         $endDate = new Date('9999-12-31', 'Y-m-d');
     }
     $time = isset($options['TIME']) ? $options['TIME'] : null;
     if ($time === null) {
         $time = new DateTime();
     }
     $month = (int) $time->format('m');
     $quarter = $month <= 3 ? 1 : ($month <= 6 ? 2 : ($month <= 9 ? 3 : 4));
     $year = (int) $time->format('Y');
     $startMonth = (int) $startDate->format('m');
     $startQuarter = $startMonth <= 3 ? 1 : ($startMonth <= 6 ? 2 : ($startMonth <= 9 ? 3 : 4));
     $startYear = (int) $startDate->format('Y');
     $endMonth = (int) $endDate->format('m');
     $endQuarter = $endMonth <= 3 ? 1 : ($endMonth <= 6 ? 2 : ($endMonth <= 9 ? 3 : 4));
     $endYear = (int) $endDate->format('Y');
     $semanticID = \CCrmDeal::GetSemanticID($stageID);
     $isNew = isset($options['IS_NEW']) ? (bool) $options['IS_NEW'] : false;
     $typeID = PhaseSemantics::isFinal($semanticID) ? HistoryEntryType::FINALIZATION : ($isNew ? HistoryEntryType::CREATION : HistoryEntryType::MODIFICATION);
     $date = Date::createFromTimestamp($time->getTimestamp());
     $isLost = PhaseSemantics::isLost($semanticID);
     $latest = self::getLatest($ownerID);
     if ($latest['STAGE_ID'] === $stageID) {
         return false;
     }
     $result = DealStageHistoryTable::add(array('TYPE_ID' => $typeID, 'OWNER_ID' => $ownerID, 'CREATED_TIME' => $time, 'CREATED_DATE' => $date, 'START_DATE' => $startDate, 'END_DATE' => $endDate, 'PERIOD_YEAR' => $year, 'PERIOD_QUARTER' => $quarter, 'PERIOD_MONTH' => $month, 'START_PERIOD_YEAR' => $startYear, 'START_PERIOD_QUARTER' => $startQuarter, 'START_PERIOD_MONTH' => $startMonth, 'END_PERIOD_YEAR' => $endYear, 'END_PERIOD_QUARTER' => $endQuarter, 'END_PERIOD_MONTH' => $endMonth, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_ID' => $stageID, 'STAGE_SEMANTIC_ID' => $semanticID, 'IS_LOST' => $isLost ? 'Y' : 'N'));
     if ($result->isSuccess() && $result->getId() > 0 && is_array($latest) && (int) $latest['TYPE_ID'] === HistoryEntryType::FINALIZATION) {
         DealStageHistoryTable::delete($latest['ID']);
     }
     return true;
 }
Beispiel #3
0
}
$rsList = new CDBResult();
$rsList->InitFromArray($orders);
$rsList->NavStart(20);
$data = new CAdminResult($rsList, $tableID);
$data->NavStart();
$adminList->NavText($data->GetNavPrint(Loc::getMessage("PAGES"), false));
$adminList->AddHeaders(array(array("id" => "provider", "content" => Loc::getMessage("SCALE_ORDER_PROVIDER"), "sort" => "provider", "default" => true), array("id" => "order_id", "content" => Loc::getMessage("SCALE_ORDER_ID"), "sort" => "order_id", "default" => true), array("id" => "status", "content" => Loc::getMessage("SCALE_ORDER_STATUS"), "sort" => "status", "default" => true), array("id" => "mtime", "content" => Loc::getMessage("SCALE_ORDER_MTIME"), "sort" => "mtime", "default" => true), array("id" => "error", "content" => Loc::getMessage("SCALE_ORDER_ERROR"), "default" => false), array("id" => "message", "content" => Loc::getMessage("SCALE_ORDER_MESSAGE"), "default" => true)));
while ($order = $data->Fetch()) {
    $provider = htmlspecialcharsbx($order["provider"]);
    $order_id = htmlspecialcharsbx($order["order_id"]);
    $row =& $adminList->AddRow($provider . "::" . $order_id, $order, "?provider=" . $provider . "&order_id=" . $order_id . "&lang=" . LANGUAGE_ID, Loc::getMessage("SCALE_ORDER_EDIT"));
    $row->AddViewField("provider", $order["provider"]);
    $row->AddViewField("order_id", $order["order_id"]);
    $langStatuses = array("finished" => Loc::getMessage("SCALE_ORDER_STATUS_FINISHED"), "complete" => Loc::getMessage("SCALE_ORDER_STATUS_COMPLETED"), "error" => Loc::getMessage("SCALE_ORDER_STATUS_ERROR"), "in_progress" => Loc::getMessage("SCALE_ORDER_STATUS_INPROCESS"));
    $status = isset($langStatuses[$order["status"]]) ? $langStatuses[$order["status"]] : $order["status"];
    $row->AddViewField("status", $status);
    $date = \Bitrix\Main\Type\Date::createFromTimestamp($order["mtime"]);
    $row->AddViewField("mtime", $date->toString());
    $row->AddViewField("error", $order["error"]);
    $row->AddViewField("message", $order["message"]);
    $arActions = array();
    if ($order["status"] == "finished") {
        $arActions[] = array("ICON" => "edit", "TEXT" => Loc::getMessage("SCALE_ORDER_ADD_TO_PULL"), "ACTION" => $adminList->ActionDoGroup($provider . "::" . $order_id, "add_to_pull"));
    }
    $row->AddActions($arActions);
}
$adminList->CheckListMode();
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$adminList->DisplayList();
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";