            <div class="block-header">
                <h2>
                     <ol class="breadcrumb breadcrumb-bg-teal">
                                <li><a href="index.php?home"><i class="material-icons">home</i> Home</a></li>
                               <li><a href="index.php?anggota"><i class="material-icons">person</i> Member</a></li>
                                <li class="active"> Member Add/Edit</li>
                            </ol>
                </h2>
            </div>
            
			<?php 
			if(isset($_POST['submit'])){
			$kategori=noninjection($koneksi,$_POST['kategori']);
			$kategori=ucwords($kategori);
			$idmember=noninjection($koneksi,$_POST['idmember']);
			$nik=noninjection($koneksi,$_POST['nik']);
			$nama=noninjection($koneksi,$_POST['nama']);
			$alamat=noninjection($koneksi,$_POST['alamat']);
			$phone=noninjection($koneksi,$_POST['phone']);
			$status=noninjection($koneksi,$_POST['status']);
			$kelompok=noninjection($koneksi,$_POST['kelompok']);
				$rfid=noninjection($koneksi,$_POST['rfid']);
			$status=strtoupper($status);
			$email=noninjection($koneksi,$_POST['email']);
			$password=noninjection($koneksi,$_POST['password']);
			$password2=noninjection($koneksi,$_POST['password2']);
			
			$pin=noninjection($koneksi,$_POST['pin']);
			$pin2=noninjection($koneksi,$_POST['pin2']);
			$task="34567fghjkl;FGHJK09865fghjs12345@#$@#$!@#";
			
			 	if(!empty($_FILES["file"]["name"])) { 
        // File info
				$uploadPath = "images/foto2/"; 
       			 $fileName = basename($_FILES["file"]["name"]); 
        		$imageUploadPath = $uploadPath . $fileName; 
        		$fileType = pathinfo($imageUploadPath, PATHINFO_EXTENSION); 
         
        // Allow certain file formats 
         		$allowTypes = array('jpg','png','jpeg','JPG','PNG','JPEG'); 
				if(in_array($fileType, $allowTypes)){ 
            // Image temp source and size 
            		$imageTemp = $_FILES["file"]["tmp_name"]; 
            		$imageSize = $_FILES["file"]["size"]; 
             
            // Compress size and upload image 
           
             
				if (move_uploaded_file($_FILES["file"]["tmp_name"], $imageUploadPath)) 
				{ $filex="https://cashless.sdibanjarmasin.id/koperasi/".$imageUploadPath;} else {$filex='-';}
			} else {$filex='-';}
			} else {$filex='-';}
		
			
				if(isset($_GET['edit']))
			{
			//edit data
				$koneksi_host=open_connection2();
			if(($idmember<>'') and ($nama<>'') and ($alamat<>'') and ($phone<>'') and ($kategori<>'') and ($status<>'')){
			$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `nik`='".$nik."',`rfid`='".$rfid."', `nama`='".$nama."', `alamat`='".$alamat."', `phone`='".$phone."', `kelompok`='".$kelompok."', `kategori`='".$kategori."',`status`='".$status."', iduser='".$_SESSION['iduser']."' WHERE idanggota='".$idmember."'");
		
			//	$res=mysqli_query($koneksi_host,"UPDATE tbregistrasi SET nama_siswa='".$nama."',kat='".$kategori."' WHERE (nis='".$idmember."') AND (npns='".$_SESSION['npsn']."')");
					if($filex <>'-'){$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `img`='".$filex."' WHERE idanggota='".$idmember."'"); }
			}
			
			if(($email<>'') and ($password<>'') and ($password2<>'')){
			$password=md5($password);
			$password=md5($password.$email.$task);
			$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `email`='".$email."',`password`='".$password."' WHERE idanggota='".$idmember."'");
		//		$res=mysqli_query($koneksi_host,"UPDATE tbregistrasi SET `email`='".$email."',`password`='".$password."' WHERE (nis='".$idmember."') AND (npns='".$_SESSION['npsn']."')");
			}
			
			if(($pin<>'') and ($pin2<>'')){
			$pin=md5($pin);
			$pin=md5($pin.$task);
				$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `pin`='".$pin."' WHERE idanggota='".$idmember."'");
			}
			
			if($res){echo ' <div class="alert bg-green alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <strong>Well done!</strong> Edit Data Sukses.
                            </div>';
							}else {
							echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> Edit Data Gagal.
                            </div>';
							}
			
			} else{
			//tambah data
				$koneksi_host=open_connection2();
			if(($idmember<>'') and ($nama<>'')  and ($alamat<>'') and ($phone<>'') and ($kategori<>'') and ($status<>'') and ($pin<>'') and ($password<>''))
			{
				if($password==$password2)
				{
					if($pin==$pin2)
					{
					$password=md5($password);
					$password=md5($password.$email.$task);
					
					$pin=md5($pin);
					$pin=md5($pin.$task);
					
					$qry_cari=mysqli_query($koneksi,"SELECT * FROM `tb_anggota` WHERE idanggota='".$idmember."'");
					$N=mysqli_num_rows($qry_cari);
					if($N<>0)
					{
					$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `nik`='".$nik."', ,`rfid`='".$rfid."' `nama`='".$nama."', `alamat`='".$alamat."', `phone`='".$phone."', `kategori`='".$kategori."', `kelompok`='".$kelompok."', `email`='".$email."', `password`='".$password."', `pin`='".$pin."', `status`='".$status."',iduser='".$_SESSION['iduser']."' WHERE idanggota='".$idmember."'");
					if($filex<>'-'){$res=mysqli_query($koneksi,"UPDATE tb_anggota SET `img`='".$filex."' WHERE idanggota='".$idmember."'"); }
				//	$res=mysqli_query($koneksi_host,"UPDATE tbregistrasi SET nama_siswa='".$nama."',kat='".$kategori."',`email`='".$email."',`password`='".$password."' WHERE (nis='".$_SESSION['iduser']."') AND (npns='".$_SESSION['npsn']."')");
			
					}else{
					$res=mysqli_query($koneksi,"INSERT INTO `tb_anggota` (`idanggota`, `nik`, `nama`, `alamat`, `phone`, `kategori`,`kelompok`, `email`, `password`, `pin`,rfid,rfid_new,img, `status`, iduser, `tgl`) VALUES ('".$idmember."', '".$nik."', '".$nama."', '".$alamat."', '".$phone."', '".$kategori."','".$kelompok."', '".$email."', '".$password."', '".$pin."','".$rfid."','0', '".$filex."', '".$status."', '".$_SESSION['iduser']."', current_timestamp());");
				//	$res=mysqli_query($koneksi_host,"INSERT INTO `tbregistrasi` ( `kat`, `npns`, `nama_sekolah`, `nisn`, `nama_siswa`, `nis`, `email`, `password`, `tgl`) VALUES
//('".$kategori."', '".$_SESSION['npsn']."', '".$_SESSION['sekolah']."', '".$idmember."', '".$nama."', '".$idmember."', '".$email."', '".$password."',  current_timestamp());");
					}
					if($res){echo ' <div class="alert bg-green alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <strong>Well done!</strong> Simpan Data Sukses.
                            </div>';
							}else {
							echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> Simpan Data Gagal.
                            </div>';
							}
					}else {echo '<div class="alert alert-warning alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                 <strong>Warning!</strong> PIN tidak Sama.
                            </div>';} 
				
				}else {echo '<div class="alert alert-warning alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                 <strong>Warning!</strong> Password tidak Sama.
                            </div>';}
			} else {echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> Input Data dengan lengkap.
                            </div>';}
			}}
			
			if(isset($_GET['edit']))
			{
			    $edit=noninjection($koneksi,$_GET['edit']);
			    $qry_cari=mysqli_query($koneksi,"SELECT * FROM `tb_anggota` WHERE idanggota='".$edit."'");
			    $row=mysqli_fetch_array($qry_cari);
			    $kategori=$row['kategori'];
			    $idmember=$row['idanggota'];
			    $nik=$row['nik'];
			    $nama=$row['nama'];
			    $alamat=$row['alamat'];
			    $phone=$row['phone'];
			    $status=$row['status'];
			    $email=$row['email'];
			    $kelompok=$row['kelompok'];
			    $rfid=$row['rfid'];
			}else {
			    $rfid='';
			    $kategori='';
			    $idmember='';
			    $nik='';
			    $nama='';
			    $alamat='';
			    $phone='';
			    $kelompok='';
			    $status='';
			    $email='';
			}
			
			?>
 <div class="row clearfix">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="card">
                        <div class="header">
                            <h2>MEMBER ADD</h2>
                           
                        </div>
                        <div class="body">
						
		
                            <form id="form_advanced_validation" enctype="multipart/form-data" method="POST" action="index.php?anggota<?php if(isset($_GET['edit'])){$edit=noninjection($koneksi,$_GET['edit']);echo "&edit=".$edit;}?>">
							<div class="form-group form-float">
                                    <div class="form-line">
                                       <div class="form-group">
									   
									 <input type="radio" name="kategori" value="Siswa" id="santri" class="with-gap" <?php if(($kategori=='Siswa') or ($kategori=='')){?>checked="checked"<?php }?>>
                                    <label for="santri">Siswa</label>
									   
                                    <input type="radio" name="kategori" value="Karyawan" id="karyawan" class="with-gap" <?php if($kategori=='Karyawan'){?>checked="checked"<?php }?>>
                                    <label for="karyawan">Karyawan</label>

                                   
                                </div>
                                       
                                    </div>
									
                                    <div class="help-info">Kategori</div>
                                </div>
							
                                <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="idmember" maxlength="10" minlength="3" onkeypress="return isNumberKey(event);" value="<?php echo $idmember;?>" required>
                                        <label class="form-label">ID Member</label>
                                    </div>
                                    <div class="help-info">Min. 3, Max. 10 characters [Numeric] <b>Ex: 2022060001</b></div>
                                </div>
								
								  <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="kelompok"  value="<?php echo $kelompok;?>" required>
                                        <label class="form-label">Kelompok</label>
                                    </div>
                                    <div class="help-info">Kelompok </b></div>
                                </div>
								
									<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="rfid"   value="<?php echo $rfid;?>" >
                                        <label class="form-label">RFID</label>
                                    </div>
                                    <div class="help-info">Tap Kartu RFID </div>
                                </div>
								
								<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="nik" onkeypress="return isNumberKey(event);" maxlength="20" minlength="8" value="<?php echo $nik;?>" required>
                                        <label class="form-label">NIK</label>
                                    </div>
                                    <div class="help-info">Nomor Induk Kependudukan <b>Ex: 105024570890 0001</b></div>
                                </div>
								
                                <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="nama" value="<?php echo $nama;?>" required>
                                        <label class="form-label">Nama</label>
                                    </div>
                                    <div class="help-info">Min. Value: 3, Max. Value: 120</div>
                                </div>
								
								 <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="alamat"  value="<?php echo $alamat;?>" required>
                                        <label class="form-label">Alamat</label>
                                    </div>
                                    <div class="help-info">Min. Value: 3, Max. Value: 200</div>
                                </div>
								
								
                                <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" name="phone" class="form-control" onkeypress="return isNumberKey(event);" value="<?php echo $phone;?>"  required>
                                        <label class="form-label">Phone</label>
                                    </div>
                                    <div class="help-info">Ex: 08530000000</div>
                                </div>
								
								
							<div class="form-group form-float">
                                    <div class="form-line">
                                    
                                      <input name="file" type="file"  class="form-control" accept="image/png, image/jpeg, image/jpg" />
                                    </div>
                                    <div class="help-info">Foto </div>
                                </div> 	
                                
								
                              <div class="form-group form-float">
                                    <div class="form-line">
                                       <div class="form-group">
									 <input type="radio" name="status" value="OPEN" id="on" class="with-gap" <?php if(($status=='OPEN') or ($status=='')){?>checked="checked"<?php }?>>
                                    <label for="on">OPEN</label>
									   
                                    <input type="radio" name="status" value="SUSPEND" id="suspend" class="with-gap" <?php if($status=='SUSPEND'){?>checked="checked"<?php }?>>
                                    <label for="suspend">SUSPEND</label>

                                    <input type="radio" name="status" value="CLOSE" id="close" class="with-gap" <?php if($status=='CLOSE'){?>checked="checked"<?php }?>>
                                    <label for="close" class="m-l-20">CLOSE</label>
                                </div>
                                       
                                    </div>
									
                                    <div class="help-info">Status</div>
                                </div>
								
								<div class="header">
                           		 <h2>USER LOGIN MEMBER</h2>
                       			 </div>
								
								<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="email" class="form-control" name="email" value="<?php echo $email;?>"  required>
                                        <label class="form-label">Email</label>
                                    </div>
                                    <div class="help-info">member@gmail.com</div>
                                </div>
								
								<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="password" class="form-control" name="password">
                                        <label class="form-label">Password</label>
                                    </div>
                                    <div class="help-info">Min. 8 characters</div>
                                </div>
								
								<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="password" class="form-control" name="password2">
                                        <label class="form-label">Password Confirm</label>
                                    </div>
                                    <div class="help-info">Min. 8 characters / Ulangi password</div>
                                </div>
								<div class="header">
                           		 <h2>PIN TRANSAKSI</h2>
                       			 </div>
								
									<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="password" class="form-control" name="pin" >
                                        <label class="form-label">PIN</label>
                                    </div>
                                    <div class="help-info">Min. 6 characters, untuk keamanan Transaksi</div>
                                </div>
								
								<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="password" class="form-control" name="pin2" >
                                        <label class="form-label">PIN Confirm</label>
                                    </div>
                                    <div class="help-info">Min. 6 characters / Ulangi PIN</div>
                                </div>
								
                                <button class="btn btn-primary waves-effect" name="submit" type="submit" data-toggle="tooltip" data-placement="right" title="Simpan Data">SUBMIT</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- #END# Advanced Validation -->