View attachment 324779 View attachment 324780View attachment 324781View attachment 324782
Patulong naman po about sa programming sa php, Yung sa holiday meron pa po ba kayong alternative way sa pagkuwa ng Fines/penalties sa library system php? Kase nahihirapan po ako sa holiday pero pag due date at return lang ok naman yung mismong pag insert lang ng holiday mismo. Sana matulungan niyo po ako eto po yung code ko
Patulong naman po about sa programming sa php, Yung sa holiday meron pa po ba kayong alternative way sa pagkuwa ng Fines/penalties sa library system php? Kase nahihirapan po ako sa holiday pero pag due date at return lang ok naman yung mismong pag insert lang ng holiday mismo. Sana matulungan niyo po ako eto po yung code ko
Code:
$borrowdate = new Datetime($row['date_return'],new DateTimeZone('Asia/Manila'));
$returndate = new Datetime($row['due_date'],new DateTimeZone('Asia/Manila'));
$currentdate = new Datetime('Asia/Manila');
$returndate->setTime(0,0);
$currentdate->setTime(0,0);
$borrowdate->setTime(0,0);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($returndate, $interval, $borrowdate);
$borrowdate->format("D");
$weekendDays = 0;
$totalDays = 0;
$holiday = 0;
$query_holiday =mysqli_query($dbcon,"SELECT * FROM holiday_tbl");
$fi = $row['borrow_details_id'];
$row=mysqli_fetch_array($query_holiday);
$decholi = $row ['holiday'];
foreach ($period as $p )
{
$totalDays++;
if($p->format( "w" )== 0 or $p->format( "w" )== 6 ) $weekendDays++;
foreach ($row as $decholi) {
if ($p->format('Y-m-d') == $decholi) $holiday++ ;
}
}
echo "<p>Total days: $totalDays</p><p>Weekend days: $weekendDays </p> <p> Holidays: $holiday </p>" ;
$minusdays = ($totalDays - $holiday);
$fines = ($minusdays - $weekendDays) * 5;
if($type == 'Teacher') {
$fines = 0;
}
echo "₱ ". $fines;
mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'");