示例#1
0
 /**
  * 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;
                     }
                 }
             }
         }
     }
 }
     //        {
     //            exit("[ Error ]: Akun ".$data['noakun']." harus dilengkapi dengan NIK/nama Karyawan.");
     //        }
     //=====end tambahan dz
     unset($data['nojurnal']);
     unset($data['kodejurnal']);
     unset($data['nourut']);
     $data['tanggal'] = tanggalsystem($data['tanggal']);
     $data['jumlah'] = str_replace(',', '', $data['jumlah']);
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     $where = "nojurnal='" . $param['nojurnal'] . "' and nourut='" . $param['nourut'] . "'";
     $query = updateQuery($dbname, 'keu_jurnaldt', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     echo json_encode($param);
     break;
 case 'delete':
     $where = "nojurnal='" . $param['nojurnal'] . "' and nourut='" . $param['nourut'] . "'";
     $query = "delete from `" . $dbname . "`.`keu_jurnaldt` where " . $where;
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
 default:
     $primVal = explode('##', $_POST['primVal']);
     unset($primary['namabarang']);
     unset($primary['satuan']);
     unset($data['namabarang']);
     unset($data['satuan']);
     # Create Condition
     $where = "";
     for ($i = 1; $i < count($primary); $i++) {
         if ($i == 1) {
             $where .= "`" . $primary[$i] . "`='" . $primVal[$i] . "'";
         } else {
             $where .= " AND `" . $primary[$i] . "`='" . $primVal[$i] . "'";
         }
     }
     # Create Query
     $query = updateQuery($dbname, 'setup_kegiatannorma', $data, $where);
     # Update Data
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error($conn);
     }
     break;
 case 'delete':
     $data = $_POST;
     unset($data['proses']);
     unset($data['primary']);
     unset($data['primVal']);
     $primary = explode('##', $_POST['primary']);
     $primVal = explode('##', $_POST['primVal']);
     unset($primary['namabarang']);
     unset($primary['satuan']);
     unset($data['namabarang']);
示例#4
0
     $res = "";
     foreach ($data as $cont) {
         $res .= "##" . $cont;
     }
     $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}";
     echo $result;
     break;
 case 'edit':
     $data = $param;
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     $where = "kodeorg='" . $param['kodeorg'] . "' and shift=" . $param['shift'] . " and nik='" . $param['cond_nik'] . "'";
     $query = updateQuery($dbname, 'pabrik_5shiftanggota', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     echo json_encode($param);
     break;
 case 'delete':
     $where = "kodeorg='" . $param['kodeorg'] . "' and shift=" . $param['shift'] . " and nik='" . $param['nik'] . "'";
     $query = "delete from `" . $dbname . "`.`pabrik_5shiftanggota` where " . $where;
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
 default:
示例#5
0
     $data['rupiahpersatuan'] = str_replace(',', '', $data['rupiahpersatuan']);
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     cekRealisasi($param);
     $where = "notransaksi='" . $param['notransaksi'] . "'and kodekegiatan='" . $param['cond_kodekegiatan'] . "' and kodeblok='" . $param['cond_kodeblok'] . "'";
     $query = updateQuery($dbname, 'log_spkdt', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     } else {
         $whereBA = "notransaksi='" . $param['notransaksi'] . "'and kodekegiatan='" . $param['cond_kodekegiatan'] . "' and blokspkdt='" . $param['cond_kodeblok'] . "'";
         $dataBA = array('kodekegiatan' => $param['kodekegiatan'], 'blokspkdt' => $param['kodeblok']);
         $queryBA = updateQuery($dbname, 'log_baspk', $dataBA, $whereBA);
         if (!mysql_query($queryBA)) {
             echo "DB Error : " . mysql_error();
             exit;
         }
     }
     echo json_encode($param);
     break;
     /** Delete existing data detail */
 /** Delete existing data detail */
 case 'delete':
     //================periksa realisasi
     $m = 0;
     $strx = "select sum(jumlahrealisasi) from " . $dbname . ".log_baspk \n                  where notransaksi='" . $param['notransaksi'] . "'";
     $resx = mysql_query($strx);
     while ($barx = mysql_fetch_array($resx)) {
                    $errorDB .= "Rollback 2 Error :" . mysql_error() . "\n" . $queryRB2;
                }
                if (!mysql_query($queryRBKonter)) {
                    $errorDB .= "Rollback Counter Error :" . mysql_error() . "\n" . $queryRBKonter;
                }
                echo "DB Error :\n" . $errorDB;
                exit;
            }
        }
    }
    // else if namabarang
    if (empty($errorDB)) {
        // Update Setup Blok, jika kegiatan sisip, completering, tanam baru
        $where = "nilai = '" . $kodekegiatan . "' and kodeaplikasi = 'TN'";
        // kalo kodeparameter SISIP
        $query = selectQuery($dbname, 'setup_parameterappl', '*', $where);
        $resSisip = fetchData($query);
        if (!empty($resSisip)) {
            // Ambil Blok Lama
            $qBlok = selectQuery($dbname, 'setup_blok', 'jumlahpokok', "kodeorg='" . $kodeblok . "'");
            $resBlok = fetchData($qBlok);
            // Update Blok Baru
            $dataUpd = array('jumlahpokok' => $resBlok[0]['jumlahpokok'] + $hasilkerja);
            $updBlok = updateQuery($dbname, 'setup_blok', $dataUpd, "kodeorg='" . $kodeblok . "'");
            if (!mysql_query($updBlok)) {
                exit("Update Blok Error: " . mysql_error());
            }
        }
    }
}
// else 256
示例#7
0
 function getLatestContents($nbcontents, $sort_type = 0, $catselect = "no", $rootid = null)
 {
     switch ($sort_type) {
         /* Popular */
         case 2:
             $order_sql = "ORDER BY a.views DESC,a.date_created DESC ,a.id DESC ";
             break;
             /* Random */
         /* Random */
         case 1:
             $order_sql = "ORDER BY RAND() ";
             break;
             /* Latest */
         /* Latest */
         case 0:
         default:
             $order_sql = "ORDER BY a.date_created DESC ,a.id DESC ";
             break;
     }
     if (version_compare(JVERSION, '1.6', 'ge')) {
         $listCategories = TPermissions::getAuthorisedCategories('read');
         //If the variable is an array and if it's not empty, we add a filter to the request
         //If not we're not return any category
         if (is_array($listCategories) && !empty($listCategories)) {
             $categories = implode(',', $listCategories);
             $listCategories = " AND c.id IN (" . $categories . ") ";
         } else {
             $listCategories = " AND 0 ";
         }
     } else {
         $listCategories = "";
     }
     $cat_query = "";
     switch ($catselect) {
         case "no":
             break;
         case "-1":
             $catid = JRequest::getInt('catid', 0);
             if ($catid != 0 && $catid != -1) {
                 $this->_db->setQuery("SELECT c.id, c.name,c.parent " . " FROM #__adsmanager_categories as c " . " WHERE c.published = 1 {$listCategories} ORDER BY c.parent,c.ordering");
                 $listcats = $this->_db->loadObjectList();
                 //List
                 $list = array();
                 $list[] = $catid;
                 $this->_recurseSearch($listcats, $list, $catid);
                 $listids = implode(',', $list);
                 $cat_query = "adcat.catid IN ({$listids}) AND ";
             }
             break;
         default:
             $this->_db->setQuery("SELECT c.id, c.name,c.parent " . " FROM #__adsmanager_categories as c " . " WHERE c.published = 1 {$listCategories} ORDER BY c.parent,c.ordering");
             $listcats = $this->_db->loadObjectList();
             $catsid = explode(',', $catselect);
             //List
             $list = array();
             foreach ($catsid as $catid) {
                 $list[] = $catid;
                 $this->_recurseSearch($listcats, $list, $catid);
             }
             $listids = implode(',', $list);
             $cat_query = " adcat.catid IN ({$listids}) AND ";
             break;
     }
     if (ADSMANAGER_SPECIAL == 'newspaper') {
         $cat_query .= " (a.ad_publishtype = 'both' OR a.ad_publishtype = 'online') AND ";
     }
     $currentSession = JSession::getInstance('none', array());
     $sql = $currentSession->get("sqlglobalfilter", "");
     $globalfilter = "";
     if ($sql != "") {
         $globalfilter = " AND {$sql} ";
     }
     $sql = " SELECT a.*,p.id as parentid,p.name as parent,c.id as catid, c.name as cat,u.username as user " . " FROM #__adsmanager_ads as a " . " INNER JOIN #__adsmanager_adcat as adcat ON adcat.adid = a.id " . " LEFT JOIN #__users as u ON a.userid = u.id " . " INNER JOIN #__adsmanager_categories as c ON adcat.catid = c.id " . " LEFT JOIN #__adsmanager_categories as p ON c.parent = p.id " . " WHERE 1 {$globalfilter} AND {$cat_query} c.published = 1 and a.published = 1 GROUP BY a.id {$order_sql} LIMIT 0, {$nbcontents}";
     if (function_exists("updateQuery")) {
         updateQuery($sql);
     }
     $this->_db->setQuery($sql);
     $contents = $this->_db->loadObjectList();
     if ($contents == null) {
         $contents = array();
     }
     foreach ($contents as &$content) {
         $content->images = @json_decode($content->images);
         $content->cat = JText::_($content->cat);
         if ($content->parent != "") {
             $content->parent = JText::_($content->parent);
         }
         if (!is_array($content->images)) {
             $content->images = array();
         }
     }
     return $contents;
 }
            if (!mysql_query($queryToJ)) {
                $errorDB .= "Posting Mark Error :" . mysql_error() . "\n";
            }
            $queryKonter = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $tmpKonter[0]['nokounter'] + 1), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'");
            if (!mysql_query($queryKonter)) {
                $errorDB .= "Update Counter Error :" . mysql_error() . "\n" . $errorDB . "___" . $queryKonter;
            }
        }
    }
}
if ($errorDB != "") {
    // Rollback
    $where = "nojurnal='" . $nojurnal . "'";
    $queryRB = "delete from `" . $dbname . "`.`keu_jurnalht` where " . $where;
    $queryRB2 = updateQuery($dbname, 'kebun_aktifitas', array('jurnal' => 0), "notransaksi='" . $dataH[0]['notransaksi'] . "'");
    $queryRBKonter = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $tmpKonter[0]['nokounter']), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodeJurnal . "'");
    if (!mysql_query($queryRB)) {
        $errorDB .= "Rollback 1 Error :" . mysql_error() . "\n";
    }
    if (!mysql_query($queryRB2)) {
        $errorDB .= "Rollback 2 Error :" . mysql_error() . "\n";
    }
    if (!mysql_query($queryRBKonter)) {
        $errorDB .= "Rollback Counter Error :" . mysql_error() . "\n";
    }
    echo "DB Error :\n" . $errorDB . "___" . $queryRB2;
    //echo "DB Error :\n".$errorDB."___".$queryRB2;
    exit;
} else {
    // Posting Success
}
 if ($headErr == '') {
     $detailErr = '';
     foreach ($dataRes['detail'] as $row) {
         $insDet = insertQuery($dbname, 'keu_jurnaldt', $row);
         if (!mysql_query($insDet)) {
             $detailErr .= "Insert Detail Error : " . addslashes(mysql_error($conn)) . "\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."'");
         $updJurnal = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter), "kodeorg='" . $ptpengguna . "' and kodekelompok='" . $kodeJurnal . "'");
         if (!mysql_query($updJurnal)) {
             echo "Update Kode Jurnal Error : " . addslashes(mysql_error($conn)) . "\n";
             # Rollback if Update Failed
             $RBDet = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal . "'");
             if (!mysql_query($RBDet)) {
                 echo "Rollback Delete Header Error : " . addslashes(mysql_error($conn)) . "\n";
                 exit;
             }
             exit;
         } else {
             #berhasil di jurnal
             //                    echo "warning: \nheader1pemilik_".$header1pemilik."\nnojurnal_".$nojurnal."\n".$insHead;
             //                    exit;
             #proses gudang
             $errGudang = '';
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;
    }
}
 case 'edit':
     $data = $_POST;
     unset($data['nojurnal']);
     $data['tanggal'] = tanggalsystem($data['tanggal']);
     //echo "warning: <pre>";
     //print_r($data);
     //echo "<pre>";
     $query = updateQuery($dbname, 'keu_jurnalht', $data, "nojurnal='" . $_POST['nojurnal'] . "'");
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
     } else {
         $data['tanggal'] = tanggalnormal($data['tanggal']);
         echo json_encode($data);
     }
     $dataz['revisi'] = $_POST['revisi'];
     $query = updateQuery($dbname, 'keu_jurnaldt', $dataz, "nojurnal='" . $_POST['nojurnal'] . "'");
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
     }
     //        else {
     //	    $dataz['revisi'] = $_POST['revisi'];
     //	    echo json_encode($dataz);
     //	}
     break;
 case 'delete':
     $query = selectQuery($dbname, 'keu_jurnaldt', 'nojurnal', "nojurnal='" . $data['nojurnal'] . "'");
     $res = fetchData($query);
     if (empty($res)) {
         $qDel = "delete from `" . $dbname . "`.`keu_jurnalht` where nojurnal='" . $data['nojurnal'] . "'";
         echo $qDel;
         if (!mysql_query($qDel)) {
示例#12
0
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;
}
 $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;
 // }
 // if ($ada==false)
示例#14
0
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
        }
        break;
    case 'delete':
        $where = "nokonosemen='" . $param['nokonosemen'] . "'";
        $query = "delete from `" . $dbname . "`.`log_konosemenht` where " . $where;
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
            exit;
        }
        break;
    case 'posting':
        $data = array('postingkirim' => 1);
        $where = "nokonosemen='" . $param['nokonosemen'] . "'";
        $query = updateQuery($dbname, 'log_konosemenht', $data, $where);
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
        }
    default:
        break;
}
function formHeader($mode, $data)
{
    global $dbname;
    # Default Value
    if (empty($data)) {
        $data['nokonosemen'] = 'KS' . date('Ymdhi');
        $data['nokonosemenexp'] = '';
        $data['kodept'] = '';
        $data['kodeorg'] = $_SESSION['empl']['lokasitugas'];
示例#15
0
# Header
foreach ($data['header'] as $key => $dataDet) {
    $queryH = insertQuery($dbname, 'keu_jurnalht', $dataDet);
    if (!mysql_query($queryH)) {
        $errorDB .= "Header :" . mysql_error() . "\n";
    }
}
# Detail
if ($errorDB == '') {
    foreach ($dataRes['detail'] as $key => $dataDet) {
        $queryD = insertQuery($dbname, 'keu_jurnaldt', $dataDet);
        if (!mysql_query($queryD)) {
            $errorDB .= "Detail " . $key . " :" . mysql_error() . "\n";
        }
    }
    #update jurnal counter
    $queryKonter = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter + 1), "kodeorg='" . $param['pt'] . "' and kodekelompok='" . $kodejurnal . "'");
    if (!mysql_query($queryKonter)) {
        $errorDB .= "Update Counter Error :" . mysql_error() . "\n" . $errorDB . "___" . $queryKonter;
    }
}
if ($errorDB != "") {
    # Rollback
    foreach ($arrNoJurnal as $key => $nojur) {
        $queryRB = "delete from `" . $dbname . "`.`keu_jurnalht` where nojurnal='" . $nojur . "'";
        if (!mysql_query($queryRB)) {
            $errorDB .= "Rollback 1 Error :" . mysql_error() . "\n";
        }
    }
    echo "Error " . $errorDB;
}
示例#16
0
function updateSettings($name, $value)
{
    $data = array('value' => $value);
    if (!updateQuery(TBL_SETTINGS, $data, "name='" . $name . "'")) {
        return false;
    } else {
        return true;
    }
}
示例#17
0
     if ($data['hutangunit'] == '') {
         $data['hutangunit'] = 0;
     }
     $where = "notransaksi='" . $data['notransaksi'] . "' and kodeorg='" . $data['kodeorg'] . "' and noakun='" . $data['oldNoakun'] . "' and tipetransaksi='" . $data['tipetransaksi'] . "'";
     $wheredt = "notransaksi='" . $data['notransaksi'] . "' and kodeorg='" . $data['kodeorg'] . "'";
     $datadt['noakun2a'] = $param['noakun'];
     $datadt['matauang'] = $param['matauang'];
     $datadt['kurs'] = $param['kurs'];
     unset($data['notransaksi']);
     unset($data['kodeorg']);
     unset($data['oldNoakun']);
     unset($data['tipetransaksi']);
     $data['tanggal'] = tanggalsystem($data['tanggal']);
     $data['jumlah'] = str_replace(',', '', $data['jumlah']);
     $query = updateQuery($dbname, 'keu_kasbankht', $data, $where);
     $querydt = updateQuery($dbname, 'keu_kasbankdt', $datadt, $wheredt);
     if (!mysql_query($query)) {
         echo "DB Error ht : " . mysql_error();
     } else {
         if (!mysql_query($querydt)) {
             echo "DB Error dt : " . mysql_error();
         } else {
             echo 'Done.';
         }
     }
     // tadinya ga pake else echo Done, tapi kalo ga pake update-annya ga kesimpen. koq bisa ya?
     // tambahan querydt untuk ngupdate noakun2a kasbankdt
     break;
 case 'delete':
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodeorg='" . $param['kodeorg'] . "' and noakun='" . $param['noakun'] . "' and tipetransaksi='" . $param['tipetransaksi'] . "'";
     $query = "delete from `" . $dbname . "`.`keu_kasbankht` where " . $where;
    $errCounter = "";
    if (!mysql_query($queryJ)) {
        $errCounter .= "Update Counter Parameter Jurnal Error :" . mysql_error() . "\n";
    }
    if ($errCounter != "") {
        $queryJRB = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $tmpKonter[0]['nokounter']), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $dataD[0]['kode'] . "'");
        $errCounter = "";
        if (!mysql_query($queryJRB)) {
            $errorJRB .= "Rollback Parameter Jurnal Error :" . mysql_error() . "\n";
        }
        echo "DB Error :\n" . $errorJRB;
        exit;
    }
    #=== Add Counter Jurnal Otomatis === =======================================
    if ($dataH[0]['hutangunit'] == 1) {
        $queryJ = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konteroto), "kodeorg='" . $indukpemilikhutang . "' and kodekelompok='" . $kodejurnal . "'");
        $errCounter = "";
        if (!mysql_query($queryJ)) {
            $errCounter .= "Update Counter Parameter Jurnal Error :" . mysql_error() . "\n";
        }
        if ($errCounter != "") {
            $queryJRB = updateQuery($dbname, 'keu_5kelompokjurnal', array($noKon[0]['nokounter']), "kodeorg='" . $indukpemilikhutang . "' and kodekelompok='" . $kodejurnal . "'");
            $errCounter = "";
            if (!mysql_query($queryJRB)) {
                $errorJRB .= "Rollback Parameter Jurnal Error :" . mysql_error() . "\n";
            }
            echo "DB Error :\n" . $errorJRB;
            exit;
        }
    }
}
示例#19
0
    $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
    $where = "`" . $prim['field'] . "`='" . $prim['value'] . "'";
    # Make Query
    $query = updateQuery($dbname, 'setup_matauang', $data, $where);
    # Update Data
    if (!mysql_query($query)) {
        echo "DB Error : " . mysql_error($conn);
    }
} elseif ($_POST['proses'] == 'main_delete') {
    # Create Query
    $query = "delete from `" . $dbname . "`.`setup_matauang` where `kode`='" . $_POST['primVal'] . "'";
    # Delete
    if (!mysql_query($query)) {
        echo "DB Error : " . mysql_error($conn);
    }
}
示例#20
0
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());
        }
    }
}
     foreach ($data as $cont) {
         $res .= "##" . $cont;
     }
     $result = "{res:\"" . $res . "\",theme:\"" . $_SESSION['theme'] . "\"}";
     echo $result;
     break;
 case 'edit':
     $data = $param;
     unset($data['notransaksi']);
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodekegiatan='" . $param['cond_kodekegiatan'] . "' and kodeorg='" . $param['cond_kodeorg'] . "'";
     $query = updateQuery($dbname, 'kebun_prestasi', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     echo json_encode($param);
     break;
 case 'delete':
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodekegiatan='" . $param['kodekegiatan'] . "' and kodeorg='" . $param['kodeorg'] . "'";
     $query = "delete from `" . $dbname . "`.`kebun_prestasi` where " . $where;
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
 default:
     foreach ($param as $key => $row) {
         if (substr($key, 8, 10) == 'tahuntanam') {
             $param['tahuntanam'] = $row;
         }
     }
     $data = array();
     $data['kodebarang'] = $param['kodebarang'];
     $data['jumlah'] = $param['jumlah'];
     unset($data['nopengolahan']);
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     $where = "nopengolahan='" . $param['nopengolahan'] . "' and kodeorg='" . $param['kodeorg'] . "' and tahuntanam='" . $param['tahuntanam'] . "' and kodebarang='" . $param['cond_kodebarang'] . "'";
     $query = updateQuery($dbname, 'pabrik_pengolahan_barang', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     echo json_encode($data);
     break;
 case 'delete':
     foreach ($param as $key => $row) {
         if (substr($key, 8, 7) == 'station') {
             $param['kodeorg'] = $row;
         }
     }
     foreach ($param as $key => $row) {
         if (substr($key, 8, 10) == 'tahuntanam') {
             $param['tahuntanam'] = $row;
                    $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());
        break;
        // Delete Detail
    // Delete Detail
    case 'deleteDetail':
        $where = "nosj='" . $param['nosj'] . "' and kodept='" . $param['kodept'] . "' and kodebarang='" . $param['kodebarang'] . "' and nopo='" . $param['nopo'] . "' and nopp='" . $param['nopp'] . "'";
        $query = deleteQuery($dbname, 'log_suratjalandt', $where);
        mysql_query($query) or die("Error DB: " . mysql_error());
        break;
    default:
        break;
}
 case 'edit':
     cekVendorKasKecil();
     // Cek Vendor Kas Kecil
     $data = $param;
     if ($data['kurs'] == 0 || $data['kurs'] == '') {
         exit("[ Error ]: The value of the kurs rate there should be.");
     }
     unset($data['notransaksi']);
     foreach ($data as $key => $cont) {
         if (substr($key, 0, 5) == 'cond_') {
             unset($data[$key]);
         }
     }
     $data['jumlah'] = str_replace(',', '', $data['jumlah']);
     $where = "notransaksi='" . $param['notransaksi'] . "' and noakun='" . $param['cond_noakun'] . "' and tipetransaksi='" . $param['tipetransaksi'] . "' and noakun2a='" . $param['noakun2a'] . "' and keterangan1='" . $param['cond_keterangan1'] . "' and keterangan2='" . $param['cond_keterangan2'] . "' and kodeorg='" . $param['kodeorg'] . "'";
     $query = updateQuery($dbname, 'keu_kasbankdt', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     echo json_encode($param);
     break;
 case 'delete':
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodeorg='" . $param['kodeorg'] . "' and noakun='" . $param['noakun'] . "' and noakun2a='" . $param['noakun2a'] . "' and tipetransaksi='" . $param['tipetransaksi'] . "' and keterangan1='" . $param['keterangan1'] . "'\n\t\t\t\t and keterangan2='" . $param['keterangan2'] . "'";
     $query = "delete from `" . $dbname . "`.`keu_kasbankdt` where " . $where;
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
 case 'updField':
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;
            }
        }
    }
}
             $RBDet1 = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal1 . "'");
             if (!mysql_query($RBDet1)) {
                 $RBErr .= "Rollback Delete Header 1 Error : " . mysql_error() . "\n";
                 exit;
             }
             $RBDet2 = deleteQuery($dbname, 'keu_jurnalht', "nojurnal='" . $nojurnal2 . "'");
             if (!mysql_query($RBDet2)) {
                 $RBErr .= "Rollback Delete Header 2 Error : " . mysql_error() . "\n";
                 exit;
             }
             # Rollback Update
             $RBJurnal1 = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter1 - 1), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodejurnal1 . "'");
             if (!mysql_query($RBJurnal1)) {
                 $RBErr .= "Rollback Update Jurnal 1 Error : " . mysql_error() . "\n";
             }
             $RBJurnal2 = updateQuery($dbname, 'keu_5kelompokjurnal', array('nokounter' => $konter2 - 1), "kodeorg='" . $_SESSION['org']['kodeorganisasi'] . "' and kodekelompok='" . $kodejurnal2 . "'");
             if (!mysql_query($RBJurnal2)) {
                 $RBErr .= "Rollback Update Jurnal 2 Error : " . mysql_error() . "\n";
             }
             if ($RBErr != '') {
                 echo $RBErr;
             }
             exit;
         } else {
             #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Success
             echo '1';
         }
     }
 } else {
     #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Insert Detail failed
     echo $detailErr;
     #========================== 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);
         }
     }
 } else {
     echo $detailErr;
     # Rollback, Delete Header
     unset($data['matauang']);
     unset($data['numRow1']);
     unset($data['numRow2']);
     $data['jumlahrealisasi'] = str_replace(',', '', $data['jumlahrealisasi']);
     $data['jjgkontanan'] = str_replace(',', '', $data['jjgkontanan']);
     # Empty Data
     foreach ($data as $cont) {
         if ($cont == '') {
             echo 'Warning : Data tidak boleh ada yang kosong';
             exit;
         }
     }
     # Convert Tanggal
     $param['tanggal'] = tanggalsystem($param['tanggal']);
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodeblok='" . $param['blokalokasi'] . "' and kodekegiatan='" . $param['kodekegiatan'] . "' and tanggal='" . $param['tanggal'] . "' and blokspkdt='" . $param['kodeblok'] . "' and kodesegment='" . $param['kodesegment'] . "'";
     $query = updateQuery($dbname, 'log_baspk', $data, $where);
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
 case 'delete':
     # Convert Tanggal
     $param['tanggal'] = tanggalsystem($param['tanggal']);
     $where = "notransaksi='" . $param['notransaksi'] . "' and kodeblok='" . $param['blokalokasi'] . "' and kodekegiatan='" . $param['kodekegiatan'] . "' and tanggal='" . $param['tanggal'] . "' and blokspkdt='" . $param['kodeblok'] . "' and kodesegment='" . $param['kodesegment'] . "'";
     $query = "delete from `" . $dbname . "`.`log_baspk` where " . $where;
     if (!mysql_query($query)) {
         echo "DB Error : " . mysql_error();
         exit;
     }
     break;
        } 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;
}
示例#30
0
        }
        $data['tanggal'] = tanggalsystem($data['tanggal']);
        $cols = array('kodeorg', 'notransaksi', 'tanggal', 'divisi', 'koderekanan');
        $query = insertQuery($dbname, 'log_spkht', $data, $cols);
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
        }
        break;
        # Proses Edit Header
    # Proses Edit Header
    case 'edit':
        $data = $_POST;
        $where = "nopengolahan='" . $data['nopengolahan'] . "'";
        unset($data['nopengolahan']);
        $data['tanggal'] = tanggalsystem($data['tanggal']);
        $query = updateQuery($dbname, 'log_spkht', $data, $where);
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
        }
        break;
    case 'delete':
        $where = "notransaksi='" . $param['notransaksi'] . "'";
        $query = "delete from `" . $dbname . "`.`log_spkht` where " . $where;
        if (!mysql_query($query)) {
            echo "DB Error : " . mysql_error();
            exit;
        }
        break;
    default:
        break;
}