<?php
session_start();
require('../lib/dbclass.php');
//header('location:logout.php');
$disable = 0;

if ($_GET['blockid']) {
    $id   = $_GET['blockid'];
    $data = findQuery("select tbl_transaction.clubid,tbl_customer.name,tbl_customer.Mobile,tbl_customer.Panchayat,tbl_customer.Ward,tbl_customer.id custid,tbl_transaction.sponsorship,tbl_transaction.donation from  
tbl_transaction inner join tbl_customer on tbl_customer.id=tbl_transaction.customerid where tbl_transaction.id=$id");
    $disable = 0;
}

$panchayat = $data[0]['Panchayat'];


if ($data[0]['donation'] == 1) {
    $type = 2;
} elseif ($data[0]['sponsorship'] == 1) {
    $type = 1;
} else {
    $type = 0;
}

$ward = get_option('tbl_ward', 'ward_name', 'id!=0 and status=0 and panchayat_id=' . $panchayat);



if ($data[0]['sponsorship'] == 1 || $data[0]['donation'] == 1) {
    $usertyp = [];
} else {
    $club    = get_option('tbl_club', 'club_name', 'id!=0 and status=0');
    $usertyp = $club;
}
?>

<!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><?php echo sitename ?></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="<?php echo sitename ?>">
    <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="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.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/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="user_management.php">Challenge Report Management</a></li>
                                    <li class="breadcrumb-item"><a href="add_user.php">Edit Details</a></li>

                                </ol>
                            </nav>






                        </div>
                        <div class="row ">
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                       
                                        
                                         <?php
                                    if ($id == 0) {
                                        ?>
                                       <h5 class="card-title">Add </h5>
                                    <?php
                                    } else {
                                        ?>
                                   
                                     <h5 class="card-title">Edit </h5>
                                    <?php
                                    }
?>
                                        
                                        
                                        
                                        <form class="needs-validation" novalidate="true" action="save.php" method="post">
                                            <div class="form-row">
                                                
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01"> Transaction Type</label>
                                                 <select name="type" class="form-control" >
					 <option value="0" <?php if ($type == 0) {
					     echo 'selected="selected"';
					 }?>>Challenge</option>
				 <option value="1" <?php if ($type == 1) {
				     echo 'selected="selected"';
				 }?>>Sponsorship</option>
				 <option value="2" <?php if ($type == 2) {
				     echo 'selected="selected"';
				 }?>>Donation</option>
				  
				 </select>
                      </div>                         
                                                    <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01"> Organsiation</label>
                                                    <select name="clubid" id=""
 class="mb-2 form-control select2" >
                                                       
				  	<?php    echo array_options($usertyp, $data[0]['clubid']); ?>
				  </select>
                                                         
                                                </div>
                                               
                                                
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01"> Name</label>
                                                    <input type="text" class="form-control" id="validationCustom01"
                                                        placeholder="Enter name" value="<?php echo $data[0]['name'] ?>" required="true" name="name" id="name"
                                                        >
                                                        <div class="invalid-feedback">
                                                             Please enter name.
                                                            </div> 
                                                </div>
                                                
                                                <div class="col-md-3 mb-3">
                                                    <label for="validationCustom01"> Mobile</label>
                                                    <input type="text" class="form-control" id="validationCustom01"
                                                        placeholder="Enter mobile" value="<?php echo $data[0]['Mobile'] ?>" required  name="mobile" id="mobile"
                                                        >
                                                        <div class="invalid-feedback">
                                                             Please enter mobile.
                                                            </div> 
                                                </div>
                                                <div class="col-md-3 mb-3">
                                                    <label for="Ward">Ward</label>
                                                    <!--<select class="mb-2 form-control">
                                                        <option>Select district</option>
                                                        <option>Default Select</option>
                                                        <option>Default Select</option>
                                                        <option>Default Select</option>
                                                        <option>Default Select</option>
                                                        </select>-->
                                                        
                                                        
                        <select name="ward_id" id="ward_id"
 class="mb-2 form-control select2" required>
				  	<?php echo array_options($ward, $data[0]['Ward']); ?>
				  </select>
				  
				      
                                           <div id="select-feedback" class="invalid-feedback mt-3">
                                                            Please select
                                                            </div>    
				    </div>
				    
				    
				     
                                                      
                                           
                                                
                                                
                                                 
                                                
                                            </div>
                                            <div class="d-flex justify-content-end">
                                               <a href="challengereport.php"> <button class="btn btn-outline-dark mx-3" type="button">Back</button></a>
                                                
                                                <button class="btn btn-success" type="submit">Save
                                                </button>
                                            
                                            <input type="hidden" id="id" name="id" value="<?php echo $_GET['blockid'] ?>">
                                            <input type="hidden" id="typeid" name="typeid" value="<?php echo $type ?>">
                                            <input type="hidden" id="custid" name="custid" value="<?php echo $data[0]['custid'] ?>"> 
                                            
                                            
                                            </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 == 'Already Taken.'){
                    $('#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>
