<?php
session_start();
require('../lib/dbclass.php');

//header('location:logout.php');
if ($_GET['blockid']) {
    $id   = $_GET['blockid'];
    $data = findQuery("select * from  tbl_assembly where id=$id");
}




$product = get_option_without_select('tbl_product', 'product_name', 'id!=0 and status=0');



?>

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Language" content="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CH CENTER TIRUR</title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no" />
    <meta name="description" content="CH CENTER TIRUR">
    <link rel="icon" type="image/x-icon" href="../assets/images/Shade logo.png">
    <link href="..\assets\css\main.css" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/daterangepicker.css">
    <link rel="stylesheet" href="../assets/css/choosen.css">
</head>

<body>
    <div class="app-container app-theme-white body-tabs-shadow fixed-sidebar fixed-header">
        <div class="app-header header-shadow">
            <div class="app-header__logo">
                <div class="logo-sr">
                    <img width="55px" src="../assets/images/Shade logo.png" alt="">
                </div>
                <div class="header__pane ml-auto">
                    <div>
                        <button type="button" class="hamburger close-sidebar-btn hamburger--elastic"
                            data-class="closed-sidebar">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>





            <div class="app-header__mobile-menu">
                <div>
                    <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                        <span class="hamburger-box">
                            <span class="hamburger-inner"></span>
                        </span>
                    </button>
                </div>
            </div>
            <div class="app-header__menu">
                <span>
                    <button type="button"
                        class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                        <span class="btn-icon-wrapper">
                            <i class="fa fa-ellipsis-v fa-w-6"></i>
                        </span>
                    </button>
                </span>
            </div>
            <div class="app-header__content">

                <div class="app-header-right">
                    <div class="header-btn-lg pr-0">
                        <div class="widget-content p-0">
                            <div class="widget-content-wrapper">

                                <div class="widget-content-left  ml-3 header-user-info">
                                   <!-- <div class="widget-heading">
                                        Muhammed murshid
                                    </div>
                                    <div class="widget-subheading">
                                        Admin
                                    </div>-->
                                </div>

                                <div class="d-inline-block dropdown ml-3 p-0">
                                    <button style="width: 40px;" type="button" data-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false"
                                        class="btn-shadow dropdown-toggle btn btn-info" fdprocessedid="rwibbh">


                                        <img style="width: 100%;" src="../assets/images/Shade logo.png" alt="">
                                    </button>
                                    <div tabindex="-1" role="menu" aria-hidden="true"
                                        class="dropdown-menu dropdown-menu-right">
                                        <ul class="nav flex-column">
                                            <li class="nav-item">
                                                <a href="logout.php" class="nav-link">
                                                    <i class="nav-link-icon lnr-inbox"></i>
                                                    <span> Logout</span>
                                                </a>
                                            </li>

                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="app-main">
            <div class="app-sidebar sidebar-shadow">
                <div class="app-header__logo">

                    <div class="header__pane ml-auto">
                        <div>
                            <button type="button" class="hamburger close-sidebar-btn hamburger--elastic "
                                id="toggleButton-header">
                                <span class="hamburger-box">
                                    <span class="hamburger-inner"></span>
                                </span>
                            </button>

                        </div>
                    </div>
                </div>
                <div class="app-header__mobile-menu">
                    <div>
                        <img src="../../assets/images/Shade logo.png" alt="">
                        <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
                <div class="app-header__menu">
                    <span>
                        <button type="button"
                            class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                            <span class="btn-icon-wrapper">
                                <i class="fa fa-ellipsis-v fa-w-6"></i>
                            </span>
                        </button>
                    </span>
                </div>
                <div class="scrollbar-sidebar ps ps--active-y">
                    <div class="app-sidebar__inner">
                        <ul class="vertical-nav-menu metismenu">

                            
                            
                            <li>
                                <a href="assembly_management.php">

                                    <i class="fa fa-sitemap" aria-hidden="true"></i> </i>Assembly Management
                                </a>
                            </li>
                            <li>
                                <a href="../Panchayat/panchayat_management.php">

                                    <i class="fa fa-industry" aria-hidden="true"></i> </i>Panchayat Management
                                </a>
                            </li>
                            <li>
                                <a href="../Ward/ward_management.php">

                                    <i class="fa fa-home" aria-hidden="true"></i>Ward management
                                </a>
                            </li>
                            <li>
                                <a href="../Club/club_management.php">

                                    <i class="fa fa-sign-language" aria-hidden="true"></i></i>Organisation Management
                                </a>
                            </li>
                            
                            <li>
                                <a href="../SPNRProduct/spnr_product_management.php">

                                    <i class="fa fa-shopping-basket" aria-hidden="true"></i>Sponsor Product Management
                                </a>
                            </li>
                            <li>
                                <a href="../Challenge/challenge_management.php">

                                    <i class="fa fa-shopping-bag" aria-hidden="true"></i></i>Challenge Management
                                </a>
                            </li>
                            <li>
                                <a href="../User/user_management.php">

                                    <i class="fa fa-users" aria-hidden="true"></i>User Management
                                </a>
                            </li>
                            <li>
                                <a href="../ChallengeReport/challengereport.php">

                                    <i class="fa fa-users" aria-hidden="true"></i>Challenge Report
                                </a>
                            </li>

                        </ul>
                    </div>
                    <div class="ps__rail-x" style="left: 0px; bottom: 0px;">
                        <div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
                    </div>
                    <div class="ps__rail-y" style="top: 0px; height: 643px; right: 0px;">
                        <div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 610px;"></div>
                    </div>
                </div>
            </div>

            <div class="app-main__outer">
                <div class="app-main__inner h-100">

                <div class="app-page-title app-page-title-simple">
                        <div class="page-title-wrapper d-flex justify-content-between">
                            <div class="page-title-heading">

                            </div>

                            <nav class="" aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="challenge_management.php">Challenge Management</a></li>
                                    <li class="breadcrumb-item"><a href="add_challenge.php">Add New Challenge</a></li>

                                </ol>
                            </nav>






                        </div>
                        <div class="row ">
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <h5 class="card-title">Add New Challenge</h5>
                                        <form class="needs-validation" novalidate="" action="save.php" method="post" enctype="multipart/form-data">
                                            <div class="form-row">
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Challenge name</label>
                                                    <input type="text" class="form-control" id="challenge_name" name="challenge_name"
                                                        placeholder="Enter challenge name" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please enter challenge name.
                                                    </div>
                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Image (326*203px,only jpeg/jpg allowed)</label>
                                                    

                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Challenge Start Date</label>
                                                    <input type="date" class="form-control" id="challenge_startdate" name="challenge_startdate"
                                                        placeholder="Enter challenge start date" value=""
                                                        required="true">
                                                    <div class="invalid-feedback">
                                                        Please select challenge start date.
                                                    </div>

                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Challenge End Date</label>
                                                    <input type="date" class="form-control" id="challenge_enddate" name="challenge_enddate"
                                                        placeholder="Enter challenge end date" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please select challenge end date.
                                                    </div>
                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Location</label>
                                                    <input type="text" class="form-control" id="location" name="location"
                                                        placeholder="Enter challenge location" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please enter challenge location.
                                                    </div>
                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Description</label>
                                                    <textarea name="description" id="exampleText" class="form-control" name="description"
                                                        placeholder="Enter challenge description" required></textarea>
                                                    <div class="invalid-feedback">
                                                        Please enter challenge description.
                                                    </div>
                                                </div>
                                                
                                                
                                                 <div class="col-md-3 mb-3">
                                                     <br><br>
                                                <input type="checkbox"  name="showdistrictandassembly">
                <label for="exampleInputEmail1">Show Assembly & District</label></div>
                
                 <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Unit to Display</label>
                                                    <input type="text" class="form-control" id="unit" name="unit"
                                                        placeholder="Enter challenge unit" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please enter challenge unit.
                                                    </div>
                                                </div>
                                                

                                            </div>
                                            <h5 class="card-title">Add Order Product</h5>
                                            <div class="form-row">
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">Product name</label>
                                                    <input type="text" class="form-control" id="product_name1" name="product_name1"
                                                        placeholder="Enter product name" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please enter product name.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Image (326*164px,only jpeg/jpg allowed)</label>
                                                    

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Product Amount</label>
                                                    <input type="text" class="form-control" id="product_amount1" name="product_amount1"
                                                        placeholder="Enter product amount" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please enter product amount.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="">Delivery Date</label>
                                                    <input type="date" class="form-control" id="delivary_date1" name="delivary_date1"
                                                        placeholder="Enter challenge end date" value="" required="true">
                                                    <div class="invalid-feedback">
                                                        Please select delivery date.
                                                    </div>
                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Product Conversion Count</label>
                                                    <input type="text" class="form-control" id="productconversion1" name="productconversion1"
                                                        placeholder="Enter Product conversion rate" value="1" >
                                                    <div class="invalid-feedback">
                                                        Please enter Product conversion rate.
                                                    </div>

                                                </div>
                                                 <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">2nd Product name</label>
                                                    <input type="text" class="form-control" id="product_name2" name="product_name2"
                                                        placeholder="Enter 2nd product name" value="" >
                                                    <div class="invalid-feedback">
                                                        Please enter 2nd product name.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Image (326*164px,only jpeg/jpg allowed)</label>
                                                    

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">2nd Product Amount</label>
                                                    <input type="text" class="form-control" id="product_amount2" name="product_amount2"
                                                        placeholder="Enter 2nd product amount" value="">
                                                    <div class="invalid-feedback">
                                                        Please enter 2nd product amount.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="">2nd Delivery Date</label>
                                                    <input type="date" class="form-control" id="delivary_date2" name="delivary_date2"
                                                        placeholder="Enter 2nd challenge end date" value="" >
                                                    <div class="invalid-feedback">
                                                        Please select delivery date.
                                                    </div>
                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Product Conversion Count</label>
                                                    <input type="text" class="form-control" id="productconversion2" name="productconversion2"
                                                        placeholder="Enter Product conversion rate" value="1" >
                                                    <div class="invalid-feedback">
                                                        Please enter Product conversion rate.
                                                    </div>

                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01">3rd Product name</label>
                                                    <input type="text" class="form-control" id="product_name3" name="product_name3"
                                                        placeholder="Enter 3rd product name" value="" >
                                                    <div class="invalid-feedback">
                                                        Please enter 3rd product name.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Image (326*164px,only jpeg/jpg allowed)</label>
                                                    

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">3rd Product Amount</label>
                                                    <input type="text" class="form-control" id="product_amount3" name="product_amount3"
                                                        placeholder="Enter 3rd product amount" value="" >
                                                    <div class="invalid-feedback">
                                                        Please enter 3rd product amount.
                                                    </div>

                                                </div>
                                                <div class="col-md-2 mb-3">
                                                    <label for="">3rd Delivery Date</label>
                                                    <input type="date" class="form-control" id="delivary_date3" name="delivary_date3"
                                                        placeholder="Enter 3rd challenge end date" value="" >
                                                    <div class="invalid-feedback">
                                                        Please select delivery date.
                                                    </div>
                                                </div>
                                                
                                                <div class="col-md-2 mb-3">
                                                    <label for="validationCustom01">Product Conversion Count</label>
                                                    <input type="text" class="form-control" id="productconversion3" name="productconversion3"
                                                        placeholder="Enter Product conversion rate" value="1" >
                                                    <div class="invalid-feedback">
                                                        Please enter Product conversion rate.
                                                    </div>

                                                </div>
                                            </div>
                                            <h5 class="card-title">Add Sponsors Product</h5>
                                            <div class="form-row">
                                                <div class="col-md-4 mb-3">
                                                    <label for="validationCustom01">Product name</label>

                                                    <select data-placeholder="Select five products" name="sponsorproductid[]" id="sponsorproductid"
                                                        class="chosen-select form-control" multiple tabindex="6"
                                                        required="true">
                                                        <!--<option value=""></option>
                                                        <optgroup label="NFC EAST">
                                                            <option>Dallas Cowboys</option>
                                                            <option>New York Giants</option>
                                                            <option>Philadelphia Eagles</option>
                                                            <option>Washington Redskins</option>
                                                        <optgroup>-->
                                                     
                                                       	<?php echo array_options($product, $data[0]['sponsorproductid']); ?>
                                                       
                                                    </select>
                                                    <div class="invalid-feedback">
                                                        Please select atleast one sponsors product.
                                                    </div>


                                                </div>

                                            </div>

                                            <div class="d-flex justify-content-end">
                                                <a href=""><button class="btn btn-outline-dark mx-3" type="button">Back
                                                    </button></a>
                                                <button class="btn btn-success" type="submit">Save
                                                </button>

                                            </div>

                                        </form>

                                    </div>
                                </div>
                            </div>
                        </div>












                    </div>
                    
                </div>
                
                <div class="app-wrapper-footer">
                    <div class="app-footer">
                        <div class="app-footer__inner d-flex justify-content-center">
                            <li style="list-style-type: none;">Developed by <a href="https://workmateinfotech.com/">Workmate Infotech Pvt Ltd</a> </li>
                        </div>
                    </div>
                </div>
	</div>
            </div>
        <!-- Bootstrap 4 Modal -->
            
          <div class="success_modal_new">
					<div class="modal fade show" id="statusSuccessModal" tabindex="-1" role="dialog"
						data-bs-backdrop="static" data-bs-keyboard="false">
						<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
							<div class="modal-content">
								<div class="modal-body text-center p-lg-4">
									<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2">
										<circle class="path circle" fill="none" stroke="#198754" stroke-width="6"
											stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
										<polyline class="path check" fill="none" stroke="#198754" stroke-width="6"
											stroke-linecap="round" stroke-miterlimit="10"
											points="100.2,40.2 51.5,88.8 29.8,67.5 " />
									</svg>
									<h4 class="text-success mt-3">Oh Yeah!</h4>
									<p class="mt-3"><div id="messagesuccess"></div></p>
									<button type="button" class="btn btn-sm  btn-success"
										data-dismiss="modal">Ok</button>
								</div>
							</div>
						</div>
					</div>
				</div>
                <div class="success_modal_new">
					<div class="modal fade show" id="statusErrorsModal" tabindex="-1" role="dialog"
						data-bs-backdrop="static" data-bs-keyboard="false">
						<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
							<div class="modal-content">
								<div class="modal-body text-center p-lg-4">
									<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2">
                                        <circle class="path circle" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
                                        <line class="path line" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-linecap="round" stroke-miterlimit="10" x1="34.4" y1="37.9" x2="95.8"
                                            y2="92.3" />
                                        <line class="path line" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-linecap="round" stroke-miterlimit="10" x1="95.8" y1="38" X2="34.4"
                                            y2="92.2" />
                                    </svg>
                                    <h4 class="text-danger mt-3">Oh No!</h4>
                                    <p class="mt-3"><div id="messagefailed"></div></p>
                                    <button type="button" class="btn btn-sm mt-3 btn-danger"
                                        data-dismiss="modal">Ok</button>
								</div>
							</div>
						</div>
					</div>
				</div>

                
            <script src="../assets/scripts/jquery.min.js"></script>
            <script src="../assets/scripts/moment.min.js"></script>
            <script src="../assets/scripts/daterangepicker.min.js"></script>
            <script src="../assets/scripts/custome.js"></script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/js/bootstrap.min.js"></script>
            <script type="text/javascript" src="../assets/scripts/main.js"></script>
            <script src="https://use.fontawesome.com/f9637666d8.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.js"></script>
       
           
            <script>
                $(document).ready(function() {
                  // Check if the URL has a parameter indicating invalid login
                  const urlParams = new URLSearchParams(window.location.search);
                  const message = urlParams.get('message');
              
                  if (message == 'Registered successfully!') {
                    $('#statusSuccessModal').modal('show');
                    $('#messagesuccess').text(message);
                  }
                  else if (message == 'Something went wrong, please try again'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                   else if (message == 'Check Start & end dates'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  else if (message == 'Please upload jpg,jpeg images'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  else if (message == 'Challenge Image size exceeds 1 MB'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  else if (message == 'Product-1 Image size exceeds 1 MB'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  else if (message == 'Product-2 Image size exceeds 1 MB'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  else if (message == 'Product-3 Image size exceeds 1 MB'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  
                    else if (message == 'Challenge image size must be 326 x 203 pixels'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                   else if (message == 'Product-1 image size must be 326 x 164 pixels'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                   else if (message == 'Product-2 image size must be 326 x 164 pixels'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                   else if (message == 'Product-3 image size must be 326 x 164 pixels'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                 
                 
                  
               else if (message == 'A challenge already exist in same period'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
                  // Event listener for modal close event
                  $('#statusSuccessModal').on('hidden.bs.modal', function () {
                    // Remove the message parameter from the URL
                    window.history.replaceState({}, document.title, window.location.pathname);
                  });
                  $('#statusErrorsModal').on('hidden.bs.modal', function () {
                    // Remove the message parameter from the URL
                    window.history.replaceState({}, document.title, window.location.pathname);
                  });
                });
              </script>



</body>

</html>
