Bagaimana script/query mengurangi jumlah hak_cuti

Assalamualaikum selamat pagi mohon bantuannya bagaimana script/query mengurangi jumlah hak_cuti di tabel pegawai ketika di tabel mohon cuti field jml_hari itu disetujui? jadi ini pake 2 tabel ?

https://glot.io/snippets/fjm7xj0du4 Kondisi Approved-cuti

avatar 4hm4d
@4hm4d

5 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

rumusnya : sisa cuti - jumlah hari cuti

<a href='https://stackoverflow.com/questions/3653882/how-to-count-days-between-two-dates-in-php'>hitung hari</a> <pre> &lt;?php

$sisaCuti = 10;

$cutiDari = strtotime("2020/01/13"); $cutiSampai = strtotime("2020/01/16");

$timeDiff = abs($cutiSampai - $cutiDari );

$numberDays = $timeDiff / 86400; // 86400 seconds in one day

// and you might want to convert to integer $numberDays = intval($numberDays);

$hasil = $sisaCuti - $numberDays;

// query sql update pegawai set cuti = $hasil where id_pegawai = ? </pre>

avatar sonypiay
@sonypiay

12 Kontribusi 8 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban