$qu2 = mysql_query($sql); $row2 = mysql_fetch_array($qu2); $sql = "SELECT dana_" . tahun_ke($tahun) . " as dana FROM m_aldana_kegiatan WHERE kdgiat = '" . $row['kdgiat'] . "'"; $qu3 = mysql_query($sql); $row3 = mysql_fetch_array($qu3); #$sql = "SELECT id FROM thbp_kak_kegiatan WHERE th = '".$tahun."' AND kdunitkerja = '".$row2['kdunitkerja']."' AND kdgiat = '".$row['kdgiat']."' AND kddept = '".$row2['kddept']."' AND kdunit = '".$row2['kdunit']."' AND kdprogram = '".$row2['kdprogram']."' AND jml_anggaran = '".$row3['dana']."'"; #$cek = mysql_query($sql); ## Mengisi tabel thbp_kak_kegiatan #if (mysql_num_rows($cek) == 0) #{ $sql = "INSERT INTO thbp_kak_kegiatan VALUES ('','" . $tahun . "','" . $row['kdunitkerja'] . "','" . $row2['kddept'] . "','" . $row2['kdunit'] . "','" . $row2['kdprogram'] . "','" . $row['kdgiat'] . "','" . $row3['dana'] . "')"; # echo $sql.";<br>"; mysql_query($sql); #} $thnn = $tahun - 1; $sql = "SELECT kdoutput, target_" . tahun_ke($thnn) . " as volume1, target_" . tahun_ke($tahun) . " as volume2, masuk_renja FROM m_ikk_kegiatan WHERE kdgiat = '" . $row['kdgiat'] . "' AND masuk_renja = '1' ORDER BY kdoutput"; $qu4 = mysql_query($sql); while ($row4 = mysql_fetch_array($qu4)) { $volume = $row4['volume2'] - $row4['volume1']; #$sql = "SELECT id FROM thbp_kak_output WHERE th = '".$tahun."' AND kdunitkerja = '".$row2['kdunitkerja']."' AND kdgiat = '".$row['kdgiat']."' AND kdoutput = '".$row4['kdoutput']."' AND volume = '".$volume."'"; #$cek = mysql_query($sql); ## Mengisi tabel thbp_kak_output #if (mysql_num_rows($cek) == 0) #{ $thnn = $tahun - 1; $kodee = $row['kdgiat'] . $row4['kdoutput']; $anggaran = anggaran_output($thnn, $kodee); $sql = "INSERT INTO thbp_kak_output VALUES ('','" . $tahun . "','" . $row2['kdunitkerja'] . "','" . $row['kdgiat'] . "','" . $row4['kdoutput'] . "','" . $anggaran . "','" . $row4['volume'] . "','')"; #echo $sql.";<br>"; mysql_query($sql); #}
if (isset($form)) { if ($err != true) { $tahun_dipa = $_REQUEST['tahun_dipa']; $tahun = $_REQUEST['tahun']; $sql = "SELECT KDGIAT, sum(JUMLAH) as anggaran_dipa FROM d_item WHERE THANG='{$tahun_dipa}' GROUP BY KDGIAT ORDER BY KDGIAT"; $qu = mysql_query($sql); #hapus dulu datanya $sql = "DELETE FROM thbp_kak_kegiatan WHERE th = '" . $tahun . "'"; mysql_query($sql); $sql = "DELETE FROM thbp_kak_output WHERE th = '" . $tahun . "'"; mysql_query($sql); while ($row = mysql_fetch_array($qu)) { $sql = "SELECT kdunitkerja, kddept, kdunit, kdprogram FROM tb_giat WHERE kdgiat = '" . $row['KDGIAT'] . "'"; $qu2 = mysql_query($sql); $row2 = mysql_fetch_array($qu2); $sql = "SELECT dana_" . tahun_ke($tahun) . " as dana FROM m_aldana_kegiatan WHERE kdgiat = '" . $row['KDGIAT'] . "'"; $qu3 = mysql_query($sql); $row3 = mysql_fetch_array($qu3); #$sql = "SELECT id FROM thbp_kak_kegiatan WHERE th = '".$tahun."' AND kdunitkerja = '".$row2['kdunitkerja']."' AND kdgiat = '".$row['kdgiat']."' AND kddept = '".$row2['kddept']."' AND kdunit = '".$row2['kdunit']."' AND kdprogram = '".$row2['kdprogram']."' AND jml_anggaran = '".$row3['dana']."'"; #$cek = mysql_query($sql); ## Mengisi tabel thbp_kak_kegiatan #if (mysql_num_rows($cek) == 0) #{ $sql = "INSERT INTO thbp_kak_kegiatan VALUES ('','" . $tahun . "','" . $row2['kdunitkerja'] . "','" . $row2['kddept'] . "','" . $row2['kdunit'] . "','" . $row2['kdprogram'] . "','" . $row['KDGIAT'] . "','" . $row3['dana'] . "','" . $row['anggaran_dipa'] . "','" . $row['anggaran_dipa'] . "')"; # echo $sql.";<br>"; mysql_query($sql); #} $sql = "SELECT KDOUTPUT, SUM(JUMLAH) as dipa_output FROM d_item WHERE THANG='{$tahun_dipa}' and KDGIAT='{$row['KDGIAT']}' GROUP BY KDOUTPUT ORDER BY KDOUTPUT"; $qu4 = mysql_query($sql); while ($row4 = mysql_fetch_array($qu4)) { $sql = "SELECT VOL FROM d_output WHERE THANG='{$tahun_dipa}' and KDDEPT='{$row2['kddept']}' and KDUNIT='{$row2['kdunit']}' and KDPROGRAM='{$row2['kdprogram']}' and KDGIAT='{$row['KDGIAT']}' and KDOUTPUT='{$row4['KDOUTPUT']}'";