Jump to content

I applied two condition in which if leave is half day or full day then subtract it from Remleaves or else if leave is Sick or Casual then subtract it from Scremleaves. Pls Help


Amazon

Recommended Posts

<td style="font-size:16px;"><b>No of Leaves Available: </b></td>
                                               <td colspan="3">
                                                <?php 
                                                  $st1 = "<?php echo htmlentities($result->LeaveType);?>";
                                                  $st2 = "Half Day";
                                                  $st3 = "Full Day";
                                                  if($st1 == $st2 or $st3){
                                                  $stats=$result->Status;
                                                  if($stats==1 && $update==1){$ld=($result->Remleaves)-($result->Applydays);}
                                                  else{$ld=$result->Remleaves;}
                                                  if($ld<=0){
                                                $ld=0;
                                                //$war="(Available Leaves got exhausted)";
                                                  }
                                                  echo htmlentities($ld);
                                                 ?> <span style="color:red"><?php echo htmlentities($war);?></span><?php
                                                  $eid=$result->id;
                                                  $sql='update tblemployees set Remleaves=:ld where id=:eid';
                                                    $query = $dbh->prepare($sql);
                                                    $query->bindParam(':ld',$ld,PDO::PARAM_STR);
                                                     
                                                    $query->bindParam(':eid',$eid,PDO::PARAM_INT);
                                                    $query->execute();
                                                    $lastInsertId = $dbh->lastInsertId();
                                                }  
                                               
                                                else{
                                                    $st1 = "<?php echo htmlentities($result->LeaveType);?>";
                                                  $st2 = "Sick Leave";
                                                  $st3 = "Casual Leave";
                                                  if($st1 == $st2 or $st3){
                                                  
                                                  $stats=$result->Status;
                                                  if($stats==1 && $update==1){$ld=($result->Scremleaves)-($result->Applydays);}
                                                  else{$ld=$result->Scremleaves;}
                                                  if($ld<=0){
                                                $ld=0;
                                                //$war="(Available Leaves got exhausted)";
                                                  }
                                                  echo htmlentities($ld);
                                                 ?> <span style="color:red"><?php echo htmlentities($war);?></span><?php
                                                  $eid=$result->id;
                                                  $sql='update tblemployees set Scremleaves=:ld where id=:eid';
                                                    $query = $dbh->prepare($sql);
                                                    $query->bindParam(':ld',$ld,PDO::PARAM_STR);
                                                     
                                                    $query->bindParam(':eid',$eid,PDO::PARAM_INT);
                                                    $query->execute();
                                                    $lastInsertId = $dbh->lastInsertId();
                                                  }
                                                }?></td>

Link to comment
Share on other sites

First please us the code icon (<>) on the top menu. A quick glance I see something I don't think you meant:

 if($st1 == $st2 or $st3){

This will always evaluate to true since $st3 will be true. I am guessing you really meant this:

 if($st1 == $st2 or $st1 == $st3){

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.