/** * doJournal * Lakukan Jurnal berdasarkan data yang diberikan */ public function doJournal($pt, $kodeJurnal, $dataRes, $counter, $ketKelompok = "", $updateCounter = true) { global $dbname; #Cek Nojurnal sudah terdaftar, Jika sudah terdaftar exit $sCek = "select nojurnal from " . $dbname . ".keu_jurnaldt where nojurnal='" . $dataRes['header']['nojurnal'] . "'"; $qCek = mysql_query($sCek) or die(mysql_error($conn)); $rCek = mysql_num_rows($qCek); if ($rCek != 0) { exit("warning: Nojurnal :" . $dataRes['header']['nojurnal'] . " sudah ada"); } $qHeader = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); $qDetail = insertQuery($dbname, 'keu_jurnaldt', $dataRes['detail']); $dataIns = array($pt, $kodeJurnal, $ketKelompok, $counter); $insCounter = insertQuery($dbname, 'keu_5kelompokjurnal', $dataIns); $updCounter = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $counter), "kodeorg='" . $pt . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($qHeader)) { echo "Header DB Error: " . mysql_error() . "\n"; $this->rbJournal($dataRes['header']['nojurnal']); exit; } else { if (!mysql_query($qDetail)) { echo "Detail DB Error: " . mysql_error() . "\n"; $this->rbJournal($dataRes['header']['nojurnal']); exit; } else { if ($updateCounter) { if (!mysql_query($insCounter)) { // Insert Kelompok Jurnal jika belum ada if (!mysql_query($updCounter)) { // Update jika sudah ada echo "DB Error: " . mysql_error() . "\n"; $this->rbJournal($dataRes['header']['nojurnal']); exit; } } } } } }
function scraping_test($url, $num, $conn) { // create HTML DOM $url = $num == 1 ? $url : $url . '?s=' . $num; $html = file_get_html($url); // get Whole class of each product details $newVar = $html->find('p[class="row"]'); $productInformation = array(); foreach ($newVar as $key => $products) { $price = trim($products->find('span.price', 0)->plaintext); $title = trim($products->find('a.hdrlnk', 0)->plaintext); // remove $ sign from price $price = $price == "" ? '0' : str_replace("$", "", $price); // We have to create text file to save Data in insert queries if ($title != '' && $price != '') { $str = "INSERT INTO product_details(id,title,price) VALUES (NULL,'" . addslashes($title) . "',{$price});\n"; } $result = insertQuery($str, $conn); } $html->clear(); unset($html); return $ret; }
$data = $_POST; unset($data['proses']); switch ($_POST['proses']) { case 'add': # Check Valid Data foreach ($data as $key => $row) { if ($row == '') { echo "Error : Data " . $key . " tidak boleh kosong"; exit; } } # Unset Data unset($data['namabarang']); unset($data['satuan']); # Make Query $query = insertQuery($dbname, 'setup_kegiatannorma', $data); # Insert Data if (!mysql_query($query)) { echo "DB Error : " . mysql_error($conn); } else { echo $_SESSION['theme']; } break; case 'edit': $data = $_POST; unset($data['proses']); unset($data['primary']); unset($data['primVal']); $primary = explode('##', $_POST['primary']); $primVal = explode('##', $_POST['primVal']); unset($primary['namabarang']);
$Form->setError('error', 'Please write user password'); } // Password if (!isset($_POST['phone']) || empty($_POST['phone'])) { $Form->setError('error', 'Please write user phone number'); } // Agency if (!isset($_POST['agency']) || empty($_POST['agency'])) { $Form->setError('error', 'Please select a agency'); } /** * Error Found! * Redirect back to form page */ if ($Form->num_errors > 0) { $Form->return_msg_to('add-a-user.php'); } $first_name = cleanData($_POST['first_name']); $last_name = cleanData($_POST['last_name']); $email = cleanData($_POST['email']); $password = cleanData($_POST['password']); $phone = cleanData($_POST['phone']); $agency = cleanData($_POST['agency']); $userAdd = insertQuery(TBL_USER, array('type' => 'user', 'agency_id' => $agency, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'password' => $password, 'phone_no' => $phone, 'create_date' => 'NOW()')); if (!$userAdd) { $Form->setError('error', 'Database error! Please try again.'); $Form->return_msg_to('add-a-user.php'); } else { $Form->setError('success', 'New user added successfully'); $Form->return_msg_to('user.php'); }
function prosesAlokasi() { global $conn; global $tanggal; global $param; global $dbname; global $defSegment; #1 ambil periode akuntansi $str = "select tanggalmulai,tanggalsampai from " . $dbname . ".setup_periodeakuntansi where \r\n kodeorg ='" . $_SESSION['empl']['lokasitugas'] . "' and tutupbuku=0"; $tgmulai = ''; $tgsampai = ''; $res = mysql_query($str); if (mysql_num_rows($res) < 1) { exit("Error: Tidak ada periode akuntansi untuk induk " . $_SESSION['empl']['lokasitugas']); } while ($bar = mysql_fetch_object($res)) { $tgsampai = $bar->tanggalsampai; $tgmulai = $bar->tanggalmulai; } if ($tgmulai == '' || $tgsampai == '') { exit("Error: Periode akuntasi tidak terdaftar"); } #2 output pada jurnal kolom noreferensi ALK_KERJA_AB $group = 'VHC1'; #ambil akun alokasi $str = "select noakundebet from " . $dbname . ".keu_5parameterjurnal\r\n where jurnalid='" . $group . "' limit 1"; $res = mysql_query($str); if (mysql_num_rows($res) < 1) { exit("Error: No.Akun pada parameterjurnal belum ada untuk VHC1"); } else { $bar = mysql_fetch_object($res); $akunalok = $bar->noakundebet; } #3 ambil semua lokasi kegiatan $str = "select sum(a.jumlah) as jlh,a.alokasibiaya,b.noakun,a.kodesegment from " . $dbname . ".vhc_rundt a\r\n left join " . $dbname . ".vhc_kegiatan b on a.jenispekerjaan=b.kodekegiatan\r\n left join " . $dbname . ".vhc_runht c on a.notransaksi=c.notransaksi \r\n where c.kodevhc='" . $param['kodevhc'] . "'\r\n and c.tanggal>='" . $tgmulai . "' and c.tanggal <='" . $tgsampai . "' and alokasibiaya!='' \r\n and jenispekerjaan!='' \r\n group by jenispekerjaan,noakun,alokasibiaya,kodesegment"; // if($param['kodevhc']=='B9530XR'){ // echo "Error".$str;exit(); // } $res = mysql_query($str); //echo mysql_error($conn); $lokasi = array(); $biaya = array(); $jam = array(); $akun = array(); $kodeasset = array(); $segment = array(); $ttl = 0; while ($bar = mysql_fetch_object($res)) { #kusus jika project if (substr($bar->alokasibiaya, 0, 2) == 'AK' or substr($bar->alokasibiaya, 0, 2) == 'PB') { #ambil akun aktiva dalam konstruksi $tipeasset = substr($bar->alokasibiaya, 3, 3); $tipeasset = str_replace("0", "", $tipeasset); $str1 = "select akunak from " . $dbname . ".sdm_5tipeasset where kodetipe='" . $tipeasset . "'"; $res1 = mysql_query($str1); if (mysql_num_rows($res1) < 1) { exit(" Error: Akun aktiva dalam konstruksi untuk " . $tipeasset . " beum disetting dari keuangan->setup->tipeasset"); } else { while ($bar1 = mysql_fetch_object($res1)) { if ($bar1->akunak == '') { exit(" Error: Akun aktiva dalam konstruksi untuk " . $tipeasset . " beum disetting dari keuangan->setup->tipeasset"); } else { $akun[] = $bar1->akunak; } } $kodeasset[] = $bar->alokasibiaya; $lokasi[] = $bar->alokasibiaya; $jam[] = $bar->jlh; $biaya[] = $bar->jlh * $param['jumlah']; $kegiatan[] = ''; $segment[] = $bar->kodesegment; } } else { $lokasi[] = $bar->alokasibiaya; $akun[] = $bar->noakun; $jam[] = $bar->jlh; $biaya[] = $bar->jlh * $param['jumlah']; $kegiatan[] = $bar->noakun . "01"; $kodeasset[] = ''; $segment[] = $bar->kodesegment; } } // foreach ($jam as $key=>$val) // { // $biaya[$key] =$val*$param['jumlah']; // } foreach ($biaya as $key => $nilai) { #periksa unit $dataRes['header'] = array(); $dataRes['detail'] = array(); $intern = true; $pengguna = substr($lokasi[$key], 0, 4); if (substr($lokasi[$key], 0, 2) == 'AK' or substr($lokasi[$key], 0, 2) == 'PB') { #khusus project $str = "select kodeorg from " . $dbname . ".project where kode='" . $lokasi[$key] . "'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $pengguna = $bar->kodeorg; $lokasi[$key] = ''; } } #ambil piutang ke pengguna $str = "select akunpiutang,jenis from " . $dbname . ".keu_5caco where kodeorg='" . $pengguna . "'"; $res = mysql_query($str); $intraco = ''; $interco = ''; while ($bar = mysql_fetch_object($res)) { if ($bar->jenis == 'intra') { $intraco = $bar->akunpiutang; } else { $interco = $bar->akunpiutang; } } #++++++++++++++++++++++++++++++++++++++ $akunpekerjaan = $akun[$key]; #++++++++++++++++++++++++++++++++++++++++ $ptpengguna = ''; $str = "select induk from " . $dbname . ".organisasi where kodeorganisasi='" . $pengguna . "'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $ptpengguna = $bar->induk; } $ptGudang = ''; $str = "select induk from " . $dbname . ".organisasi where kodeorganisasi='" . $_SESSION['empl']['lokasitugas'] . "'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $ptGudang = $bar->induk; } #jika pt tidak sama maka pakai akun interco $akunpengguna = ''; if ($ptGudang != $ptpengguna) { #ambil akun interco $intern = false; $str = "select akunhutang from " . $dbname . ".keu_5caco where kodeorg='" . $_SESSION['empl']['lokasitugas'] . "' and jenis='inter'"; $res = mysql_query($str); $akunpengguna = ''; while ($bar = mysql_fetch_object($res)) { $akunpengguna = $bar->akunhutang; } $akunsendiri = $interco; if ($akunpengguna == '') { exit("Error: Akun intraco atau interco belum ada untuk unit " . $pengguna); } } else { if ($pengguna != $_SESSION['empl']['lokasitugas']) { #jika satu pt beda kebun #ambil akun intraco $intern = false; $str = "select akunhutang from " . $dbname . ".keu_5caco where kodeorg='" . $_SESSION['empl']['lokasitugas'] . "' and jenis='intra'"; $res = mysql_query($str); $akunpengguna = ''; while ($bar = mysql_fetch_object($res)) { $akunpengguna = $bar->akunhutang; } $akunsendiri = $intraco; if ($akunpengguna == '') { exit("Error: Akun intraco atau interco belum ada untuk unit " . $pengguna); } } else { $intern = true; } } if ($intern) { #proses data $kodeJurnal = $group; #======================== Nomor Jurnal ============================= # Get Journal Counter $queryJ = selectQuery($dbname, 'keu_5kelompokjurnal', 'nokounter', "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "' "); $tmpKonter = fetchData($queryJ); $konter = addZero($tmpKonter[0]['nokounter'] + 1, 3); # Transform No Jurnal dari No Transaksi $nojurnal = str_replace("-", "", $tanggal) . "/" . $_SESSION['empl']['lokasitugas'] . "/" . $kodeJurnal . "/" . $konter; #======================== /Nomor Jurnal ============================ # Prep Header $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodeJurnal, 'tanggal' => $tanggal, 'tanggalentry' => date('Ymd'), 'posting' => 1, 'totaldebet' => $biaya[$key], 'totalkredit' => -1 * $biaya[$key], 'amountkoreksi' => '0', 'noreferensi' => 'ALK_KERJA_AB', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akunpekerjaan, 'keterangan' => $param['periode'] . ':Biaya Kendaraan ' . $param['kodevhc'], 'jumlah' => $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => $kodeasset[$key], 'kodebarang' => '', 'nik' => 0, 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => $lokasi[$key], 'revisi' => '0', 'kodesegment' => $segment[$key]); $noUrut++; # Kredit $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akunalok, 'keterangan' => $param['periode'] . ':Alokasi biaya kend' . $param['kodevhc'], 'jumlah' => -1 * $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => '', 'kodebarang' => '', 'nik' => '0', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => $lokasi[$key], 'revisi' => '0', 'kodesegment' => $segment[$key]); $noUrut++; $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header Intern Error : ' . mysql_error() . "\n"; } if (empty($headErr)) { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); if (!mysql_query($insDet)) { $detailErr .= "Insert Detail Intern Error : " . mysql_error() . "\n"; break; } } if ($detailErr == '') { # Header and Detail inserted #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Update Kode Jurnal $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($updJurnal)) { echo "Update Kode Jurnal Error : " . mysql_error() . "\n"; # Rollback if Update Failed $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error() . "\n"; exit; } exit; } else { } } else { echo $detailErr; # Rollback, Delete Header $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error(); exit; } } } else { echo $headErr; exit; } } else { # Data Detail $noUrut = 1; #proses data $kodeJurnal = $group; #======================== Nomor Jurnal ============================= # Get Journal Counter $queryJ = selectQuery($dbname, 'keu_5kelompokjurnal', 'nokounter', "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "' "); $tmpKonter = fetchData($queryJ); $konter = addZero($tmpKonter[0]['nokounter'] + 1, 3); # Transform No Jurnal dari No Transaksi $nojurnal = str_replace("-", "", $tanggal) . "/" . $_SESSION['empl']['lokasitugas'] . "/" . $kodeJurnal . "/" . $konter; #======================== /Nomor Jurnal ============================ # Prep Header $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodeJurnal, 'tanggal' => $tanggal, 'tanggalentry' => date('Ymd'), 'posting' => 1, 'totaldebet' => $biaya[$key], 'totalkredit' => -1 * $biaya[$key], 'amountkoreksi' => '0', 'noreferensi' => 'ALK_KERJA_AB', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akunsendiri, 'keterangan' => $param['periode'] . ':Biaya Kendaraan ' . $param['kodevhc'], 'jumlah' => $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => '', 'kodebarang' => '', 'nik' => '0', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; # Kredit $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akunalok, 'keterangan' => $param['periode'] . ':Alokasi biaya kend' . $param['kodevhc'], 'jumlah' => -1 * $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => '', 'kodebarang' => '', 'nik' => '0', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header Ex.Self Error : ' . mysql_error() . "\n"; } if (empty($headErr)) { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); if (!mysql_query($insDet)) { $detailErr .= "Insert Detail Ex.Self Error : " . mysql_error() . "\n"; break; } } if ($detailErr == '') { # Header and Detail inserted #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Update Kode Jurnal $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($updJurnal)) { echo "Update Kode Jurnal Error : " . mysql_error() . "\n"; # Rollback if Update Failed $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error() . "\n"; exit; } exit; } else { } } else { echo $detailErr; # Rollback, Delete Header $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error(); exit; } } } else { echo $headErr; exit; } #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #sisi Pengguna $kodeJurnal = $group; #ambil periodeaktif pengguna // $strd="select tanggalmulai,tanggalsampai from ".$dbname.".setup_periodeakuntansi where // kodeorg='".$pengguna."' and tutupbuku=0"; // // $resd=mysql_query($strd); // $tgmulaid=''; // while($bard=mysql_fetch_object($resd)) // { // $tgmulaid = $bard->tanggalmulai; // } // if($tgmulaid=='' or substr($tgmulaid,0,7)==substr($tanggal,0,7))#jika periode sama maka biarkan $tgmulaid = $tanggal; #======================== Nomor Jurnal ============================= # Get Journal Counter $queryJ = selectQuery($dbname, 'keu_5kelompokjurnal', 'nokounter', "kodeorg='" . $ptpengguna . "' and kodekelompok='" . $kodeJurnal . "' "); $tmpKonter = fetchData($queryJ); $konter = addZero($tmpKonter[0]['nokounter'] + 1, 3); # Transform No Jurnal dari No Transaksi $nojurnal = str_replace("-", "", $tgmulaid) . "/" . $pengguna . "/" . $kodeJurnal . "/" . $konter; #======================== /Nomor Jurnal ============================ # Prep Header unset($dataRes['header']); //ganti header $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodeJurnal, 'tanggal' => $tgmulaid, 'tanggalentry' => date('Ymd'), 'posting' => 1, 'totaldebet' => $biaya[$key], 'totalkredit' => -1 * $biaya[$key], 'amountkoreksi' => '0', 'noreferensi' => 'ALK_KERJA_AB', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); //print_r($dataRes['header']); //exit("Error"); # Debet 1 $noUrut = 1; unset($dataRes['detail']); //ganti header $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tgmulaid, 'nourut' => $noUrut, 'noakun' => $akunpekerjaan, 'keterangan' => $param['periode'] . ':Biaya Kendaraan ' . $param['kodevhc'], 'jumlah' => $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $pengguna, 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => $kodeasset[$key], 'kodebarang' => '', 'nik' => '0', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => $lokasi[$key], 'revisi' => '0', 'kodesegment' => $segment[$key]); $noUrut++; # Kredit 1 $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tgmulaid, 'nourut' => $noUrut, 'noakun' => $akunpengguna, 'keterangan' => $param['periode'] . ':Alokasi biaya kend' . $param['kodevhc'], 'jumlah' => -1 * $biaya[$key], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $pengguna, 'kodekegiatan' => $kegiatan[$key], 'kodeasset' => '', 'kodebarang' => '', 'nik' => '0', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_KERJA_AB', 'noaruskas' => '', 'kodevhc' => $param['kodevhc'], 'nodok' => '', 'kodeblok' => $lokasi[$key], 'revisi' => '0', 'kodesegment' => $segment[$key]); $noUrut++; $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header OSIDE Error : ' . mysql_error() . "\n"; } if (empty($headErr)) { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); if (!mysql_query($insDet)) { $detailErr .= "Insert Detail OSIDE Error : " . mysql_error() . "\n" . $insDet; break; } } if ($detailErr == '') { # Header and Detail inserted #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Update Kode Jurnal $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $ptpengguna . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($updJurnal)) { echo "Update Kode Jurnal Error : " . mysql_error() . "\n"; # Rollback if Update Failed $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error() . "\n"; exit; } exit; } else { } } else { echo $detailErr; # Rollback, Delete Header $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error(); exit; } } } else { echo $headErr; exit; } } } }
$data = array(); if (is_array($_POST['data'])) { foreach ($_POST['data'] as $key => $row) { if ($_POST['jenis'] == 'po') { $jumlah = $row['jumlah']; $satuan = $row['satuan']; } elseif ($_POST['jenis'] == 'pl') { $jumlah = 1; $satuan = 'PETI'; } else { $jumlah = 0; $satuan = $row['satuan']; } $data[] = array('nosj' => $_POST['nosj'], 'kodept' => $_POST['kodept'], 'kodebarang' => $row['kodebarang'], 'jenis' => strtoupper($_POST['jenis']), 'jumlah' => $jumlah, 'satuanpo' => $satuan, 'nopo' => isset($row['nopo']) ? $row['nopo'] : '', 'nopp' => isset($row['nopp']) ? $row['nopp'] : '', 'notransaksireferensi' => '', 'jumlahditerima' => 0); } $query = insertQuery($dbname, 'log_suratjalandt', $data); mysql_query($query) or die("Error DB: " . mysql_error()); } break; // Save Detail // Save Detail case 'saveDetail': $where = "nosj='" . $param['nosj'] . "' and kodept='" . $param['kodept'] . "' and kodebarang='" . $param['kodebarang'] . "' and nopo='" . $param['nopo'] . "' and nopp='" . $param['nopp'] . "'"; $cols = "*"; $data = array('jumlah' => $param['jumlah']); if (isset($param['newNopo'])) { $data['nopo'] = $param['newNopo']; $data['nopp'] = $param['newNopp']; } $query = updateQuery($dbname, 'log_suratjalandt', $data, $where); mysql_query($query) or die("Error DB: " . mysql_error());
case 'add': $cols = array('kodekegiatan', 'kodeorg', 'kodesegment', 'hasilkerja', 'jumlahhk', 'upahkerja', 'umr', 'upahpremi', 'notransaksi', 'tahuntanam', 'norma', 'statusblok', 'pekerjaanpremi', 'penalti1', 'penalti2', 'penalti3', 'penalti4', 'penalti5', 'nik'); $data = $param; unset($data['numRow']); # Additional Default Data $data['tahuntanam'] = 0; $data['norma'] = 0; $data['statusblok'] = '0'; $data['pekerjaanpremi'] = '0'; $data['penalti1'] = 0; $data['penalti2'] = 0; $data['penalti3'] = 0; $data['penalti4'] = 0; $data['penalti5'] = 0; $data['nik'] = '-'; $query = insertQuery($dbname, 'kebun_prestasi', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } unset($data['notransaksi']); unset($data['tahuntanam']); unset($data['norma']); unset($data['statusblok']); unset($data['pekerjaanpremi']); unset($data['penalti1']); unset($data['penalti2']); unset($data['penalti3']); unset($data['penalti4']); unset($data['penalti5']); unset($data['nik']);
function simpanData($x, $jenisdata) { global $dbname; global $conn; global $pemisah; $jlhbaris = count($x) - 1; #baris pertama adalah header; foreach ($x[0] as $val) { $header[] = trim($val); } switch ($jenisdata) { case 'ACCBAL': #ambil noakun $str = "select noakun from " . $dbname . ".keu_5akun where length(noakun)=7"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $noakun[] = $bar->noakun; } #periksa kelengkapan data if (count($x[0]) != 4) { exit("Error: Form not valid"); } foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { if ($header[$ids] == 'periode' and strlen($rinc) != 6) { exit("Error: some data on period not valid (line " . $key . ")"); } else { if ($header[$ids] == 'noakun' and strlen($rinc) != 7) { exit("Error: some data on noakun not valid (line " . $key . ")"); } else { if ($header[$ids] == 'kodeorg' and strlen($rinc) != 4) { exit("Error: some data on kodeorg not valid (line " . $key . $rinc . ")"); } else { if ($header[$ids] == 'noakun') { #periksa noakun yang disubmit $akunbermasalah[$rinc] = $rinc; foreach ($noakun as $bb => $cc) { if ($cc == $rinc) { unset($akunbermasalah[$rinc]); } } } } } } } } } if (count($akunbermasalah) > 0) { echo "The following account number were not defined:<br>"; print_r($akunbermasalah); exit; } #ambil kolom periode foreach ($header as $ki => $val) { if ($val == 'periode') { $index = $ki; } if ($val == 'kodeorg') { $idkOrg = $ki; } } $column = 'awal' . substr($x[1][$index], 4, 2); foreach ($header as $ki => $val) { if ($val == 'saldo') { $header[$ki] = $column; $indexNumeric = $ki; } } #delete first $str = "delete from " . $dbname . ".keu_saldobulanan where kodeorg='" . $x[1][$idkOrg] . "' and periode='" . $x[1][$index] . "'"; mysql_query($str); #generate SQL: $stringSQL = "insert into " . $dbname . ".keu_saldobulanan("; foreach ($header as $ki => $val) { if ($ki == 0) { $stringSQL .= $val; } else { $stringSQL .= "," . $val; } } $stringSQL .= ") values"; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ki => $val) { if ($ki == 0) { if ($key == 1) { $stringSQL .= "('" . trim($val) . "'"; } else { $stringSQL .= ",('" . trim($val) . "'"; } } else { $stringSQL .= ",'" . trim($val) . "'"; } } $stringSQL .= ")"; } } $stringSQL .= ";"; if (mysql_query($stringSQL)) { echo "Uploaded"; } else { echo mysql_error($conn) . $stringSQL; } break; #===========================================================end prevbal ====================================================== #===========================================================end prevbal ====================================================== case 'JOURNAL': #ambil noakun $str = "select noakun from " . $dbname . ".keu_5akun where length(noakun)=7"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $noakun[] = $bar->noakun; } #ambil nik $str = "select karyawanid from " . $dbname . ".datakaryawan"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $nik[] = $bar->karyawanid; } #ambil kegiatan $str = "select kodekegiatan from " . $dbname . ".setup_kegiatan"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $kegiatan[] = $bar->kodekegiatan; } #ambil supplier $str = "select supplierid from " . $dbname . ".log_5supplier"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $supplier[] = $bar->supplierid; } #ambil custommer $str = "select kodecustomer from " . $dbname . ".pmn_4customer"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $custommer[] = $bar->kodecustomer; } #ambil blok $str = "select kodeorg from " . $dbname . ".setup_blok"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $blok[] = $bar->kodeorg; } #periksa kelengkapan data $zz = 0; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { $x[$key][$ids] = trim($rinc); if ($header[$ids] == 'tanggal') { $rinc = str_replace('-', '', $rinc); $rinc = str_replace('/', '', $rinc); if (strlen($rinc) != 8) { exit("Error: some data on date not valid (line " . $key . ")"); } else { if (substr($rinc, 0, 4) < '2000') { exit("Error: date not valid (line " . $key . ")"); } else { $x[$key][$ids] = $rinc; } } } if ($header[$ids] == 'noakun' and strlen($rinc) != 7 and $rinc != '0') { exit("Error: some data on noakun not valid (line " . $key . ")"); } if ($header[$ids] == 'kodeorg' and strlen($rinc) != 4) { exit("Error: some data on kodeorg not valid (line " . $key . ")"); } if ($header[$ids] == 'matauang') { if (trim($rinc) == '') { exit("Error: some data on currency not valid (line " . $key . ")"); } } if ($header[$ids] == 'kurs') { if (trim($rinc) == '') { $x[$key][$ids] = 1; } } if ($header[$ids] == 'nourut') { if (trim($rinc) == '') { $x[$key][$ids] = $zz++; } } if ($header[$ids] == 'noakun') { #periksa noakun yang disubmit $akunbermasalah[$rinc] = $rinc; foreach ($noakun as $bb => $cc) { if ($cc == $rinc or trim($rinc) == '0') { unset($akunbermasalah[$rinc]); } } } if ($header[$ids] == 'nik' and trim($rinc) != '') { #periksa nik yang disubmit $nikbermasalah[$rinc] = $rinc; foreach ($nik as $bb => $cc) { if ($cc == $rinc) { unset($nikbermasalah[$rinc]); } } } if ($header[$ids] == 'kodekegiatan' and trim($rinc) != '') { $kegiatanbermasalah[$rinc] = $rinc; foreach ($kegiatan as $bb => $cc) { if ($cc == $rinc) { unset($kegiatanbermasalah[$rinc]); } } } if ($header[$ids] == 'kodesupplier' and trim($rinc) != '') { $supplierbermasalah[$rinc] = $rinc; foreach ($supplier as $bb => $cc) { if ($cc == $rinc) { unset($supplierbermasalah[$rinc]); } } } if ($header[$ids] == 'kodecustomer' and trim($rinc) != '') { $custommerbermasalah[$rinc] = $rinc; foreach ($custommer as $bb => $cc) { if ($cc == $rinc) { unset($custommerbermasalah[$rinc]); } } } if ($header[$ids] == 'kodeblok' and trim($rinc) != '') { $blokbermasalah[$rinc] = $rinc; foreach ($blok as $bb => $cc) { if ($cc == $rinc) { unset($blokbermasalah[$rinc]); } } } } } } $bermasalah = false; if (count($akunbermasalah) > 0) { echo "The folowing account number were not defined:<br>"; print_r($akunbermasalah); $bermasalah = true; } if (count($nikbermasalah) > 0) { echo "The folowing NIK were not defined:<br>"; print_r($nikbermasalah); $bermasalah = true; } if (count($kegiatanbermasalah) > 0) { echo "The folowing activity code were not defined:<br>"; print_r($kegiatanbermasalah); $bermasalah = true; } if (count($supplierbermasalah) > 0) { echo "The folowing supplier/contractor code were not defined:<br>"; print_r($supplierbermasalah); $bermasalah = true; } if (count($custommerbermasalah) > 0) { echo "The folowing custommer code were not defined:<br>"; print_r($custommerbermasalah); $bermasalah = true; } if (count($blokbermasalah) > 0) { echo "The folowing block code were not defined:<br>"; print_r($blokbermasalah); $bermasalah = true; } if ($bermasalah) { exit; } #periksa jumlah debet dan kredit foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { if ($header[$ids] == 'jumlah') { $total += $rinc; $tt += abs($rinc); } } } } $tdecre = $tt / 2; if (abs($total) > 100) { exit("Error:Total amount not balance:" . $total); } #create header journal #ambil kolom periode foreach ($header as $ki => $val) { if ($val == 'tanggal') { $itanggal = $ki; } if ($val == 'nojurnal') { $inojurnal = $ki; } if ($val == 'kurs') { $ikurs = $ki; } if ($val == 'matauang') { $imatauang = $ki; } if ($val == 'noreferensi') { $inoreferensi = $ki; } } // #delete first $str = "delete from " . $dbname . ".keu_jurnalht where nojurnal='" . $x[2][$inojurnal] . "'"; mysql_query($str); #generate header journal $str = "insert into " . $dbname . ".keu_jurnalht (`nojurnal`, `kodejurnal`, `tanggal`, `tanggalentry`, `posting`, `totaldebet`, `totalkredit`, `amountkoreksi`, `noreferensi`, `autojurnal`, `matauang`, `kurs`, `revisi`) VALUES\n ('" . $x[2][$inojurnal] . "', 'Hist', '" . $x[2][$itanggal] . "', '" . date('Ymd') . "', 1," . $tdecre . ", -" . $tdecre . ", '0', '" . $x[2][$inoreferensi] . "', 1, '" . $x[2][$imatauang] . "', " . $x[2][$ikurs] . ", 0);"; // #generate detail SQL: $stringSQL = "insert into " . $dbname . ".keu_jurnaldt("; foreach ($header as $ki => $val) { if ($ki == 0) { $stringSQL .= $val; } else { $stringSQL .= "," . $val; } } $stringSQL .= ") values"; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ki => $val) { if ($ki == 0) { if ($key == 1) { $stringSQL .= "('" . trim($val) . "'"; } else { $stringSQL .= ",('" . trim($val) . "'"; } } else { $stringSQL .= ",'" . trim($val) . "'"; } } $stringSQL .= ")"; } } $stringSQL .= ";"; if (mysql_query($str)) { #insert header if (mysql_query($stringSQL)) { #insert detail echo "Uploaded"; } else { echo "Error insert detail " . mysql_error($conn) . $stringSQL; } } else { echo "Error insert header " . mysql_error($conn) . $str; } break; #===========================================================end prevbal ====================================================== #==============================BEGIN MATERIAL #===========================================================end prevbal ====================================================== #==============================BEGIN MATERIAL case 'INV': #ambil blok $str = "select kodebarang from " . $dbname . ".log_5masterbarang"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $barang[] = $bar->kodebarang; } #ambil kodeorganisasi $str = "select kodeorganisasi from " . $dbname . ".organisasi"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $org[] = $bar->kodeorganisasi; } #periksa kelengkapan data $zz = 0; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { $x[$key][$ids] = trim($rinc); } } } foreach ($header as $ki => $val) { if ($val == 'periode') { $iperiode = $ki; } if ($val == 'kodeorg') { $ikodeorg = $ki; } if ($val == 'kodebarang') { $ikodebarang = $ki; } if ($val == 'saldoakhirqty') { $isaldoakhirqty = $ki; } if ($val == 'hargarata') { $ihargarata = $ki; } if ($val == 'kodegudang') { $ikodegudang = $ki; } } #periksa periode gudang $str = "select periode from " . $dbname . ".setup_periodeakuntansi where periode='" . $x[1][$iperiode] . "' and\n kodeorg='" . $x[1][$ikodegudang] . "' and tutupbuku=0"; $res = mysql_query($str); if (mysql_num_rows($res) < 1) { exit("Error: Accounting period for " . $x[1][$ikodegudang] . " not defined"); } #periksa pt apakah terdaftar atau tidak $kodept = false; foreach ($org as $bb => $vb) { if ($x[1][$ikodeorg] == $vb) { $kodept = true; } } if (!$kodept) { exit("Error : Company code not found"); } #periksa kode barang foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { $arrkodemasalah[$arr[$ikodebarang]] = $arr[$ikodebarang]; foreach ($barang as $tt => $gh) { if ($arr[$ikodebarang] == $gh) { unset($arrkodemasalah[$arr[$ikodebarang]]); } } if ($arr[$ihargarata] == '0') { $hargamasalah[$arr[$ikodebarang]] = $arr[$ikodebarang]; } if ($arr[$isaldoakhirqty] <= '0') { $qtymasalah[$arr[$isaldoakhirqty]] = $arr[$isaldoakhirqty]; } } } if (count($arrkodemasalah) > 0) { echo " The folowing material code not defined on material master:"; print_r($arrkodemasalah); exit; } else { if (count($hargamasalah) > 0) { echo " The folowing material with blank price"; print_r($hargamasalah); exit; } else { if (count($qtymasalah) > 0) { echo " The folowing material with blank qty"; print_r($qtymasalah); exit; } } } // #delete first $str = "delete from " . $dbname . ".log_5saldobulanan where periode='" . $x[1][$iperiode] . "' and kodegudang='" . $x[1][$ikodegudang] . "'"; mysql_query($str); $str = "delete from " . $dbname . ".log_5masterbarangdt where kodegudang='" . $x[1][$ikodegudang] . "'"; mysql_query($str); #generate sql $stringSQL = "insert into " . $dbname . ".log_5saldobulanan(kodeorg,kodebarang,saldoakhirqty,hargarata,lastuser,periode,\n nilaisaldoakhir,kodegudang,saldoawalqty,hargaratasaldoawal,nilaisaldoawal) values"; $stringSQL1 = "insert into " . $dbname . ".log_5masterbarangdt(kodeorg,kodebarang,saldoqty,hargalastin,\n hargalastout,lastuser,kodegudang) values"; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { if ($key == '1') { $stringSQL .= "('" . $arr[$ikodeorg] . "','" . $arr[$ikodebarang] . "','" . $arr[$isaldoakhirqty] . "','" . $arr[$ihargarata] . "',0,'" . $arr[$iperiode] . "',\n '" . $arr[$isaldoakhirqty] * $arr[$ihargarata] . "','" . $arr[$ikodegudang] . "','" . $arr[$isaldoakhirqty] . "',\n '" . $arr[$ihargarata] . "','" . $arr[$isaldoakhirqty] * $arr[$ihargarata] . "')"; $stringSQL1 .= "('" . $arr[$ikodeorg] . "','" . $arr[$ikodebarang] . "','" . $arr[$isaldoakhirqty] . "','" . $arr[$ihargarata] . "','" . $arr[$ihargarata] . "',0,\n '" . $arr[$ikodegudang] . "')"; } else { $stringSQL .= ",('" . $arr[$ikodeorg] . "','" . $arr[$ikodebarang] . "','" . $arr[$isaldoakhirqty] . "','" . $arr[$ihargarata] . "',0,'" . $arr[$iperiode] . "',\n '" . $arr[$isaldoakhirqty] * $arr[$ihargarata] . "','" . $arr[$ikodegudang] . "','" . $arr[$isaldoakhirqty] . "',\n '" . $arr[$ihargarata] . "','" . $arr[$isaldoakhirqty] * $arr[$ihargarata] . "')"; $stringSQL1 .= ",('" . $arr[$ikodeorg] . "','" . $arr[$ikodebarang] . "','" . $arr[$isaldoakhirqty] . "','" . $arr[$ihargarata] . "','" . $arr[$ihargarata] . "',0,\n '" . $arr[$ikodegudang] . "')"; } } } $stringSQL .= ";"; $stringSQL1 .= ";"; //exit($stringSQL."<br>".$stringSQL1); if (mysql_query($stringSQL)) { #insert header if (mysql_query($stringSQL1)) { #insert detail echo "Uploaded"; } else { echo "Error insert masterbarangdt " . mysql_error($conn) . $stringSQL1; } } else { echo "Error insert saldobulanan " . mysql_error($conn) . $stringSQL; } break; #====================================================END INV ================================================ #====================================================END INV ================================================ case 'PO': #ambil supplier $str = "select supplierid from " . $dbname . ".log_5supplier"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $supplier[] = $bar->supplierid; } #ambil kodeorganisasi $str = "select kodeorganisasi from " . $dbname . ".organisasi where tipe='PT'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $kodept[] = $bar->kodeorganisasi; } #ambil kodeorganisasi $str = "select kodebarang from " . $dbname . ".log_5masterbarang"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $kdbarang[] = $bar->kodebarang; } foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { if ($header[$ids] == 'kodeorg' and strlen($rinc) != 3) { exit("Error: some data on kodeorg not " . $x[$key][$ids] . "___" . $ids . "__" . $key . " valid (line " . $key . ")"); } if ($header[$ids] == 'matauang') { if (trim($rinc) == '') { exit("Error: some data on currency not valid (line " . $key . ")"); } } if ($header[$ids] == 'kodesupplier') { $supplierbermasalah[$rinc] = $rinc; foreach ($supplier as $bb => $cc) { if ($cc == $rinc) { unset($supplierbermasalah[$rinc]); } } } if ($header[$ids] == 'kodeorg') { #periksa kodeblok yang disubmit $kdptbermasalah[$rinc] = $rinc; foreach ($kodept as $bb => $cc) { if ($cc == $rinc) { unset($kdptbermasalah[$rinc]); } } } if ($header[$ids] == 'kodebarang' and trim($rinc) != '') { $kdbarangbermasalah[$rinc] = $rinc; foreach ($kdbarang as $bb => $cc) { if ($cc == $rinc) { unset($kdbarangbermasalah[$rinc]); } } } if ($header[$ids] == 'kurs') { if (trim($rinc) == '') { $x[$key][$ids] = 1; } } if ($header[$ids] == 'tanggal') { $rinc = str_replace('-', '', $rinc); if (strlen($rinc) != 8) { exit("Error: some data on date not valid (line " . $key . ":" . $rinc . ")"); } else { if (substr($rinc, 0, 4) < '2000') { exit("Error: date not valid (line " . $key . ")"); } } } } } } if (count($supplierbermasalah) > 0) { echo "The following supplier/contractor code on were not defined:<br>"; echo "<pre>"; print_r($supplierbermasalah); echo "</pre>"; exit; } if (count($kdptbermasalah) > 0) { echo "The following company code were not defined:<br>"; echo "<pre>"; print_r($kdptbermasalah); echo "</pre>"; exit; } if (count($kdbarangbermasalah) > 0) { echo "The following material code were not defined:<br>"; echo "<pre>"; print_r($kdbarangbermasalah); echo "</pre>"; exit; } $jmhrBrs = count($x[0]); $jmlhRow = count($x); $aer = 0; foreach ($x[0] as $lstDt => $lstNama) { if ($aer == 0) { $sinsHed .= "insert into " . $dbname . ".log_poht (`" . trim($lstNama) . "`"; $aet = 0; $nopo = $lstNama; } else { if ($aer < 11) { $sinsHed .= ",`" . trim($lstNama) . "`"; } else { if ($aet == 0) { $sinsHed .= ",`statuspo`,`stat_release`,`lokalpusat`) values "; $sInsDet .= "insert into " . $dbname . ".log_podt (`" . trim($nopo) . "`,`" . trim($lstNama) . "`"; } else { if ($aet < 4) { $sInsDet .= ",`" . trim($lstNama) . "`"; } } $aet++; } } if ($aer < 11) { $aer++; } if ($aet == 4) { $sInsDet .= ",`harganormal`,`hargasbldiskon`) "; } } for ($aerto = 1; $aerto < $jmlhRow; $aerto++) { if ($nopohead != $x[$aerto][0]) { $nopohead = ""; $headUtm = ""; $headUtm .= $sinsHed; $nopohead = $x[$aerto][0]; $scek = "select * from " . $dbname . ".log_poht where nopo='" . $nopohead . "'"; $qcek = mysql_query($scek) or die(mysql_error($conn)); if (mysql_num_rows($qcek) < 1) { $headUtm .= "('" . trim($x[$aerto][0]) . "','" . trim($x[$aerto][1]) . "','" . trim($x[$aerto][2]) . "','" . trim($x[$aerto][3]) . "','" . trim($x[$aerto][4]) . "','" . trim($x[$aerto][5]) . "','" . trim($x[$aerto][6]) . "','" . trim($x[$aerto][7]) . "','" . trim($x[$aerto][8]) . "','" . trim($x[$aerto][9]) . "','" . trim($x[$aerto][10]) . "','2','1','" . trim($x[$aerto][15]) . "')"; //exit("error:".$headUtm."__masuk sini"); if (!mysql_query($headUtm)) { exit("error:\n" . $headUtm . "__l" . mysql_error()); } else { $detData = ""; $detData .= $sInsDet . " values "; $hrgdis[$aerto] = trim($x[$aerto][14]); if (intval($x[$aerto][6]) != 0) { $hrgdis[$aerto] = floatval($x[$aerto][14]) - floatval($x[$aerto][14]) * (floatval($x[$aerto][6]) / 100); } $sDelDt = "delete from " . $dbname . ".log_podt where nopo='" . trim($x[$aerto][0]) . "' and kodebarang='" . trim($x[$aerto][11]) . "'"; if (mysql_query($sDelDt)) { $detData .= "('" . trim($x[$aerto][0]) . "','" . trim($x[$aerto][11]) . "','" . trim($x[$aerto][12]) . "','" . trim($x[$aerto][13]) . "','" . $hrgdis[$aerto] . "','" . $hrgdis[$aerto] . "','" . trim($x[$aerto][14]) . "')"; if (!mysql_query($detData)) { exit("error:\n" . $detData . "__uatas" . mysql_error()); } } } } else { $sdel = "delete from " . $dbname . ".log_poht where nopo='" . $x[$aerto][0] . "'"; if (mysql_query($sdel)) { $headUtm .= "('" . trim($x[$aerto][0]) . "','" . trim($x[$aerto][1]) . "','" . trim($x[$aerto][2]) . "','" . trim($x[$aerto][3]) . "','" . trim($x[$aerto][4]) . "','" . trim($x[$aerto][5]) . "','" . trim($x[$aerto][6]) . "','" . trim($x[$aerto][7]) . "','" . trim($x[$aerto][8]) . "','" . trim($x[$aerto][9]) . "','" . trim($x[$aerto][10]) . "','2','1','" . trim($x[$aerto][15]) . "')"; if (!mysql_query($headUtm)) { exit("error:\n" . $headUtm . "__s" . mysql_error($conn)); } else { $detData = ""; $detData .= $sInsDet . " values "; $hrgdis[$aerto] = trim($x[$aerto][14]); if (intval($x[$aerto][6]) != 0) { $hrgdis[$aerto] = floatval($x[$aerto][14]) - floatval($x[$aerto][14]) * (floatval($x[$aerto][6]) / 100); } $sDelDt = "delete from " . $dbname . ".log_podt where nopo='" . trim($x[$aerto][0]) . "' and kodebarang='" . trim($x[$aerto][11]) . "'"; if (mysql_query($sDelDt)) { $detData .= "('" . trim($x[$aerto][0]) . "','" . trim($x[$aerto][11]) . "','" . trim($x[$aerto][12]) . "','" . trim($x[$aerto][13]) . "','" . $hrgdis[$aerto] . "','" . $hrgdis[$aerto] . "','" . trim($x[$aerto][14]) . "')"; if (!mysql_query($detData)) { exit("error:\n" . $detData . "__t" . mysql_error($conn)); } } } } } } else { $detData = ""; $detData .= $sInsDet . " values "; $hrgdis[$aerto] = trim($x[$aerto][14]); if (intval($x[$aerto][6]) != 0) { $hrgdis[$aerto] = floatval($x[$aerto][14]) - floatval($x[$aerto][14]) * (floatval($x[$aerto][6]) / 100); } $sDelDt = "delete from " . $dbname . ".log_podt where nopo='" . trim($x[$aerto][0]) . "' and kodebarang='" . trim($x[$aerto][11]) . "'"; if (mysql_query($sDelDt)) { $detData .= "('" . trim($x[$aerto][0]) . "','" . trim($x[$aerto][11]) . "','" . trim($x[$aerto][12]) . "','" . trim($x[$aerto][13]) . "','" . $hrgdis[$aerto] . "','" . $hrgdis[$aerto] . "','" . trim($x[$aerto][14]) . "')"; if (!mysql_query($detData)) { exit("error:\n" . $detData . "__u1" . mysql_error()); } } } } //exit("error:masuk".$headUtm."____".$detData."__".$aet."___".$jmlhRow); break; # ====================================================END PO===================================== #====================================================START ABSENSI================================================ # ====================================================END PO===================================== #====================================================START ABSENSI================================================ case 'ABSENSI': $data = $x; // Validasi Kosong if (empty($data)) { exit("Isi File Kosong"); } // Cek apakah ada periode yang berbeda dan pengecekan format tanggal $periode = substr($data[1][0], 0, 7); $listNik = array(); foreach ($data as $key => $row) { if ($key > 0) { $tmpDate = explode('-', $row[0]); // Validasi Format Tanggal if (count($tmpDate) != 3 or strlen($tmpDate[0]) != 4 or strlen($tmpDate[1]) != 2 or strlen($tmpDate[2]) != 2) { exit("Format Tanggal tidak valid.<br>Format tanggal = YYYY-MM-DD"); } // Validasi Periode if ($periode != substr($row[0], 0, 7)) { exit("Warning: Ada periode yang tidak sama " . substr($row[0], 0, 7)); } $listNik[trim($row[1])] = trim($row[1]); } } // Kode Absen $str2 = "select kodeabsen from " . $dbname . ".sdm_5absensi order by kelompok asc"; $res2 = mysql_query($str2); while ($bar = mysql_fetch_object($res2)) { $kdaben[] = $bar->kodeabsen; } // Get Data Karyawan $str = "select karyawanid,nik,lokasitugas,subbagian from " . $dbname . ".datakaryawan where nik in ('" . implode("','", $listNik) . "') \n\t\t\tand tanggalkeluar='0000-00-00' and tipekaryawan!=0 order by nik asc"; //echo $str; $res = mysql_query($str); $dataNik = $dataKaryId = $dataLokasi = $dataSubbagian = array(); $listSubbagian = $listLokasi = $listAllLokasi = array(); while ($bar = mysql_fetch_object($res)) { $dataNik[$bar->nik] = $bar->nik; $dataKaryId[$bar->nik] = $bar->karyawanid; $dataLokasi[$bar->nik] = $bar->lokasitugas; if (!empty($bar->subbagian)) { $dataSubbagian[$bar->nik] = $bar->subbagian; $listSubbagian[$bar->subbagian] = $bar->subbagian; $listAllLokasi[$bar->subbagian] = $bar->subbagian; } $listLokasi[$bar->lokasitugas] = $bar->lokasitugas; $listAllLokasi[$bar->lokasitugas] = $bar->lokasitugas; } // Get Tipe Karyawan $optTipe = makeOption($dbname, 'datakaryawan', 'karyawanid,tipekaryawan', "karyawanid in ('" . implode("','", $dataKaryId) . "')"); // Cek Periode Aktif $scek = "select distinct kodeorg,periode from " . $dbname . ".setup_periodeakuntansi where\n\t\t\tkodeorg in ('" . implode("','", $listLokasi) . "') and\n\t\t\ttutupbuku=0 order by periode asc"; $resCek = fetchData($scek); // Cek Periode tidak sama $optPeriod = array(); foreach ($resCek as $row) { $optPeriod[$row['kodeorg']] = $row['periode']; } foreach ($optPeriod as $org => $p) { if ($periode != $p) { exit("error: Period is not the same with active period :" . $p); } } // Cek Periode tidak ada foreach ($listLokasi as $row) { if (!isset($optPeriod[$row])) { exit("Warning: " . $row . " tidak ada periode aktif"); } } // Cek Data Bermasalah $nopoisi = 0; $nikbermasalah = $absenbermasalah = array(); $tanggalNow = ''; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { if ($ids == 0) { $x[$key][0] = tanggalsystemn($rinc); } if ($nopoisi != 1) { $nopoisi = 1; if ($header[0] == 'tanggal') { $rinc = str_replace('-', '', $x[$key][0]); if (strlen($rinc) != 8) { exit("Error: some data on date not valid (line " . $key . "__" . $rinc . ")"); } else { if (substr($rinc, 0, 4) < '2000') { exit("Error: date not valid (line " . $key . ")"); } } } } if (isset($header[1]) and $header[1] == 'nik') { $rinc = $x[$key][1]; $nikbermasalah[$rinc] = $rinc; foreach ($dataKaryId as $bb => $cc) { if ($bb == $rinc) { unset($nikbermasalah[$rinc]); } } } if (isset($header[3]) and $header[3] == 'absensi') { $rinc = $x[$key][3]; $absenbermasalah[$rinc] = $rinc; foreach ($kdaben as $bb => $cc) { if ($cc == $rinc) { unset($absenbermasalah[$rinc]); } } } } } //else } //foreach $bermasalah = false; if (count($nikbermasalah) > 0) { echo "Warning - The following nik on were not defined:<br>"; echo "<pre>"; print_r($nikbermasalah); echo "</pre>"; $bermasalah = true; } if (count($absenbermasalah) > 0) { echo "Warning - The following absence on were not defined:<br>"; echo "<pre>"; print_r($absenbermasalah); echo "</pre>"; $bermasalah = true; } if ($bermasalah == true) { exit; } // Get List Lokasi & Tanggal $lokTgl = array(); foreach ($data as $key => $row) { if ($key > 0) { $tmpLok = isset($dataSubbagian[$row[1]]) ? $dataSubbagian[$row[1]] : $dataLokasi[$row[1]]; $lokTgl[$tmpLok . $row[0]] = $tmpLok . $row[0]; } } // Pool Data & Insert Header $dataD = array(); foreach ($data as $key => $row) { if ($key > 0) { foreach ($listAllLokasi as $lok) { if (isset($lokTgl[$lok . $row[0]])) { // Insert Header $dataH = array('tanggal' => trim($row[0]), 'kodeorg' => $lok, 'periode' => $periode); $qIns = insertQuery($dbname, 'sdm_absensiht', $dataH, array('tanggal', 'kodeorg', 'periode')); // Execute, jika gagal skip if (!mysql_query($qIns)) { if (mysql_errno() != 1062) { exit("Insert Header Error: " . mysql_error()); } } } } $cekAbs = false; if ($optTipe[$dataKaryId[trim($row[1])]] == 4) { // Jika PHL, cek BKM // Cek BKM Rawat $qRawat = selectQuery($dbname, 'kebun_kehadiran_vw', '*', "karyawanid = '" . $dataKaryId[trim($row[1])] . "' and\n\t\t\t\t\t\t\t\t\t\t tanggal = '" . trim($row[0]) . "'"); $resRawat = fetchData($qRawat); if (!empty($resRawat)) { $cekAbs = true; break; } // Cek BKM Panen $qPnn = selectQuery($dbname, 'kebun_prestasi_vw', '*', "karyawanid = '" . $dataKaryId[trim($row[1])] . "' and\n\t\t\t\t\t\t\t\t\t\t tanggal = '" . trim($row[0]) . "'"); $resPnn = fetchData($qPnn); if (!empty($resPnn)) { $cekAbs = true; break; } } // Pool Detail if (!$cekAbs) { // Jika Belum ada di BKM $org = isset($dataSubbagian[$row[1]]) ? $dataSubbagian[$row[1]] : $dataLokasi[$row[1]]; if ($dataLokasi[trim($row[1])] == substr($org, 0, 4)) { $dataD[] = array('kodeorg' => $org, 'tanggal' => trim($row[0]), 'karyawanid' => $dataKaryId[trim($row[1])], 'shift' => trim($row[2]), 'absensi' => trim($row[3]), 'jam' => trim($row[4]), 'jamPlg' => trim($row[5]), 'penjelasan' => trim($row[6]), 'catu' => 0, 'penaltykehadiran' => 0, 'premi' => 0, 'insentif' => 0, 'fingerprint' => 1); } } } } // Insert Detail foreach ($dataD as $row) { $qIns = insertQuery($dbname, 'sdm_absensidt', $row); if (!mysql_query($qIns)) { if (mysql_errno() != 1062) { exit("Insert Detail Error: " . mysql_error()); } } } echo "Notice: Data berhasil diupload"; break; #====================================================START HARGA HARIAN PASAR================================================ #====================================================START HARGA HARIAN PASAR================================================ case 'HARGAHARIANPASAR': $nopoisi = 0; foreach ($x as $key => $arr) { if ($key == 0) { continue; } else { foreach ($arr as $ids => $rinc) { if ($nopoisi != 1) { $nopoisi = 1; if ($header[2] == 'tanggal') { if (strlen($x[$key][2]) == 1) { $x[$key][2] = '0' . $x[$key][2]; } else { if (strlen($x[$key][2]) == 2) { $x[$key][2] = $x[$key][2]; } } } } } } //else } //foreach $jmlhRow = count($x); $key = 1; for ($ind = 1; $ind < $jmlhRow; $ind++) { $w = "insert into " . $dbname . ".pmn_hargapasar (tanggal,kodeproduk,pasar,satuan,harga,matauang,statusharga,ffa,mni) values"; $w .= " ('" . $x[$ind][0] . '-' . $x[$ind][1] . '-' . $x[$ind][2] . "','" . $x[$ind][3] . "','" . $x[$ind][4] . "','" . $x[$ind][5] . "',"; $w .= "'" . trim($x[$ind][6]) . "','" . trim($x[$ind][7]) . "','" . trim($x[$ind][8]) . "','" . trim($x[$ind][9]) . "','" . trim($x[$ind][10]) . "')"; if (!mysql_query($w)) { exit("error: gagal" . $w); } } echo "Notice: Data berhasil diupload"; break; default: break; } }
$userinfo = "INSERT INTO userinfo (FK_users, dateOfBirth, gender, maritalSt, studies, InstitutionName, currentLocation, religion, photo)\r\n VALUE ({$id}, '{$dateOfBirth}','{$gender}','{$maritalSt}','{$studies}','{$institution}','{$location}','{$religion}', '{$photo}');"; mysql_query($userinfo) or die("Error in query: {$userinfo}. " . mysql_error()); } insertUser(1, 'Daniel', 'Gimenez', 'dg', 1, '14-11-1940', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(2, 'Tomas', 'Alabes', 'ta', 1, '15-11-1945', 'Female', 'Single', 'University', 'UA', 'Argentina', 'Musulman', 'img08'); insertUser(3, 'Mariano', 'Claveria', 'mc', 1, '16-11-1988', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Musulman', 'img08'); insertUser(4, 'Agustin', 'Miura', 'am', 1, '17-11-2002', 'Female', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(5, 'Daniel', 'Grane', 'dag', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(6, 'Damian', 'Minniti', 'dm', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(7, 'Martin', 'Sanchez', 'ms', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(8, 'Pablo', 'Celentano', 'pc', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(9, 'Jorge', 'Gonzales', 'jg', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); insertUser(10, 'Pedro', 'Sorio', 'ps', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08'); // Insert query $dates = array(getNextDate($phpdate), getNextDate($phpdate), getNextDate($phpdate), getNextDate($phpdate)); insertQuery(1, 'Chocolate', 1, $dates[2]); insertAnswer(1, 1, 2); insertAnswer(2, 1, 3); insertAnswer(3, 1, 4); insertAnswer(4, 1, 5); insertQuestion(1, 'Do you like milka?', 1); insertOption(1, 'Yes', 1, 1); insertAnsOpt(1, 1, 1); insertAnsOpt(2, 3, 1); insertAnsOpt(7, 4, 1); insertOption(2, 'No', 2, 1); insertAnsOpt(3, 2, 2); insertQuestion(2, 'How much do you like kinder eggs?', 1); insertOption(3, 'Lot', 1, 2); insertAnsOpt(4, 1, 3); insertAnsOpt(5, 3, 3);
$data['nojurnal'] = tanggalsystem($data['tanggal']) . "/" . $_SESSION['empl']['lokasitugas'] . "/" . $data['kodejurnal'] . "/" . $counter; $nojur = $data['nojurnal']; #=============== Insert Process # Column $column = array('kodejurnal', 'tanggal', 'noreferensi', 'matauang', 'revisi', 'nojurnal', 'tanggalentry', 'posting', 'totaldebet', 'totalkredit', 'amountkoreksi', 'autojurnal', 'kurs'); # Add Default Data $data['tanggal'] = tanggalsystem($data['tanggal']); $data['tanggalentry'] = date('Ymd'); $data['posting'] = 0; $data['totaldebet'] = 0; $data['totalkredit'] = 0; $data['amountkoreksi'] = 0; $data['autojurnal'] = 0; $data['kurs'] = 0; # Query $query = insertQuery($dbname, 'keu_jurnalht', $data, $column); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); } else { $updData = array('nokounter' => $tmpC); $query2 = updateQuery($dbname, 'keu_5kelompokjurnal', $updData, $whereNo); if (!mysql_query($query2)) { echo "DB Error : " . mysql_error(); } else { echo $nojur; } } break; case 'edit': $data = $_POST; unset($data['nojurnal']);
require_once 'master_validation.php'; require_once 'config/connection.php'; require_once 'lib/nangkoelib.php'; require_once 'lib/zLib.php'; require_once 'lib/fpdf.php'; require_once 'lib/terbilang.php'; $proses = $_GET['proses']; $kodevhc = checkPostGet('kodevhc', ''); $kmhmakhir = checkPostGet('kmhmakhir', ''); switch ($proses) { case 'getKm': $qKm = selectQuery($dbname, 'vhc_kmhm_track', 'kmhmakhir', "kodevhc='" . $kodevhc . "'"); $resKm = fetchData($qKm); if (empty($resKm)) { echo 0; } else { echo $resKm[0]['kmhmakhir']; } break; case 'reset': $dataIns = array($kodevhc, $kmhmakhir); $qIns = insertQuery($dbname, 'vhc_kmhm_track', $dataIns); if (!mysql_query($qIns)) { $dataUpd = array('kmhmakhir' => $kmhmakhir); $qUpd = updateQuery($dbname, 'vhc_kmhm_track', $dataUpd, "kodevhc='" . $kodevhc . "'"); if (!mysql_query($qUpd)) { exit("Update KM/HM Error: " . mysql_error()); } } break; }
//exit("Error:$xCek"); $ada = false; $yCek = mysql_query($xCek) or die(mysql_error()); while ($zCek = mysql_fetch_assoc($yCek)) { $ada = true; } if ($ada == true) { echo "warning : data already exist "; exit; } // Input Budget BJR $optThnTnm = makeOption($dbname, 'setup_blok', 'kodeorg,tahuntanam', "kodeorg='" . $kdblok . "'"); $dataIns = array('tahunbudget' => $thnbudget, 'kodeorg' => $kdblok, 'thntanam' => $optThnTnm[$kdblok], 'bjr' => $bjr, 'updateby' => $_SESSION['standard']['userid'], 'lastupdate' => date('Y-m-d H:i:s'), 'close' => 0); $dataUpd = array('bjr' => $bjr, 'updateby' => $_SESSION['standard']['userid'], 'lastupdate' => date('Y-m-d H:i:s')); $whereUpd = "tahunbudget='" . $thnbudget . "' and kodeorg='" . $kdblok . "' and thntanam='" . $optThnTnm[$kdblok] . "'"; $insBjr = insertQuery($dbname, 'bgt_bjr', $dataIns); $updBjr = updateQuery($dbname, 'bgt_bjr', $dataUpd, $whereUpd); if (!mysql_query($insBjr)) { if (!mysql_query($updBjr)) { exit("DB Error: " . mysql_error()); } } ##UNTUK VALIDASI TAHUN DI BJR // $iCek="select tahunbudget from ".$dbname.".bgt_bjr where tahunbudget='".$thnbudget."' "; // exit("Error:$xCek"); // $ada=false; // $nCek=mysql_query($iCek)or die(mysql_error()); // while($dCek=mysql_fetch_assoc($nCek)) // { // $ada=true; // }
echo "DB Error : " . mysql_error(); } else { // Delete Pajak $qDel = deleteQuery($dbname, 'log_spk_tax', "notransaksi='" . $param['notransaksi'] . "'"); if (!mysql_query($qDel)) { exit("Delete Tax Error: " . mysql_error()); } else { // Insert Detail Pajak $dataIns = array(); print_r($param); foreach ($param['tax'] as $akun => $nilai) { if ($nilai > 0) { $dataIns[] = array('kodeorg' => $param['kodeorg'], 'notransaksi' => $param['notransaksi'], 'noakun' => $akun, 'nilai' => $nilai); } } $qIns = insertQuery($dbname, 'log_spk_tax', $dataIns); echo $qIns; if (!mysql_query($qIns)) { exit("Insert Tax Error: " . mysql_error()); } } } break; case 'delete': //================periksa realisasi $m = 0; $strx = "select sum(jumlahrealisasi) from " . $dbname . ".log_baspk \n\t\t\t where notransaksi='" . $param['notransaksi'] . "' and statusjurnal = '1'"; $resx = mysql_query($strx); while ($barx = mysql_fetch_array($resx)) { $m = $barx[0]; }
} if ($warning != '') { echo "Warning :\n" . $warning; exit; } $data['tanggalberangkat'] = tanggalsystem($data['tanggalberangkat']); $data['tanggaltiba'] = tanggalsystem($data['tanggaltiba']); $data['tanggal'] = tanggalsystem($data['tanggal']); $data['penerima'] = 0; $data['tanggalterima'] = "0000-00-00"; $data['postingby'] = 0; $cols = array(); foreach ($data as $key => $row) { $cols[] = $key; } $query = insertQuery($dbname, 'log_konosemenht', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); } break; # Proses Edit Header # Proses Edit Header case 'edit': $data = $_POST; $where = "nokonosemen='" . $data['nokonosemen'] . "'"; unset($data['nokonosemen']); $data['tanggal'] = tanggalsystem($data['tanggal']); $data['tanggaltiba'] = tanggalsystem($data['tanggaltiba']); $data['tanggalberangkat'] = tanggalsystem($data['tanggalberangkat']); $query = updateQuery($dbname, 'log_konosemenht', $data, $where); if (!mysql_query($query)) {
//=====end tambahan ginting // exit("qwe: ".$data['noakun']); //=====tambahan dz, fungsi cekAkun ada di lib/tanaman.php #periksa apakah akun hutang, dan jika akun hutang maka harus ada nik/pelanggan/supplier // $nik=str_replace(" ","",$data['nik']); // $kodesupplier=str_replace(" ","",$data['kodesupplier']); // if(cekAkunSupplier($data['noakun']) and $kodesupplier=='') // { // exit("[ Error ]: Akun ".$data['noakun']." harus dilengkapi dengan kode/nama Supplier."); // } // if(cekAkunNik($data['noakun']) and $nik=='') // { // exit("[ Error ]: Akun ".$data['noakun']." harus dilengkapi dengan NIK/nama Karyawan."); // } //=====end tambahan dz $query = insertQuery($dbname, 'keu_jurnaldt', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } unset($data['nojurnal']); unset($data['kodejurnal']); unset($data['tanggal']); unset($data['kodeorg']); $res = ""; foreach ($data as $cont) { $res .= "##" . $cont; } $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}"; echo $result; break;
} else { $tmpTrans = substr($resTrans[0]['notransaksi'], 17, 5); $tmpTrans++; $data['notransaksi'] = $noTrans . str_pad($tmpTrans, 5, '0', STR_PAD_LEFT); } //cek notransaksi pada kasbankht $str = "select * from " . $dbname . ".keu_kasbankht where notransaksi='" . $data['notransaksi'] . "'"; $res = mysql_query($str); if (mysql_num_rows($res) > 0) { exit("Error: Dokumen dengan nomor yang sama sudah ada\nSilahkan buat no.baru"); } $data['tanggal'] = tanggalsystem($data['tanggal']); $data['jumlah'] = str_replace(',', '', $data['jumlah']); $data['userid'] = $_SESSION['standard']['userid']; $cols = array('notransaksi', 'noakun', 'tanggal', 'matauang', 'kurs', 'tipetransaksi', 'jumlah', 'cgttu', 'keterangan', 'yn', 'kodeorg', 'nocek', 'hutangunit', 'pemilikhutang', 'noakunhutang', 'userid'); $query = insertQuery($dbname, 'keu_kasbankht', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); } else { echo $data['notransaksi']; } break; # Proses Edit Header # Proses Edit Header case 'edit': $data = $_POST; if ($data['kurs'] == 0 || $data['kurs'] == '') { exit("Error: Nilai kurs harus diisi (tidak boleh kosong)."); } if ($data['hutangunit'] == 1 and ($data['pemilikhutang'] == '' or $data['noakunhutang'] == '')) { exit("Error: Silakan melengkapi data hutang.");
//`nojurnal`, `tanggal`, `nourut`, `noakun`, `keterangan`, `jumlah`, `matauang`, `kurs`, `kodeorg`, `kodekegiatan`, `kodeasset`, `kodebarang`, `nik`, `kodecustomer`, `kodesupplier`, `noreferensi`, `noaruskas`, `kodevhc`, `nodok`, `kodeblok` $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $dataH[0]['tanggal'], 'nourut' => $noUrut, 'noakun' => $akunkredit, 'keterangan' => $tulisanpanen, 'jumlah' => $totalJumlah * -1, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => '', 'kodekegiatan' => $kodekegiatan, 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => $dataH[0]['notransaksi'], 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $row['kodesegment']); # Total D/K $dataRes['header']['totaldebet'] = $totalJumlah; $dataRes['header']['totalkredit'] = $totalJumlah; #=== Insert Data === $errorDB = ""; # Header $queryH = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($queryH)) { $errorDB .= "Header :" . mysql_error() . "\n test"; } # Detail if ($errorDB == '') { foreach ($dataRes['detail'] as $key => $dataDet) { $queryD = insertQuery($dbname, 'keu_jurnaldt', $dataDet); //echo "warning".$queryD; if (!mysql_query($queryD)) { $errorDB .= "Detail " . $key . " :" . mysql_error() . "\n ini yang error"; } } if ($errorDB == '') { #=== Switch Jurnal to 1 === # Cek if already posted $queryJ = selectQuery($dbname, 'kebun_aktifitas', "jurnal", "notransaksi='" . $param['notransaksi'] . "'"); $isJ = fetchData($queryJ); if ($isJ[0]['jurnal'] == 1) { $errorDB .= "Data posted by another user"; } else { $queryToJ = updateQuery($dbname, 'kebun_aktifitas', array('jurnal' => 1), "notransaksi='" . $dataH[0]['notransaksi'] . "'"); if (!mysql_query($queryToJ)) {
function prosesGajiKebun() { global $conn; global $tanggal; global $param; global $dbname; global $defSegment; #karyawan kebun #output pada jurnal kolom noreferensi ALK_GAJI if ($param['komponen'] == 1 or $param['komponen'] == 14) { $group = 'KBNB0'; } elseif ($param['komponen'] == 16 or $param['komponen'] == 32 or $param['komponen'] == 33) { $group = 'KBNB1'; } elseif ($param['komponen'] == 28) { $group = 'KBNB3'; } elseif ($param['komponen'] == 26) { $group = 'KBNB4'; } elseif ($param['komponen'] == 21) { $group = 'KBNB5'; } else { $group = 'KBNB2'; } //defaultnya tunjangan $str = "select noakundebet,noakunkredit from " . $dbname . ".keu_5parameterjurnal\r\n where jurnalid='" . $group . "' limit 1"; $res = mysql_query($str); if (mysql_num_rows($res) < 1) { exit("Error: No.Akun pada parameterjurnal belum ada untuk " . $param['namakomponen']); } else { $akundebet = ''; $akunkredit = ''; $bar = mysql_fetch_object($res); $akundebet = $bar->noakundebet; $akunkredit = $bar->noakunkredit; } #proses data $kodeJurnal = $group; #======================== Nomor Jurnal ============================= # Get Journal Counter $queryJ = selectQuery($dbname, 'keu_5kelompokjurnal', 'nokounter', "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "' "); $tmpKonter = fetchData($queryJ); $konter = addZero($tmpKonter[0]['nokounter'] + 1, 3); # Transform No Jurnal dari No Transaksi $nojurnal = str_replace("-", "", $tanggal) . "/" . $_SESSION['empl']['lokasitugas'] . "/" . $kodeJurnal . "/" . $konter; #======================== /Nomor Jurnal ============================ # Prep Header $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodeJurnal, 'tanggal' => $tanggal, 'tanggalentry' => date('Ymd'), 'posting' => 1, 'totaldebet' => $param['jumlah'], 'totalkredit' => -1 * $param['jumlah'], 'amountkoreksi' => '0', 'noreferensi' => 'ALK_GAJI', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akundebet, 'keterangan' => $param['namakomponen'] . ' ' . $param['namakaryawan'], 'jumlah' => $param['jumlah'], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => $param['karyawanid'], 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_GAJI', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $param['subbagian'], 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; # Kredit $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $akunkredit, 'keterangan' => $param['namakomponen'] . ' ' . $param['namakaryawan'], 'jumlah' => -1 * $param['jumlah'], 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => $param['karyawanid'], 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'ALK_GAJI', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $param['subbagian'], 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; /* #periksa apakah sudah pernah diproses dengan karyawan yang sama $str="select * from ".$dbname.".keu_jurnaldt where nojurnal like '".str_replace("-","",$tanggal)."/".$_SESSION['empl']['lokasitugas']."/".$kodeJurnal."/%' and noakun='".$akundebet."' and nik='".$param['karyawanid']."'"; if(mysql_num_rows(mysql_query($str))>0) exit("Error: Data sudah pernah di proses"); * */ $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header BTL Error : ' . mysql_error() . "\n"; } if (empty($headErr)) { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); echo $insDet; if (!mysql_query($insDet)) { $detailErr .= "Insert Detail Error 2 : " . mysql_error() . "\n"; break; } } if ($detailErr == '') { # Header and Detail inserted #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Update Kode Jurnal $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($updJurnal)) { echo "Update Kode Jurnal Error : " . mysql_error() . "\n"; # Rollback if Update Failed $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header BTL Error : " . mysql_error() . "\n"; exit; } exit; } else { } } else { echo $detailErr; # Rollback, Delete Header $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error(); exit; } } } else { echo $headErr; exit; } }
include_once 'config/connection.php'; include_once 'lib/zMysql.php'; # Extract Data $data = $_POST; unset($data['proses']); # Add Required Data $data['kurs'] = 0; $data['kurspajak'] = 0; if ($_POST['proses'] == 'main_add') { # Check Valid Data if ($data['kode'] == '' || $data['matauang'] == '' || $data['simbol'] == '' || $data['kodeiso'] == '') { echo "Error : Data tidak boleh ada yang kosong"; exit; } # Make Query $query = insertQuery($dbname, 'setup_matauang', $data); # Insert Data if (!mysql_query($query)) { echo "DB Error : " . mysql_error($conn); } } elseif ($_POST['proses'] == 'main_edit') { # Check Valid Data if ($data['kode'] == '' || $data['matauang'] == '' || $data['simbol'] == '' || $data['kodeiso'] == '') { echo "Error : Data tidak boleh ada yang kosong"; exit; } # Extract Primary Key unset($data['primField']); unset($data['primVal']); $prim = array('field' => $_POST['primField'], 'value' => $_POST['primVal']); # Create Condition
function updateKmHm($kodevhc) { global $dbname; // Get KM/HM Akhir $qKm = selectQuery($dbname, 'vhc_kmhmakhir_vw', '*', "kodevhc='" . $kodevhc . "'"); $resKm = fetchData($qKm); $kmhmAkhir = empty($resKm) ? 0 : $resKm[0]['kmhmakhir']; $dataIns = array($kodevhc, $kmhmAkhir); $qIns = insertQuery($dbname, 'vhc_kmhm_track', $dataIns); if (!mysql_query($qIns)) { $dataUpd = array('kmhmakhir' => $kmhmAkhir); $qUpd = updateQuery($dbname, 'vhc_kmhm_track', $dataUpd, "kodevhc='" . $kodevhc . "'"); if (!mysql_query($qUpd)) { exit("Update KM/HM Error: " . mysql_error()); } } }
echo "DB Error :\n" . $errorDB; exit; } else { $errorY = ''; $errorX = ''; #insert transaksi gudang ht foreach ($dataMat['header'] as $key => $dataX) { $queryD = insertQuery($dbname, 'log_transaksiht', $dataX); if (!mysql_query($queryD)) { $errorX = " Error insert header material :" . $queryD . ":" . mysql_error() . "\n"; } } if ($errorX == '') { #insert transaksi gudang dt foreach ($dataMat['detail'] as $key => $dataY) { $queryD = insertQuery($dbname, 'log_transaksidt', $dataY); if (!mysql_query($queryD)) { $errorY = " Error insert detail material :" . $queryD . ":" . mysql_error() . "\n"; } } if ($errorY == '') { #bentuk saldo akhir $errSal = ''; foreach ($gud as $keygud => $valgud) { foreach ($brg[$valgud] as $keybrg => $valbrg) { $sth = "update " . $dbname . ".log_5saldobulanan set saldoakhirqty=" . ($saldo[$valgud][$valbrg] - $jumlah[$valgud][$valbrg]) . ",\r\n nilaisaldoakhir=" . ($nilaisaldoakhir[$valgud][$valbrg] - $jumlah[$valgud][$valbrg] * $harga[$valgud][$valbrg]) . ",\r\n qtykeluar=" . ($qtykeluar[$valgud][$valbrg] + $jumlah[$valgud][$valbrg]) . ",\r\n qtykeluarxharga=" . ($qtykeluar[$valgud][$valbrg] + $jumlah[$valgud][$valbrg]) * $harga[$valgud][$valbrg] . "\r\n where periode='" . $periode[$valgud] . "' and kodegudang='" . $valgud . "' and kodebarang='" . $valbrg . "'"; if (!mysql_query($sth)) { $errSal .= " Error update saldo bulanan" . addslashes(mysql_error($conn)) . $sth; } $stup = "update " . $dbname . ".kebun_pakaimaterial set hargasatuan=" . $harga[$valgud][$valbrg] . " where kodegudang='" . $valgud . "'\r\n and kodebarang='" . $valbrg . "' and notransaksi='" . $param['notransaksi'] . "'"; mysql_query($stup);
# Get Data $data = array(); $data['nopengolahan'] = $param['nopengolahan']; foreach ($param as $key => $row) { if (substr($key, 8, 7) == 'station') { $data['kodeorg'] = $row; } } foreach ($param as $key => $row) { if (substr($key, 8, 10) == 'tahuntanam') { $data['tahuntanam'] = $row; } } $data['kodebarang'] = $param['kodebarang']; $data['jumlah'] = $param['jumlah']; $query = insertQuery($dbname, 'pabrik_pengolahan_barang', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } unset($data['nopengolahan']); unset($data['kodeorg']); unset($data['tahuntanam']); $res = ""; foreach ($data as $cont) { $res .= "##" . $cont; } $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}"; echo $result; break; case 'edit':
$formTab1->_afterEditMode = "afterEditMode"; #== Display View # Draw Tab echo "<fieldset><legend><b>Detail</b></legend>"; $formTab1->render(); echo "</fieldset>"; break; /** Add New Detail Data */ /** Add New Detail Data */ case 'add': $cols = array('kodeblok', 'kodekegiatan', 'hk', 'hasilkerjajumlah', 'satuan', 'jumlahrp', 'rupiahpersatuan', 'notransaksi'); $data = $param; unset($data['numRow']); $data['jumlahrp'] = str_replace(',', '', $data['jumlahrp']); $data['rupiahpersatuan'] = str_replace(',', '', $data['rupiahpersatuan']); $query = insertQuery($dbname, 'log_spkdt', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } unset($data['notransaksi']); $res = ""; foreach ($data as $cont) { $res .= "##" . $cont; } $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}"; echo $result; break; /** Edit existing Data Detail */ /** Edit existing Data Detail */ case 'edit':
$data = array(); $num = 0; foreach ($resData as $row) { if ($param['hutangunit'] == 1) { if ($row['noakun'] == $param['noakunhutang']) { $row['noakun'] = $noakuncaco; } else { continue; } } $row['jumlah'] = $row['jumlah'] * -1; $num++; $data[] = array('notransaksi' => $param['notransaksi'], 'noakun' => $row['noakun'], 'tipetransaksi' => $param['tipetransaksi'], 'tanggal' => tanggalsystem($param['tanggal']), 'jumlah' => $row['jumlah'], 'noakun2a' => $param['noakun'], 'kode' => $param['kode'], 'keterangan1' => $row['nodok'], 'keterangan2' => $row['keterangan'], 'matauang' => $param['matauang'], 'kurs' => $param['kurs'], 'kurs2' => 1, 'noaruskas' => $row['noaruskas'], 'kodeorg' => $param['kodeorg'], 'kodekegiatan' => $row['kodekegiatan'], 'kodeasset' => $row['kodeasset'], 'kodebarang' => $row['kodebarang'], 'nik' => $row['nik'], 'kodecustomer' => $row['kodecustomer'], 'kodesupplier' => $row['kodesupplier'], 'kodevhc' => $row['kodevhc'], 'orgalokasi' => '', 'nodok' => $param['nojurnal'], 'hutangunit1' => $param['hutangunit'], 'kodesegment' => $defSegment); } foreach ($data as $row) { $query = insertQuery($dbname, 'keu_kasbankdt', $row); if (!mysql_query($query)) { echo 'DB Error: ' . mysql_error() . "\n" . $query; } } break; default: break; } function cekVendorKasKecil() { global $dbname; global $param; // Get Parameter Aplikasi $qParam = selectQuery($dbname, 'setup_parameterappl', "nilai", "kodeaplikasi='KB' and kodeparameter='VENCASH'"); $resParam = fetchData($qParam);
# Table $theTable2 = new uTable('kasbankTable', $_SESSION['lang']['tabel'] . " " . $_SESSION['lang']['anggotashif'], $cols, $data, $dataShow); # FormTable $formTab2 = new uFormTable('ftPrestasi', $theForm2, $theTable2, null, array('kodeorg##shift')); $formTab2->_target = "pabrik_slave_5shift"; #== Display View # Draw Tab echo "<fieldset><legend><b>Detail</b></legend>"; $formTab2->render(); echo "</fieldset>"; break; case 'add': $cols = array('nik', 'kodeorg', 'shift'); $data = $param; unset($data['numRow']); $query = insertQuery($dbname, 'pabrik_5shiftanggota', $data, $cols); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } unset($data['kodeorg']); unset($data['shift']); $res = ""; foreach ($data as $cont) { $res .= "##" . $cont; } $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}"; echo $result; break; case 'edit': $data = $param;
$noUrut++; $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $blok['debet'][$key] != '' ? $blok['debet'][$key] : $BUN06['debet'], 'keterangan' => 'Alokasi Jamsostek ' . $namakaryawan . ' (BUN06-D)', 'jumlah' => $jms, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => $karyawanid, 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => $notransaksi, 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $val, 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; # Kredit $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => $tanggal, 'nourut' => $noUrut, 'noakun' => $BUN06['kredit'], 'keterangan' => 'Alokasi Jamsostek ' . $namakaryawan . ' (BUN06-C)', 'jumlah' => -1 * $jms, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $_SESSION['empl']['lokasitugas'], 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => $karyawanid, 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => $notransaksi, 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $val, 'revisi' => '0', 'kodesegment' => $defSegment); } $noUrut++; $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header unalocated Error : ' . mysql_error() . "\n"; } if ($headErr == '') { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); if (!mysql_query($insDet)) { $detailErr .= "Insert Detail Unalocated Error : " . mysql_error() . "\n"; break; } } if ($detailErr == '') { # Header and Detail inserted #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Update Kode Jurnal $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'"); if (!mysql_query($updJurnal)) { echo "Update Kode Jurnal Error : " . mysql_error() . "\n"; # Rollback if Update Failed $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error() . "\n";
} } } #==================== /Prep Jurnal ==================================== createSaldoAwal($param['periode'], $tahunLanjut . '-' . addZero($bulanLanjut, 2), $param['kodeorg']); #========================== Proses Insert dan Update ========================== # Header and Detail inserted # Update Status Tutup Buku $queryUpd = updateQuery($dbname, 'setup_periodeakuntansi', array('tutupbuku' => 1), "kodeorg='" . $param['kodeorg'] . "' and periode='" . $param['periode'] . "'"); if (!mysql_query($queryUpd)) { echo 'Error Update : ' . mysql_error(); exit; } else { # Insert periode baru $dataIns = array('kodeorg' => $param['kodeorg'], 'periode' => $tahunLanjut . '-' . addZero($bulanLanjut, 2), 'tanggalmulai' => $tglAwal, 'tanggalsampai' => $tglAkhir, 'tutupbuku' => 0); $queryIns = insertQuery($dbname, 'setup_periodeakuntansi', $dataIns); echo '1'; if (!mysql_query($queryIns)) { # Rollback echo 'Error Insert : ' . mysql_error(); $queryRB = updateQuery($dbname, 'setup_periodeakuntansi', array('tutupbuku' => 0), "kodeorg='" . $param['kodeorg'] . "' and periode='" . $param['periode'] . "'"); if (!mysql_query($queryRB)) { echo 'Error Rollback Update : ' . mysql_error(); exit; } } else { //update history tutup buku $str = "delete from " . $dbname . ".keu_setup_watu_tutup where periode='" . $param['periode'] . "' and kodeorg='" . $param['kodeorg'] . "'"; mysql_query($str); $str = "insert into " . $dbname . ".keu_setup_watu_tutup(kodeorg,periode,username) values(\n '" . $param['kodeorg'] . "','" . $param['periode'] . "','" . $_SESSION['standard']['username'] . "')"; mysql_query($str);
if (substr($kodeparameter, 0, 5) == 'SISIP') { if ($sisasisip < 0) { echo "error: Harap diinput data pokok mati dan rencana sisipan, rencana sisip: " . $rencanasisip . ", sudah sisip: " . $sudahsisip . " + " . $hasilkerja . ", sisa rencana sisip: " . $sisasisip . "."; exit; } } // # Convert Tanggal $data['tanggal'] = tanggalsystem($data['tanggal']); $strKurs = "select * from " . $dbname . ".setup_matauangrate where daritanggal=" . $data['tanggal'] . ""; $qryKurs = mysql_query($strKurs) or die(mysql_error($conn)); $numRows = mysql_num_rows($qryKurs); if ($param['matauang'] != 'IDR' && $numRows <= 0) { echo "Gagal : Data kurs untuk mata uang " . $param['matauang'] . " pada tanggal " . tanggalnormal($data['tanggal']) . " masih belum ada"; } else { $query = insertQuery($dbname, 'log_baspk', $data, $dtCol); if (!mysql_query($query)) { echo "DB Error : " . mysql_error(); exit; } else { // Init Segment $optSegment = array(); $defaultSegment = colDefaultValue($dbname, 'keu_5segment', 'kodesegment'); // Opt Segment for New Row $blok = key($optBlok); $query = "select distinct a.kodesegment,a.namasegment from " . $dbname . ".keu_5segment a\r\n\t\t\t\t\tleft join " . $dbname . ".keu_5proporsisegment b on a.kodesegment=b.kodesegment\r\n\t\t\t\t\twhere b.kodeblok='" . $blok . "' or a.kodesegment = '" . $defaultSegment . "'"; $res = fetchData($query); $optSegment = array(); foreach ($res as $row) { $optSegment[$row['kodesegment']] = $row['namasegment']; }
} else { echo $listbutton . $list0 . $list2 . $list3; } break; case 'post': #delete first $sdel = "delete from " . $dbname . ".sdm_gaji " . " where idkomponen not in ('28','46','47') " . " and periodegaji='" . $param['periodegaji'] . "' and kodeorg='" . $param['kodeorg'] . "' " . " and karyawanid in (select distinct karyawanid from " . $dbname . ".datakaryawan " . " where sistemgaji='Harian' and lokasitugas='" . $param['kodeorg'] . "')"; //exit("Error:$sdel"); mysql_query($sdel) or die(mysql_error($conn)); # Insert All ready data $insError = ""; foreach ($readyData as $row) { if ($row['jumlah'] == 0 or $row['jumlah'] == '') { continue; } else { $queryIns = insertQuery($dbname, 'sdm_gaji', $row); if (!mysql_query($queryIns)) { $queryUpd = updateQuery($dbname, 'sdm_gaji', $row, "kodeorg='" . $row['kodeorg'] . "' and periodegaji='" . $row['periodegaji'] . "' and karyawanid='" . $row['karyawanid'] . "' and idkomponen=" . $row['idkomponen']); $tmpErr = mysql_error($conn); if (!mysql_query($queryUpd)) { echo "DB Insert Error :" . $tmpErr . "\n"; print_r($row); echo "DB Update Error :" . mysql_error($conn) . "\n"; } } } } break; default: break; }
function posting($kodeorg, $periode, $jumlah, $dbname, $conn) { // Default Segment $defSegment = colDefaultValue($dbname, 'keu_5segment', 'kodesegment'); $tgl1 = ''; $tgl2 = ''; $str = "select tanggalmulai,tanggalsampai from " . $dbname . ".sdm_5periodegaji where kodeorg='" . $kodeorg . "'\r\n and periode='" . $periode . "' and jenisgaji='H'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $tgl1 = str_replace("-", "", $bar->tanggalmulai); $tgl2 = str_replace("-", "", $bar->tanggalsampai); } if ($tgl1 == '' or $tgl2 == '') { exit(" Error: Periode penggajian Harian tidak ditemukan/ Daily base payrol period not found"); } //periksa periode akuntansi $str = "select * from " . $dbname . ".setup_periodeakuntansi where kodeorg='" . $kodeorg . "' \r\n and periode='" . $periode . "' and tutupbuku=0"; $res = mysql_query($str); if (mysql_num_rows($res) == 0) { exit(" Error: Sorry, accounting period is not active on choson period"); } //periksa periode penggajian unit untuk memastikan apakah sudah selesai inputan BKM,KKD,ABSENSI $str = "select sudahproses from " . $dbname . ".sdm_5periodegaji where kodeorg='" . $kodeorg . "' \r\n and periode='" . $periode . "' and sudahproses=0"; $res = mysql_query($str); if (mysql_num_rows($res) > 0) { exit(" Error: Sorry, input for presence, CARLOG and Foreman daoly book not yet close, please make sure for those transaction by confirmation via Setu->Periode Penggajian unit"); } //periksa tipe organisasi $str = "select tipe from " . $dbname . ".organisasi where kodeorganisasi='" . $kodeorg . "'"; $res = mysql_query($str); $tipe = 'KANWIL'; while ($bar = mysql_fetch_object($res)) { $tipe = $bar->tipe; } if ($tipe == 'KEBUN') { //ambil noakun dari parameter jurnal $debet = ''; $kredit = ''; $nojurnal = str_replace("-", "", $periode) . "28/" . $kodeorg . "/CT01/001"; $str = "select noakundebet,noakunkredit from " . $dbname . ".keu_5parameterjurnal where jurnalid='CT01'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $debet = $bar->noakundebet; $kredit = $bar->noakunkredit; } if ($debet == '' or $kredit == '') { exit('Error: Journal parameter for CT01 not defined, contact administrator'); } $kodejurnal = 'CT01'; //ambil porsi biaya umum $byumum = 0; $str = "select sum(jumlahrupiah) as byumum from " . $dbname . ".sdm_catu where periodegaji='" . $periode . "' \r\n and kodeorg='" . $kodeorg . "' and subbagian=''"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $byumum = $bar->byumum; } $bytanaman = $jumlah - $byumum; //prepare jurnal # Prep Header $dataRes = array(); $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodejurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'tanggalentry' => date('Ymd'), 'posting' => '1', 'totaldebet' => $jumlah, 'totalkredit' => $jumlah * -1, 'amountkoreksi' => '0', 'noreferensi' => 'CT01', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; //jika biaya umum>0 if ($byumum > 0) { # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $byumum, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } //ambil kodeblok dan kegiatan untuk melengkapi sisi debet #1 ambil noakun panen $akunpanen = ''; $str = "select noakundebet from " . $dbname . ".keu_5parameterjurnal where jurnalid='PNN01'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $akunpanen = $bar->noakundebet; } if ($akunpanen == '') { exit(" Error: Account for harvesting not defined in journal parameter PNN01"); } #2 Ambil blok panen $sAbsn = "select distinct kodeorg from " . $dbname . ".kebun_prestasi_vw \r\n where tanggal between '" . $tgl1 . "' and '" . $tgl2 . "' and unit ='" . $kodeorg . "'"; $respanen = mysql_query($sAbsn); $jml_baris = mysql_num_rows($respanen); #3 ambil noakun dan blok perawatan $sAbsn = "select distinct noakun,kodeorg,kodekegiatan from " . $dbname . ".kebun_perawatan_vw \r\n where tanggal between '" . $tgl1 . "' and '" . $tgl2 . "' and unit ='" . $kodeorg . "'"; $resrawat = mysql_query($sAbsn); $jml_baris += mysql_num_rows($resrawat); #4 dibagi per masing-masing baris if ($jml_baris == 0 and $bytanaman > 0) { #jika tidak ada pekerjaan lapangan #kembalikan ke biaya umum $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $bytanaman, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { $biayaperblok = $bytanaman / $jml_baris; } if ($biayaperblok > 0 and $jml_baris > 0) { #5 Bentuk detail jurnal pelengkap disisi debet while ($bar = mysql_fetch_object($respanen)) { # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $akunpanen, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $biayaperblok, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => $akunpanen . "01", 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $bar->kodeorg, 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } while ($bar = mysql_fetch_object($resrawat)) { # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $bar->noakun, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $biayaperblok, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => $bar->kodekegiatan, 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $bar->kodeorg, 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } } # Kredit (Kreditnya cukup satu saja) $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $kredit, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => -1 * $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { if ($tipe == 'TRAKSI') { $debet = ''; $kredit = ''; $nojurnal = str_replace("-", "", $periode) . "28/" . $kodeorg . "/CT03/001"; $str = "select noakundebet,noakunkredit from " . $dbname . ".keu_5parameterjurnal where jurnalid='CT03'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $debet = $bar->noakundebet; $kredit = $bar->noakunkredit; } if ($debet == '' or $kredit == '') { exit('Error: Journal parameter for CT03 (Traksi) not defined, contact administrator'); } $kodejurnal = 'CT03'; #1 Ambil semua kendaraan yang bekerja di bulan ini $str = "select distinct kodevhc from " . $dbname . ".vhc_runht where tanggal between '" . $tgl1 . "' and '" . $tgl2 . "' \r\n and kodeorg ='" . $kodeorg . "'"; $res = mysql_query($str); $jml_baris = mysql_num_rows($res); //prepare jurnal # Prep Header $dataRes = array(); $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodejurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'tanggalentry' => date('Ymd'), 'posting' => '1', 'totaldebet' => $jumlah, 'totalkredit' => $jumlah * -1, 'amountkoreksi' => '0', 'noreferensi' => 'CT03', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; if ($jml_baris == 0) { //jika tidak ada pekerjaan kendaraan # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT03', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { $byperkendaraan = $jumlah / $jml_baris; while ($bar = mysql_fetch_object($res)) { # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $byperkendaraan, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT03', 'noaruskas' => '', 'kodevhc' => $bar->kodevhc, 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } } # Kredit (Kreditnya cukup satu saja) $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $kredit, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => -1 * $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT03', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { if ($tipe == 'PABRIK') { $debet = ''; $kredit = ''; $nojurnal = str_replace("-", "", $periode) . "28/" . $kodeorg . "/CT04/001"; $str = "select noakundebet,noakunkredit from " . $dbname . ".keu_5parameterjurnal where jurnalid='CT04'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $debet = $bar->noakundebet; $kredit = $bar->noakunkredit; } if ($debet == '' or $kredit == '') { exit('Error: Journal parameter CT04 (PKS) not defined'); } $kodejurnal = 'CT04'; //ambil porsi biaya umum $byumum = 0; $str = "select sum(jumlahrupiah) as byumum from " . $dbname . ".sdm_catu where periodegaji='" . $periode . "' \r\n and kodeorg='" . $kodeorg . "' and subbagian=''"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $byumum = $bar->byumum; } $bystasiun = $jumlah - $byumum; #1 Ambil semua statiun yang ada dalam pks $str = "select kodeorganisasi from " . $dbname . ".organisasi where tipe='STATION' \r\n and induk ='" . $kodeorg . "'"; $res = mysql_query($str); $jml_baris = mysql_num_rows($res); //prepare jurnal # Prep Header $dataRes = array(); $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodejurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'tanggalentry' => date('Ymd'), 'posting' => '1', 'totaldebet' => $jumlah, 'totalkredit' => $jumlah * -1, 'amountkoreksi' => '0', 'noreferensi' => 'CT04', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; if ($jml_baris == 0) { //jika tidak ada pekerjaan kendaraan # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT04', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { //biaya umum masuk dulu if ($byumum > 0) { $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $byumum, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT04', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } //bagi biaya station ke setiap station $byperstasiun = $bystasiun / $jml_baris; while ($bar = mysql_fetch_object($res)) { # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $byperstasiun, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT04', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => $bar->kodeorganisasi, 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } } # Kredit (Kreditnya cukup satu saja) $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $kredit, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => -1 * $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT04', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } else { $debet = ''; $kredit = ''; $nojurnal = str_replace("-", "", $periode) . "28/" . $kodeorg . "/CT01/001"; $str = "select noakundebet,noakunkredit from " . $dbname . ".keu_5parameterjurnal where jurnalid='CT01'"; $res = mysql_query($str); while ($bar = mysql_fetch_object($res)) { $debet = $bar->noakundebet; $kredit = $bar->noakunkredit; } if ($debet == '' or $kredit == '') { exit('Error: Journal parameter CT01 (Kebun) not defined'); } $kodejurnal = 'CT01'; //prepare jurnal # Prep Header $dataRes = array(); $dataRes['header'] = array('nojurnal' => $nojurnal, 'kodejurnal' => $kodejurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'tanggalentry' => date('Ymd'), 'posting' => '1', 'totaldebet' => $jumlah, 'totalkredit' => $jumlah * -1, 'amountkoreksi' => '0', 'noreferensi' => 'CT01', 'autojurnal' => '1', 'matauang' => 'IDR', 'kurs' => '1', 'revisi' => '0'); # Data Detail $noUrut = 1; # Debet $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $debet, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; $dataRes['detail'][] = array('nojurnal' => $nojurnal, 'tanggal' => str_replace("-", "", $periode) . "28", 'nourut' => $noUrut, 'noakun' => $kredit, 'keterangan' => 'Catu Beras -' . $periode, 'jumlah' => -1 * $jumlah, 'matauang' => 'IDR', 'kurs' => '1', 'kodeorg' => $kodeorg, 'kodekegiatan' => '', 'kodeasset' => '', 'kodebarang' => '', 'nik' => '', 'kodecustomer' => '', 'kodesupplier' => '', 'noreferensi' => 'CT01', 'noaruskas' => '', 'kodevhc' => '', 'nodok' => '', 'kodeblok' => '', 'revisi' => '0', 'kodesegment' => $defSegment); $noUrut++; } } } #execute #========================== Proses Insert dan Update ========================== #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Header $headErr = ''; $insHead = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']); if (!mysql_query($insHead)) { $headErr .= 'Insert Header Error : ' . mysql_error() . "\n"; } if ($headErr == '') { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail $detailErr = ''; foreach ($dataRes['detail'] as $row) { $insDet = insertQuery($dbname, 'keu_jurnaldt', $row); if (!mysql_query($insDet)) { $detailErr .= "Insert Detail Error : " . mysql_error() . "\n"; break; } } if ($detailErr == '') { #update sdm_catu status posting $str = "update " . $dbname . ".sdm_catu set posting=1 where kodeorg='" . $kodeorg . "' and periodegaji='" . $periode . "'"; mysql_query($str); } else { echo $detailErr; # Rollback, Delete Header $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'"); if (!mysql_query($RBDet)) { echo "Rollback Delete Header Error : " . mysql_error(); exit; } } } else { echo $headErr; exit; } }