Jump to content

ramiwahdan

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by ramiwahdan

  1. I tried to add add page to the php not working. now i have empty page. include('fpdf.php'); foreach ($res as $row) { if ($row['oracleid'] != $previd) { // id changed so output total if ($previd != 0) { $theid = $row['oracleid']; echo "<tr><td colspan='6'></td><td>Total Permission Time:</td><td>$total2</td></tr>"; echo '<tr>'; echo "<tr><td colspan='7'><h3><a href='fpdf.php?oracleid=$userid&sdate=$thefirstday&edate=$curdate' target='_blank'>Print Attendance Reports for $name</a></h3></td><td>Total Attendance Time:</td><td>$total</td></tr>"; echo "<tr><td colspan='9' bgcolor='red'></td>"; echo "<tr><td colspan='9' bgcolor='red'></td>"; $pdf->AddPage(); added at the end the output $pdf->output('D','filename.pdf'); ?> i can't use the fpdf inside the php?
  2. exactly i don't pass id, so how to reference the fpdf file then to do the functions to generate the reports of attendance and absents? what i need to pass and what needs to change in that fpdf file. public function __construct($conn, $oracleid, $sdate, $edate) is then wrong since i am not pass each oracle id! is that correct?
  3. yes i understand that and i have the pdf in different file as you guided me but the way the fpdf file is done, it is taking a link from the php file that passes oracle id (each at a time), question is, how to pass all the id's and totals in one go? Thanks.
  4. After removing "Remove "WHERE oracleie = ?"" now attendance is empty, I will change this in the fpdf file, how to link all id's from the php file? Thanks for all the help.
  5. this will download the file after clicking a link but still i have to click for all staff to download each one. What i mean, the fpdf file i have (you helped me with), takes one staff at a time, how to make it inside a loop?
  6. doing so i will be generating one link for each staff and that is what i have, but i want to generate 1 pdf file fir all?\, how?
  7. Here is what i tried: include('session.php'); include('dbcon.php'); require('fpdf/fpdf.php'); $userid = $_GET['GetID']; $isdone = -1; $query = "select * from attendance_records where OracleID = '".$userid."' and isdone= '".$isdone."'"; $result = mysqli_query($con, $query); // Define your columns like so: $columns = array(array("name" => "OracleID","width" => 20), array("name" => "Name","width" => 35), array("name" => "Des", "width" => 35)); $pdf = new FPDF(); $pdf->AddPage(); // Table header $pdf->SetFillColor(232, 232, 232); $pdf->SetFont('Arial', 'B', 8); foreach ($columns as $column) { $pdf->Cell($column['width'], 6, strtoupper($column['name']), 1, 0, 'L', 1); } $pdf->Ln(); $pdf->SetFont('Arial', '', 8); $qry = "select staffname, joindate from staff where OracleID = '".$userid."'"; $answ = mysqli_query($con, $qry); $rowanswer = mysqli_fetch_assoc($answ); $thefirstdate = $rowanswer['joindate']; $thefirstdate2 = date("d-m-Y",strtotime($rowanswer['joindate'])); $staffname = $rowanswer['staffname']; $t=time(); $curdate = date("d-m-Y",$t); $curTime = date("g:i:s A",$t); ?> <html> <head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> </head> <body> <div class="container"> <div class="row"> <div class="col m-auto"> <div class="card mt-5"> <table class="table table-bordered"> <?php $query2 = "SELECT sec_to_time(SUM(timestampdiff(SECOND, ClockingInDate, ClockingOutDate))) as total from attendance_records where OracleID = '".$userid."' and isdone= '".$isdone."'"; $result2 = mysqli_query($con, $query2); $query3 = "SELECT sec_to_time(SUM(timestampdiff(SECOND, PermissionOutDate, PermissionInDate))) as total2 from attendance_records where OracleID = '".$userid."' and isdone= '".$isdone."'"; $result3 = mysqli_query($con, $query3); $num_row = mysqli_num_rows($result); $counter = 0; $previd = 0; $thecount = 0; while ($row = mysqli_fetch_assoc($result)) { $name = $row['Name']; $des = $row['Des']; $theday = $row['theday']; $clockingindate = $row['ClockingInDate']; $peroutdate = $row['PermissionOutDate']; $perindate = $row['PermissionInDate']; $clockingoutdate = $row['ClockingOutDate']; $perduration = $row['PerDuration']; $duration = $row['Duration']; $fullday = $row['fullday']; $reason = $row['reason']; $counter = $counter + 1; if ($peroutdate != Null) { if ($fullday == -1) { $fullday = "Yes"; if ($perindate == Null) { $perindate = "All Day"; } if ($perduration == Null) { $perduration = "All Day"; } } else { $fullday = "No"; } } else{ $fullday = Null; $perindate = Null; $perduration = Null; } if ($row['OracleID'] != $previd) { // id changed so output total if ($previd != 0) { echo " <tr> <td>OracleID</td> <td>{$row['OracleID']}</td> <td>Name</td> <td>{$row['Name']}</td> <td>Designation</td> <td>{$row['Des']}</td> <td>Joining Date</td> <td>$thefirstdate2</td> </tr> "; foreach ($columns as $column) { $pdf->Cell($column['width'], 6, $row[$column['name']], 1); } $pdf->Ln(); } else{ echo " <tr> <td>OracleID</td> <td>{$row['OracleID']}</td> <td>Name</td> <td>{$row['Name']}</td> <td>Designation</td> <td>{$row['Des']}</td> <td>Joining Date</td> <td>$thefirstdate2</td> </tr> "; foreach ($columns as $column) { $pdf->Cell($column['width'], 6, $row[$column['name']], 1); } $pdf->Ln(); } $previd = $row['OracleID']; $pdf->AddPage(); } echo "<th colspan='9'></th>"; $thecount = $thecount + 1; echo " <tr> <td>Day</td> <td>Clocking In</td> <td>Permission Out</td> <td>Full Day?</td> <td>Permission Reason</td> <td>Permission In</td> <td>Clocking Out</td> <td>Permission Duration</td> <td>Normal Duration</td> </tr> <tr> <td>$theday</td> <td>$clockingindate</td> <td>$peroutdate</td> <td>$fullday</td> <td>$reason</td> <td>$perindate</td> <td>$clockingoutdate</td> <td>$perduration</td> <td>$duration</td> </tr> "; } $row2 = mysqli_fetch_assoc($result2); $totals= $row2['total']; $row3 = mysqli_fetch_assoc($result3); $totals2 = $row3['total2']; if ($num_row > 0) { if ($perduration == "All Day") { if ($totals2 == Null) { $totals2 = "All Day"; } } } echo '<tr>'; echo '<td><td><td><td><td><td><td><b>Total Permission Time:</b></td></td></td></td></td></td></td>'; echo '<td>'; echo $totals2; echo '</td>'; echo '</tr>'; echo "<tr><td colspan='7'><h3><a href='fpdf.php?oracleid=$userid&sdate=$thefirstdate2&edate=$curdate' target='_blank'>Print Attendance Reports for $staffname</a></h3></td><td><b>Total Attendance Time:</b></td><td>$totals</td></tr>"; ?> </table> <a href="singlereportbyid.php" width="100%">Click here to go back to Main Menu</a> </div> </div> </div> </div> <?php $pdf->Output(); ?> </body> </html> it gives error that table already exist. Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file why?
  8. can i just get small hint? the loop should be in the php file not the fpdf file, right? how to pass a loop to the given fpdf function, i am saying this because at the moment i am having a link for each staff. The reason why i am getting one by one (staff) is because in the long run each will have 100's of records. public function __construct($conn, $oracleid, $sdate, $edate) we have around 55 staff members and each will have 100's of records that is why i have a link for each staff. is there a way to have them all in one link? the way the attendance system goes, by range of dates based on each staff on his own. not all staff have same login and logoff times.
  9. Thanks, can you help on this. I have the file that generates each link 'fpdf.php?oracleid=$userid&sdate=$thefirstday&edate=$curdate' and this will go to fpdf file that has this: public function __construct($conn, $oracleid, $sdate, $edate) { parent::__construct(); $this->today = date('jS M Y'); $this->db = $conn; $this->oracleid = $oracleid; $this->sdate = new DateTime($sdate); $this->edate = new DateTime($edate); $res = $this->db->prepare("SELECT staffname FROM staff WHERE oracleid = ? "); $res->execute([$oracleid]); $this->staffname = $res->fetchColumn(); } so how to pass all records if fpdf is taking one at each time?
  10. Is there like merge library that can take the links into one file? Like pdf merge online?
  11. I thought of that but this will change my whole coding that I already struggled with.
  12. Something was wrong with my logic. It's ok now
  13. Hi, With my attendance system I generated one fpdf link to generate pdf file. What if I have 50 staff members, Its hard to open the 50 pdf files separately. Is there a away to merge them all in one big pdf file?
  14. here is my code, I know the answer to the count(*) is 4 so it should go through the second if statement but its not. foreach ($res as $row) { if($row['counter'] == 1) { if ($row['oracleid'] != $previd) { if ($previd != 0) { $thecounter = 1; $previd = $row['oracleid']; } else{ $thecounter = $thecounter + 1; $previd = $row['oracleid']; echo "<br>"; echo $thecounter; } } } if ($row['counter'] > 1) { if ($row['oracleid'] != $previd) { if ($previd != 0) { $thecounter = 1; $previd = $row['oracleid']; echo "<br>"; echo $thecounter; } else{ $thecounter = $thecounter + 1; $previd = $row['oracleid']; } } else { $thecounter = $thecounter + 1; $previd = $row['oracleid']; } } } if ($row['counter'] > 1) is not work, what is wrong? i echo out the result for the count(*) and says 4.
  15. I was able to do it, Thanks. Now i need to know how to count the records. my code: $res = $conn->query("SELECT count(*) as counter ,oracleid , name , clockingindate as clockin FROM attendance_records where isdone =-1 and Month(ClockingInDate) = $themonth and Year(ClockingInDate) = $theyear ORDER BY oracleid "); $previd = 0; $thecounter = 0; foreach ($res as $row) { if($row['counter'] == 1) it is not working, how to know how many records i have?
  16. Hi, I have db field with date. I want to make select statement with where clause when part of the date (month) is true. Example, i have records from 2020-2-1 until 2020-4-3, i want to select records for march only 2020-3-1 to 2020-3-31. how to do that?
  17. I figured it out, just created a counter and got this year value.
  18. hi, I have a form that has 2 lists, first one has the months from Jan to Dec which i am done with, for the second list i want to have years from current year for other say 5 years. Example, we are in 2020 so i should have the list populate 2020,2021,2022,2023,2024 and next year it should show 2021-2025, how to do that. Here is what i have as HTML: <html> <head> <link rel="stylesheet" type="text/css" href="reportstyle.css"> </head> <body> <div class="form-wrapper"> <form action="reportanalysis.php" method="post"> <div class="form-item"> <h4>Select a month:</h4> <select id="months" name="months" required="required"> <option selected="selected" value="chose">Choose one option...</option> <option value="jan">Jan - 01</option> <option value="feb">Feb - 02</option> <option value="mar">Mar - 03</option> <option value="apr">Apr - 04</option> <option value="may">May - 05</option> <option value="jun">Jun - 06</option> <option value="jul">Jul - 07</option> <option value="aug">Aug - 08</option> <option value="sep">Sep - 09</option> <option value="oct">Oct - 10</option> <option value="nov">Nov - 11</option> <option value="dec">Dec - 12</option> </select> </div> <div class="form-item"> <h4>Select a year:</h4> <select id="years" name="years" required="required"> <option selected="selected" value="chose">Choose one option...</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> </select> </div> <div class="button-panel"> <center><button type="submit" name="reporting" class="buttonstyle">Generate Graph Report</button></center> </div> <div class="reminder"> <p><a href="home.php">Return to Main Menu</a> </div> </form> </div> </body> </html>
  19. yes it is for the same db of absent days, so i build on the fpdf file that generates the absent days.
  20. Hi, I need to calculate absent percentage but not sure how. working days from Sunday to Thursday every week so 5 working days a week. i will calculate the absent days from joining date until current date. Example if joining date is 24-3-2020 and today's date is 7-4-2020 i should get the number of absent days to 11 days since both Friday and Saturday are excluded. How to do that? here is what I have: $workingdays = $curdate - $joindate; $workingdays = $workingdays - $absent = ($counter / $workingdays) * 100; the second line i missing the number of days for (Fridays and Saturdays) that should be excluded from calculations. The third line i did calculate the actual working days ($counter) for the employee so then i can get percentage of absent days. How to exclude the weekend days from calculations?
  21. Figured it out $ids = join("','",$arr); $qry = "select OracleID, StaffName,joindate from staff WHERE OracleID NOT IN ('$ids')"; $answ = mysqli_query($con, $qry); Thanks
  22. Hi, I have an empty array and i populated the array through code and i printed to check if everything ok. So far so good. I now have an array say $ids = ('123','456'). Now, i have a table in db that has ids as well, I need to make a query to check for id's that are not inside the array, so if the db table have '123','456','789' i want the result of the query to be only the last one '789'. $arr = array(); array_push($arr,$previd2); print_r ($arr); I get the result as follows: Array ( [0] => 533349 [1] => 533355 ) so what query i can use to get the other id's from db table that is not part of that array? here is what i tried: $qry = "select staffname, joindate from staff WHERE OracleID NOT IN ($arr)"; $answ = mysqli_query($con, $qry); I get error: Notice : Array to string conversion in C:\xampp\htdocs\AttendanceSystem\login\reportsforallid.php
  23. it should output to a single link to go to the fpdf file you shared with me
  24. I really feel very stupid today sorry about that. here is the full code for the php part: <?Php include('session.php'); include('dbcon.php'); ?> <html> <head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> </head> <body> <div class="container"> <div class="row"> <div class="col m-auto"> <div class="card mt-5"> <table class="table table-bordered"> <?php $servername = "localhost"; $username = "rwahdan"; $password = "fatima2010"; $conn = new PDO("mysql:host=$servername;dbname=timeclock", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $res = $conn->query("SELECT oracleid , name , des , theday , clockingindate as clockin , permissionoutdate as perout , permissionindate as perin , clockingoutdate as clockout , fullday , reason , timediff(permissionindate,permissionoutdate ) as perduration , timediff(clockingoutdate, clockingindate) as duration , total , total2 FROM attendance_records JOIN ( SELECT oracleid , sec_to_time(sum(timestampdiff(SECOND, clockingindate, clockingoutdate))) as total , sec_to_time(sum(timestampdiff(SECOND, permissionoutdate, permissionindate))) as total2 FROM attendance_records where isdone =-1 GROUP BY oracleid ) tots USING (oracleid) where isdone =-1 ORDER BY oracleid, clockingindate "); ?> <?php $t=time(); $curdate = date("d-m-Y",$t); $curTime = date("g:i:s A",$t); $previd = 0; foreach ($res as $row) { if ($row['oracleid'] != $previd) { // id changed so output total if ($previd != 0) { echo "<tr><td colspan='4'</td><td><td><td>Total Permission Time:</td></td></td><td>$total2</td></tr>"; echo '<tr>'; echo "<tr><td colspan='4'</td><td><td><td><td>Total Attendance Time:</td></td><td>$total</td></tr>"; echo " <tr> <td>OracleID</td> <td>{$row['oracleid']}</td> <td>Name</td> <td>{$row['name']}</td> <td>Designation</td> <td>{$row['des']}</td> </tr> "; $userid = $row['oracleid']; $qry = "select joindate from staff where OracleID = '$userid'"; $answ = mysqli_query($con, $qry); $rowanswer = mysqli_fetch_assoc($answ); $thefirstday = $rowanswer['joindate']; } else{ $userid = $row['oracleid']; $qry = "select joindate from staff where OracleID = '$userid'"; $answ = mysqli_query($con, $qry); $rowanswer = mysqli_fetch_assoc($answ); $thefirstday = $rowanswer['joindate']; echo " <tr> <td>OracleID</td> <td>{$row['oracleid']}</td> <td>Name</td> <td>{$row['name']}</td> <td>Designation</td> <td>{$row['des']}</td> </tr> "; } $previd = $row['oracleid']; $name = $row['name']; } $fullday = $row['fullday']; $perindate = $row['perin']; $perduration = $row['perduration']; $peroutdate = $row['perout']; if ($peroutdate != Null) { if ($fullday == -1) { $fullday = "Yes"; if ($perindate == Null) { $perindate = "All Day"; } if ($perduration == Null) { $perduration = "All Day"; } } else { $fullday = "No"; } } else{ $fullday = Null; $perindate = Null; $perduration = Null; } ?> <th colspan='9'></th> <?php echo " <tr> <td>Day</td> <td>Clocking In</td> <td>Permission Out</td> <td>Full Day?</td> <td>Permission Reason</td> <td>Permission In</td> <td>Clocking Out</td> <td>Permission Duration</td> <td>Normal Duration</td> </tr> <tr> <td>{$row['theday']}</td> <td>{$row['clockin']}</td> <td>{$row['perout']}</td> <td>{$fullday}</td> <td>{$row['reason']}</td> <td>{$perindate}</td> <td>{$row['clockout']}</td> <td>{$perduration}</td> <td>{$row['duration']}</td> </tr> "; $total = $row['total']; $total2 = $row['total2']; if ($perduration == "All Day") { if ($total2 == Null) { $total2 = "All Day"; } } echo "<h1><a href='fpdf.php?oracleid=$userid&sdate=$thefirstday&edate=$curdate'>Print Attendance and Absent Reports for $name</a></h1>"; } echo "<tr><td colspan='4'</td><td><td><td>Total Permission Time:</td></td></td><td>$total2</td></tr>"; echo '<tr>'; echo "<tr><td colspan='4'</td><td><td><td><td>Total Attendance Time:</td></td><td>$total</td></tr>"; ?> </table> <a href="singlereportbyid.php" width="100%">Click here to go back to Main Menu</a> </div> </div> </div> </div> </body> </html> as for the fpdf file it is what you have given me. Thanks
  25. i am getting a link for each record not each oracle id! i need to have one link for all the id's Print Attendance and Absent Reports for Rami T Wahdan Print Attendance and Absent Reports for Rami T Wahdan Print Attendance and Absent Reports for Shahed R Wahdan Print Attendance and Absent Reports for Shahed R Wahdan As you see, I have 2 records for Rami and 2 records for Shahed, the reason why i am getting for each record because i have this inside while loop. I can figure it out to print once for each oracle id, but the problem is, how to send one link for all oracle ids? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.