<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template files receive local context variables from their controller.
namespace SPAATG;

use SPAATG\Helper\UiHelper;

if ( ! defined( 'ABSPATH' ) ) {
 exit; // Exit if accessed directly.
}

?>

<section class="panel summary" data-panel="summary">
  <div class="panel-container">

    <!--<h3 class="heading"><span>
      <?php esc_html_e('SPAATG Bulk AI SEO - Summary','shortpixel-ai-alt-text-generator'); ?>
    </h3>

    <p class='description'><?php esc_html_e('Welcome to the bulk AI SEO wizard, where you can select the images that SPAATG will process in the background for you.','shortpixel-ai-alt-text-generator'); ?></p>
-->

    <?php 
    
    $this->loadView('bulk/part-progressbar',false, ['part' => 'summary']); ?>

      <h3><?php esc_html_e('Review & Start Processing', 'shortpixel-ai-alt-text-generator'); ?>
       <!-- <span>
            <img src="<?php echo esc_url(wpSPAATG()->plugin_url('res/img/robo-notes.png')); ?>" style="transform: scale(-1, 1);height: 50px;"/>
        </span> -->
      </h3>

  <div class='credits-wrapper summary-list'>
    <div class='credits-sub-wrapper'>
  <?php
    $quotaData = $this->view->quotaData;
?>

    <div class="credits">
      <p class='heading totals'><span>
        
        <?php
          $quotaData->unlimited ? esc_html_e('Total AI credits','shortpixel-ai-alt-text-generator') : esc_html_e('Total AI credits needed','shortpixel-ai-alt-text-generator');
              ?>: 
        </span>
         <span class='hidden' data-stats-total="images-images" data-check-total-total>0</span>
        <span class="number" data-stats-media="images-images_ai" data-check-has-ai >0</span>
      </p>
  <?php 
      if(true === $quotaData->unlimited): ?>

					<p><span><?php esc_html_e('This site is currently on the SPAATG Unlimited plan, so you do not have to worry about credits. Enjoy!', 'shortpixel-ai-alt-text-generator'); ?></span></p>
      
      <!--	</div> -->
	    <?php else: ?>
      <p class='heading'><span><?php esc_html_e('Your Available Credits', 'shortpixel-ai-alt-text-generator'); ?></span>
        <span><b><?php echo esc_html($this->formatNumber($quotaData->total->remaining, 0)) ?></b></span>

      </p>

      <p><span><?php esc_html_e('Your monthly plan','shortpixel-ai-alt-text-generator'); ?></span>
         <span><b><?php echo esc_html($quotaData->monthly->text) ?></b> |
              <?php esc_html_e('Used:', 'shortpixel-ai-alt-text-generator'); ?> <b><?php echo esc_html($this->formatNumber($quotaData->monthly->consumed, 0)); ?></b> |
              <?php esc_html_e('Remaining:', 'shortpixel-ai-alt-text-generator'); ?> <b><?php echo esc_html($this->formatNumber($quotaData->monthly->remaining, 0)); ?></b>
          </span>
      </p>

      <p>
          <span><?php esc_html_e('Your one-time credits', 'shortpixel-ai-alt-text-generator') ?></span>
          <span><b><?php echo esc_html($quotaData->onetime->text) ?></b> |
             <?php esc_html_e('Used:', 'shortpixel-ai-alt-text-generator'); ?> <b><?php echo esc_html($this->formatNumber($quotaData->onetime->consumed, 0)); ?></b> |
             <?php esc_html_e('; Remaining:', 'shortpixel-ai-alt-text-generator'); ?> <b><?php echo esc_html($this->formatNumber($quotaData->onetime->remaining, 0)) ?></b>
         </span>
      </p>

      <p>	<span>
        <a href="<?php echo esc_url($this->view->buyMoreHref) ?>" target="_new" class='button button-primary unlimited'>
	        <span><?php echo wp_kses(UIHelper::getIcon('res/images/icon/shortpixel.svg'), array('img' => array('src' => array(), 'class' => array(), 'width' => array(), 'height' => array(), 'alt' => array()))); ?></span>
        <?php esc_html_e('Buy unlimited credits','shortpixel-ai-alt-text-generator'); ?>
        </a></span>
      </p>
      <?php endif;
	    ?>


  </div>
  </div>
  <div class='ai-credits-sub-wrapper'>
    <!--- ### AI BOX #### --> 
    <div class='section-wrapper ai' data-check-visibility data-control="data-check-has-ai">
    <h4><span class='dashicons dashicons-open-folder'>&nbsp;</span><?php esc_html_e('AI Image SEO', 'shortpixel-ai-alt-text-generator') ?></h4>
      <div class="list-table">

            <div class='' >
							<span>&nbsp; <?php esc_html_e('Images ','shortpixel-ai-alt-text-generator'); ?> </span><span data-stats-media="images-images_ai" data-check-has-ai>&nbsp;</span>
						</div>
        <div><h4 class="totals"><?php esc_html_e('Total images for AI Image SEO','shortpixel-ai-alt-text-generator'); ?></h4><span class="totals" data-stats-media="images-images_ai" data-check-has-ai>0</span></div>

      </div>
      
    </div>

    <div class='credits ai' data-check-visibility data-control="data-check-has-ai">

      <p class='heading totals'><span>
        
        <?php   $quotaData->unlimited ? esc_html_e('Total','shortpixel-ai-alt-text-generator') : esc_html_e('Total AI credits needed','shortpixel-ai-alt-text-generator');
              ?>: 
        </span>
        <span class="number" data-stats-media="images-images_ai" >0</span>
      </p>

      <?php if (false === $quotaData->unlimited): ?>
      <p>				
        <span>
          <a href="<?php echo esc_url($this->view->buyMoreHref) ?>" target="_new" class='button button-primary unlimited'>
	          <span><?php echo wp_kses(UIHelper::getIcon('res/images/icon/shortpixel.svg'), array('img' => array('src' => array(), 'class' => array(), 'width' => array(), 'height' => array(), 'alt' => array()))); ?></span>
          <?php esc_html_e('Buy Unlimited AI credits','shortpixel-ai-alt-text-generator'); ?>
          </a>
        </span>
      </p>
      <?php endif;  ?>

  </div>
  </div> <!--- // credits wrapper --> 

  <?php if (false == $quotaData->unlimited): ?>
  <div class="over-quota" data-check-visibility="false" data-control="data-quota-remaining" data-control-check="data-check-total-total">
      <span><img src="<?php echo esc_url(wpSPAATG()->plugin_url('res/img/bulk/over-quota.svg')) ?>" /></span>
            <p><?php /* translators: 1: opening warning markup, 2: available credits, 3: closing warning markup, 4: selected images count markup. */ ?>
            <?php printf(esc_html__('In your SPAATG account you %1$shave only %2$s credits available %3$s, but you have chosen %4$s images for AI Image SEO generation in this bulk process. You can either go back and select fewer images, or you can upgrade to a higher plan or buy one-time credits.','shortpixel-ai-alt-text-generator'), '<span class="red">', esc_html($this->formatNumber($quotaData->total->remaining, 0)), '</span>', '<b data-stats-total="images-images">0</b>'); ?>

	       <a href="<?php echo esc_url($this->view->buyMoreHref); ?>" target="_blank" rel="noopener noreferrer" class="button"><?php esc_html_e('Buy more credits', 'shortpixel-ai-alt-text-generator') ?></a>
     </p>

       <span class='hidden' data-quota-remaining><?php
             // This is hidden check, no number format.
                echo esc_html($quotaData->total->remaining);
             ?></span>
    </div>
    <?php endif; // check unlimited ?> 
  
    <div class='no-images' data-check-visibility="false" data-control="data-check-total-total">
        <?php esc_html_e('The current selection contains no images. The bulk process cannot start.', 'shortpixel-ai-alt-text-generator'); ?>
    </div>

    </div> <!-- // credits --> 
    <nav>
      <button class="button" type="button" data-action="open-panel" data-panel="selection">
				<span class='dashicons dashicons-arrow-left' ></span>
				<p><?php esc_html_e('Back','shortpixel-ai-alt-text-generator'); ?></p>
			</button>
      <button class="button-primary button" type="button" data-action="StartBulk" data-control="data-check-total-total" data-check-presentation="disable">
				<span class='dashicons dashicons-arrow-right'></span>
	        <?php if ($view->customOperationMedia !== false)
	        {
		            echo '<p>' . esc_html(
			            sprintf(
				            /* translators: %s: custom bulk operation media label. */
				            __('Start %s', 'shortpixel-ai-alt-text-generator'),
				            $view->customOperationMedia
			            )
		            ) . '</p>';
	        }
        else
        {
          ?>
            <p><?php esc_html_e('Start Bulk AI SEO Generation', 'shortpixel-ai-alt-text-generator'); ?></p>
          <?php 
        } ?>
				
			</button>
    </nav>
  </div>
</section>
