#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Procedure not working


    DELIMITER $$

    CREATE
    /*[DEFINER = { user | CURRENT_USER }]*/
    PROCEDURE `emp_reg`.`calc`()
    /*LANGUAGE SQL
    | [NOT] DETERMINISTIC
    | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
    | SQL SECURITY { DEFINER | INVOKER }
    | COMMENT 'string'*/
    BEGIN
    DECLARE earres[] INT UNSIGNED DEFAULT 0;
    DECLARE done INT DEFAULT 0;
    DECLARE cur CURSOR FOR SELECT empinfo.emp_code,empinfo.basic,empinfo.designation_id,empinfo.client_code,empinfo.branch_code,

    attendancemaster.earning_duty,attendancemaster.weekly_off,attendancemaster.total_work_days,
    attendancemaster.other_duty,attendancemaster.incentive_duty,attendancemaster.month_days,
    attendancemaster.month,attendancemaster.year,

    empearnings.e_amount1,empearnings.e_amount4,empearnings.e_amount9,empearnings.e_amount10,
    empearnings.e_amount11,empearnings.e_amount16,empearnings.e_amount17,empearnings.d_amount1,
    empearnings.d_amount2,empearnings.d_amount3,empearnings.d_amount4,empearnings.d_amount5,
    empearnings.d_amount6,empearnings.d_amount7,

    netsalary.salary_type,netsalary.gross_earning,netsalary.total_deduction,netsalary.net_salary,
    netsalary.payment_mode,netsalary.transaction_id,netsalary.transaction_date,netsalary.pay_date,

    clientallowancemaster.e_head10,clientallowancemaster.percent_value10,clientallowancemaster.fixed_val ue10,
    clientallowancemaster.e_head11,clientallowancemaster.percent_value11,clientallowancemaster.fixed_val ue11,
    clientallowancemaster.e_head13,clientallowancemaster.percent_value13,clientallowancemaster.fixed_val ue13,
    clientallowancemaster.e_head15,clientallowancemaster.percent_value15,clientallowancemaster.fixed_Val ue15,
    clientallowancemaster.e_head16,clientallowancemaster.percent_value16,clientallowancemaster.fixed_Val ue16,
    clientallowancemaster.e_head3,clientallowancemaster.percent_value3,clientallowancemaster.fixed_Value 3,
    clientallowancemaster.e_head5,clientallowancemaster.percent_value5,clientallowancemaster.fixed_Value 5,
    clientallowancemaster.e_head6,clientallowancemaster.percent_value6,clientallowancemaster.fixed_Value 6,

    empearnings.e_amount3,empearnings.e_amount5,empearnings.e_amount6,

    clientmaster.state_code,clientmaster.esic_deduction,clientmaster.pt_deduction,

    actualsalary.basic, actualsalary.hra,actualsalary.medical_allowance,actualsalary.conveyance,
    actualsalary.incentive,actualsalary.uniform_allow,actualsalary.washing_allow,actualsalary.bonus,
    actualsalary.leave_wage,actualsalary.xman_allow,actualsalary.other_allow,actualsalary.special_allow,
    actualsalary.gross_salary,actualsalary.epf,actualsalary.pt,actualsalary.esic,actualsalary.mess_ratio n,
    actualsalary.coupon,actualsalary.uniform,actualsalary.advance,actualsalary.total_deduction,
    actualsalary.net_salary

    FROM empinfo,attendancemaster,empearnings,netsalary,clientallowancemaster,clientmaster,actualsalary

    WHERE empinfo.emp_code=attendancemaster.emp_code && empinfo.emp_code=empearnings.emp_code &&
    empinfo.emp_code=netsalary.emp_code && empinfo.client_code=clientallowancemaster.client_code &&
    empinfo.designation_id=clientallowancemaster.designation_id &&
    empinfo.client_code=clientallowancemaster.client_code &&
    clientallowancemaster.client_code=clientmaster.client_code &&
    actualsalary.emp_code=empinfo.emp_code;

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

    OPEN cur;
    REPEAT
    FETCH cur INTO earres[];
    UNTIL done = 1 END REPEAT;
    CLOSE cur;
    while ($a_earres=($ear_res))
    //Earning Head

    $v_amt1=($a_earres[1] * $a_earres[7])/$a_earres[10];//calculates basic (ear1) AS per basic * no. of WORK days formula: basic *
    $v_amt2=$a_earres[13] * 0.0833;//calculates bonus (ear17) WHERE .0833=8.33%
    $v_amt3=(($a_earres[13] * 15)/$a_earres[10])/12;//calculates LEAVE wage (ear9) FOR 15 days per MONTH WHERE //15 IS days,$a_earres[10] IS MONTH days & 12 IS no. of months IN a YEAR

    $v_amt4=($a_earres[1] * $a_earres[8])/$a_earres[10];//calculates incentives(ear4)
    $v_amt5=$a_earres[17]; //calculates special allowance (ear11) AS per basic earning * percent_value11
    $v_amt6=$a_earres[18]; //calculates uniform allowance (ear16) AS per basic earning * percent_value16
    $v_amt7=$a_earres[16]; //calculates X-man allowance(ear10) AS per basic earning * percent_value10
    $v_amt20=$a_earres[59]; //calculates HRA AS per basic earning * percent_value3
    $v_amt21=$a_earres[60]; //calculates Conveyance AS per basic earning * percent_value5
    $v_amt22=$a_earres[61]; //calculates Medical Allowance AS per basic earning * percent_value6

    //Deduction Head
    $v_amt8=($a_earres[1] * $a_earres[5] * 0.12) / 26; //calculates epf (ded1) AS per basic earning * 12%

    $v_amt12=$a_earres[21]; //calculates the esi deduction 1.75% of (basic + specialallowance)
    $v_amt13=$a_earres[22]; //calculates pt (ded3) AS per gross earning FIXED pt IS decided BY govt.
    $v_amt14=$a_earres[23]; //calculates manually the input VALUE of advance amount(ded4)
    $v_amt15=$a_earres[24]; //calculates manually the input VALUE of mess/ration amount (ded5)
    $v_amt16=$a_earres[25]; //calculates manually the input VALUE of coupon amount (ded6)
    $v_amt17=$a_earres[26]; //calculates manually the input VALUE of uniform deduction amount (ded7)

    //Total Earnings (FIELD IN Net Salary TABLE)

    $v_amt9= $v_amt1 + $v_amt2 + $v_amt3 + $v_amt4 + $v_amt5 + $v_amt6 + $v_amt7; //calculates gross earning

    //Tota Deduction (FIELD IN Net Salary TABLE)
    $v_amt10= $v_amt8 + $v_amt12 + $v_amt13 + $v_amt14 + $v_amt15 + $v_amt16 + $v_amt17;//calculates total deduction

    //Net Salary
    $v_amt11= $v_amt9 - $v_amt10; //calculates net salary of an employee

    //Total WORK Days
    $v_amt18=$a_earres[5] + $a_earres[6]; //calculates total WORK days=earning duty + weekly off

    //Total Duty
    $v_amt19=$a_earres[7] + $a_earres[8]; //calculates total duty=total WORK days + other duty

    //Calculation FOR Actual Salary TABLE

    $v_amt23=($a_earres[65]+$a_earres[66]+$a_earres[67]+$a_earres[68]+$a_earres[69]+$a_earres[70]+$a_earres[71]+$a_earres[72]+$a_earres[73]+$a_earres[74]+$a_earres[75]+$a_earres[76]);//calculates gross salary

    $v_amt24=($a_earres[78]+$a_earres[79]+$a_earres[80]+$a_earres[81]+$a_earres[82]+$a_earres[83]+$a_earres[84]);//calculates total deduction

    $v_amt25=($v_amt23-$v_amt24);//calculates net salary

    //Calculation FOR calculating Special allowance,Uniform,X-man allowance,HRA,Conveyance & Medical allowance

    IF ($a_earres[2]==1)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==3)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==4)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==5)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==6)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==10)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    ELSEIF ($a_earres[2]==11)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }

    //Calculation FOR calculating Professional Tax (PT) AS per state_code AND client_code

    IF($a_earres[64]==1)
    {
    IF($a_earres[62]==1)
    {
    IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=10;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=40;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=80;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=100;
    }

    }
    ELSEIF($a_earres[62]==2)
    {
    IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=40;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=80;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=150;
    }

    }
    ELSEIF($a_earres[62]==3)
    {
    IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=60;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=120;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=150;
    }
    }
    ELSEIF($a_earres[62]==4)
    {
    IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    ELSEIF($a_earres[62]==5)
    {
    IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    ELSEIF($a_earres[62]==6)
    { IF($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    ELSEIF ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    }

    //calculation FOR calculating ESIC AS per state_code, client_Code & ESIC deducted zone


    IF($a_earres[63]==1)
    {
    IF ($a_earres[62]==1)
    {
    $v_amt12=($a_earres[13] + $a_earres[17]) * 0.0175;
    }
    ELSEIF ($a_earres[63]==0)
    {
    $v_amt12=0;
    }
    }


    update attendancemaster set total_work_days=$v_amt18 where emp_code=$a_earres[0];
    update attendancemaster set total_duty=$v_amt19 where emp_code=$a_earres[0];

    update empearnings set e_amount1=$v_amt1 where emp_code=$a_earres[0];
    update empearnings set e_amount3=$v_amt20 where emp_code=$a_earres[0];
    update empearnings set e_amount4=$v_amt4 where emp_code=$a_earres[0];
    update empearnings set e_amount5=$v_amt21 where emp_code=$a_earres[0];
    update empearnings set e_amount6=$v_amt22 where emp_code=$a_earres[0];
    update empearnings set e_amount9=$v_amt3 where emp_code=$a_earres[0];
    update empearnings set e_amount10=$v_amt7 where emp_code=$a_earres[0];
    update empearnings set e_amount11=$v_amt5 where emp_code=$a_earres[0];
    update empearnings set e_amount16=$v_amt6 where emp_code=$a_earres[0];
    update empearnings set e_amount17=$v_amt2 where emp_code=$a_earres[0];

    update empearnings set d_amount1=$v_amt8 where emp_code=$a_earres[0];
    update empearnings set d_amount2=$v_amt12 where emp_code=$a_earres[0];
    update empearnings set d_amount3=$v_amt13 where emp_code=$a_earres[0];
    update empearnings set d_amount4=$v_amt14 where emp_code=$a_earres[0];
    update empearnings set d_amount5=$v_amt15 where emp_code=$a_earres[0];
    update empearnings set d_amount6=$v_amt16 where emp_code=$a_earres[0];
    update empearnings set d_amount7=$v_amt17 where emp_code=$a_earres[0];

    update netsalary set gross_earning=$v_amt9 where emp_code=$a_earres[0];
    update netsalary set total_deduction=$v_amt10 where emp_code=$a_earres[0];

    update actualsalary set gross_salary=$v_amt23 where emp_code=$a_earres[0];
    update actualsalary set total_deduction=$v_amt24 where emp_code=$a_earres[0];
    update actualsalary set net_salary=$v_amt25 where emp_code=$a_earres[0];
    END$$

    DELIMITER ;
  2. #2
  3. Hockey face
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    St. Catharines, Canada
    Posts
    8,144
    Rep Power
    1316
    Not enough info. What does "not working" mean? Error messages? Inserting incorrect data?

    That's an awful lot of code for people to be asked to walk through and guess what the problem is with it.

    It also might help if you took the time to format it better.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by Guelphdad
    Not enough info. What does "not working" mean? Error messages? Inserting incorrect data?

    That's an awful lot of code for people to be asked to walk through and guess what the problem is with it.

    It also might help if you took the time to format it better.
    dear thnx for noticing...

    basically i need to do calculation inside mysql tables

    so i m using mysql procedure

    first fetching it values from diff tables
    1:how can i store all the fetched value in array?
    can i do it?how

    after that
    i hv perform basic calculation formula on values which are fetched
    and stored them in diffrent varibles
    after that i hv updated the values in respective tables

    plz help me frnds

    as i m student n ihv to complete this project

    i know the logic and formulas but sumwhat failed to understand the syntax in mysql

    plz help me...:


    this is the php file from which i mdeveloping my procedure in mysql...

    can u just give me sum guidelines so that i can develop it better as im a learner


    <?php

    include("connect.php")


    $ear_res=mysql_query("select empinfo.emp_code,empinfo.basic,empinfo.designation_id,empinfo.client_code,empinfo.branch_code,

    attendancemaster.earning_duty,attendancemaster.weekly_off,attendancemaster.total_work_days,
    attendancemaster.other_duty,attendancemaster.incentive_duty,attendancemaster.month_days,
    attendancemaster.month,attendancemaster.year,

    empearnings.e_amount1,empearnings.e_amount4,empearnings.e_amount9,empearnings.e_amount10,
    empearnings.e_amount11,empearnings.e_amount16,empearnings.e_amount17,empearnings.d_amount1,
    empearnings.d_amount2,empearnings.d_amount3,empearnings.d_amount4,empearnings.d_amount5,
    empearnings.d_amount6,empearnings.d_amount7,

    netsalary.salary_type,netsalary.gross_earning,netsalary.total_deduction,netsalary.net_salary,
    netsalary.payment_mode,netsalary.transaction_id,netsalary.transaction_date,netsalary.pay_date,

    clientallowancemaster.e_head10,clientallowancemaster.percent_value10,clientallowancemaster.fixed_val ue10,
    clientallowancemaster.e_head11,clientallowancemaster.percent_value11,clientallowancemaster.fixed_val ue11,
    clientallowancemaster.e_head13,clientallowancemaster.percent_value13,clientallowancemaster.fixed_val ue13,
    clientallowancemaster.e_head15,clientallowancemaster.percent_value15,clientallowancemaster.fixed_Val ue15,
    clientallowancemaster.e_head16,clientallowancemaster.percent_value16,clientallowancemaster.fixed_Val ue16,
    clientallowancemaster.e_head3,clientallowancemaster.percent_value3,clientallowancemaster.fixed_Value 3,
    clientallowancemaster.e_head5,clientallowancemaster.percent_value5,clientallowancemaster.fixed_Value 5,
    clientallowancemaster.e_head6,clientallowancemaster.percent_value6,clientallowancemaster.fixed_Value 6,

    empearnings.e_amount3,empearnings.e_amount5,empearnings.e_amount6,

    clientmaster.state_code,clientmaster.esic_deduction,clientmaster.pt_deduction,

    actualsalary.basic, actualsalary.hra,actualsalary.medical_allowance,actualsalary.conveyance,
    actualsalary.incentive,actualsalary.uniform_allow,actualsalary.washing_allow,actualsalary.bonus,
    actualsalary.leave_wage,actualsalary.xman_allow,actualsalary.other_allow,actualsalary.special_allow,
    actualsalary.gross_salary,actualsalary.epf,actualsalary.pt,actualsalary.esic,actualsalary.mess_ratio n,
    actualsalary.coupon,actualsalary.uniform,actualsalary.advance,actualsalary.total_deduction,
    actualsalary.net_salary

    from empinfo,attendancemaster,empearnings,netsalary,clientallowancemaster,clientmaster,actualsalary

    where empinfo.emp_code=attendancemaster.emp_code && empinfo.emp_code=empearnings.emp_code && empinfo.emp_code=netsalary.emp_code && empinfo.client_code=clientallowancemaster.client_code && empinfo.designation_id=clientallowancemaster.designation_id && empinfo.client_code=clientallowancemaster.client_code && clientallowancemaster.client_code=clientmaster.client_code && actualsalary.emp_code=empinfo.emp_code") or die("errors");


    while ($a_earres=mysql_fetch_array($ear_res))
    {

    //Earning Head

    $v_amt1=($a_earres[1] * $a_earres[7])/$a_earres[10];//calculates basic (ear1) as per basic * no. of work days
    $v_amt2=$a_earres[13] * 0.0833;//calculates bonus (ear17) where .0833=8.33%
    $v_amt3=(($a_earres[13] * 15)/$a_earres[10])/12;//calculates leave wage (ear9) for 15 days per month where //15 is days,$a_earres[10] is month days & 12 is no. of months in a year

    $v_amt4=($a_earres[1] * $a_earres[8])/$a_earres[10];//calculates incentives(ear4)
    $v_amt5=$a_earres[17]; //calculates special allowance (ear11) as per basic earning * percent_value11
    $v_amt6=$a_earres[18]; //calculates uniform allowance (ear16) as per basic earning * percent_value16
    $v_amt7=$a_earres[16]; //calculates x-man allowance(ear10) as per basic earning * percent_value10
    $v_amt20=$a_earres[59]; //calculates HRA as per basic earning * percent_value3
    $v_amt21=$a_earres[60]; //calculates Conveyance as per basic earning * percent_value5
    $v_amt22=$a_earres[61]; //calculates Medical Allowance as per basic earning * percent_value6

    //Deduction Head
    $v_amt8=($a_earres[1] * $a_earres[5] * 0.12) / 26; //calculates epf (ded1) as per basic earning * 12%

    $v_amt12=$a_earres[21]; //calculates the esi deduction 1.75% of (basic + specialallowance)
    $v_amt13=$a_earres[22]; //calculates pt (ded3) as per gross earning fixed pt is decided by govt.
    $v_amt14=$a_earres[23]; //calculates manually the input value of advance amount(ded4)
    $v_amt15=$a_earres[24]; //calculates manually the input value of mess/ration amount (ded5)
    $v_amt16=$a_earres[25]; //calculates manually the input value of coupon amount (ded6)
    $v_amt17=$a_earres[26]; //calculates manually the input value of uniform deduction amount (ded7)

    //Total Earnings (Field in Net Salary Table)

    $v_amt9= $v_amt1 + $v_amt2 + $v_amt3 + $v_amt4 + $v_amt5 + $v_amt6 + $v_amt7; //calculates gross earning

    //Tota Deduction (Field in Net Salary Table)
    $v_amt10= $v_amt8 + $v_amt12 + $v_amt13 + $v_amt14 + $v_amt15 + $v_amt16 + $v_amt17;//calculates total deduction

    //Net Salary
    $v_amt11= $v_amt9 - $v_amt10; //calculates net salary of an employee

    //Total Work Days
    $v_amt18=$a_earres[5] + $a_earres[6]; //calculates total work days=earning duty + weekly off

    //Total Duty
    $v_amt19=$a_earres[7] + $a_earres[8]; //calculates total duty=total work days + other duty

    //Calculation for Actual Salary Table

    $v_amt23=($a_earres[65]+$a_earres[66]+$a_earres[67]+$a_earres[68]+$a_earres[69]+$a_earres[70]+$a_earres[71]+$a_earres[72]+$a_earres[73]+$a_earres[74]+$a_earres[75]+$a_earres[76]);//calculates gross salary

    $v_amt24=($a_earres[78]+$a_earres[79]+$a_earres[80]+$a_earres[81]+$a_earres[82]+$a_earres[83]+$a_earres[84]);//calculates total deduction

    $v_amt25=($v_amt23-$v_amt24);//calculates net salary

    //Calculation for calculating Special allowance,Uniform,X-man allowance,HRA,Conveyance & Medical allowance

    if ($a_earres[2]==1)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==3)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==4)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==5)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==6)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==10)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }
    elseif ($a_earres[2]==11)
    {
    $v_amt5=$a_earres[13] * $a_earres[39];
    $v_amt6=$a_earres[13] * $a_earres[48];
    $v_amt7=$a_earres[13] * $a_earres[36];
    $v_amt20=$a_earres[13] * $a_earres[51];
    $v_amt21=$a_earres[13] * $a_earres[54];
    $v_amt22=$a_earres[13] * $a_earres[57];
    }

    //Calculation for calculating Professional Tax (PT) as per state_code and client_code

    if($a_earres[64]==1)
    {
    if($a_earres[62]==1)
    {
    if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=10;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=40;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=100;
    }

    }
    elseif($a_earres[62]==2)
    {
    if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=40;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=150;
    }

    }
    elseif($a_earres[62]==3)
    {
    if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=60;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=120;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=150;
    }
    }
    elseif($a_earres[62]==4)
    {
    if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    elseif($a_earres[62]==5)
    {
    if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    elseif($a_earres[62]==6)
    { if($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;
    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    }
    }

    //calculation for calculating ESIC as per state_code, client_Code & ESIC deducted zone


    if($a_earres[63]==1)
    {
    if ($a_earres[62]==1)
    {
    $v_amt12=($a_earres[13] + $a_earres[17]) * 0.0175;
    }
    elseif ($a_earres[63]==0)
    {
    $v_amt12=0;
    }
    }


    /* if ($a_earres[13] + $a_earres[18]<3000)
    {
    $v_amt13=0;

    }
    elseif ($a_earres[13] + $a_earres[18]>=3000 && $a_earres[13] + $a_earres[18]<=5999)
    {
    $v_amt13=20;
    }
    elseif ($a_earres[13] + $a_earres[18]>=6000 && $a_earres[13] + $a_earres[18]<=8999)
    {
    $v_amt13=80;
    }
    elseif ($a_earres[13] + $a_earres[18]<=9000 && $a_earres[13] + $a_earres[18]<=11999)
    {
    $v_amt13=150;
    }
    elseif ($a_earres[13] + $a_earres[18]>=12000)
    {
    $v_amt13=200;
    }
    */
    /*
    mysql_query("update (empearnings set e_amount1=$v_amt1,e_amount17=$v_amt2,e_amount9=$v_amt3,e_amount4=$v_amt4,e_amount11=$v_amt5,e_amount 16=$v_amt6,e_amount10=$v_amt7,d_amount1=$v_amt8,d_amount=$v_amt12,d_amount3=$v_amt13,d_amount4=$v_am t14,d_amount5=$v_amt15,d_amount6=$v_amt16,d_amount7=$v_amt17,e_amount3=$v_amt20,e_amount5=$v_amt21,e _amount6=$v_amt22),(netsalary set gross_earning=$v_amt9,total_deduction=$v_amt10,net_salary=$v_amt11),(attendancemaster set total_work_days=$v_amt18,total_duty=$v_amt19),(actualsalary set gross_salary=$v_amt23,total_deduction=$v_amt24,net_salary=$v_amt25) where emp_code=$a_earres[0]");

    */

    mysql_query("update attendancemaster set total_work_days=$v_amt18 where emp_code=$a_earres[0]");
    mysql_query("update attendancemaster set total_duty=$v_amt19 where emp_code=$a_earres[0]");

    mysql_query("update empearnings set e_amount1=$v_amt1 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount3=$v_amt20 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount4=$v_amt4 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount5=$v_amt21 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount6=$v_amt22 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount9=$v_amt3 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount10=$v_amt7 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount11=$v_amt5 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount16=$v_amt6 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set e_amount17=$v_amt2 where emp_code=$a_earres[0]");

    mysql_query("update empearnings set d_amount1=$v_amt8 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount2=$v_amt12 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount3=$v_amt13 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount4=$v_amt14 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount5=$v_amt15 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount6=$v_amt16 where emp_code=$a_earres[0]");
    mysql_query("update empearnings set d_amount7=$v_amt17 where emp_code=$a_earres[0]");

    mysql_query("update netsalary set gross_earning=$v_amt9 where emp_code=$a_earres[0]");
    mysql_query("update netsalary set total_deduction=$v_amt10 where emp_code=$a_earres[0]");

    mysql_query("update actualsalary set gross_salary=$v_amt23 where emp_code=$a_earres[0]");
    mysql_query("update actualsalary set total_deduction=$v_amt24 where emp_code=$a_earres[0]");
    mysql_query("update actualsalary set net_salary=$v_amt25 where emp_code=$a_earres[0]");

    }



    ?>

    plzzzz
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    73
    Rep Power
    36
    hahaha

    Here's what you do:
    1) Paste over 1000 lines of code without telling us where you are getting an error (check)
    2) Don't even have the courtesy to wrap it in the appropriate colour coding tags (check)
    3) Tell us to basically do your assignment (check)

    Seeing as though you've done all three of those things; you have in fact successfully ignored all the forum posting rules.

    Now, how about this:

    1) Tell us what part of this code is failing (and put it in the appropriate tags so we can actual read it. DO NOT PASTE YOUR WHOLE SOURCE!!!
    2) Don't expect us to actually do your assignment for you - we couldn't give two squirts of piss if you're a student or not; and moreover whether you fail or not.
    3) Respect our time.

    Do the last 3 things, and you might get a response that helps you finish your assignment.
  8. #5
  9. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by Guelphdad
    Not enough info.
    on the contrary, his post was ---->
    TL;DR

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo