<?php 
$modals_html = '';
ob_start();
?>

<?php foreach ($tools as $key => $tool) { ?>
	<tr class="align-middle">
		<!-- Image -->
		<td class="text-center">
		    <img class="rounded shadow-sm intg-thumb" 
		         src="<?= $tool['featured_image'] ?>" 
		         alt="<?= htmlspecialchars($tool['name']) ?>" 
		         data-bs-toggle="modal" data-bs-target="#campaign-details-<?= $tool['id']; ?>">
		</td>

		<!-- Campaign Name -->
		<td>
		    <div>
		        <div class="fw-semibold text-dark mb-1" title="<?= htmlspecialchars($tool['name']) ?>">
		            <?= ucwords(strtolower($tool['name'])) ?>
		        </div>
		        <div class="d-flex align-items-center gap-1 flex-wrap mb-1">
		            <span class="badge bg-<?= $tool['_tool_type'] == 'program' ? 'info' : ($tool['_tool_type'] == 'action' ? 'success' : 'secondary') ?>">
		                <?= parseIntegrationType($tool['_tool_type']) ?>
		            </span>
		            <?php if($tool['username']): ?>
		                <span class="badge bg-success">
		                    <i class="bi bi-person me-1"></i><?= ucwords($tool['username']) ?>
		                </span>
		            <?php else: ?>
		                <span class="badge bg-primary">
		                    <i class="bi bi-shield-lock me-1"></i><?= __('admin.admin') ?>
		                </span>
		            <?php endif; ?>
		            <?php if($tool['category_name']): ?>
		                <span class="badge bg-light text-dark"><?= $tool['category_name'] ?></span>
		            <?php endif; ?>
		        </div>
		        <small class="text-muted">
		            <i class="bi bi-calendar3 me-1"></i><?= date('M d, Y H:i', strtotime($tool['created_at'])) ?>
		        </small>
		    </div>
		</td>

		<!-- Integration Plugin -->
		<td>
		    <?php if(isset($integration_plugins[$tool['tool_integration_plugin']])): ?>
		        <span class="badge bg-primary">
		            <i class="bi bi-plug me-1"></i><?= $integration_plugins[$tool['tool_integration_plugin']]['name'] ?>
		        </span>
		    <?php else: ?>
		        <span class="badge bg-secondary">
		            <i class="bi bi-gear me-1"></i><?= parseIntegrationType($tool['_tool_type']) ?>
		        </span>
		    <?php endif; ?>
		</td>

		<!-- View Count -->
		<td class="text-center">
		    <span class="badge bg-info fs-6">
		        <i class="bi bi-eye me-1"></i><?= number_format($tool['total_trigger_count']) ?>
		    </span>
		</td>
		
		<!-- Ratio -->
		<td>
			<?php 
	        	if($tool['_tool_type'] == 'action' || $tool['_tool_type'] == 'single_action')
	        	{
	        		$conversionratio=0;
	        		$totalratiocount=(int)$tool['total_action_click_count'];
	        		if($tool['total_trigger_count']>0)
	        			$conversionratio=(int)($totalratiocount*100/$tool['total_trigger_count']);
	        		$conversionratio = is_float($conversionratio) ==1 ? number_format((float)$conversionratio, 2, '.', '') : $conversionratio;
	        		echo '<div class="mb-1">';
	        		echo '<span class="badge bg-info text-dark">'.__('admin.action').'</span> ';
	        		echo '<span class="fw-bold">'. $conversionratio . '%</span>';
	        		echo '</div>';
	        	}
	        	if($tool['_tool_type'] == 'general_click')
	        	{
	        		$conversionratio=0;
	        		$totalratiocount=(int)$tool['total_general_click_count'];
	        		if($tool['total_trigger_count']>0)
	        			$conversionratio=(int)($totalratiocount*100/$tool['total_trigger_count']);
	        		$conversionratio = is_float($conversionratio) ==1 ? number_format((float)$conversionratio, 2, '.', '') : $conversionratio;
	        		echo '<div class="mb-1">';
	        		echo '<span class="badge bg-secondary">'.__('admin.click').'</span> ';
	        		echo '<span class="fw-bold">'. $conversionratio . '%</span>';
	        		echo '</div>';
	        	}
	        	if($tool['_tool_type'] == 'program' && $tool['click_status']) 
	        	{
	        		$conversionratio=0;
	        		$totalratiocount=(int)$tool['total_click_count'];
	        		if($tool['total_trigger_count']>0)
	        			$conversionratio=(int)($totalratiocount*100/$tool['total_trigger_count']);
	        		$conversionratio = is_float($conversionratio) ==1 ? number_format((float)$conversionratio, 2, '.', '') : $conversionratio;
	        		echo '<div class="mb-1">';
	        		echo '<span class="badge bg-primary">'.__('admin.product_click').'</span> ';
	        		echo '<span class="fw-bold">'. $conversionratio . '%</span>';
	        		echo '</div>';
	        	}
	        	if($tool['_tool_type'] == 'program' && $tool['sale_status'])  
	        	{
	        		$conversionratio=0;
	        		$totalratiocount=(int)$tool['total_sale_count'];
	        		if($tool['total_trigger_count']>0)
	        		$conversionratio=(int)($totalratiocount*100/$tool['total_trigger_count']);
	        		$conversionratio = is_float($conversionratio) ==1 ? number_format((float)$conversionratio, 2, '.', '') : $conversionratio;
	        		echo '<div>';
	        		echo '<span class="badge bg-success">'.__('admin.sale').'</span> ';
	        		echo '<span class="fw-bold">'. $conversionratio . '%</span> ';
	        		echo '<span class="text-muted">(' . number_format($totalratiocount) . ')</span>';
	        		echo '</div>';
	        	}
	        	 ?>
		</td>

		<!-- Integration Status -->
		<td class="text-center security-status">
			<div class="d-flex flex-column align-items-center gap-1">
				<?php $im = isset($tool['integration_method']) ? $tool['integration_method'] : 'js_pixel'; ?>
				<?= ads_security_status($tool['security_status'], null, $im); ?>

				<?php if ($im === 's2s_direct'): ?>
				    <span class="badge bg-info text-dark"><i class="bi bi-phone me-1"></i><?= __('admin.integration_type_s2s_mobile') ?></span>
				    <button class="btn btn-sm btn-outline-info btn-show-setup" data-id="<?= $tool['id'] ?>"
				       data-bs-toggle="tooltip" title="<?= __('admin.s2s_mobile_view_setup') ?>">
				        <i class="bi bi-phone"></i>
				    </button>
				<?php elseif ($im === 's2s'): ?>
				    <span class="badge bg-warning text-dark"><i class="bi bi-hdd-rack me-1"></i><?= __('admin.integration_type_s2s') ?></span>
				    <button class="btn btn-sm btn-outline-warning btn-show-setup" data-id="<?= $tool['id'] ?>"
				       data-bs-toggle="tooltip" title="<?= __('admin.s2s_view_setup') ?>">
				        <i class="bi bi-hdd-rack"></i>
				    </button>
				<?php elseif ($im === 'postback'): ?>
				    <span class="badge bg-secondary"><i class="bi bi-arrow-left-right me-1"></i><?= __('admin.integration_type_postback') ?></span>
				    <button class="btn btn-sm btn-outline-secondary btn-show-setup" data-id="<?= $tool['id'] ?>"
				       data-bs-toggle="tooltip" title="<?= __('admin.integration_type_postback') ?>">
				        <i class="bi bi-arrow-left-right"></i>
				    </button>
				<?php elseif ($im === 'conversion_api'): ?>
				    <span class="badge bg-dark"><i class="bi bi-braces me-1"></i><?= __('admin.integration_method_conv_api') ?></span>
				    <button class="btn btn-sm btn-outline-dark btn-show-setup" data-id="<?= $tool['id'] ?>"
				       data-bs-toggle="tooltip" title="<?= __('admin.integration_method_conv_api') ?>">
				        <i class="bi bi-braces"></i>
				    </button>
				<?php else: ?>
				    <span class="badge bg-primary"><i class="bi bi-code-slash me-1"></i><?= __('admin.integration_type_js_pixel') ?></span>
				    <button data-bs-toggle="tooltip" title="<?= __('admin.integration_code') ?>" 
				            class="btn-show-code btn btn-sm btn-outline-primary" data-id='<?= $tool['id'] ?>'>
				        <i class="bi bi-code-slash"></i>
				    </button>
				<?php endif; ?>
			</div>
		</td>

		<!-- Campaign Status -->
		<td class="text-center">
		    <div class="d-flex flex-column align-items-center gap-1">
		        <?= ads_status($tool['status']); ?>
		        <?php if($tool['status'] == 1):
		            $isRunning = 1;
		            $isRunningTooltip = __('admin.lifetime');

		            if (!empty($tool['start_date']) && $tool['start_date'] != null) {
		                $startDateAvailable = date('M d, Y H:i', strtotime($tool['start_date']));
		                if (time() < strtotime($tool['start_date'])) {
		                    $isRunning = 0;
		                }
		            } else {
		                $startDateAvailable = date('M d, Y H:i', strtotime($tool['created_at']));
		            }

		            if (!empty($tool['end_date']) && $tool['end_date'] != null) {
		                $endDateAvailable = date('M d, Y H:i', strtotime($tool['end_date']));
		                if (time() > strtotime($tool['end_date'])) {
		                    $isRunning = 2;
		                }
		            } else {
		                $endDateAvailable = __('admin.lifetime');
		            } ?>

		            <button type="button" class="btn btn-sm btn-outline-secondary" 
		                    data-bs-toggle="tooltip" 
		                    title="<?= __('admin.schedule') ?>: <?= $startDateAvailable ?> - <?= $endDateAvailable ?>">
		                <i class="bi bi-clock text-<?= ads_running_status($isRunning) == 'success' ? 'success' : ($isRunning == 0 ? 'warning' : 'danger') ?>"></i>
		            </button>
		        <?php endif ?>
		    </div>
		</td>

		<!-- Actions (Dropdown) -->
		<td class="text-center">
		    <div class="d-flex align-items-center justify-content-center gap-1">
		        <!-- Primary actions visible -->
		        <a data-bs-toggle="tooltip" title="<?= __('admin.edit') ?>" 
		           class="btn btn-sm btn-outline-primary" 
		           onclick="return confirm('<?= __('admin.are_you_sure_to_edit') ?>');" 
		           href="<?= base_url('integration/integration_tools_form/'. $tool['_type'] .'/' . $tool['id']) ?>">
		            <i class="bi bi-pencil-square"></i>
		        </a>

		        <!-- More actions dropdown -->
		        <div class="dropdown intg-action-dropdown">
		            <button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
		                <i class="bi bi-three-dots-vertical"></i>
		            </button>
		            <ul class="dropdown-menu dropdown-menu-end">
		                <?php if($tool['main_commission_type'] != 'disabled'): ?>
		                <li>
		                    <a class="dropdown-item btn-show-integration-mlm-info" href="javascript:void(0)" data-id="<?= $tool['id'] ?>">
		                        <i class="bi bi-diagram-3 me-2 text-info"></i><?= __('admin.integration_mlm_info') ?>
		                    </a>
		                </li>
		                <?php endif ?>
		                <li>
		                    <a class="dropdown-item btn-campaign-detail" href="javascript:void(0)" 
		                       data-bs-toggle="modal" data-bs-target="#campaign-details-<?= $tool['id']; ?>" data-id="<?= $tool['id']; ?>">
		                        <i class="bi bi-info-circle me-2 text-primary"></i><?= __('admin.campaign_info') ?>
		                    </a>
		                </li>
		                <li>
		                    <a class="dropdown-item btn-show-terms" href="javascript:void(0)" data-id="<?= $tool['id'] ?>">
		                        <i class="bi bi-file-earmark-text me-2 text-secondary"></i><?= __('admin.terms') ?>
		                    </a>
		                </li>
		                <li>
		                    <a class="dropdown-item check-campaign-with-id" href="javascript:void(0)" data-id="<?= $tool['id'] ?>">
		                        <i class="bi bi-shield-check me-2 text-warning"></i><?= __('admin.validate_campaign') ?>
		                    </a>
		                </li>
		                <li><hr class="dropdown-divider"></li>
		                <li>
		                    <a class="dropdown-item" href="<?= base_url('integration/integration_tools_duplicate/'. $tool['id']) ?>">
		                        <i class="bi bi-copy me-2 text-info"></i><?= __('admin.duplicate') ?>
		                    </a>
		                </li>
		                <li>
		                    <a class="dropdown-item text-danger tool-remove-link" href="<?= base_url('integration/integration_tools_delete/'. $tool['id']) ?>">
		                        <i class="bi bi-trash me-2"></i><?= __('admin.delete') ?>
		                    </a>
		                </li>
		            </ul>
		        </div>
		    </div>
		</td>
	</tr>
	
	<?php 
	ob_start();
	?>
	<div class="modal fade" id="campaign-details-<?= $tool['id']; ?>" tabindex="-1" aria-labelledby="campaignModal<?= $tool['id'] ?>" aria-hidden="true">
	    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable intg-modal">
	        <div class="modal-content">
	            <div class="intg-modal-header">
	                <div class="intg-modal-header-left">
	                    <div class="intg-modal-icon intg-modal-icon--primary">
	                        <i class="bi bi-info-circle"></i>
	                    </div>
	                    <div>
	                        <h5 class="intg-modal-title" id="campaignModal<?= $tool['id'] ?>"><?= ucwords(strtolower($tool['name'])) ?></h5>
	                        <p class="intg-modal-subtitle"><?= __('admin.campaign_info') ?></p>
	                    </div>
	                </div>
	                <button type="button" class="intg-modal-close" data-bs-dismiss="modal" aria-label="Close"><i class="bi bi-x-lg"></i></button>
	            </div>
	            <div class="modal-body">
	                <!-- Quick Info -->
	                <div class="row g-2 mb-3">
	                    <div class="col-md-6">
	                        <div class="intg-modal-card">
	                            <div class="intg-modal-card-title"><i class="bi bi-tag"></i> <?= __('admin.tool_type') ?></div>
	                            <div class="intg-modal-card-value"><?= parseIntegrationType($tool['_tool_type']); ?></div>
	                        </div>
	                    </div>
	                    <?php if($tool['_tool_type'] == 'program'){ ?>
	                    <div class="col-md-6">
	                        <div class="intg-modal-card">
	                            <div class="intg-modal-card-title"><i class="bi bi-plug"></i> <?= __('admin.integration_plugin_name') ?></div>
	                            <div class="intg-modal-card-value"><?= isset($integration_plugins[$tool['tool_integration_plugin']]) ? $integration_plugins[$tool['tool_integration_plugin']]['name'] : "<span class='text-muted'>".__('admin.not_available_dashed')."</span>" ?></div>
	                        </div>
	                    </div>
	                    <?php } ?>
	                </div>

	                <!-- Commission Structure -->
	                <div class="mb-3">
	                    <div class="intg-modal-section-title"><i class="bi bi-percent"></i> <?= __('admin.commission_structure') ?></div>

	                    <?php if ($tool['_tool_type'] == 'action' || $tool['_tool_type'] == 'single_action') { ?>
	                        <div class="intg-modal-card mb-2">
	                            <div class="intg-modal-card-title"><i class="bi bi-lightning"></i> <?= __('admin.action_click') ?></div>
	                            <div class="row g-2">
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--green"><i class="bi bi-person"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.affiliate_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["action_amount"]). " ".__('admin.per')." ". $tool['action_click'] ." ".__('admin.actions') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php if($tool['vendor_id']){ ?>
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--blue"><i class="bi bi-shield-lock"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.admin_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["admin_action_amount"]). " ".__('admin.per')." ". $tool['admin_action_click'] ." ".__('admin.actions') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php } ?>
	                            </div>
	                        </div>
	                    <?php } ?>

	                    <?php if($tool['_tool_type'] == 'general_click') { ?>
	                        <div class="intg-modal-card mb-2">
	                            <div class="intg-modal-card-title"><i class="bi bi-cursor"></i> <?= __('admin.general_click') ?></div>
	                            <div class="row g-2">
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--green"><i class="bi bi-person"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.affiliate_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["general_amount"]). " ".__('admin.per')." ". $tool['general_click'] ." ".__('admin.clicks') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php if($tool['vendor_id']){ ?>
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--blue"><i class="bi bi-shield-lock"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.admin_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["admin_general_amount"]). " ".__('admin.per')." ". $tool['admin_general_click'] ." ".__('admin.clicks') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php } ?>
	                            </div>
	                        </div>
	                    <?php } ?>

	                    <?php if($tool['_tool_type'] == 'program' && $tool['click_status']) { ?>
	                        <div class="intg-modal-card mb-2">
	                            <div class="intg-modal-card-title"><i class="bi bi-cart"></i> <?= __('admin.product_click') ?></div>
	                            <div class="row g-2">
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--green"><i class="bi bi-person"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.affiliate_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["commission_click_commission"]). " ".__('admin.per')." ". $tool['commission_number_of_click'] ." ".__('admin.clicks') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php if($tool['vendor_id']){ ?>
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--blue"><i class="bi bi-shield-lock"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.admin_will_get') ?></div>
	                                            <div class="intg-modal-stat-value"><?= c_format($tool["admin_commission_click_commission"]). " ".__('admin.per')." ". $tool['admin_commission_number_of_click'] ." ".__('admin.clicks') ?></div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php } ?>
	                            </div>
	                        </div>
	                    <?php } ?>

	                    <?php if($tool['_tool_type'] == 'program' && $tool['sale_status']) { ?>
	                        <div class="intg-modal-card mb-2">
	                            <div class="intg-modal-card-title"><i class="bi bi-currency-dollar"></i> <?= __('admin.sale_commisssion') ?></div>
	                            <div class="row g-2">
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--green"><i class="bi bi-person"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.affiliate_will_get') ?></div>
	                                            <div class="intg-modal-stat-value">
	                                                <?php 
	                                                if($tool['commission_type'] == 'percentage'){ 
	                                                    echo $tool['commission_sale'].'%'; 
	                                                } else if($tool['commission_type'] == 'fixed'){ 
	                                                    echo c_format($tool['commission_sale']); 
	                                                }
	                                                ?>
	                                            </div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php if($tool['vendor_id']){ ?>
	                                <div class="col-md-6">
	                                    <div class="intg-modal-stat">
	                                        <div class="intg-modal-stat-icon intg-modal-stat-icon--blue"><i class="bi bi-shield-lock"></i></div>
	                                        <div>
	                                            <div class="intg-modal-stat-label"><?= __('admin.admin_will_get') ?></div>
	                                            <div class="intg-modal-stat-value">
	                                                <?php 
	                                                if($tool['admin_commission_type'] == 'percentage'){ 
	                                                    echo $tool['admin_commission_sale'].'%'; 
	                                                } else if($tool['admin_commission_type'] == 'fixed'){ 
	                                                    echo c_format($tool['admin_commission_sale']); 
	                                                }
	                                                ?>
	                                            </div>
	                                        </div>
	                                    </div>
	                                </div>
	                                <?php } ?>
	                            </div>
	                        </div>
	                    <?php } ?>
	                </div>

	                <!-- Transaction Statistics -->
	                <div class="mb-2">
	                    <div class="intg-modal-section-title"><i class="bi bi-graph-up"></i> <?= __('admin.transactions_details') ?></div>
	                    <div class="row g-2">
	                        <?php if($tool['_tool_type'] == 'action' || $tool['_tool_type'] == 'single_action') { ?>
	                            <div class="col-md-6">
	                                <div class="intg-modal-card">
	                                    <div class="intg-modal-card-title"><i class="bi bi-lightning"></i> <?= __('admin.action_click') ?></div>
	                                    <div class="d-flex justify-content-between mb-1"><span class="intg-modal-stat-label"><?= __('admin.admin_count') ?></span><span class="intg-modal-stat-value"><?= number_format((int)$tool['total_action_click_count']) ?></span></div>
	                                    <div class="d-flex justify-content-between"><span class="intg-modal-stat-label"><?= __('admin.admin_amount') ?></span><span class="intg-modal-stat-value"><?= $tool['total_action_click_amount'] ?></span></div>
	                                </div>
	                            </div>
	                        <?php } ?>

	                        <?php if($tool['_tool_type'] == 'general_click') { ?>
	                            <div class="col-md-6">
	                                <div class="intg-modal-card">
	                                    <div class="intg-modal-card-title"><i class="bi bi-cursor"></i> <?= __('admin.general_click') ?></div>
	                                    <div class="d-flex justify-content-between mb-1"><span class="intg-modal-stat-label"><?= __('admin.admin_count') ?></span><span class="intg-modal-stat-value"><?= number_format((int)$tool['total_general_click_count']) ?></span></div>
	                                    <div class="d-flex justify-content-between"><span class="intg-modal-stat-label"><?= __('admin.admin_amount') ?></span><span class="intg-modal-stat-value"><?= $tool['total_general_click_amount'] ?></span></div>
	                                </div>
	                            </div>
	                        <?php } ?>

	                        <?php if($tool['_tool_type'] == 'program' && $tool['click_status']) { ?>
	                            <div class="col-md-6">
	                                <div class="intg-modal-card">
	                                    <div class="intg-modal-card-title"><i class="bi bi-cart"></i> <?= __('admin.product_click') ?></div>
	                                    <div class="d-flex justify-content-between mb-1"><span class="intg-modal-stat-label"><?= __('admin.admin_count') ?></span><span class="intg-modal-stat-value"><?= number_format((int)$tool['total_click_count']) ?></span></div>
	                                    <div class="d-flex justify-content-between"><span class="intg-modal-stat-label"><?= __('admin.admin_amount') ?></span><span class="intg-modal-stat-value"><?= $tool['total_click_amount'] ?></span></div>
	                                </div>
	                            </div>
	                        <?php } ?>

	                        <?php if($tool['_tool_type'] == 'program' && $tool['sale_status']) { ?>
	                            <div class="col-md-6">
	                                <div class="intg-modal-card">
	                                    <div class="intg-modal-card-title"><i class="bi bi-currency-dollar"></i> <?= __('admin.sale_commisssion') ?></div>
	                                    <div class="d-flex justify-content-between mb-1"><span class="intg-modal-stat-label"><?= __('admin.admin_count') ?></span><span class="intg-modal-stat-value"><?= number_format((int)$tool['total_sale_count']) ?></span></div>
	                                    <div class="d-flex justify-content-between"><span class="intg-modal-stat-label"><?= __('admin.admin_amount') ?></span><span class="intg-modal-stat-value"><?= $tool['total_sale_amount'] ?></span></div>
	                                </div>
	                            </div>
	                        <?php } ?>
	                    </div>
	                </div>
	            </div>
	            <div class="intg-modal-footer">
	                <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
	                    <i class="bi bi-x-lg me-1"></i><?= __('admin.close') ?>
	                </button>
	            </div>
	        </div>
	    </div>
	</div>
	<?php
	$modals_html .= ob_get_clean();
	?>
<?php } ?>

<script>
$('.postback-info-icon').click(() => Swal.fire({
   title: '<?= __('admin.postback_campaign') ?>',
   text: '<?= __('admin.postback_campaign_no_integration_needed') ?>',
   icon: 'info',
   confirmButtonText: '<?= __('admin.ok') ?>'
}));

$(document).ready(function() {
    var modalsHtml = <?= json_encode($modals_html) ?>;
    $('#campaign-modals-container').append(modalsHtml);
});
</script>
