<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");
require("../phpqrcode/qrlib.php");
cek_session_admin();
(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';

if ($pg == 'ubah') {
	$kodex=1;
		$data = [
        'qrcode'        => $_POST['kode']
		
    ];
    update($koneksi, 'pengaturan', $data, ['id_setting' => 1]);
	$tempdir = "../../temp/"; 
if (!file_exists($tempdir)) 
	
    mkdir($tempdir);
  
$codeContents = $_POST['kode'];
QRcode::png($codeContents, $tempdir . $_POST['kode'] . '.png', QR_ECLEVEL_M, 8);
}
if ($pg == 'gps') {
	
	$data = [
        'lat'        => $_POST['lat'],
		 'lon'        => $_POST['lon'],
		  'jarak'        => $_POST['jarak']
    ];
    update($koneksi, 'pengaturan', $data, ['id_setting' => 1]);
}