示例#1
0
//echo $sGetKary;
//$sGetKar="";
//echo $sGetKary; exit;
$rGetkary = fetchData($sGetKary);
foreach ($rGetkary as $row => $kar) {
    $resData[$kar['karyawanid']][] = $kar['karyawanid'];
    //$karyawanid[$kar['karyawanid']]=$kar['karyawanid'];
    $jumlahUmr[$kar['karyawanid']] = $kar['jumlah'];
    $namakar[$kar['karyawanid']] = $kar['namakaryawan'];
    $nikkar[$kar['karyawanid']] = $kar['nik'];
    $nmJabatan[$kar['karyawanid']] = $kar['namajabatan'];
    $sbgnb[$kar['karyawanid']] = $kar['subbagian'];
    $tipekaryawan[$kar['karyawanid']] = $kar['tipekaryawan'];
    $golongankar[$kar['karyawanid']] = $kar['kodegolongan'];
}
$test = rangeTanggal($tgl1, $tgl2);
$jmlHari = count($test);
$colspanTgl = $jmlHari * 2;
//cek max hari inputan
if ($jmlHari > 32) {
    echo "warning:Range tanggal tidak valid";
    exit;
}
$sAbsen = "select kodeabsen from " . $dbname . ".sdm_5absensi order by kodeabsen";
$qAbsen = mysql_query($sAbsen) or die(mysql_error());
$jmAbsen = mysql_num_rows($qAbsen);
$colSpan = intval($jmAbsen) + 2;
if ($proses == 'excel') {
    $border = "border=1";
} else {
    $border = "border=0";
    if ($tgl1 == '' or $tgl2 == '') {
        echo "Warning: Tanggal tidak boleh kosong";
        exit;
    } else {
        if ($tgl1 > $tgl2) {
            echo "Warning: Tanggal pertama tidak boleh lebih besar dari tanggal kedua";
            exit;
        }
    }
}
##############################
############PREPARE###########
#############DATA#############
##############################
#bentuk range tanggal
$rangetanggal = rangeTanggal($tgl1, $tgl2);
#bentuk netto , sumber pabrik_timbangan
/*$iTim="select tanggal,sum(beratbersih) as netto,sum(jjg) as jjg,sum(beratbersih)/sum(jjg) as bjr,count(notiket) as truk "
  . " from ".$dbname.".pabrik_timbangan_vw where millcode='".$kdorg."' and kodecustomer='".$sup."' "
  . " and kodebarang='40000003' and tanggal between '".$tgl1."' and '".$tgl2."' group by tanggal ";*/
$iTim = "select tanggal,sum(beratbersih) as netto,sum(jjg) as jjg,sum(beratbersih)/sum(jjg) as bjr " . " from " . $dbname . ".pabrik_timbangan_vw where millcode='" . $kdorg . "' and kodecustomer='" . $sup . "' " . " and kodebarang='40000003' and tanggal between '" . $tgl1 . "' and '" . $tgl2 . "' group by tanggal ";
$nTim = mysql_query($iTim) or die(mysql_error($conn));
while ($dTim = mysql_fetch_assoc($nTim)) {
    $netto[$dTim['tanggal']] = $dTim['netto'];
    $jjg[$dTim['tanggal']] = $dTim['jjg'];
    $bjr[$dTim['tanggal']] = $dTim['bjr'];
}
##bentuk jumlah yang disortasi //perbedaan dengan query pertama adalah where kgpotsortasi>0
##untuk mengsortir nomor tiket yang disortasi.
##karena dari beberapa tiket persupplier belum tentu semua di sortasi
$iSortim = "select tanggal,count(notiket) as truk,sum(beratbersih) as netto " . " from " . $dbname . ".pabrik_timbangan_vw where millcode='" . $kdorg . "' and kodecustomer='" . $sup . "' " . " and kodebarang='40000003' and tanggal between '" . $tgl1 . "' and '" . $tgl2 . "'" . " and kgpotsortasi>0 group by tanggal ";
//$where = "a.kodeorg='".$kdpabrik."' and a.tanggal='2015-01-05' ";// and a.tanggal='2015-01-04'
$where = "a.kodeorg='" . $kdpabrik . "' and a.tanggal between '" . $tgl1 . "' and '" . $tgl2 . "' ";
// and a.tanggal='2015-01-04'
// $query = selectQuery($dbname,'pabrik_pengolahan',$cols,$where)." group by tanggal";
$iList = "select distinct " . $cols . " from " . $dbname . ".pabrik_pengolahan a left join " . $dbname . ".pabrik_produksi b \r\n                 on (a.kodeorg=b.kodeorg and a.tanggal=b.tanggal) where " . $where . " group by a.tanggal";
$nList = mysql_query($iList) or die(mysql_error($conn));
while ($dList = mysql_fetch_assoc($nList)) {
    $jamstagnasi[$dList['tanggal']] = $dList['jamstagnasi'];
    $jamoprasional[$dList['tanggal']] = $dList['jamdinasbruto'];
    $jumlahlori[$dList['tanggal']] = $dList['jumlahlori'];
    $tbsdiolah[$dList['tanggal']] = $dList['tbsdiolah'];
    $cpo[$dList['tanggal']] = $dList['cpo'];
    $pk[$dList['tanggal']] = $dList['pk'];
    $nopengolahan[$dList['tanggal']] = $dList['nopengolahan'];
}
$listtanggal = rangeTanggal($tgl1, $tgl2);
function fixjam($jam, $menit)
{
    if (strlen($menit) == 1) {
        $menit = $menit * 10;
    } else {
        $menit = $menit;
    }
    $menitnya = number_format($menit / 100 * 60);
    if (strlen($menitnya == 0)) {
        $menitnya = $menitnya . '0';
    }
    return $jam . ':' . $menitnya;
}
foreach ($listtanggal as $ar => $tgl) {
    $formatjam = explode(".", $jamoprasional[$tgl]);
        echo " Error " . $_SESSION['lang']['irisan'];
        exit(0);
    } else {
        if ($sampai < $dari) {
            echo " Error < >";
            exit(0);
        }
    }
}
//===============================================
if ($diambil == '') {
    $diambil = 0;
}
switch ($method) {
    case 'delete':
        $rangeTglDel = rangeTanggal($_POST['dariJ'], $_POST['sampaiJ']);
        foreach ($rangeTglDel as $val) {
            $strDelAbs = "delete from " . $dbname . ".sdm_absensidt where kodeorg='" . $optSubBagian[$karyawanid] . "' and karyawanid='" . $karyawanid . "' and tanggal='" . $val . "' and absensi='C'";
            mysql_query($strDelAbs);
        }
        $str = "delete from " . $dbname . ".sdm_cutidt\r\n\t\t       where kodeorg='" . $kodeorg . "'\r\n\t\t\t   and karyawanid=" . $karyawanid . "\r\n\t\t\t   and periodecuti='" . $periode . "'\r\n\t\t\t   and daritanggal='" . $_POST['dariJ'] . "'";
        break;
    case 'insert':
        foreach ($rangeTgl as $val) {
            $strAbs = "insert into " . $dbname . ".sdm_absensidt (kodeorg,tanggal,karyawanid,shift,absensi,jam,jamPlg,penjelasan,catu,penaltykehadiran,premi,insentif,fingerprint) values ('" . $optSubBagian[$karyawanid] . "','" . $val . "','" . $karyawanid . "','','C','00:00:00','00:00:00','" . $keterangan . "','0','0','0','0','0')";
            mysql_query($strAbs);
        }
        $str = "insert into " . $dbname . ".sdm_cutidt \r\n\t\t      (kodeorg,karyawanid,periodecuti,daritanggal,\r\n\t\t\t  sampaitanggal,jumlahcuti,keterangan\r\n\t\t\t  )\r\n\t\t      values('" . $kodeorg . "'," . $karyawanid . ",\r\n\t\t\t  '" . $periode . "','" . $dari . "','" . $sampai . "',\r\n\t\t\t  " . $diambil . ",'" . $keterangan . "'\r\n\t\t\t  )";
        break;
    default:
        break;
示例#5
0
 $iTahap = "select * from " . $dbname . ".project_dt where kodeproject='" . $kode . "' ";
 //echo $iTahap;
 $nTahap = mysql_query($iTahap) or die(mysql_error($conn));
 while ($dTahap = mysql_fetch_assoc($nTahap)) {
     //$i+=1;
     //$listKdProject[$dTahap['kodeproject']]=$dTahap['kodeproject'];
     $tahapan[$dTahap['namakegiatan']] = $dTahap['namakegiatan'];
     $tglMulai[$dTahap['namakegiatan']] = $dTahap['tanggalmulai'];
     $tglSelesai[$dTahap['namakegiatan']] = $dTahap['tanggalselesai'];
 }
 echo $i;
 //$tglMulai[$dTahap['namakegiatan'].$dTahap['tanggalmulai']]
 //$arrTgl=rangeTanggal($dHead['tanggalmulai'],$dHead['tanggalselesai']);
 if (!empty($tahapan)) {
     foreach ($tahapan as $listTahapan) {
         $arrTglData = rangeTanggal($tglMulai[$listTahapan], $tglSelesai[$listTahapan]);
         $listTersimpan = false;
         $dert = false;
         $stream .= "<tr>\n                        <td>" . $tahapan[$listTahapan] . "</td>";
         $isi = "";
         if (!empty($arrTgl)) {
             foreach ($arrTgl as $listTgl) {
                 if ($dert == false) {
                     if ($tglSelesai[$listTahapan] == $listTgl) {
                         $isi = "bgcolor=blue";
                         //$isi="bgcolor=red";
                         $listTersimpan = false;
                         //$tglSelesai[$listTahapan]="";
                         $dert = true;
                     } else {
                         if ($listTersimpan == false) {