-
Notifications
You must be signed in to change notification settings - Fork 0
/
spend.php
606 lines (269 loc) · 10.4 KB
/
spend.php
1
<?phpsession_start();if(!isset($_SESSION['mysession']))header('location:index.php');/*This is the detail page*/require_once('template/head.php');?></style> </head><body><div class="container-fluid"> <?php require_once('template/nav.php'); require_once('class/Person.php'); ?> <div> <table class="table table-hover table-responsive"><colgroup> <col span="5" style="background-color:lightblue"> <col style="background-color:beige"> <col style="background-color:#f1fff8"> <col style="background-color:darkorange"> <col style="background-color:#febbff"> <col style="background-color:rgba(76, 175, 219, 0.31)"> <col style="background-color:rgba(116, 219, 18, 0.31)"> <col style="background-color:rgba(219, 128, 131, 0.31)"> <col style="background-color:rgba(184, 131, 219, 0.31)"> <col style="background-color:rgba(154, 219, 26, 0.31)"> <col style="background-color:rgba(219, 206, 133, 0.31)"> <col style="background-color:rgba(150, 200, 130, 0.31)"> <col style="background-color:rgba(140, 150, 100, 0.31)"> <col style="background-color:rgba(120, 160, 120, 0.31)"> <col style="background-color:rgba(110, 170, 125, 0.31)"> <col style="background-color:rgba(100, 180, 105, 0.31)"><col style="background-color:rgba(106, 120, 150, 0.31)"><col style="background-color:rgba(116, 110, 140, 0.31)"><col style="background-color:rgba(126, 128, 170, 0.31)"><col style="background-color:rgba(124, 135, 165, 0.31)"> </colgroup><tr> <th> Ref.No </th> <th> Date </th> <th> Item Name</th> <th>Paid Person </th> <th>Amount</th> <th>Wsk Share</th> <!-- <th>Imd Share</th> --> <th>Brk Share</th> <th>Ijz Share</th> <!-- <th>nwb Share</th>--> <th>isn Share</th> <!-- <th>jal Share</th> --> <th>kas Share</th> <!-- <th>nsr Share</th> <th>isr Share</th> <th>yas Share</th> --> <!-- c1 --> <th> nwbc share</th> <th> ans share</th> <th> mhb share</th> <!-- <th> mus share</th> <th> isq share</th><th> asf share</th> !--><th> irf share</th><!-- <th> nae share</th> --> <th> wzr share</th> <th>Select</th> </tr> <?php//mechnism for going to myspend logicif(isset($_GET['mypage']))$which_page=$_GET['mypage'];else$which_page="spend";/*Control come to this place when delete button is pressed*/ if(isset($_GET['work'])){ $id=$_GET['id']; $evdate=$_GET['edate']; $d=date_difference($evdate,$actor); $q="UPDATE bills SET status=3,actor='$actor' WHERE no=$id"; if($d<1){ $ds=mysqli_query($con,$q)or die('error in delete'); if($ds) echo '<h3 class="bg-success"> Row Deleted </h3>'; if($which_page=="mydetail") header('refresh:3;url=spend.php?mypage=mydetail'); else if($which_page=="mycredit") header('refresh:3;url=spend.php?mypage=mycredit'); else header('refresh:3;url=spend.php'); } else{ echo '<h2 class="bg-danger text-center"> Not allowed after one day </h2>'; if($which_page=="mydetail") header('refresh:3;url=spend.php?mypage=mydetail'); else if($which_page=="mycredit") header('refresh:3;url=spend.php?mypage=mycredit'); else header("refresh:3; url=spend.php"); } // end of else not allowed after one day } /**End of Delete block**///function is defined in sandbox.$no_of_record=select_one_col($con,"setting","records",$actor);$num_rec_per_page=$no_of_record;if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };$start_from = ($page-1) * $num_rec_per_page; //$q="SELECT * FROM bills WHERE status=1 AND $shareholdser>0 ORDER BY no DESC LIMIT $start_from,$num_rec_per_page";if($which_page=="mydetail") $q="SELECT * FROM bills WHERE status=1 AND $shareholdser>0 ORDER BY no DESC LIMIT $start_from,$num_rec_per_page";else if($which_page=="mycredit") $q="SELECT * FROM bills WHERE status=1 AND paid_person='$pperson' ORDER BY no DESC LIMIT $start_from,$num_rec_per_page";else $q="SELECT * FROM bills WHERE status=1 ORDER BY no DESC LIMIT $start_from,$num_rec_per_page";$exe=mysqli_query($con,$q);$i=1; while($exer=mysqli_fetch_assoc($exe)){$p=$exer['paid_person'];if($p=="waqas"){echo '<tr class="">';}else if($p=="ijaz"){echo '<tr class="">';}else if($p=="barkat"){echo '<tr class="">';}else if($p=="imdad"){echo '<tr class="">';}else if($p=="nawab"){echo '<tr class="">';}else if($p=="ihsan"){ echo '<tr class="">'; } else if($p=="jalil"){ echo '<tr class="">'; } else if($p=="kashif"){ echo '<tr class="">'; } else if($p=="nasar"){ echo '<tr class="">'; } //chage two T4else if($p=="israr"){ echo '<tr class="">'; }else if($p=="yasir"){ echo '<tr class="">'; }else if($p=="nawabc"){ echo '<tr class="">'; } else if($p=="ansar"){ echo '<tr class="">'; }/*label area code starts*/$no=$exer['no']; $amount=$exer['paid_amount']; $wsk_share=$exer['wsk_share']."<br>"; $ijz_share=$exer['ijz_share']."<br>"; $imd_share=$exer['imd_share']."<br>"; $brk_share=$exer['brk_share']."<br>"; $nwb_share=$exer['nwb_share']."<br>"; $isn_share=$exer['isn_share']."<br>"; $jal_share=$exer['jal_share']."<br>"; $kas_share=$exer['kas_share']."<br>"; $nsr_share=$exer['nsr_share']."<br>"; // change three T5 $isr_share=$exer['isr_share']."<br>"; $yas_share=$exer['yas_share']."<br>"; $nwbc_share=$exer['nwbc_share']."<br>"; $ans_share=$exer['ans_share']."<br>"; $mhb_share=$exer['mhb_share']."<br>"; $mus_share=$exer['mus_share']."<br>"; $isq_share=$exer['isq_share']."<br>";$asf_share=$exer['asf_share']."<br>";$irf_share=$exer['irf_share']."<br>";$nae_share=$exer['nae_share']."<br>"; $wzr_share=$exer['wzr_share']."<br>"; //for calution of one share i neeed the sum of all shares; //change four T6 $ts=$sh->total_share($wsk_share,$ijz_share,$imd_share,$brk_share,$nwb_share,$isn_share,$jal_share,$kas_share,$nsr_share,$isr_share,$yas_share,$nwbc_share,$ans_share,$mhb_share,$mus_share,$isq_share,$asf_share,$irf_share,$nae_share,$wzr_share); $one_share=$sh->one_share_price($amount,$ts);/*lable area code ends*/ // change five T7 echo '<td> '.$no.'</td> <td>'.$exer['eventdate'].'</td> <td>'.$exer['item_name'].'</td> <td>'.$p.'</td> <td>'.$exer['paid_amount'].'</td> <td>'.$wsk_share.' <span class="label label-success">'.round($wsk_share*$one_share,1).'</span></td> <!-- <td>'.$imd_share.' <span class="label label-success">'.round($imd_share*$one_share,1).'</span></td> --> <td>'.$brk_share.' <span class="label label-success">'.round($brk_share*$one_share,1).'</span></td> <td>'.$ijz_share.' <span class="label label-success">'.round($ijz_share*$one_share,1).'</span></td><!-- <td>'.$nwb_share.' <span class="label label-success">'.round($nwb_share*$one_share,1).'</span> </td>--> <td>'.$isn_share.' <span class="label label-success">'.round($isn_share*$one_share,1).'</span></td><!-- <td>'.$jal_share.' <span class="label label-success">'.round($jal_share*$one_share,1).'</span></td> --> <td>'.$kas_share.' <span class="label label-success">'.round($kas_share*$one_share,1).'</span></td><!-- <td>'.$nsr_share.' <span class="label label-success">'.round($nsr_share*$one_share,1).'</span></td> --><!-- <td>'.$isr_share.' <span class="label label-success">'.round($isr_share*$one_share,1).'</span></td> --><!-- <td>'.$yas_share.' <span class="label label-success">'.round($yas_share*$one_share,1).'</span></td> --> <td>'.$nwbc_share.' <span class="label label-success">'.round($nwbc_share*$one_share,1).'</span></td> <td>'.$ans_share.' <span class="label label-success">'.round($ans_share*$one_share,1).'</span></td> <td>'.$mhb_share.' <span class="label label-success">'.round($mhb_share*$one_share,1).'</span></td><!-- <td>'.$mus_share.' <span class="label label-success">'.round($mus_share*$one_share,1).'</span></td> --><!-- <td>'.$isq_share.' <span class="label label-success">'.round($isq_share*$one_share,1).'</span></td> --><!-- <td>'.$asf_share.' <span class="label label-success">'.round($asf_share*$one_share,1).'</span></td> --> <td>'.$irf_share.' <span class="label label-success">'.round($irf_share*$one_share,1).'</span></td> <td>'.$wzr_share.' <span class="label label-success">'.round($wzr_share*$one_share,1).'</span></td><!-- <td>'.$nae_share.' <span class="label label-success">'.round($nae_share*$one_share,1).'</span></td> --> '; $a=$exer['actor'];if($actor==$a ||$actor=="admin"){ if($which_page=="myspend") { echo '<td> <a href="edit.php?id='.$exer['no'].'"class="btn btn-info btn-xs">Edit </a> <a href="spend.php?mypage=mydetail&work=del&id='.$exer['no'].'&edate='.$exer['eventdate'].'"class="btn btn-danger btn-xs align-right">Delete</a> </td>'; } else if($which_page=="mycredit"){ echo '<td> <a href="edit.php?id='.$exer['no'].'"class="btn btn-info btn-xs">Edit </a> <a href="spend.php?mypage=mycredit&work=del&id='.$exer['no'].'&edate='.$exer['eventdate'].'"class="btn btn-danger btn-xs align-right">Delete</a> </td>'; } else{ echo '<td> <a href="edit.php?id='.$exer['no'].'"class="btn btn-info btn-xs">Edit </a> <a href="spend.php?work=del&id='.$exer['no'].'&edate='.$exer['eventdate'].'"class="btn btn-danger btn-xs align-right">Delete</a> </td>'; }}else{}echo' <tr>'; $i++; }?> </table> </div> <div > <?phpif($which_page=="mydetail") $sql = "SELECT * FROM bills where status=1 AND $shareholdser>0";else if($which_page=="mycredit") $sql = "SELECT * FROM bills where status=1 AND paid_person='$shareholdser'";else $sql = "SELECT * FROM bills where status=1";$rs_result = mysqli_query($con,$sql); //run the query$total_records = mysqli_num_rows($rs_result); //count number of records$total_pages = ceil($total_records / $num_rec_per_page);echo'<ul class="pagination pagination-lg">';for($i=1; $i<=$total_pages; $i++) { if($which_page=="mydetail") echo '<li><a href="spend.php?mypage=mydetail&page='.$i.'">'.$i.'</a></li>'; else if($which_page=="mycredit") echo '<li><a href="spend.php?mypage=mycredit&page='.$i.'">'.$i.'</a></li>'; else echo '<li><a href="spend.php?page='.$i.'">'.$i.'</a></li>'; }echo'</ul>';?></div> <?php require_once('template/foot.php'); ?>