Untitled
unknown
plain_text
14 days ago
8.7 kB
3
Indexable
Never
break; case 'absent': $error = array(); list($width, $height) = getimagesize($lokasi_file); if($extension=="jpg" || $extension=="jpeg" ){$src = imagecreatefromjpeg($lokasi_file);} else if($extension=="png"){$src = imagecreatefrompng($lokasi_file);} else {$src = imagecreatefromgif($lokasi_file);} list($width,$height)=getimagesize($lokasi_file); /* ---------- Set Size Foto ----------------*/ $width_new = 300; $height_new = ($height/$width)*$width_new; $tmp_name = imagecreatetruecolor($width_new,$height_new); imagecopyresampled($tmp_name,$src,0,0,0,0,$width_new,$height_new,$width,$height); /* ---------- Set Size Foto ----------------*/ if (empty($_GET['latitude'])) { $error[] = 'Silahkan Izinkan Lokasi Anda saat ini!'; } else { $latitude= mysqli_real_escape_string($connection,$_GET['latitude']); } if (empty($_GET['radius'])) { $error[] = 'Jarak Lokasi tidak ditemukan!'; } else { $radius = mysqli_real_escape_string($connection,$_GET['radius']); } if (empty($_FILES['webcam']['name'])){ $error[] = 'Foto belum di unggah.!'; } else { $file_name = $_FILES['webcam']['name']; $fileExt = pathinfo($_FILES['webcam']['name'], PATHINFO_EXTENSION); $file_size = $_FILES['webcam']['size']; $file_tmp = $_FILES['webcam']['tmp_name']; $sourceProperties = getimagesize($file_tmp); $uploadImageType = $sourceProperties[2]; $sourceImageWidth = $sourceProperties[0]; $sourceImageHeight = $sourceProperties[1]; } if (empty($error)){ $uploadPath = '../sw-content/absent/'; if(in_array($fileExt, $allowed_ext) === true){ if ($file_size <= $max_size) { // Cek User yang sudah login ----------------------------------------------- $query_u="SELECT employees.id,employees.employees_code,employees.employees_name,employees.shift_id,shift.shift_id,shift.time_in,shift.time_out,building.radius FROM employees,shift,building WHERE employees.shift_id=shift.shift_id AND employees.building_id=building.building_id AND employees.id='$row_user[id]'"; $result_u = $connection->query($query_u); if($result_u->num_rows > 0){ $row_u = $result_u->fetch_assoc(); $time_out = strtotime(''.$row_u['time_out'].' - 60 minute'); $time_out = date('H:i:s', $time_out); // Cek Radius Absensi ------------------------------ if($row_u['radius'] > $radius){ // Cek data Absen Berdasarkan tanggal sekarang $query ="SELECT employees_id,time_in,time_out FROM presence WHERE employees_id='$row_u[id]' AND presence_date='$date'"; $result = $connection->query($query); if($result->num_rows > 0){ $row = $result->fetch_assoc(); // Update Absensi Pulang if($time_out < $time){ if($row['time_out']=='00:00:00'){ //Update Jam Pulang /* -------- Upload Foto pulang -------*/ $resizeFileName = 'absen-out-'.$row_user['id'].'-'.time().''; $foto = ''.$resizeFileName.'.'.$fileExt.''; /* -------- Upload Foto pulang -------*/ $update ="UPDATE presence SET time_out='$time',picture_out='$foto',latitude_longtitude_out='$latitude' WHERE employees_id='$row_u[id]' AND presence_date='$date'"; if($connection->query($update) === false) { die($connection->error.__LINE__); echo'Sepetinya sitem kami sedang error!'; } else{ //Jam Pulang echo'success/Selamat "'.$row_user['employees_name'].'" berhasil Absen Pulang pada Tanggal '.tanggal_ind($date).' dan Jam : '.$time.', Hati-hati dijalan saat pulang "'.$row_u['employees_name'].'"!'; switch ($uploadImageType) { case IMAGETYPE_JPEG: $resourceType = imagecreatefromjpeg($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagejpeg($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; case IMAGETYPE_GIF: $resourceType = imagecreatefromgif($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagegif($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; case IMAGETYPE_PNG: $resourceType = imagecreatefrompng($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagepng($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; default: $imageProcess = 0; break; } } } else{ echo'Sebelumnya "'.$row_user['employees_name'].'" sudah pernah Absen Pulang pada Tanggal '.tanggal_ind($date).' dan Jam '.$row['time_out'].'.!'; } }else{ echo'Absen pulang belum diperbolehkan "'.$row_user['employees_name'].'", Absen pulang aktif 60 menit sebelum jam pulang.!'; } // Else Absen Mmasuk }else{ /* -------- Upload Foto Masuk -------*/ $resizeFileName = 'absen-in-'.$row_user['id'].'-'.time().''; $foto = ''.$resizeFileName.'.'.$fileExt.''; /* -------- Upload Foto Masuk -------*/ $add ="INSERT INTO presence (employees_id, presence_date, time_in, time_out, picture_in, picture_out, present_id, latitude_longtitude_in, latitude_longtitude_out, information) values('$row_u[id]', '$date', '$time', '00:00:00', '$foto', '', /*picture out kosong*/ '1', /*hadir*/ '$latitude', '', '')"; if($connection->query($add) === false) { die($connection->error.__LINE__); echo'Sepertinya Sistem Kami sedang error!'; } else{ echo'success/Selamat Anda berhasil Absen Masuk pada Tanggal '.tanggal_ind($date).' dan Jam : '.$time.', Semangat bekerja "'.$row_u['employees_name'].'" !'; switch ($uploadImageType) { case IMAGETYPE_JPEG: $resourceType = imagecreatefromjpeg($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagejpeg($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; case IMAGETYPE_GIF: $resourceType = imagecreatefromgif($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagegif($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; case IMAGETYPE_PNG: $resourceType = imagecreatefrompng($file_tmp); $imageLayer = resizeImage($resourceType,$sourceImageWidth,$sourceImageHeight); imagepng($imageLayer,$uploadPath."".$resizeFileName.'.'. $fileExt); break; default: $imageProcess = 0; break; } } } }else{ echo'Posisi Anda saat ini di radius '.$radius.'M, tidak ditempat atau Jauh dari Radius..!'; }} else{ // Jika user tidak ditemukan echo'User tidak ditemukan';die($connection->error.__LINE__); }} else{ echo 'Foto terlalu besar Maksimal Size 5MB.!'; } } else{ echo'Gambar/Foto yang di unggah tidak sesuai dengan format, Berkas harus berformat JPG,JPEG,GIF..!'; } } else{ foreach ($error as $key => $values) { echo"$values\n"; } }
Leave a Comment