Jump to content
#StayAtHome ×

ramiwahdan

Members
  • Content Count

    70
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ramiwahdan

  • Rank
    Regular Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. 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?
  2. Figured it out $ids = join("','",$arr); $qry = "select OracleID, StaffName,joindate from staff WHERE OracleID NOT IN ('$ids')"; $answ = mysqli_query($con, $qry); Thanks
  3. 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
  4. it should output to a single link to go to the fpdf file you shared with me
  5. 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
  6. 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
  7. I am using your code, i passed link from my old page to new page that has your code, the line that makes the select statement is having that error. for fpdf i am using your code with page named fpdf.php
  8. Hi, you need to change $conn to $link you have: if ($conn->query($sql) === TRUE) { and have: $conn->close(); change them to if ($link->query($sql) === TRUE) { and $link->close();
  9. Hi, So I put the link in my original php file and when i am directed to the fpdf page i get the first error as i am walking my way through... First my code: <?php require('fpdf/fpdf.php'); include('dbcon.php'); // ADD YOUR OWN PDO CONNECTION CODE // $servername = "localhost"; $username = "???"; $password = "???"; $db = "timeclock"; $conn = new PDO("mysql:host=$servername;dbname=$db", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); class attendPDF extends FPDF { protected $today; protected $headbase; protected $db; protected $sid; protected $name; protected $sdate; protected $edate; //constructor public function __construct($db, $oracleid, $sdate, $edate) { parent::__construct(); $this->today = date('jS M Y'); $this->db = $db; $this->sid = $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->name = $res->fetchColumn(); } and here is the error: Fatal error: Uncaught Error: Call to a member function prepare() on string in C:\xampp\htdocs\AttendanceSystem\login\fpdf.php:36 Stack trace: #0 C:\xampp\htdocs\AttendanceSystem\login\fpdf.php(148): attendPDF->__construct('timeclock', '533349', '2020-03-01', '2020-03-31') #1 {main} thrown in C:\xampp\htdocs\AttendanceSystem\login\fpdf.php on line 36 I confirm all info is correct so why there is an error
  10. First, thanks for the big help. So i will keep my original untouched or i will only take the code you gave me? If i keep the original, what changes i need to do to that? your screenshots shows both attendance and absent tables, is if from the file you gave me? If i need to add the link you gave me to my original php file, it changes based on choices, how to get that? Lastly, I used to get the dates from a form, in your file, how are we getting these dates?
  11. i am trying to use FPDF as you mention it but i am able to find out the problem. and here is what i tried: require('fpdf/fpdf.php'); $pdf = new FPDF(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Absent Report'); $pdf->SetFont('Arial','',8); and i am adding the pages at the end after displaying my data \\ code before foreach ($res as $r) { $tdata .= "<tr><td>" . join('</td><td>', $r) . "</td></tr>\n"; } ?> <p>Absent Report:</p> <table border='1'> <tr><th>ID</th><th>Name</th><th>Absent</th></tr> <?=$tdata?> <?php $pdf->AddPage(); $pdf->Cell(40,10,$tdata); $pdf->Output(); ?> </table> <a href="singlereportbyid.php" width="100%">Click here to go back to Main Menu</a> </div> </div> </div> </div> </body> </html> I get this error Fatal error : Uncaught Exception: FPDF error: No page has been added yet in C:\xampp\htdocs\AttendanceSystem\login\fpdf\fpdf.php:271 Stack trace: #0 C:\xampp\htdocs\AttendanceSystem\login\fpdf\fpdf.php(1447): FPDF->Error('No page has bee...') #1 C:\xampp\htdocs\AttendanceSystem\login\fpdf\fpdf.php(643): FPDF->_out('BT 2.83 822.92 ...') #2 C:\xampp\htdocs\AttendanceSystem\login\singlereportidfinal.php(22): FPDF->Cell(40, 10, 'Absent Report') #3 {main} thrown in C:\xampp\htdocs\AttendanceSystem\login\fpdf\fpdf.php on line 271 I am trying to put the last table (absents) in new page
  12. screenshot, the data split to second page, instead i want the absent table to all move to second page in the printer
  13. I have print page using window.print in the body tag at the beginning of php file and i am trying to make the rest of the code as second page, the last table will be on the second page. it is not working. code: <b>Absent Report:</b> <table style ="page-break-before: always;" border='1'> <tr><th>ID</th><th>Name</th><th>Absent</th></tr> <?=$tdata?> </table> <a href="singlereportbyid.php" width="100%">Click here to go back to Main Menu</a> </div> </div> </div> </div> </body> </html> why it is not working?
  14. i got it when you said the word date and realized i have start date. now, can i add to that code an end date? $month = $sdate1; $start_date = new DateTime("$month"); $incr = DateInterval::createFromDateString('next weekday'); $period = new DatePeriod($start_date, $incr, new DateTime()); can i have end date since it is taking start date?
  15. i am sorry that you got upset but in my company they might search for someone for a week as example so they dont want to look the whole month.
×
×
  • 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.