Example #1
0
    // cek kesamaan auth dan idhash
    if ($idhash != $auth) {
        eksyen('No Trespassing!', '?p=intern');
    } else {
        if ($aksi == md5("start")) {
            mysql_query("update internship_registration set STATUS='IN PROGRESS', DTMUPD=now(), USRUPD='" . $_SESSION['firstname'] . "' where GUID='{$idinter}'");
            eksyen('It is starting!', '?p=intern');
        } elseif ($aksi == md5("finish")) {
            // update status internship
            mysql_query("update internship_registration set STATUS='DONE', DTMUPD=now(), USRUPD='" . $_SESSION['firstname'] . "' where GUID='{$idinter}'");
            // update quota
            $dq = mysql_query("select * from internship_registration where GUID='{$idinter}'");
            $ddq = mysql_fetch_array($dq);
            $idtopik = $ddq['MASTER_TOPIC_ID'];
            $weeksekarang = findweek(date('d'), 'long');
            $angkaweek = findweek(date('d'), 'short');
            $bln = date('m');
            $thn = date('Y');
            $qw = getdata("quota", "TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'", "WEEK" . $angkaweek);
            $sql = "update quota set " . $weeksekarang . "='{$qw}'+1 where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'";
            mysql_query($sql);
            // kirim email finish
            $_SESSION['namanya'] = data_user_detail($ddq['USER_DETAIL_ID'], "FIRSTNAME");
            $_SESSION['emailnya'] = data_user_detail($ddq['USER_DETAIL_ID'], "EMAIL");
            include 'email/finish.php';
            eksyen('It is finished! ', '?p=intern');
        } else {
            eksyen('No Trespassing!', '?p=intern');
        }
    }
}
Example #2
0
function cekquota($idtopik)
{
    $tgl = date('d');
    $bln = date('m');
    $thn = date('Y');
    $qck = mysql_query("select * from quota where TOPIC_ID='{$idtopik}' and YEAR='{$thn}'");
    $jck = mysql_num_rows($qck);
    // jika berganti tahun
    if ($jck < 1) {
        $qta = mysql_query("select WEEK5 from quota where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='12'");
        $dta = mysql_fetch_array($qta);
        $dweek5 = $dta['WEEK5'];
        mysql_query("insert into quota(GUID,TOPIC_ID,YEAR,MONTH,WEEK1,DTMCRT,USRCRT) values(uuid(),'{$idtopik}','{$thn}'+1,'01','{$dweek5}',now(),'{$_SESSION['username']}')");
        echo "<script>alert('Quota update tahunan')</script>";
    } else {
        $qcb = mysql_query("select * from quota where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'");
        $jcb = mysql_num_rows($qcb);
        // jika berganti bulan
        if ($jcb < 1) {
            $qba = mysql_query("select WEEK5 from quota where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'");
            $dba = mysql_fetch_array($qba);
            $dweek5 = $dba['WEEK5'];
            mysql_query("insert into quota(GUID,TOPIC_ID,YEAR,MONTH,WEEK1,DTMCRT,USRCRT) values(uuid(),'{$idtopik}','{$thn}','{$bln}'+1,'{$dweek5}',now(),'{$_SESSION['username']}')");
            echo "<script>alert('Quota update bulanan')</script>";
        } else {
            $minggu = findweek($tgl, "long");
            $wik = findweek($tgl, "sebelum");
            // minggu sebelumnya
            $qcw = mysql_query("select {$minggu} as minggunya, {$wik} as minggunya2 from quota where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'");
            $dcw = mysql_fetch_array($qcw);
            // jika berganti minggu
            if ($dcw['minggunya'] == NULL) {
                $datanya = $dcw['minggunya2'];
                mysql_query("update quota set {$minggu}='{$datanya}' where TOPIC_ID='{$idtopik}' and YEAR='{$thn}' and MONTH='{$bln}'");
                echo "<script>alert('Quota update mingguan')</script>";
            }
        }
    }
}