30 users online (1 members and 29 guests)  


  Results 1 to 2 of 2

Related

  1. Replies: 3
  2. Replies: 3
  3. Problem saving images    Forum: PHP Forum
    Replies: 1
  4. Replies: 8
  1. #1
    newphpcoder's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Sep 2010
    Posts
    52

    Problem in saving data

    Hi...

    I create a payroll system and now I have an issue or problem in saving data before I save data using save button now i want to save data when clicking the employee name at the navigalist list from the left side.


    Here is my code for the searching and displaying employee name at navigation list:


    Here is my code for search.php:

    Code:
    <?php
    
    session_start();
    include 'config.php';
    
    $queryString = $_GET["query"];
    
    if ($queryString == "" || $queryString == null) {
    
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL 
            ORDER BY FULLNAME ASC";
    }
    else {
    
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.')  LIKE '" . $queryString . "%' ORDER BY FULLNAME ASC";
    
    }
    
    $recPersonalQuery = $conn->Execute($sql);
    if (!$recPersonalQuery->BOF) {
        $recPersonalQuery->MoveFirst();
    }
    
    echo "<hr />";
    echo "<ul>";
    while (!$recPersonalQuery->EOF) {
        $empID   = $recPersonalQuery->fields["EMP_ID"]; 
        $empFullName = $recPersonalQuery->fields["FULLNAME"];
    
      echo "<li onclick=changeEmployeePay('$empID'); >$empFullName</li>";
      //echo "<li onkeyup=changeEmployeePay('$empID'); >$empFullName</li>";
        echo "<hr />";
        $recPersonalQuery->MoveNext();
    } 
    echo "</ul>";
    
    $recPersonalQuery->Close();
    exit();    
    ?>

    here is the javascript code and the template for displaying employee name list:
    Code:
    <html>
    <head>
    <title></title>
    <script>
    function searchemppay(queryString) {
        var ajaxRequest = remoteRequestObject();
        ajaxRequest.onreadystatechange = function() {
            if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
                var result = ajaxRequest.responseText;
             
                document.getElementById('searchpayroll').innerHTML = result;
            } 
        }
    
        var url = "search.php?query=" + queryString;
        ajaxRequest.open("GET", url, true);
        ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        ajaxRequest.send(null);
    
    }
    
    function changeEmployeePay(queryID) {
     
    window.location = "SearchData.php?queryEmpID=" + queryID;
    }
    </script>
    
    </head>
    <body>
    <div id="Search">
    <form>
    <p class="serif"><b>Search Lastname:</b></p>
    <input type="text" name="search_" size="20" onkeyup="searchemppay(this.value);">  
    <div id="searchpayroll" style="overflow:auto; height:390px; width:auto; margin-left:2px" >
    <hr />
    <ul>
    {section name=co_emp loop=$personalAll}
    <li onclick="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li>
    <!--<li onkeyup="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li>-->
    <hr />
    {sectionelse}
    <li>No records found</li>
    {/section}
    </ul>
    </div>
    </div>
    
    </body>
    </html>
    and here is the code for displaying employee data and saving data like Earnings, Other Earnings, Deductions, Loan Deductions
    Code:
    <?php
    include 'config.php';
    $currentEmpID = $_SESSION['empID']; 
     
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC";
    $recPersonalNav = $conn->GetAll($sql);
    $smarty->assign('personalAll', $recPersonalNav);
    
    $EMP_NO = $_POST['EMP_NO'];
    
    $sql = "SELECT em.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL p, EMPLOYMENT em  WHERE p.EMP_ID='$currentEmpID' AND em.EMP_ID = '$currentEmpID'";      
      
    $recPersonalHead = $conn->Execute($sql);
    $fullName = $recPersonalHead->fields["FULLNAME"];
    $empno = $recPersonalHead->fields["EMP_NO"];
    
    $smarty->assign('empid', $currentEmpID);
    $smarty->assign('fullname', $fullName);
    $smarty->assign('empno', $empno);
    
     $sql = "SELECT EMP_ID, RATE FROM wage WHERE EMP_ID = '$currentEmpID'";
     $rsWage = $conn->Execute($sql);
     
     $Rate      = $rsWage->fields['RATE'];    
     
    
     $sql = "SELECT EMP_ID,EMP_NO, STATUS FROM employment WHERE EMP_ID = '$currentEmpID'";
     $rsStatus = $conn->Execute($sql);
     
     $STATUS = $rsStatus->fields['STATUS'];
     $EMP_ID = $rsStatus->fields['EMP_ID'];
    
    
    $sql = "SELECT em.EMP_NO, em.STATUS, w.RATE, r.Hours, o.OT_Hours 
    FROM $ADODB_DB.employment AS em 
    INNER JOIN $ADODB_DB.wage AS w ON em.EMP_ID = w.EMP_ID
    LEFT JOIN $PAYROLL.regular_sum_hours AS r ON em.EMP_NO = r.EMP_NO
    LEFT JOIN $PAYROLL.ot_data AS o ON r.EMP_NO = o.EMP_NO
    WHERE  em.EMP_ID = '$currentEmpID' AND o.STATUS = 'Offset'";
     
      $RsEarnings = $conn2->Execute($sql); 
      
      $Rate      = $RsEarnings->fields['RATE'];
      $Hours      = $RsEarnings->fields['Hours'];
      $Offset = $RsEarnings->fields['OT_Hours'];
    
      $Hours = substr($Hours, 0, 5);
      $Hours = str_replace(':', '.', $Hours);
      
      $Hours = ($Hours + $Offset);
      
     $Amount = $_POST["Amount"];
     
     $Amount = round(($Hours/8)* $Rate, 2); 
    
      $smarty->assign('Rate', $Rate);
      $smarty->assign('Hours', $Hours);
      $smarty->assign('Amount', $Amount);
    
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours, o.STATUS FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'RegularOvertime' AND o.STATUS = 'Overtime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $OTReg_Hours = $rsOTData->fields['OT_Hours'];
    $OTReg_Hours = round($OTReg_Hours, 2);
    
    $OTReg_Amt = round((($Rate / 8 * 1.3) * $OTReg_Hours), 2);
    
    $smarty->assign('OTReg_Hours', $OTReg_Hours);
    $smarty->assign('OTReg_Amt', $OTReg_Amt);
    
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em  WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'SundayRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $SunReg_Hours = $rsOTData->fields['OT_Hours'];
    $SunReg_Hours = round($SunReg_Hours, 2);
    
    $SunReg_Amt = round((($Rate / 8 * 1.35) * $SunReg_Hours), 2); 
    
    $smarty->assign('SunReg_Hours', $SunReg_Hours);
    $smarty->assign('SunReg_Amt', $SunReg_Amt); 
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'SundayOvertime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $OTSun_Hours = $rsOTData->fields['OT_Hours'];
    $OTSun_Hours = round($OTSun_Hours, 2);
    
    $OTSun_Amt = round((($Rate / 8 * 1.35 * 1.35) * $OTSun_Hours), 2);
    
    $smarty->assign('OTSun_Hours', $OTSun_Hours);
    $smarty->assign('OTSun_Amt', $OTSun_Amt); 
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'HolidayRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $HolReg_Hours = $rsOTData->fields['OT_Hours'];
    $HolReg_Hours = round($HolReg_Hours, 2);
    
    $HolReg_Amt = round((($Rate / 8 * 1.5) * $HolReg_Hours), 2);
    
    $smarty->assign('HolReg_Hours', $HolReg_Hours);
    $smarty->assign('HolReg_Amt', $HolReg_Amt); 
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'HolidayRegularOvertime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $HolRegOT_Hours = $rsOTData->fields['OT_Hours'];
    $HolRegOT_Hours = round($HolRegOT_Hours, 2);
    
    $HolRegOT_Amt = round((($Rate / 8 * 2.05 * 1.35) * $HolRegOT_Hours), 2);
    
    $smarty->assign('HolRegOT_Hours', $HolRegOT_Hours);
    $smarty->assign('HolRegOT_Amt', $HolRegOT_Amt); 
    
    
    $sql = "SELECT em.EMP_NO, SUM(l.HOURS_LEAVE) AS HOURS_LEAVE FROM $PAYROLL.leave_data l, $ADODB_DB.employment em WHERE em.EMP_NO = l.EMP_NO AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    
    $HolLeave_Hours = $rsOTData->fields['HOURS_LEAVE'];
    
    $HolLeave_Hours = round($HolLeave_Hours, 2);
    
    $HolLeave_Amt = round((($Rate) * $HolLeave_Hours), 2);
    
    $smarty->assign('HolLeave_Hours', $HolLeave_Hours);
    $smarty->assign('HolLeave_Amt', $HolLeave_Amt); 
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $NPReg_Hours = $rsOTData->fields['OT_Hours'];
    $NPReg_Hours = round($NPReg_Hours, 2);
    
    $NPReg_Amt = round((($Rate / 8 * 0.15) * $NPReg_Hours), 2);
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumSunday' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $NPSun_Hours = $rsOTData->fields['OT_Hours'];
    $NPSun_Hours = round($NPSun_Hours, 2);
    
    $NPSun_Amt = round((($Rate / 8 * 1.35 * 0.15) * $NPSun_Hours), 2);
    
    
    $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumHoliday' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $NPHol_Hours = $rsOTData->fields['OT_Hours'];
    $NPHol_Hours = round($NPHol_Hours, 2);
    
    $NPHol_Amt = round((($Rate / 8 * 2.05 * 0.15) * $NPHol_Hours), 2);
    
    
    $NP_Hours = round(($NPReg_Hours + $NPSun_Hours + $NPHol_Hours), 2);
    $NP_Hours = round($NP_Hours, 2);
    
    $NP_Amt =  round(($NPReg_Amt + $NPSun_Amt + $NPHol_Amt), 2); 
    
    $smarty->assign('NP_Hours', $NP_Hours);
    $smarty->assign('NP_Amt', $NP_Amt);
    
    $sql = "SELECT COUNT(o.EMP_NO) AS EMP_NO, o.OT_Category, o.OT_Hours, o.STATUS FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category IN ('RegularOvertime', 'HolidayRegular', 'HolidayRegularOvertime') AND o.OT_Hours > 2  AND em.EMP_ID = '$currentEmpID' AND o.STATUS = 'Overtime' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    $MealReg_Hours = $rsOTData->fields['EMP_NO'];
    $MealReg_Hours = round($MealReg_Hours, 2);
    
    $MealReg_Amt = round(($MealReg_Hours * 23), 2);
    
    $sql = "SELECT COUNT(o.EMP_NO) AS EMP_NO, o.OT_Category, o.OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category IN ('SundayRegular', 'SundayOvertime') AND o.OT_Hours > 2 AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO";
    $rsOTData = $conn2->Execute($sql);
    
    $MealSun_Hours = $rsOTData->fields['EMP_NO'];
    $MealSun_Hours = round($MealSun_Hours, 2);
    
    
    $MealSun_Amt = round(($MealSun_Hours * 30), 2);
    
    $Meal_Hours = round(($MealReg_Hours + $MealSun_Hours), 2);
    
    $Meal_Amt = round(($MealReg_Amt + $MealSun_Amt), 2);
    $smarty->assign('Meal_Hours', $Meal_Hours);
    $smarty->assign('Meal_Amt', $Meal_Amt);
    
    
    $sql = "SELECT COUNT(a.EMP_NO) AS EMP_NO, w.RATE FROM $ADODB_DB.wage w, $ADODB.employment em, $PAYROLL.attendance a WHERE em.EMP_NO = a.EMP_NO AND w.RATE = 302 AND em.EMP_ID = '$currentEmpID' GROUP BY w.RATE";
    $rsOTData = $conn2->Execute($sql);
    
    $Cola_Hours = $rsOTData->fields['EMP_NO'];
    $Cola_Hours = round($Cola_Hours, 2);
    
    
    $Cola_Amt = round(($Cola_Hours * 28), 2);
          
    $smarty->assign('Cola_Hours', $Cola_Hours);
    $smarty->assign('Cola_Amt', $Cola_Amt);
    
    $TotEarn = $_POST['TotEarn'];
    
    $TotEarn = round(($Amount + $OTReg_Amt + $SunReg_Amt + $OTSun_Amt + $HolReg_Amt + $HolRegOT_Amt + $HolLeave_Amt + $NP_Amt + $Meal_Amt + $Cola_Amt), 2);
    
    $smarty->assign('TotEarn', $TotEarn);
    
    
    $HDMF = $_POST['HDMF'];
    
    $sql = "SELECT Ref_No, Range FROM $PAYROLL.hdmf, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
    $rs = $conn2->Execute($sql);
    
    $Range = $rs->fields['Range'];
     
    if ($TotEarn <= $Range) {
        $HDMF = round(($TotEarn * 0.01), 2);
    } else {
        $HDMF = round(($TotEarn * 0.02), 2);
    }  
    
    $smarty->assign('HDMF', $HDMF);
    
    
    $SSS = $_POST['SSS'];
    
    $sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range";
    $rs = $conn2->Execute($sql);
    
    $SSS = $rs->fields['Employee_Share'];
    
    $smarty->assign('SSS', $SSS);     
    
    
    
    $PCHL = $_POST['PCHL'];
    
    $sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.pchl, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range";
    $rs = $conn2->Execute($sql);
    
    $PCHL = $rs->fields['Employee_Share'];
    
    $smarty->assign('PCHL', $PCHL);
    
    $TAX = $_POST['TAX'];
    
    $sql = "SELECT EMP_ID, EMP_NO, W4_STATUS, DEPENDENTS FROM employment  WHERE EMP_ID = '$currentEmpID'";
    $rsTax = $conn->Execute($sql);
    
    $W4_STATUS = $rsTax->fields['W4_STATUS'];
    $DEPENDENTS = $rsTax->fields['DEPENDENTS'];
    
    if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 0 AND $TotEarn <= 2083){
      $TAX = round($TotEarn * .05);
    }
    elseif($W4_STATUS == 2 AND $DEPENDENTS == 0 AND $TotEarn >= 0 AND $TotEarn <= 2083){
      $TAX = round($TotEarn * .05);
      
    }
    elseif($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 2083 AND $TotEarn <= 2500) {
      $TAX = round($TotEarn - 2083);
      $TAX = round(20.83 + ($TAX * .10));
    }
    elseif($W4_STATUS == 2 AND $DEPENDENTS == 0 AND $TotEarn >= 2083 AND $TotEarn <= 2500) {
      $TAX = round($TotEarn - 2083);
      $TAX = round(20.83 + ($TAX * .10));
    }
    elseif($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 2500 AND $TotEarn <= 3333) {
      $TAX = round($TotEarn - 2500);
      $TAX = round(104.17 + ($TAX * .15));
    } 
    else{
        $TAX = round(0);
    }
    
    $smarty->assign('TAX', $TAX);
    
    
     $sql = "SELECT s.EMP_NO, s.SSSAmor FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO = s.EMP_NO AND em.EMP_ID = '$currentEmpID'";
     $RsDed = $conn2->Execute($sql);
     
     $SSSAmor = round($RsDed->fields['SSSAmor']);
     
    $sql = "SELECT h.EMP_NO, h.HDMFAmor FROM $PAYROLL.hdmfloan h, $ADODB_DB.employment em WHERE em.EMP_NO = h.EMP_NO AND em.EMP_ID = '$currentEmpID'"; 
     $RsHDMF = $conn2->Execute($sql);
     
     $HDMFAmor = round($RsHDMF->fields['HDMFAmor']);
     
     
    $sql = "SELECT u.EMP_NO, u.UDTAmor FROM $PAYROLL.udtloan u, $ADODB_DB.employment em WHERE em.EMP_NO = u.EMP_NO AND em.EMP_ID = '$currentEmpID'";
     $RsUDT = $conn2->Execute($sql);
     
     $UDTAmor = round($RsUDT->fields['UDTAmor']);
    
    $TotalDed = $_POST['TotalDed'];
    
     $sql = "SELECT o.EMP_NO, o.BurialSeparationCont, o.TaxAjt, o.CashAdvance, o.AdvanceShirt, o.AdvanceMed, o.AdvanceOther FROM $PAYROLL.other_deductions o, $ADODB_DB.personal p, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND em.EMP_NO = o.EMP_NO";
     $rsOtherDed = $conn2->Execute($sql);
     
     $BurialSep = round($rsOtherDed->fields['BurialSeparationCont']);
     $TaxAjt = round($rsOtherDed->fields['TaxAjt']);
     $CashAdvance = round($rsOtherDed->fields['CashAdvance']);
     $AdvancesShirt = round($rsOtherDed->fields['AdvanceShirt']);
     $AdvancesMed = round($rsOtherDed->fields['AdvanceMed']);
     $AdvancesOthers = round($rsOtherDed->fields['AdvanceOther']);
     
     $smarty->assign('BurialSep', $BurialSep);
     $smarty->assign('TaxAjt', $TaxAjt);
     $smarty->assign('CashAdvance', $CashAdvance);
     $smarty->assign('AdvancesShirt', $AdvancesShirt);
     $smarty->assign('AdvancesMed', $AdvancesMed);
     $smarty->assign('AdvancesOthers', $AdvancesOthers);
     
    
    $TotalDed = round(($SSS + $HDMF + $PCHL + $TAX + $SSSAmor + $HDMFAmor + $UDTAmor + $BurialSep + $TaxAjt + $CashAdvance + $AdvancesShirt + $AdvancesMed + $AdvancesOthers), 2); 
    
     $smarty->assign('SSSAmor', $SSSAmor);
     $smarty->assign('HDMFAmor', $HDMFAmor);
     $smarty->assign('UDTAmor', $UDTAmor);
     $smarty->assign('TotalDed', $TotalDed);
     
    $THP = $_POST["TakeHomePay"];
    
    $THP = round($TotEarn - $TotalDed, 2);
    
    $smarty->assign('THP', $THP);
    
     
     $sql = "SELECT EMP_NO, OTReg_Amt, SunReg_Amt, OTSun_Amt, HolReg_Amt, HolRegOT_Amt, HolLeave_Amt, NP_Amt, Meal_Amt, Cola_Amt FROM other_earnings WHERE EMP_NO = '$empno'";
     $RsOtherEarnings = $conn2->Execute($sql);
     
     $numrowsOtherEarnings = $RsOtherEarnings->RecordCount();
     
     if($numrowsOtherEarnings > 0){ 
     
     $saverec['EMP_NO'] = $empno;
     $saverec['OTReg_Amt'] = $OTReg_Amt;
     $saverec['SunReg_Amt'] = $SunReg_Amt;
     $saverec['OTSun_Amt'] = $OTSun_Amt;
     $saverec['HolReg_Amt'] = $HolReg_Amt;
     $saverec['HolRegOT_Amt'] = $HolRegOT_Amt;
     $saverec['HolLeave_Amt'] = $HolLeaveAmt;
     $saverec['NP_Amt'] = $NP_Amt;
     $saverec['Meal_Amt'] = $Meal_Amt;
     $saverec['Cola_Amt'] = $Cola_Amt;
     
      $updateOtherEarnings = $conn2->GetUpdateSQL($RsOtherEarnings, $saverec); 
      $conn2->Execute($updateOtherEarnings); 
     }
     else{
     $sql = "SELECT o.EMP_NO, o.OTReg_Amt, o.SunReg_Amt, o.OTSun_Amt, o.HolReg_Amt, o.HolRegOT_Amt, o.HolLeave_Amt, o.NP_Amt, o.Meal_Amt, o.Cola_Amt FROM $PAYROLL.other_earnings o, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
     $RsOtherEarnings = $conn2->Execute($sql);
     
    $saverec['EMP_NO'] = $empno;
     $saverec['OTReg_Amt'] = $OTReg_Amt;
     $saverec['SunReg_Amt'] = $SunReg_Amt;
     $saverec['OTSun_Amt'] = $OTSun_Amt;
     $saverec['HolReg_Amt'] = $HolReg_Amt;
     $saverec['HolRegOT_Amt'] = $HolRegOT_Amt;
     $saverec['HolLeave_Amt'] = $HolLeaveAmt;
     $saverec['NP_Amt'] = $NP_Amt;
     $saverec['Meal_Amt'] = $Meal_Amt;
     $saverec['Cola_Amt'] = $Cola_Amt;
     
      $insertOtherEarnings = $conn2->GetInsertSQL($RsOtherEarnings, $saverec); 
      $conn2->Execute($insertOtherEarnings); 
     }
    
     
     $sql = "SELECT EMP_NO, SSS, TAX, PCHL, HDMF FROM deductions WHERE EMP_NO = '$empno'";
     $RsDeduction = $conn2->Execute($sql);
     
     $numrowsDeduction = $RsDeduction->RecordCount(); 
     
     if($numrowsDeduction > 0){
     $saverec['EMP_NO'] = $empno;
     $saverec['SSS'] = $SSS;
     $saverec['TAX'] = $TAX;
     $saverec['PCHL'] = $PCHL;
     $saverec['HDMF'] = $HDMF;
     
     
     $updateDeductionSQL = $conn2->GetUpdateSQL($RsDeduction, $saverec); 
     $conn2->Execute($updateDeductionSQL); 
     }
     else{
      $sql = "SELECT d.EMP_NO, d.SSS, d.TAX, d.PCHL, d.HDMF FROM $PAYROLL.deductions d, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
     $RsDeduction = $conn2->Execute($sql);
     
     $saverec['EMP_NO'] = $empno;
     $saverec['SSS'] = $SSS;
     $saverec['TAX'] = $TAX;  
     $saverec['PCHL'] = $PCHL;
     $saverec['HDMF'] = $HDMF;
     
     $insertSQL = $conn2->GetInsertSQL($RsDeduction, $saverec); 
     $conn2->Execute($insertSQL); 
     }
     
     
     $sql = "SELECT EMP_NO, SSSLoan, HDMFLoan, UDTLoan FROM loan_deductions WHERE EMP_NO = '$empno'";
     $RsLoan = $conn2->Execute($sql);
     
     $numrowsRsLoan = $RsLoan->RecordCount();
     
     if($numrowsRsLoan > 0){
     $saverec['EMP_NO'] = $empno;
     $saverec['SSSLoan'] = $SSSAmor;
     $saverec['HDMFLoan'] = $HDMFAmmor;
     $saverec['UDTLoan'] = $UDTAmor;
     
     $updateLoanSQL = $conn2->GetUpdateSQL($RsLoan, $saverec); 
     $conn2->Execute($updateLoanSQL); 
     }
     else{
     
     $sql = "SELECT l.EMP_NO, l.SSSLoan, l.HDMFLoan, l.UDTLoan FROM $PAYROLL.loan_deductions l, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
     $RsLoan = $conn2->Execute($sql);
     
     $saverec['EMP_NO'] = $empno;
     $saverec['SSSLoan'] = $SSSAmor;
     $saverec['HDMFLoan'] = $HDMFAmor;
     $saverec['UDTLoan'] = $UDTAmor;
     
     $insertSQL = $conn2->GetInsertSQL($RsLoan, $saverec); 
     $conn2->Execute($insertSQL); 
     }
    
       $sql = "SELECT EMP_NO, Amount, TotalEarnings, TotalDeductions, TakeHomePay FROM totalpay WHERE EMP_NO = '$empno'";
      $rsTotal = $conn2->Execute($sql);
      
      $numrows = $rsTotal->RecordCount();
      
      if($numrows > 0){
      
      $saverec['EMP_NO'] = $empno;
      $saverec['Amount'] = $Amount;
      $saverec['TotalEarnings'] = $TotEarn;
      $saverec['TotalDeductions'] = $TotalDed;
      $saverec['TakeHomePay'] = $THP;
      
      $updateSQL = $conn2->GetUpdateSQL($rsTotal, $saverec); 
      $conn2->Execute($updateSQL);  
      }
      else{ 
      $sql = "SELECT t.EMP_NO, t.Amount, t.TotalEarnings, t.TotalDeductions, t.TakeHomePay FROM $PAYROLL.totalpay t, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
      $rsTotal = $conn2->Execute($sql);
      
      $saverec['EMP_NO'] = $empno;
      $saverec['Amount'] = $Amount;
      $saverec['TotalEarnings'] = $TotEarn;
      $saverec['TotalDeductions'] = $TotalDed;
      $saverec['TakeHomePay'] = $THP;
      
      $insertSQL = $conn2->GetInsertSQL($rsTotal, $saverec); 
      $conn2->Execute($insertSQL);  
      } 
    $smarty->display('header.tpl');
    $smarty->display('left.tpl');
    $smarty->display('empPayrollData.tpl');
    $smarty->display('footer.tpl'); 
    
    ?>
    I have a problem in saving data from other deductions and the total deductions and takehomepay, because other deductions is insertable textfield and when I add other deductions the total deductions will change also the Take Home Pay. Idon't know where Can I add this code for saving data of other deductions and updating the changes if Total Deductions and Take Home Pay.

    Code:
    $sql = "SELECT EMP_NO, BurialSeparationCont, TaxAjt, CashAdvance, AdvanceShirt, AdvanceMed, AdvanceOther FROM other_deductions WHERE EMP_NO = '$empno'";
      $rsOtherDed = $conn2->Execute($sql);
      
      $numrows1 = $rsOtherDed->RecordCount();
      
      if($numrows1 > 0){  
      $saverec['EMP_NO'] = $empno;
      $saverec['BurialSeparationCont'] = $BurialSep;
      $saverec['TaxAjt'] = $TaxAjt;
      $saverec['CashAdvance'] = $CashAdvance;
      $saverec['AdvanceShirt'] = $AdvancesShirt;
      $saverec['AdvanceMed'] = $AdvancesMed;
      $saverec['AdvanceOther'] = $AdvancesOthers;
    
      $updateSQL = $conn2->GetUpdateSQL($rsOtherDed, $saverec); 
    
      $conn2->Execute($updateSQL);
    
      
      }
      else{
      $sql = "SELECT o.EMP_NO, o.BurialSeparationCont, o.TaxAjt, o.CashAdvance, o.AdvanceShirt, o.AdvanceMed, o.AdvanceOther FROM $PAYROLL.other_deductions o, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
      $rsOtherDed = $conn2->Execute($sql);
      
      $saverec['EMP_NO'] = $empno;
      $saverec['BurialSeparationCont'] = $BurialSep;
      $saverec['TaxAjt'] = $TaxAjt;
      $saverec['CashAdvance'] = $CashAdvance;
      $saverec['AdvanceShirt'] = $AdvancesShirt;
      $saverec['AdvanceMed'] = $AdvancesMed;
      $saverec['AdvanceOther'] = $AdvancesOthers;
    
      $insert = $conn2->GetInsertSQL($rsOtherDed, $saverec); 
      $conn2->Execute($insert); 
      
     }
       
       $Amount = $_POST["Amount"];
       $TotEarn = $_POST["TotEarn"];
       $TotalDed = $_POST["TotalDed"];
       $THP = $_POST["TakeHomePay"]; 
      
       $sql = "SELECT EMP_NO, Amount, TotalEarnings, TotalDeductions, TakeHomePay FROM totalpay WHERE EMP_NO = '$empno'";
      $rsTotal = $conn2->Execute($sql);
      
      $numrows = $rsTotal->RecordCount();
      
      if($numrows > 0){
      
      $saverec['EMP_NO'] = $empno;
      $saverec['Amount'] = $Amount;
      $saverec['TotalEarnings'] = $TotEarn;
      $saverec['TotalDeductions'] = $TotalDed;
      $saverec['TakeHomePay'] = $THP;
      
      $updateSQL = $conn2->GetUpdateSQL($rsTotal, $saverec); 
      $conn2->Execute($updateSQL);  
      }
      else{ 
      $sql = "SELECT t.EMP_NO, t.Amount, t.TotalEarnings, t.TotalDeductions, t.TakeHomePay FROM $PAYROLL.totalpay t, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'";
      $rsTotal = $conn2->Execute($sql);
      
      $saverec['EMP_NO'] = $empno;
      $saverec['Amount'] = $Amount;
      $saverec['TotalEarnings'] = $TotEarn;
      $saverec['TotalDeductions'] = $TotalDed;
      $saverec['TakeHomePay'] = $THP;
      
      $insertSQL = $conn2->GetInsertSQL($rsTotal, $saverec); 
      $conn2->Execute($insertSQL);  
      }
    I don't know where I can put this code to save the data that i inserted in other deductions

  2. #2
    newphpcoder's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Sep 2010
    Posts
    52

    Re: Problem in saving data

    I have an idea to get the21:35:00 - 05:35:00 shfit but I dpn't know how can I query it.

    Like for example I have this data December 2, 2011 and December 3, 2011

    00011 2011-12-02 05:35:00
    00011 2011-12-02 13:35:00
    00011 2011-12-02 13:35:00
    00011 2011-12-02 21:35:00
    00011 2011-12-02 21:35:00
    00011 2011-12-03 05:35:00

    I think I need to get the range from the previous date up to next date 05:35:00 to get the 21:35:00 - 05:35:00 shift.

    Is it possible?And how??

    I try to code it but i don't know what syntax.

    Thank you