Showing posts with label PAyroll Management System. Show all posts
Showing posts with label PAyroll Management System. Show all posts

Thursday, September 29, 2011

Bank Salary Slip Generation for Payroll Management System

Today I completed, one more section of Payroll Management System and that is Generation of Bank Salary Slip. As I am making this Web Based payroll software for a contract based firm working at Trident Group, dhaula, they need an individual slip which they ll give to Bank for payment of their employees. So, I did the same.

Here is the code for the bankslip.php to generate odt
<?php
session_start();
if($_SESSION['user']!='admin') {
    header('location:../checklogin/error.php');
}
require_once('../library/odf.php');
include '../dbfiles/config.php';
class bankslip {
    private $op;
    private $query;
    public function download_slip() {
        $odf = new odf("bankslip.odt");
        if($_POST['month']!='' && $_POST['year']=='') {
            echo "<script>alert('You forgot to submit year'); window.location='bankslip.php';</script>";
        }
        elseif ($_POST['month']=='' && $_POST['year']!='') {
            echo "<script>alert('You forgot to enter month'); window.location='bankslip.php';</script>";
        }
        elseif (($_POST['month']!='' && $_POST['year']!='') && $_POST['current']!='') {
            echo "<script>alert('Hello!! I didnt told you to select all options'); window.location='bankslip.php';</script>";
        }
        elseif (($_POST['month']=='' && $_POST['year']=='') && $_POST['current']=='') {
            echo "<script>alert('Hello!! I told you to select one option'); window.location='bankslip.php';</script>";
        }
        elseif ($_POST['month']!=''&& $_POST['year']!='') {
            $this->op= 'defined';
            $month= $_POST['month'];
            $year= $_POST['year'];

        }
        elseif ($_POST['current']!='') {
            $this->op= 'current';
            $month= date('n')-1;
            $year= date('Y');
        }
        switch ($month) {
            case 1:
                $monthname= 'January';
                break;
            case 2:
                $monthname= 'February';
                break;
            case 3:
                $monthname= 'March';
                break;
            case 4:
                $monthname= 'April';
                break;
            case 5:
                $monthname= 'May';
                break;
            case 6:
                $monthname= 'June';
                break;
            case 7:
                $monthname= 'July';
                break;
            case 8:
                $monthname= 'August';
                break;
            case 9:
                $monthname= 'September';
                break;
            case 10:
                $monthname= 'October';
                break;
            case 11:
                $monthname= 'November';
                break;
            case 12:
                $monthname= 'December';
                break;
        }
        $odf->setVars('month', $monthname);
        $odf->setVars('year', $year);
        $this->query= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance, accno from workers, worker_fixeds, worker_varys, worker_acc where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and workers.id=worker_acc.id and month='$month' and year='$year'");
        $bank = $odf->setSegment('emp');
        $s=1;
        while($result= mysql_fetch_array($this->query)) {
            if(!$result) {
                header('location:qerror.php?op='.mysql_error());
            }
            $cal= sprintf('%.2f',($result['rate'])*($result['workdays']));
            $ded= $result['pf']+$result['esi']+$result['advance'];
            if($result['workdays']<20) {
                $wages= sprintf('%.2f',(($result['rate'])*($result['workdays']))+0);
                $netpay= sprintf('%.0f', ($wages-$ded));
                $total= sprintf('%.0f', ($total+$netpay));
            }
            else {
                $wages= sprintf('%.2f',(($result['rate'])*($result['workdays']))+$result['hra']);
                $netpay= sprintf('%.0f', ($wages-$ded));
                $total= sprintf('%.0f', ($total+$netpay));
            }
            $bank->s($s);
            $bank->accno($result['accno']);
            $bank->name($result['worker_fname'].' '.$result['worker_lname']);
            $bank->amount($netpay);
            $bank->merge();
            $s=$s+1;
        }
        $odf->mergeSegment($bank);
        $odf->setVars('total', $total);
        $odf->exportAsAttachedFile('Bankslip.odt');
    }
}
$bank_slip= new bankslip();
$bank_slip->download_slip();
?>

Friday, September 23, 2011

Salary Slip Generation for Payroll System

Today I am Done with generation of salary slip for Workers in Payroll Management System. for the time I am done with only the phase of downloading complete slips for every employee.

Here Below is snapshot:-

[caption id="attachment_45" align="aligncenter" width="1024" caption="Salary Slip Generation"]Salary Slip Generation[/caption]

And below is the Complete Coding for Generating the Odt file
<?php
require_once('../library/odf.php');
include_once '../dbfiles/config.php';
class salaryslip {
private $query= array();
private $result= array();
private $calsal;
private $acc;
private $ded;
private $totwages;
private $netpay;
private $month;
public function slip() {
$odf = new odf("slip.odt");
$article = $odf->setSegment('articles');
$this->month= date('n')-1;
if($_GET['op']=='comp') {
$this->query[0]= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance, accno from workers, worker_fixeds, worker_varys, worker_acc where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and workers.id=worker_acc.id and month='$this->month'");
if(!$this->query[0]) {
header('location:qerror.php?op=uperror');
}
while($this->result[0]=mysql_fetch_array($this->query[0])) {
$comp_name= $this->result[0]['worker_fname'].' '.$this->result[0]['worker_lname'];
$this->ded=($this->result[0]['pf']+$this->result[0]['esi']+$this->result[0]['advance']);
$article->name($comp_name);
$article->accno($this->result[0]['accno']);
$article->ecode($this->result[0]['id']);
$article->basic($this->result[0]['gross']);
$article->days($this->result[0]['workdays']);
$this->calsal= sprintf('%.2f',($this->result[0]['rate'])*($this->result[0]['workdays']));
$article->calsal($this->calsal);
if($this->result[0]['workdays']<20) {
$article->hra('0');
$this->totwages=sprintf('%.2f',($this->calsal)+0);
$article->total($this->totwages);
}
else {
$article->hra($this->result[0]['hra']);
$this->totwages=sprintf('%.2f',($this->calsal)+$this->result[0]['hra']);
$article->total($this->totwages);
}
$article->pf($this->result[0]['pf']);
$article->esi($this->result[0]['esi']);
$article->advance($this->result[0]['advance']);
$article->totalded($this->ded);
$this->netpay= sprintf('%.2f',($this->totwages)-($this->ded));
$article->netpay($this->netpay);
$article->merge();
}
}
$odf->mergeSegment($article);
$odf->exportAsAttachedFile('CompleteSlip.odt');
}
}
$sh= new salaryslip();
$sh->slip();
?>

Thursday, September 22, 2011

Total For Final Salary sheet of Project

One thing which I forgot was total of each field  i.e gross, hra, cal salary, total wages, pf, esi etc. What I did, I declared an array named total in class finalsheet of page salarysheet.php

So Code Snippet got modified as below:-
<?php class finalsheet{
private $query= array();
private $result= array();
private $total= array();
private $calsal;
private $ded;
private $totwages;
private $netpay;
private $month;
public function seedata(){
$this->total[1]=0;
$this->total[2]=0;
$this->total[3]=0;
$this->total[4]=0;
$this->total[5]=0;
$this->total[6]=0;
$this->total[7]=0;
$this->total[8]=0;
$this->total[9]=0;
$this->total[10]=0;
$this->total[11]=0;
$this->month= date('n')-1;
$this->query[0]=mysql_query("Select id from worker_varys where month='$this->month'");
$count= mysql_num_rows($this->query[0]);
if($count==0){
echo "<script>var check= confirm('No data for updation');
if(check==true){
window.location='newsheet.php';}
else{
window.location='adminhome.php';}
</script>";
}
else{
$this->query[1]= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance from workers, worker_fixeds, worker_varys where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and month='$this->month'");
if(!$this->query[1]){
header('location:qerror.php?op=uperror');
}
$this->i=1;
while($this->result[2]=mysql_fetch_array($this->query[1])){
if(($this->i)%2==0){
echo "<tr>";
}
else{
echo "<tr>";
}
echo "<input type='hidden' name=id[] value=".$this->result[2]['id']." />";
echo "<td>".$this->i."</td>";
echo "<td style='width:120px;'>".$this->result[2]['worker_fname'].' '.$this->result[2]['worker_lname']."</td>";
echo "<td>".$this->result[2]['gross']."</td>";
echo "<td>".$this->result[2]['rate']."</td>";
echo "<td>".$this->result[2]['workdays']."</td>";
$this->calsal= sprintf('%.2f',($this->result[2]['rate'])*($this->result[2]['workdays']));
echo "<td>".$this->calsal."</td>";
if($this->result[2]['workdays']<20){
echo "<td>0</td>";
$this->total[5]= sprintf('%.2f', ($this->total[5]) + 0);
$this->totwages=sprintf('%.2f',($this->calsal)+0);
echo "<td>".$this->totwages."</td>";
}
else{
echo "<td>".$this->result[2]['hra']."</td>";
$this->total[5]= sprintf('%.2f', ($this->total[5]) + ($this->result[2]['hra']));
$this->totwages=sprintf('%.2f',($this->calsal)+$this->result[2]['hra']);
echo "<td>".$this->totwages."</td>";
}
echo "<td>".$this->result[2]['pf']."</td>";
echo "<td>".$this->result[2]['esi']."</td>";
echo "<td>".$this->result[2]['advance']."</td>";
$this->ded=($this->result[2]['pf']+$this->result[2]['esi']+$this->result[2]['advance']);
echo "<td>".$this->ded."</td>";
$this->netpay= sprintf('%.2f',($this->totwages)-($this->ded));
echo "<td>".$this->netpay."</td>";
$this->total[1]= $this->total[1] + $this->result[2]['gross'];
$this->total[2]= sprintf('%.2f', ($this->total[2]) + ($this->result[2]['rate']));
$this->total[3]= sprintf('%.2f', ($this->total[3]) + ($this->result[2]['workdays']));
$this->total[4]= sprintf('%.2f', ($this->total[4]) + ($this->calsal));
$this->total[6]= sprintf('%.2f', ($this->total[6]) + ($this->totwages));
$this->total[7]= sprintf('%.2f', ($this->total[7]) + ($this->result[2]['pf']));
$this->total[8]= sprintf('%.2f', ($this->total[8]) + ($this->result[2]['esi']));
$this->total[9]= sprintf('%.2f', ($this->total[9]) + ($this->result[2]['advance']));
$this->total[10]= sprintf('%.2f', ($this->total[10]) + ($this->ded));
$this->total[11]= sprintf('%.2f', ($this->total[11]) + ($this->netpay));
echo "</tr>";
$this->i=$this->i+1;
}
echo '<tr><td colspan="2" align="right" style="font-size:medium;">Total
</td>';
echo '<td>'.$this->total[1].'</td>';
echo '<td>'.$this->total[2].'</td>';
echo '<td>'.$this->total[3].'</td>';
echo '<td>'.$this->total[4].'</td>';
echo '<td>'.$this->total[5].'</td>';
echo '<td>'.$this->total[6].'</td>';
echo '<td>'.$this->total[7].'</td>';
echo '<td>'.$this->total[8].'</td>';
echo '<td>'.$this->total[9].'</td>';
echo '<td>'.$this->total[10].'</td>';
echo '<td>'.$this->total[11].'</td></tr>';
}
}
}
$sh= new finalsheet();
$sh->seedata();
?>
And Below is the screen shot of fields that get total. It is clearly visible total being performed at last row.

[caption id="attachment_41" align="aligncenter" width="1024" caption="Total of Every Field of Salary sheet"][/caption]

Tuesday, September 20, 2011

UML Diagram of Payroll System

Today I completed the Basic Functionality of Payroll Management System. Here Below is the UML Diagram for Payroll Management System. R&D of both projects Complaint Management system and Payroll Management System will go hand in hand.

[caption id="attachment_33" align="aligncenter" width="1024" caption="UML Diagram of Payroll system"][/caption]