b0y-101 Mini Shell


Current Path : E:/www/b-group.old/spfin - Copy/application/admission/appemployee/
File Upload :
Current File : E:/www/b-group.old/spfin - Copy/application/admission/appemployee/action_addappem.php

<?php
include_once("../../../conapps/dbcon.php");

$objCon = mysqli_connect($servername,$username, $password, $dbname);
	// Check connection
if ($objCon->connect_error) {
  die("Connection failed: " . $objCon->connect_error);
}


$data = $_POST;
//print_r($data);
$ref1=$data['ref1'];
//$idproem=$data['idproem'];

//echo("idproem".$idproem);



//ตรวจสอบหมายเลขบัตรประจำตัวประชาชนซ้ำหรือไม่
$check = "SELECT * FROM tb_appemployee tbem  
	WHERE tbem.cardnumber = '".$ref1."' and tbem.procode='EM66' and tbem.idproem=1 and tbem.idadreg = 5 " or die("Error:" . mysqli_error());

	
//print_r($check );	
$qcheck = mysqli_query($objCon, $check );
$fcheck = mysqli_fetch_assoc($qcheck);

if (empty($fcheck)){
	//echo "ไม่ซ้ำ เพิ่มได้";
	
	//นับจำนวนผู้สมัครสอบทั้งหมด กี่คน
	$countnum = "SELECT  * 
                 FROM tb_appemployee  
	             WHERE procode='EM66' and idproem=1 and idadreg = 5 "or die("Error:" . mysqli_error());
	//print_r($countnum);
	$cresult1 = mysqli_query($objCon, $countnum);
    $cnum=mysqli_num_rows($cresult1);
	//print_r($cnum);
	
	//$count1=$cresult1;
	if($cnum > 0)
		{	$cadmissnum = $cnum +1;
		}else{
			//กรณีเป็นค่าแรก
			$cadmissnum = 1;
		}
	
	
	
	
$procode = 'EM66';
$codepay ='01';//รหัสชำระเงิน
$yearb ='166';// ภาค2/65
$amount=300.00; //ค่าสมัครสอบแข่งขัน	
//$numberc = "000000"+$cadmissnum;	
$numberc = sprintf("%'.04d", $cadmissnum);	
$emnumber=	$procode."-".$yearb.$numberc;//เลขที่ใบสมัคร
$idadreg=5;		
$phonenumber=$data['phonenumber'];
$ref2=$idadreg.$phonenumber.$yearb.$numberc.$codepay;
$count = $cnum;
	
	
	
	//ตรวจสอบว่ามีเลข ref2 ซ้ำหรือไม่  เพื่อทำการเพิ่ม ข้อมูล qr
	//$idproject = 33;
$checkqrapi = "SELECT * FROM tb_qrcompcode  
	WHERE ref2 = '".$ref2."' and idproem = 1 and idadreg = 5"
	or die("Error:" . mysqli_error());

$cqrapi = mysqli_query($objCon, $checkqrapi );
$fcqrapi = mysqli_fetch_assoc($cqrapi);
	

	if (empty($fcqrapi)){
	//echo "เพิ่มข้อมูล";
		//}else{
	//echo '<script>alert("พบข้อผิดพลาด ระบบมีข้อมูลแล้ว");window.location="insert_appemployee.php";</script>';
	//	}
	
	
$glname = $data['glname']	;
	//รับค่า idtitle และ idtitleeng
$cap =	$data['cap'];
$idtitlethai =$cap;
$idtitleeng = $cap;
$thainame = $data['thainame'];
$surname = $data['surname'];
$firstname = $data['firstname'];
$lastname = $data['lastname'];
$idproem = 1;
$gender = $data['gender']	;
$birthday=$data['date1']."-".$data['month1']."-".$data['yearhbd'];
$ethnicity=$data['ethnicity'];
$nationality=$data['nationality'];
$mstatus=$data['mstatus'];
$namedad=$data['namedad'];
$namemom=$data['namemom'];
$positionsought=$data['positionsought'];
$department=$data['department'];
$hnumber=$data['hnumber'];
$vnumber=$data['vnumber'];
$vname=$data['vname'];
$soi=$data['soi'];
$road=$data['road'];
$subdistrict=$data['subdistrict'];
$district=$data['district'];
$province=$data['province'];
$zipcode=$data['zipcode'];
$phonenumber=$data['phonenumber'];
$email=$data['email'];
$bdobtained=$data['bdobtained'];
$bmajor=$data['bmajor'];
$bgpa=$data['bgpa'];
$buniversity=$data['buniversity'];
$byeargbe=$data['byeargbe'];
$bcountry=$data['bcountry'];
$mdobtained=$data['mdobtained'];
$mmajor=$data['mmajor'];
$mgpa=$data['mgpa'];
$muniversity=$data['muniversity'];
$myeargbe=$data['myeargbe'];
$mcountry=$data['mcountry'];
$ddobtained=$data['ddobtained'];
$dmajor=$data['dmajor'];
$dgpa=$data['dgpa'];
$duniversity=$data['duniversity'];
$dyeargbe=$data['dyeargbe'];
$dcountry=$data['dcountry'];
$odobtained=$data['odobtained'];
$omajor=$data['omajor'];
$ogpa=$data['ogpa'];
$ouniversity=$data['ouniversity'];
$oyeargbe=$data['oyeargbe'];
$ocountry=$data['ocountry'];
$empreemployer3=$data['empreemployer3'];
$emposition3=$data['emposition3'];
$emfromdate3=$data['emfromdate3'];
$emtodate3=$data['emtodate3'];
$emreasonleav3=$data['emreasonleav3'];
$empreemployer2=$data['empreemployer2'];
$emposition2=$data['emposition2'];
$emfromdate2=$data['emfromdate2'];
$emtodate2=$data['emtodate2'];
$emreasonleav2=$data['emreasonleav2'];
$empreemployer1=$data['empreemployer1'];
$emposition1=$data['emposition1'];
$emfromdate1=$data['emfromdate1'];
$emtodate1=$data['emtodate1'];
$emreasonleav1=$data['emreasonleav1'];
$languageskills1=$data['languageskills1'];
$speak1=$data['speak1'];
$read1=$data['read1'];
$write1=$data['write1'];
$languageskills2=$data['languageskills2'];
$speak2=$data['speak2'];
$read2=$data['read2'];
$write2=$data['write2'];
$computerskill=$data['computerskill'];
$academicex=$data['academicex'];
$otherex=$data['otherex'];


$statusqrcode='รอชำระเงิน';
//$dateapp =date("Y-m-d");
$dateapp = date("d")."-".date("m")."-".(date("Y")+543);
$timeapp =date("h:i:sa");	
	
	//idqrapi สุดท้าย
	$maxqra = "SELECT max(`idqrcomcode`) maxid FROM `tb_qrcompcode` "or die("Error:" . mysqli_error());
	
	$cmaxqra = mysqli_query($objCon, $maxqra);
    $cnumz = mysqli_fetch_assoc($cmaxqra);
    $numz=$cnumz["maxid"];
    $numzz=$numz+1;
	
	
	//$mastertime= "ZRUEE2303222400"	;//กำหนดวันที่สุดท้ายที่ให้ชำระเงิน
    //$timepay= $mastertime.$idadreg.$numzz;//'ZRUEE2303222400ZZZZZ'	
	
	//$c_image = 'noimg.png'; // default value



$strSQL = "INSERT INTO `tb_appemployee` (`idem`,`cardnumber`,`ref2`,`glname`,`emnumber`,`count`,`yearb`,`procode`,`codepay`,`amount`,`idtitlethai`,
`thainame`,`surname`,`idtitleeng`,`firstname`,`lastname`,`gender`,`birthday`,`ethnicity`,`nationality`,`mstatus`,`namedad`,`namemom`,`positionsought`,`department`,`hnumber`,`vnumber`,`vname`,`soi`,`road`,`subdistrict`,`district`,`province`,`zipcode`,`phonenumber`,`email`,`bdobtained`,`bmajor`,`bgpa`,`buniversity`,`byeargbe`,`bcountry`,`mdobtained`,`mmajor`,`mgpa`,`muniversity`,`myeargbe`,`mcountry`,`ddobtained`,`dmajor`,`dgpa`,`duniversity`,`dyeargbe`,`dcountry`,`odobtained`,`omajor`,`ogpa`,`ouniversity`,`oyeargbe`,`ocountry`,`empreemployer3`,`emposition3`,`emfromdate3`,`emtodate3`,`emreasonleav3`,`empreemployer2`,`emposition2`,`emfromdate2`,`emtodate2`,`emreasonleav2`,`empreemployer1`,`emposition1`,`emfromdate1`,`emtodate1`,`emreasonleav1`,`languageskills1`,`speak1`,`read1`,`write1`,`languageskills2`,`speak2`,`read2`,`write2`,`computerskill`,`academicex`,`otherex`,`dateapp`,`timeapp`,`idadreg`,`idproem`) VALUES (NULL,'$ref1','$ref2','$glname','$emnumber',$count,'$yearb','$procode','$codepay','$amount',$idtitlethai,'$thainame','$surname',$idtitleeng,'$firstname','$lastname','$gender','$birthday','$ethnicity','$nationality','$mstatus','$namedad','$namemom','$positionsought','$department','$hnumber','$vnumber','$vname','$soi','$road','$subdistrict','$district','$province','$zipcode','$phonenumber','$email','$bdobtained','$bmajor','$bgpa','$buniversity','$byeargbe','$bcountry','$mdobtained','$mmajor','$mgpa','$muniversity','$myeargbe','$mcountry','$ddobtained','$dmajor','$dgpa','$duniversity','$dyeargbe','$dcountry','$odobtained','$omajor','$ogpa','$ouniversity','$oyeargbe','$ocountry','$empreemployer3','$emposition3','$emfromdate3','$emtodate3','$emreasonleav3','$empreemployer2','$emposition2','$emfromdate2','$emtodate2','$emreasonleav2','$empreemployer1','$emposition1','$emfromdate1','$emtodate1','$emreasonleav1','$languageskills1','$speak1','$read1','$write1','$languageskills2','$speak2','$read2','$write2','$computerskill','$academicex','$otherex','$dateapp','$timeapp',$idadreg,$idproem)";
	
	//print_r($strSQL);
	
$q = mysqli_query($objCon, $strSQL);
$f = mysqli_fetch_assoc($q);
	
	
	//เพิ่มข้อมูล qr tb_qrcompcode
	$qrsql = "INSERT INTO `tb_qrcompcode` (`idqrcomcode`,`ref1`,`ref2`,`amount`,`status`,`statusqrcode`,`dstatus`,`time`,`num`, `receiptnum`, `qrtextname`,`idadreg`,`idproem`) VALUES (NULL,'$ref1','$ref2','$amount','','$statusqrcode', '', '', '', '', '',$idadreg,$idproem)";
	
$qrapi = mysqli_query($objCon, $qrsql);
//$fqrapi = mysqli_fetch_assoc($qrapi);	

//$objQuery = mysqli_query($objCon, $strSQL) or die(mysqli_error($objCon));
if ($q) {
	
	   echo '<script>alert("เพิ่มข้อมูลแล้ว");window.location="https://spfin.ru.ac.th/application/admission/appemployee/login/loginappem.php";</script>';
		
} else {
    echo '<script>alert("พบข้อผิดพลาด");window.location="insert_appemployee.php";</script>';
	//print_r($strSQL);
	//print_r($qrsql);
	//print_r($q);
	//print_r($numzz);
	//print_r($numz);
	
}
		//กรณี REF2 ซ้ำ
	}else{
	//echo '<script>alert("พบข้อผิดพลาด ระบบมีข้อมูลแล้ว");window.location="insert_appemployee.php";</script>';
		
		//echo "Error: " . $strSQL . "<br>" . $objCon->error;
		echo '<script>alert("พบข้อผิดพลาด ระบบมีข้อมูลแล้ว");window.location="insert_appemployee.php";</script>';
		}

	}else{
	
	echo '<script>alert("มีข้อมูลในระบบแล้ว");window.location="insert_appemployee-open.php";</script>';
	
}

	
?>

Copyright © 2019 by b0y-101