<?php
require_once('config.php');
require_once('inc/header.php');
?>
<main id="main" class="main">
  <div class="row">
    <div class="col-6 align-items-center">
      <div class="pagetitle mb-2">
        <h1><?php echo $page_title ?></h1>
      </div>
    </div>
  </div>
  <section class="section mt-4">
    <div class="row">
      <div class="col-lg-12">

        <form action="" method="post" enctype="multipart/form-data">
          <?php
          $all_cat = []; // Initialize the array properly

          // Grab all categories
          $data_cat = showAllttdata("mahamudfutureit_category", "ORDER BY CategoryID DESC");

          if (!empty($data_cat)) {
              foreach ($data_cat as $the_category) {
                  $pcat_ids = $the_category['CategoryID'];
                  $all_cat[$the_category['CategoryID']] = $the_category['CategoryName']." - ".count(showAllttdata("mahamudfutureit_article","WHERE (PostCategory = '$pcat_ids' OR PostSubCategory LIKE '%\"$pcat_ids\"%') AND PostStatus  = 'published'"));
              }
          }

          $args = array(
              'fields' => array(
                array(
                    'field_id'       => 'HomeFeaturedTopic',
                    'field_type'     => 'switch',
                    'field_title'     => 'Show Trending Topic',
                    'field_desc'  => 'Show topics that have been used most recently.',
                    'field_data' => $_POST['HomeFeaturedTopic'],
                ),
                array(
                    'field_id'       => 'PostBlockHeaderStyle',
                    'field_type'     => 'select',
                    'field_title'    => 'Block header Style',
                    'field_data'     => $_POST['PostBlockHeaderStyle'],
                    'field_required' => true,
                    'field_options'  => array(
                                        '1' => 'One',
                                        '2' => 'Two',
                                        '3' => 'Three',
                                        '4' => 'Four',
                                        '5' => 'Five',
                                        '6' => 'Six',
                                        '7' => 'Seven',
                                        '8' => 'Eight',
                                        '9' => 'Nine',
                                        '10' => 'Ten',
                                        ),
                ),
                array(
                    'field_id'       => 'PS_Block_FS',
                    'field_type'     => 'text',
                    'field_title'     => 'Block Title Font Size',
                    'field_data' => $_POST['PS_Block_FS'],
                    'field_required' => true,
                ),
                array(
                    'field_type'     => 'separetor',
                    'field_title'     => 'News Ticker',
                    'field_desc'  => 'News Ticker Options',
                ),
                array(
                    'field_id'       => 'NewsTickerDesign',
                    'field_type'     => 'select',
                    'field_title'    => 'News Ticker Style',
                    'field_data'     => $_POST['NewsTickerDesign'],
                    'field_required' => true,
                    'field_options'  => array(
                                        '1' => 'Ticker One',
                                        '2' => 'Ticker Two',
                                        '3' => 'Ticker Three',
                                        ),
                ),
                array(
                    'field_type'     => 'separetor',
                    'field_title'     => 'Block Category',
                    'field_desc'  => 'Select Block Category in Home page',
                ),

                array(
                    'field_id'       => 'HomeLead',
                    'field_type'     => 'disabled-text',
                    'field_title'     => 'Post Block 1',
                    'field_disval'     => 'Lead News',
                    'field_data' => $_POST['HomeLead'],
                ),
                array(
                    'field_id'       => 'HomeSpotlight',
                    'field_type'     => 'disabled-text',
                    'field_title'     => 'Post Block 2',
                    'field_disval'     => 'Spotlight News',
                    'field_data' => $_POST['HomeSpotlight'],
                ),
                array(
                    'field_id'       => 'PostBlock3',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 3',
                    'field_data'     => $_POST['PostBlock3'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock4',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 4',
                    'field_data'     => $_POST['PostBlock4'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock5',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 5',
                    'field_data'     => $_POST['PostBlock5'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock6',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 6',
                    'field_data'     => $_POST['PostBlock6'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock7',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 7',
                    'field_data'     => $_POST['PostBlock7'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock8',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 8',
                    'field_data'     => $_POST['PostBlock8'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock9',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 9',
                    'field_data'     => $_POST['PostBlock9'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock10',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 10',
                    'field_data'     => $_POST['PostBlock10'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock11',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 11',
                    'field_data'     => $_POST['PostBlock11'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock12',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 12',
                    'field_data'     => $_POST['PostBlock12'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock13',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 13',
                    'field_data'     => $_POST['PostBlock13'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock14',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 14',
                    'field_data'     => $_POST['PostBlock14'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock15',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 15',
                    'field_data'     => $_POST['PostBlock15'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock16',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 16',
                    'field_data'     => $_POST['PostBlock16'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock17',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 17',
                    'field_data'     => $_POST['PostBlock17'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock18',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 18',
                    'field_data'     => $_POST['PostBlock18'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock19',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 19',
                    'field_data'     => $_POST['PostBlock19'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock20',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 20',
                    'field_data'     => $_POST['PostBlock20'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock21',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 21',
                    'field_data'     => $_POST['PostBlock21'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock22',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 22',
                    'field_data'     => $_POST['PostBlock22'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock23',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 23',
                    'field_data'     => $_POST['PostBlock23'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock24',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 24',
                    'field_data'     => $_POST['PostBlock24'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'       => 'PostBlock25',
                    'field_type'     => 'select',
                    'field_title'    => 'Post Block 25',
                    'field_data'     => $_POST['PostBlock25'],
                    'field_options'  => $all_cat,
                ),

                array(
                    'field_id'     => 'update',
                    'field_type'   => 'button',
                    'btn_theme' => 'success',
                    'field_title'   => 'Save Changes',
                )
              )
          );
          AdvanceNews($args);
          ?>
          </form>

       </div>
    </div>
  </section>
</main>
<?php require_once('inc/footer.php'); ?>
