Web service buggy

Permisi apakah ada yang salah dengan kodingan saya ? soalnya ketika saya mau input data absen via android, webservice saya selalu "false"=> insert ditolak.

Kira-kira kenapa ya? Terima kasih banyak

<?php
//reporting_error(0);
//error_reporting(E_ALL);
include("../class.mysql.php");
date_default_timezone_set('Asia/Jakarta');

$response = array();
$odometer	= isset($_POST['odometer']);
$nama		= isset($_POST['namaoutlet']);
$keterangan	= isset($_POST['ket']);
$IMEINumber	= isset($_POST['kodeImei']);
$statusr	= isset($_POST['nilaiAbsen']);
$lng		= isset($_POST['LocationLong']);
$lat		= isset($_POST['LocationLat']);

$fileName   = isset($_POST['image_data']).'.jpg';

function getAdd($lat, $lng) {
	//$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';

 	$json = @file_get_contents($url);
 	$data=json_decode($json);
 	$status = $data->status;
 	if($status=="OK"){
   		return $data->results[0]->formatted_address;
 	}else{
   		return false;
 	}
}
$alamatReal = getAdd($lat,$lng);

$tanggal	= date("Y-m-d");
$jam		= date("H");
$detik		= date("i:s");
$tglGab		= $tanggal.' '.$jam.':'.$detik;

$dbCekAcc	= new database;
$dbCekAcc->query("SELECT ID FROM t_account WHERE imei_number='$IMEINumber'");
$rCekAcc=$dbCekAcc->tampilkan();

//Random Key
$lengthkey=10;
$key = "";
$kar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$k = 0;
while ($k < $lengthkey) {
	$char = substr($kar, mt_rand(0, strlen($kar)-1), 1);
	if (!strstr($key, $char)) {
        $key .= $char;
        $k++;
	}
}
//Fungsi Jarak
function distance($lat1, $lng1, $lat2, $lng2, $miles = true){
        $pi80 = M_PI / 180;
        $lat1 *= $pi80;
        $lng1 *= $pi80;
        $lat2 *= $pi80;
        $lng2 *= $pi80;
        $r = 6372.797; // radius dalam km
        $dlat = $lat2 - $lat1;
        $dlng = $lng2 - $lng1;
        $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
        $km = $r * $c;
        return ($miles ? ($km * 0.621371192) : $km);
}
function namahari($tanggal){
    $tgl=substr($tanggal,8,2);
    $bln=substr($tanggal,5,2);
    $thn=substr($tanggal,0,4);
    $info=date('w', mktime(0,0,0,$bln,$tgl,$thn));
    switch($info){
        case '0': return "Minggu"; break;
        case '1': return "Senin"; break;
        case '2': return "Selasa"; break;
        case '3': return "Rabu"; break;
        case '4': return "Kamis"; break;
        case '5': return "Jumat"; break;
        case '6': return "Sabtu"; break;
    };
}

$radiusData	= 100;
$dbHide = new database;
$dbHide->query("SELECT loc_attedance FROM t_account WHERE imei_number='$IMEINumber'");
$rHide=$dbHide->tampilkan();

//define time set for attedance max
$wktmasuk ="7.45";
$wktpulang ="17.00";

$inAbsen = new database;
		$strA['phoneNumber'] 	= "$IMEINumber";
		$strA['alamat'] 		= "$alamatReal";
		$strA['tanggal'] 		= "$tanggal";
		$strA['jam'] 			= "$jam";
		$strA['gambar'] 		= "$fileName";
		$strA['keterangan'] 	= "$keterangan";
		$strA['km'] 			= "$odometer";
		$strA['posisi'] 		= "$statusr";
		$strA['at_lat'] 		= "$lat";
		$strA['at_lng'] 		= "$lng";
	$inAbsen->insert("t_attedance",$strA);

	$insert	= new database;
		$str['loket_name'] 		= "$nama";
		$str['phoneNumber'] 	= "$IMEINumber";
		$str['getLatitude'] 	= "$lat";
		$str['getLongitude'] 	= "$lng";
		$str['alamat'] 			= "$alamatReal";
		$str['tanggal'] 		= "$tglGab";
		$str['gambar'] 			= "$fileName";
		$str['saran'] 			= "$keterangan";
		$str['km'] 			    = "$odometer";
		$str['stat_penjualan'] 	= "N";
		$str['dcrypt'] 	        = "N";
	$insert->insert("t_report",$str);
	//Insert Absen

//cek posting terakhir
$dbCekPts	= new database;
$dbCekPts->query("SELECT tanggal FROM t_report WHERE phoneNumber='$IMEINumber' AND stat_penjualan='N' ORDER BY tanggal DESC LIMIT 1");
$rCekPts=$dbCekPts->tampilkan();

$tgl = $rCekPts['tanggal'];

$jam_db_tamabah = date('Y-m-d H:i:s', strtotime($tgl. ' + 3 minutes'));

if($tglGab > $jam_db_tamabah)
{

	if($lng == "" || $lat == "" )
	{
		$response["value"] = 0;
		$response["message"] = "Masih mencari koordinat. Pastikan Koneksi dan GPS aktif.";
		echo json_encode($response);

	}elseif($rHide['loc_attedance']=="Y"){

		//Cari Posisi Absensi
		$dbPosisi	= new database;
		$dbPosisi->query("SELECT * FROM t_lock_attedance WHERE imeiNumber='$IMEINumber'");
		$jmlPosisi = 0;
		while($rPosisi	= $dbPosisi->tampilkan()){
			$jarak = round(distance($lat,$lng,$rPosisi['loc_lat'],$rPosisi['loc_lng'])*1000);
			if($jarak <= $radiusData){
				$jmlPosisi = $jmlPosisi+1;
			}
		}
		$hariSenin = namahari($tanggal);
		if($hariSenin == "Senin"){

			$insert	= new database;
				$str['loket_name'] 		= "$nama";
				$str['phoneNumber'] 	= "$IMEINumber";
				$str['getLatitude'] 	= "$lat";
				$str['getLongitude'] 	= "$lng";
				$str['alamat'] 			= "$alamatReal";
				$str['tanggal'] 		= "$tglGab";
				$str['gambar'] 			= "$fileName";
				$str['saran'] 			= "$keterangan";
				$str['km'] 			    = "$odometer";
				$str['stat_penjualan'] 	= "N";
				$str['dcrypt'] 	        = "N";
			$insert->insert("t_report",$str);
			//Insert Absen
			$inAbsen = new database;
				$strA['phoneNumber'] 	= "$IMEINumber";
				$strA['alamat'] 		= "$alamatReal";
				$strA['tanggal'] 		= "$tanggal";
				$strA['jam'] 			= "$jam";
				$strA['gambar'] 		= "$fileName";
				$strA['keterangan'] 	= "$keterangan";
				$strA['km'] 			= "$odometer";
				$strA['posisi'] 		= "$statusr";
				$strA['at_lat'] 		= "$lat";
				$strA['at_lng'] 		= "$lng";

			$inAbsen->insert("t_attedance",$strA);
			if($inAbsen){
				$response["value"] = 1;
				$response["message"] = "Absensi Berhasil";
				echo json_encode($response);
			}else{
				$response["value"] = 0;
				$response["message"] = "Data Gagal di input";
				echo json_encode($response);
			}
		}
		else{
			if($jmlPosisi > 0){
				$insert	= new database;
				$str['loket_name'] 		= "$nama";
				$str['phoneNumber'] 	= "$IMEINumber";
				$str['getLatitude'] 	= "$lat";
				$str['getLongitude'] 	= "$lng";
				$str['alamat'] 			= "$alamatReal";
				$str['tanggal'] 		= "$tglGab";
				$str['gambar'] 			= "$fileName";
				$str['saran'] 			= "$keterangan";
				$str['km'] 			    = "$odometer";
				$str['stat_penjualan'] 	= "N";
				$str['dcrypt'] 	        = "N";
				$insert->insert("t_report",$str);
				//Insert Absen
				$inAbsen = new database;
					$strA['phoneNumber'] 	= "$IMEINumber";
					$strA['alamat'] 		= "$alamatReal";
					$strA['tanggal'] 		= "$tanggal";
					$strA['jam'] 			= "$jam";
					$strA['gambar'] 		= "$fileName";
					$strA['keterangan'] 	= "$keterangan";
					$strA['km'] 			= "$odometer";
					$strA['posisi'] 		= "$statusr";
					$strA['at_lat'] 		= "$lat";
					$strA['at_lng'] 		= "$lng";
				$inAbsen->insert("t_attedance",$strA);
				if($insert){
					$response["value"] = 1;
					$response["message"] = "Absensi Berhasil";
					echo json_encode($response);
				}else{
					$response["value"] = 0;
					$response["message"] = "Data Gagal di input";
					echo json_encode($response);
				}
			}
			else{
					$response["value"] = 0;
					$response["message"] = "Maaf, Anda di luar jangkauan Max. $radiusData";
					echo json_encode($response);
			}
		}
	}
	else{
		$insert	= new database;
		$str['loket_name'] 		= "$nama";
		$str['phoneNumber'] 	= "$IMEINumber";
		$str['getLatitude'] 	= "$lat";
		$str['getLongitude'] 	= "$lng";
		$str['alamat'] 			= "$alamatReal";
		$str['tanggal'] 		= "$tglGab";
		$str['gambar'] 			= "$fileName";
		$str['saran'] 			= "$keterangan";
		$str['km'] 			    = "$odometer";
		$str['stat_penjualan'] 	= "N";
		$str['dcrypt'] 	        = "N";
		$insert->insert("t_report",$str);
		//Insert Absen
		$inAbsen = new database;
			$strA['phoneNumber'] 	= "$IMEINumber";
			$strA['alamat'] 		= "$alamatReal";
			$strA['tanggal'] 		= "$tanggal";
			$strA['jam'] 			= "$jam";
			$strA['gambar'] 		= "$fileName";
			$strA['keterangan'] 	= "$keterangan";
			$strA['km'] 			= "$odometer";
			$strA['posisi'] 		= "$statusr";
			$strA['at_lat'] 		= "$lat";
			$strA['at_lng'] 		= "$lng";
		$inAbsen->insert("t_attedance",$strA);
		if($inAbsen){
			$response["value"] = 1;
			$response["message"] = "Absensi Berhasil";
			echo json_encode($response);
		}else{
			$response["value"] = 0;
			$response["message"] = "Data Gagal di input";
			echo json_encode($response);
		}

	}
}
else
{
	$response["value"] = 0;
	$response["message"] = "Insert Ditolak.";
	echo json_encode($response);
}*/

?>
avatar adiernes
@adiernes

24 Kontribusi 0 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

Kalo diliat dari validasinya, kode msg itu jalan kalo ga memenuhi validasi ini

<pre> if($tglGab &gt; $jam_db_tamabah) </pre>

Yang artinya pas ngirim data jam di db nya lebih tinggi dari jam pas ngirim.. coba cek disitu.. mungkin salah pas insert

avatar apem
@apem

72 Kontribusi 27 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban