Jump to content

newphpcoder

Members
  • Posts

    254
  • Joined

  • Last visited

Posts posted by newphpcoder

  1. Hi...

     

    how can I add jo in my autogenerate number :

    for example:

    from: 1204200001

    to: JO1204200001

    $sql = "SELECT jo_number FROM job_order ORDER BY jo_date DESC LIMIT 1";
            $result = mysql_query($sql, $con);
            
            if (!$result) {
                echo 'failed'; 
                die();
            }
            $total = mysql_num_rows($result);
            if ($total <= 0) {
                $currentSRNum = 1;
                 $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //------------------------------------------------------------------------------------------------------------------
                // Stock Number iteration.... 
                $row = mysql_fetch_assoc($result);
                
                $currentSRNum = (int)(substr($row['jo_number'],0,3));
                
                $currentSRYear  = (int)(substr($row['jo_number'],2,2));
                $currentSRMonth = (int)(substr($row['jo_number'],0,2));
                $currentSRNum = (int)(substr($row['jo_number'],6,4));
    
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }                                           
            }
    //------------------------------------------------------------------------------------------------------------------         
            $yearMonth = date('ymd');    
            $currentSR = $currentYMD . sprintf("%04d", $currentSRNum);
    

     

    Thank you

  2. Thank you..

     

    my problem now is on displaying JO Number. I want to happen is it will only display after I click the approved button.

     

    <?php
        error_reporting(0);
      date_default_timezone_set("Asia/Singapore"); //set the time zone
    $con = mysql_connect('localhost', 'root','');
    if (!$con) {
        echo 'failed';
        die();
    }
    mysql_select_db("mes", $con);
    $Date_Shelve =date('Y-m-d H:i:s');
    
    ?>
    <html>
    <head>
    <title>Job Order</title>
    <link rel="stylesheet" type="text/css" href="kanban.css" />  
    </head>
    <body>
    
    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve; ?>" size="16" readonly="readonly" style="border: none;">  
    </div>
    <div id="kanban_table">
    <table width="auto">
    <th> JO No.</th>
    <th> ETD </th>
    <th> PO No. </th>
    <th> SKU Code </th>
    <th> Description </th>
    <th> PO Req </th>
    <th> Requirements </th>
    <th> Priority</th>
    <?php
    $sql = "SELECT ETD, PO_No, SKUCode, Description, POReq
    FROM sales_order";
    $res_so = mysql_query($sql, $con);
    $Approved = isset($_POST['priority']);
    if ($Approved)
    {
        $PO_No = $_POST['PO_No'];
    //----I want to display only the jo_number after click the approved button and it only display on the row where I click the approved button---
        $sql = "SELECT jo_number FROM job_order ORDER BY jo_date DESC LIMIT 1";
            $result = mysql_query($sql, $con);
          
            if (!$result) {
                echo 'failed';
                die();
            }
            $total = mysql_num_rows($result);
            if ($total <= 0) {
                $currentSRNum = 1;
                 $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
              
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD)
                {
                    $currentSRNum = 1;
                }
                else
                {
                    $currentSRNum += 1;
                }    
                
            }
            else {
    //----------------------------------------
                $row = mysql_fetch_assoc($result);
              
                $currentSRNum = (int)(substr($row['jo_number'],0,3));
              
                $currentSRYear  = (int)(substr($row['jo_number'],2,2));
                $currentSRMonth = (int)(substr($row['jo_number'],0,2));
                $currentSRNum = (int)(substr($row['jo_number'],6,4));
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
              
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD)
                {
                    $currentSRNum = 1;
                }
                else
                {
                    $currentSRNum += 1;
                }                                          
            }
            
            $yearMonth = date('ymd');  
            $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); //JO_No
    }
    
    while($row = mysql_fetch_assoc($res_so)){
    echo "<form name='joborder_form' action='' method='post'>";
    $PO_No = $row['PO_No'];
    echo "<tr>
    <td><input type='text' name='JO_No' id='JO_No' value='$currentSR' style='border:none;width:auto;' size='10'></td>
    <td><input type='text' name='ETD' id='ETD' value='$row[ETD]' style='border:none;width:auto;' size='10'></td>
    <td><input type='text' name='PO_No' id='PO_No' value='$row[PO_No]' style='border:none;' size='30'></td>
    <td><input type='text' name='SKUCode' id='SKUCode' value='$row[sKUCode]' style='border:none;' size='15'></td>
    <td><input type='text' name='Description' id='Description' value='$row[Description]' style='border:none;' size='35'></td>
    <td><input type='text' name='POReq' id='POReq' value='$row[POReq]' style='border:none;width:auto;' size='10'></td>
    <td> </td>
    <td><input type='submit' name='priority' value='Approved' id='priority'></td>
    </tr>";
    echo "</form>";
    }
    ?>
    </table>
    </div>
    </body>
    </html>
    
    

    Thank you

    Thank you

     

  3. Hi..

     

    I encountered problem in displaying joborder number or JO_No inside while loop.

     

    I want to happen is only JO_No will display after I click the Approved button and it will only appear on the row where the Approved button was click.

     

    Now in my code the JO_No was display automatically in the row of JO_No .

     

    here is my code:

     

    <?php
        error_reporting(0);
      date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    $Date_Shelve =date('Y-m-d H:i:s');  
    
    
    ?>
    <html>
    <head>
    <title>Job Order</title> 
    <link rel="stylesheet" type="text/css" href="kanban.css" />    
    </head>
    <body>
    
    
    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve; ?>" size="16" readonly="readonly" style="border: none;">    
    </div>
    
    <div id="kanban_table"> 
    <table width="auto">
    <th> JO No.</th>
    <th> ETD </th>
    <th> PO No. </th>
    <th> SKU Code </th>
    <th> Description </th>
    <th> PO Req </th>
    <th> Requirements </th>
    <th> Priority</th>
    
    <?php
    
    $sql = "SELECT ETD, PO_No, SKUCode, Description, POReq 
    FROM sales_order";
    $res_so = mysql_query($sql, $con);
    
    $Approved = isset($_POST['priority']);
    if ($Approved)
    {
        $PO_No = $_POST['PO_No'];
    //----I want to display only the jo_number after click the approved button and it only display on the row where I click the approved button---
        $sql = "SELECT jo_number FROM job_order ORDER BY jo_date DESC LIMIT 1";
            $result = mysql_query($sql, $con);
            
            if (!$result) {
                echo 'failed'; 
                die();
            }
            $total = mysql_num_rows($result);
            if ($total <= 0) {
                $currentSRNum = 1;
                 $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //----------------------------------------
                $row = mysql_fetch_assoc($result);
                
                $currentSRNum = (int)(substr($row['jo_number'],0,3));
                
                $currentSRYear  = (int)(substr($row['jo_number'],2,2));
                $currentSRMonth = (int)(substr($row['jo_number'],0,2));
                $currentSRNum = (int)(substr($row['jo_number'],6,4));
    
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['jo_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }                                           
            }
             
            $yearMonth = date('ymd');    
            $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); //JO_No
    }
    
    
    while($row = mysql_fetch_assoc($res_so)){
    echo "<form name='joborder_form' action='' method='post'>";
    $PO_No = $row['PO_No'];  
    echo "<tr>
    <td><input type='text' name='JO_No' id='JO_No' value='$currentSR' style='border:none;width:auto;' size='10'></td>
    <td><input type='text' name='ETD' id='ETD' value='$row[ETD]' style='border:none;width:auto;' size='10'></td> 
    <td><input type='text' name='PO_No' id='PO_No' value='$row[PO_No]' style='border:none;' size='30'></td>
    <td><input type='text' name='SKUCode' id='SKUCode' value='$row[sKUCode]' style='border:none;' size='15'></td>
    <td><input type='text' name='Description' id='Description' value='$row[Description]' style='border:none;' size='35'></td>
    <td><input type='text' name='POReq' id='POReq' value='$row[POReq]' style='border:none;width:auto;' size='10'></td> 
    <td> </td>
    <td><input type='submit' name='priority' value='Approved' id='priority'></td>
    </tr>";
    echo "</form>";
    }
    ?>
    
    </table>
    </div>
    
    </body>
    </html>
    

     

    I attach the sample image of my form.

     

    Any help is highly appreciated

     

    Thank you

    18137_.doc

  4. Hi...

     

    I have form which data is inside while loop and per row has a approved button, Now I have no idea that when I click the approve button the JO # from that row will display and save to the database.

     

    here is my code and sample form.

     

    <?php
        error_reporting(0);
      date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    $Date_Shelve =date('Y-m-d H:i:s');  
    ?>
    <html>
    <head>
    <title>Sales Order</title> 
    <link rel="stylesheet" type="text/css" href="kanban.css" />      
    </head>
    <body>
    <form name="loading_kanban" action="" method="post">
    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve; ?>" size="16" readonly="readonly" style="border: none;">    
    </div>
    
    <div id="kanban_table"> 
    <table>
    <th> JO No.</th>
    <th> ETD </th>
    <th> PO No. </th>
    <th> SKU Code </th>
    <th> Description </th>
    <th> PO Req </th>
    <th> Requirements </th>
    <th> Priority</th>
    
    <?php
    
    $sql = "SELECT ETD, PO_No, SKUCode, Description, POReq 
    FROM sales_order";
    $res_so = mysql_query($sql, $con);
    
    while($row = mysql_fetch_assoc($res_so)){
    
    $ETD = $row['ETD'];
    $PO_No = $row['PO_No'];
    $SKUCode = $row['SKUCode'];
    $Description = $row['Description'];
    $POReq = $row['POReq'];    
    
    echo "<tr>
    <td> </td>
    <td>$ETD</td>
    <td>$PO_No</td>
    <td>$SKUCode</td>
    <td>$Description</td>
    <td>$POReq</td>
    <td> </td>
    <td><input type='button' name='priority' value='Approved' id='priority'></td>
    </tr>";
    }
    
    
    ?>
    
    </table>
    </div>
    </form>
    </body>
    </html>
    

    18135_.doc

  5. if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 7917 AND $TotEarn <= 12500) {

    $TAX = ($TotEarn - 7917);

    $TAX = (937.50 + ($TAX * .25));

    //printf('%0.5f; %s', $TAX, number_format($TAX, 2, '.', ','));

    $TAX = number_format($TAX, 2, '.', '');

    //$TAX = round($TAX, 2);

    }

     

    $TAX = (9837.46 - 7917);

    $TAX = (937.50 + (1920.46 * .25)); // (937.50 + 480.115 )

    $TAX = number_format(1417.615, 2)

     

  6. Hi..

     

     

    I just want to know how does it happen that when I scan the barcode using barcode scanner it will automatically put on the first textbox, then the focus will go to the next textbox and on the last textbox will automatically save the data to database.

     

    here is my sample form.

     

    <?php                                                                          
       error_reporting(0);
       date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    $sr_date =date('Y-m-d H:i:s');
    
    $sql = "SELECT sr_number FROM receiving_materials ORDER BY sr_date DESC LIMIT 1";
            $result = mysql_query($sql, $con);
            
            if (!$result) {
                echo 'failed'; 
                die();
            }
            $total = mysql_num_rows($result);
            if ($total <= 0) {
                $currentSRNum = 1;
                 $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['sr_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //------------------------------------------------------------------------------------------------------------------
                // Stock Number iteration.... 
                $row = mysql_fetch_assoc($result);
                
                $currentSRNum = (int)(substr($row['sr_number'],0,3));
                
                $currentSRYear  = (int)(substr($row['sr_number'],2,2));
                $currentSRMonth = (int)(substr($row['sr_number'],0,2));
                $currentSRNum = (int)(substr($row['sr_number'],6,4));
    
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
               
                $currentSRYMD = substr($row['sr_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }                                           
            }
    //------------------------------------------------------------------------------------------------------------------         
            $yearMonth = date('ymd');    
            $currentSR = $currentYMD . sprintf("%04d", $currentSRNum);  
    ?>
    <html>
    <title>Receiving Materials</title>
    <head>
    <link rel="stylesheet" type="text/css" href="kanban.css" />
    <style type="text/css">
    #SR_date{
        position: relative;
        font-family: Arial, Helvetica, sans-serif;
        font-size: .9em;
        margin-left: 10px;
        width: auto;
        height: auto;
        float: left;
        top : 10px;
        
    }
    </style>
    
    
    </head>
    <body>
    <form name="receiving_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">      
    
    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="sr_date" value="<?php echo $sr_date; ?>" size="16" readonly="readonly" style="border: none;">    
    </div>
    <div id="SR_number">
    <label>RM# :</label>
    <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> 
    </div> 
    <div id="SI_number">
    <label class="LLabelRM">SI/DR# :</label>
    <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <br/></br/>
    <label class="LLabelRM">Supplier Name :</label>
    <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25">  <br/></br/>
    <label class="LLabelSecRM">PO # :</label>
    <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">Quantity :</label>
    <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <br/> <br/>
    <label class="LLabelSecRM">Material Code :</label>
    <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">Material Desc. :</label>
    <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25">  <br/></br/>
    <label class="LLabelSecRM">WH Code :</label>
    <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25">
    <label class="LLabelSecRM">BIN Location :</label>
    <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25">
    </div> 
    </form>
    </body>
    </html>
    
    

     

    Thank you

  7. a bit ugly solution

     

    inspired from http://stackoverflow.com/questions/5764560/how-do-i-round-a-mysql-time-to-the-nearest-hour-not-a-date-time-timestamp

     

    Step by step

    • calculate the difference in seconds unit
    • divide it with 60 (so we have the difference in minutes unit)
    • FLOOR it (take it to nearest integer)
    • add with 1
    • multiply by 60 (to return it in seconds unit)
       

     

    so the query will be:

    SEC_TO_TIME( (
    FLOOR( (
    TIME_TO_SEC(  '08:00:00' ) - TIME_TO_SEC(Rendered) )  / 60 ) + 1
    ) *60
    )

     

    I tried it:

     

    when time_to_sec(time(LOGIN)) BETWEEN time_to_sec('05:35:00') AND time_to_sec('06:59:00') AND time_to_sec(time(LOGOUT)) BETWEEN time_to_sec('09:35:00') AND time_to_sec('09:59:00')
    AND DATE_FORMAT(LOGIN, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
    then SEC_TO_TIME( (FLOOR( (TIME_TO_SEC(  '08:00:00' ) - TIME_TO_SEC(Rendered) )  / 60 ) + 1) *60)
    

     

    with this data:

     

    login in 2012-03-01 05:37:18

     

    logout 2012-03-01 13:36:35

     

    the rendered is : 07:58:41

     

    late: 00:01:19

     

     

  8. Hi..

     

    I encountered problem in rounding of numbers into two decimal places.

     

    here is my sample code:

     

    if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 7917 AND $TotEarn <= 12500) {
       $TAX = ($TotEarn - 7917);
       $TAX = (937.50 + ($TAX * .25));
       $TAX = number_format($TAX, 2, '.', '');
    }
    

     

    for example from this:

    $TAX = ($TotEarn - 7917);
      $TAX = (937.50 + ($TAX * .25));
    

    the output is: 1417.615

     

    using this:

    $TAX = number_format($TAX, 2, '.', '');
    

    the output was : 1417.61

     

    but it should be : 1417.62

     

    Thank you

  9. Hi..

     

    I got problem in getting the time difference between two datetimes.

     

    My problem is how can I only get the difference of hours and minutes disregard the seconds from datetime..

     

    here is my sample login and logout:

     

     

    Login : 2012-03-12 05:39:17

    Logout: 2012-03-12 13:35:16

     

    And here is my code in getting the Rendered or total hours:

     

    UPDATE reg_att SET Rendered = case 
    when time_to_sec(time(LOGIN)) BETWEEN time_to_sec('05:35:00') AND time_to_sec('06:59:00') AND time_to_sec(time(LOGOUT)) BETWEEN time_to_sec('13:35:00') AND time_to_sec('15:35:00')
    AND DATE_FORMAT(LOGIN, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
    then sec_to_time(time_to_sec(concat(substr(LOGIN, 1,10), ' ' , '08:00:00')) -
    (time_to_sec(LOGIN) - time_to_sec(concat(substr(LOGIN, 1,10), ' ' , '05:35:59'))))
    End;
    

     

    the output of this is :

    Rendered = 07:56:42

     

    and I need to compute the lates:

     

    I used this code for lates:

     

    UPDATE reg_att SET Late = case 
    when time_to_sec(time(LOGIN)) BETWEEN time_to_sec('05:35:00') AND time_to_sec('06:59:00') AND time_to_sec(time(LOGOUT)) BETWEEN time_to_sec('13:35:00') AND time_to_sec('15:35:00')
    AND DATE_FORMAT(LOGIN, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
    then sec_to_time(time_to_sec('08:00:00') - time_to_sec(Rendered))
    END;
    

     

    the output of this is:

     

    Late = 00:03:18

     

     

    Now, How can be the late become : 00:04:00

     

    Disregard the seconds?

     

     

    his schedule is 05:35 - 13:35

     

    he login 05:39, so he was late 4 minutes, but in my code it computes  00:03:18 because it regards the seconds.

     

    Any help is highly appreciated.

     

    Thank you so much..

     

  10. Hi..

     

    Now I used onclick to display the computed max doz, now I want it to auto compute after I input numbers in max lot. Is it possible?

     

    What code?

     

    here is my whole code:

    <html>
    <head>
    <title>Parameter Settings</title>
    
    <link rel="stylesheet" type="text/css" href="kanban.css" /> 
    
    <script type="text/javascript">
    //=========auto compute Total  Max=====//
    function autocalearn(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_max_lot = a = 0;
    for (a; a < arguments.length; ++a) //loop through text elements
    {
    field = arguments[a];
    val = parseFloat(field.value); //get value
    
    if (!isNaN(val)) //number?
    {
    Total_max_lot += val; //accumulate
    }
    }                                                                                 
    oForm.Total_max_lot.value = Total_max_lot.toFixed(2); //out
    
    }
    </script> 
    <script type="text/javascript">
    //=========auto compute Total  bch=====//
    function autobch(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_bch_wt = a = 0;
    for (a; a < arguments.length; ++a) //loop through text elements
    {
    field = arguments[a];
    val = parseFloat(field.value); //get value
    
    if (!isNaN(val)) //number?
    {
    Total_bch_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_bch_wt.value = Total_bch_wt.toFixed(2); //out
    
    }
    
    </script>
    
    <script type="text/javascript">
    //=========auto compute Total  plug=====//
    function plug(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_plug_wt = a = 0;
    for (a; a < arguments.length; ++a) //loop through text elements
    {
    field = arguments[a];
    val = parseFloat(field.value); //get value
    
    if (!isNaN(val)) //number?
    {
    Total_plug_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_plug_wt.value = Total_plug_wt.toFixed(2); //out
    
    }
    
    </script>
    
    
    <script type="text/javascript">
    //============Auto compute Total Min Lot========//
    function autocalmin(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_min_lot = a = 0;
    for (a; a < arguments.length; ++a) //loop through text elements
    {
    field = arguments[a];
    val = parseFloat(field.value); //get value
    if (!isNaN(val)) //number?
    {
    Total_min_lot += val; //accumulate
    }
    }                                                 
    oForm.Total_min_lot.value = Total_min_lot.toFixed(2); //out
    
    }
    </script>
    
    <script type="text/javascript">
    //Auto convert to Doz and auto compute total max doz=====////
    function doz(oText){  
        var P28_max_lot = document.getElementById("P28_max_lot").value;
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));     
        if( !isNaN(P28_max_convert) ){   
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2);
        }
        
        var P30_max_lot = document.getElementById("P30_max_lot").value;
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12)); 
        if( !isNaN(P30_max_convert) ){   
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2);
        }
        
        var P32_max_lot = document.getElementById("P32_max_lot").value;
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12)); 
        if( !isNaN(P32_max_convert) ){
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2);
        }
            
        var P33_max_lot = document.getElementById("P33_max_lot").value;
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_max_convert = (parseFloat(P33_max_lot) * ((parseFloat(P33_bch_wt))* parseFloat(1000)) / parseFloat(P33_plug_wt) / parseFloat(12));  
        if( !isNaN(P33_max_convert) ){
        var P33_max_doz = document.getElementById("P33_max_doz").value = P33_max_convert.toFixed(2);
        }
        
        var P35_max_lot = document.getElementById("P35_max_lot").value;
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_max_convert = (parseFloat(P35_max_lot) * ((parseFloat(P35_bch_wt))* parseFloat(1000)) / parseFloat(P35_plug_wt) / parseFloat(12)); 
        
        if( !isNaN(P35_max_convert) ){
        var P35_max_doz = document.getElementById("P35_max_doz").value = P35_max_convert.toFixed(2);
        }
        
        var P35M_max_lot = document.getElementById("P35M_max_lot").value; 
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_max_convert = (parseFloat(P35M_max_lot) * ((parseFloat(P35M_bch_wt))* parseFloat(1000)) / parseFloat(P35M_plug_wt) / parseFloat(12)); 
        if( !isNaN(P35M_max_convert) ){
        var P35M_max_doz = document.getElementById("P35M_max_doz").value = P35M_max_convert.toFixed(2);
        }
        
        var P35W_max_lot = document.getElementById("P35W_max_lot").value;  
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_max_convert = (parseFloat(P35W_max_lot) * ((parseFloat(P35W_bch_wt))* parseFloat(1000)) / parseFloat(P35W_plug_wt) / parseFloat(12));
        if( !isNaN(P35W_max_convert) ){
        var P35W_max_doz = document.getElementById("P35W_max_doz").value = P35W_max_convert.toFixed(2);
        }
        
        var P38_max_lot = document.getElementById("P38_max_lot").value;
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_max_convert = (parseFloat(P38_max_lot) * ((parseFloat(P38_bch_wt))* parseFloat(1000)) / parseFloat(P38_plug_wt) / parseFloat(12));
        if( !isNaN(P38_max_convert) ){
        var P38_max_doz = document.getElementById("P38_max_doz").value = P38_max_convert.toFixed(2);
        }
        
        var P41_max_lot = document.getElementById("P41_max_lot").value;
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_max_convert = (parseFloat(P41_max_lot) * ((parseFloat(P41_bch_wt))* parseFloat(1000)) / parseFloat(P41_plug_wt) / parseFloat(12));
        if( !isNaN(P41_max_convert) ){
        var P41_max_doz = document.getElementById("P41_max_doz").value = P41_max_convert.toFixed(2);
        }
        
        var P42_max_lot = document.getElementById("P42_max_lot").value;
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_max_convert = (parseFloat(P42_max_lot) * ((parseFloat(P42_bch_wt))* parseFloat(1000)) / parseFloat(P42_plug_wt) / parseFloat(12));
        if( !isNaN(P42_max_convert) ){
        var P42_max_doz = document.getElementById("P42_max_doz").value = P42_max_convert.toFixed(2);
        }
        
        var P43_max_lot = document.getElementById("P43_max_lot").value;
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_max_convert = (parseFloat(P43_max_lot) * ((parseFloat(P43_bch_wt))* parseFloat(1000)) / parseFloat(P43_plug_wt) / parseFloat(12));
        if( !isNaN(P43_max_convert) ){
        var P43_max_doz = document.getElementById("P43_max_doz").value = P43_max_convert.toFixed(2);        
        }
        
        var P46_max_lot = document.getElementById("P46_max_lot").value;
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_max_convert = (parseFloat(P46_max_lot) * ((parseFloat(P46_bch_wt))* parseFloat(1000)) / parseFloat(P46_plug_wt) / parseFloat(12));
       
        if( !isNaN(P46_max_convert) ){
        var P46_max_doz = document.getElementById("P46_max_doz").value = P46_max_convert.toFixed(2);
        }
        
        var P47_max_lot = document.getElementById("P47_max_lot").value;
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_max_convert = (parseFloat(P47_max_lot) * ((parseFloat(P47_bch_wt))* parseFloat(1000)) / parseFloat(P47_plug_wt) / parseFloat(12));
        
        if( !isNaN(P47_max_convert) ){
        var P47_max_doz = document.getElementById("P47_max_doz").value = P47_max_convert.toFixed(2);   
        }
        
    if (isNaN(oText.value)) //filter input
    {
    //alert('Numbers only!');
    oText.value = '';
    } 
    var field, val, oForm = oText.form, Total_max_doz = a = 0;
    for (a; a < arguments.length; ++a) //loop through text elements
    {
    field = arguments[a];
    val = parseFloat(field.value); //get value    
    
    if (!isNaN(val)) //number?
    {
    Total_max_doz += val; //accumulate
    }
    }
    oForm.Total_max_doz.value = Total_max_doz.toFixed(2); //out
    
    
    }
    </script>
    
    </head>
    <?php
    
    $con = mysql_connect('localhost', 'root','');
    
    mysql_select_db("mes", $con);
    
    ?>
    <body>
    <form name="loading_kanban" action="" method="post" onSubmit="return false">
    <div id="fieldset_PS">
    <table>
    <th>Compounds</th>
    <th>Batch Wt.</th>
    <th>UoM</th>
    <th>Plug Wt.</th>
    <th>UoM</th>
    <th>Max</th>
    <th>UoM</th>
    <th>Max</th>
    <th>UoM</th>
    <th>Min</th>
    <th>UoM</th>
    <th>Min</th>
    <th>UoM</th>
    
    <tr>
    <td><input type="text" name="P28" id="P28" value="P28"></td>
    <td><input type="text" name="P28_bch_wt" id="P28_bch_wt" value="<?php echo $P28_bch_wt; ?>" onKeyUp="return autobch(this, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P28_bch_uom" id="P28_bch_uom" value="Kg"></td>
    <td><input type="text" name="P28_plug_wt" id="P28_plug_wt"  value="<?php echo $P28_plug_wt;?>" onKeyUp="return plug(this, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P28_plug_uom" id="P28_plug_uom" value="g" ></td> 
    <td><input type="text" name="P28_max_lot" id="P28_max_lot" value="<?php echo $P28_max_lot; ?>" onKeyUp="return autocalearn(this, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P28_max_lot_uom" id="P28_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P28_max_doz" id="P28_max_doz" value="<?php echo $P28_max_doz;?>" onClick="return doz(this, P30_max_doz, P32_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P28_max_doz_uom" id="P28_max_doz_uom" value="Doz"></td> 
    </tr>
    <tr>
    <td><input type="text" name="P30" id="P30" value="P30" ></td>
    <td><input type="text" name="P30_bch_wt" id="P30_bch_wt" value="<?php echo $P30_bch_wt;?>" onKeyUp="return autobch(this, P28_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P30_bch_uom" id="P30_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P30_plug_wt" id="P30_plug_wt" size="8" value="<?php echo $P30_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P30_plug_uom" id="P30_plug_uom" value="g"></td>
    <td><input type="text" name="P30_max_lot" id="P30_max_lot" value="<?php echo $P30_max_lot;?>" onKeyUp="return autocalearn(this, P28_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P30_max_lot_uom" id="P30_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P30_max_doz" id="P30_max_doz" value="<?php echo $P30_max_doz; ?>" onClick="return doz(this, P28_max_doz, P32_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P30_max_doz_uom" id="P30_max_doz_uom" value="Doz"></td>
    </tr>    
    
    <tr> 
    <td><input type="text" name="P32" id="P32" value="P32"></td>
    <td><input type="text" name="P32_bch_wt" id="P32_bch_wt" value="<?php echo $P32_bch_wt ;?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P32_bch_uom" id="P32_bch_uom" value="Kg"></td>
    <td><input type="text" name="P32_plug_wt" id="P32_plug_wt" value="<?php echo $P32_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P32_plug_uom" id="P32_plug_uom" value="g"></td>
    <td><input type="text" name="P32_max_lot" id="P32_max_lot" value="<?php echo $P32_max_lot ;?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P32_max_lot_uom" id="P32_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P32_max_doz" id="P32_max_doz" value="<?php echo $P32_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P32_max_doz_uom" id="P32_max_doz_uom" value="Doz"></td>
    </tr>   
    <tr>
    <td><input type="text" name="P33" id="P33" value="P33"></td>
    <td><input type="text" name="P33_bch_wt" id="P33_bch_wt" value="<?php echo $P33_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P33_bch_uom" id="P33_bch_uom" value="Kg"></td>
    <td><input type="text" name="P33_plug_wt" id="P33_plug_wt" value="<?php echo $P33_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P33_plug_uom" id="P33_plug_uom" value="g"></td>
    <td><input type="text" name="P33_max_lot" id="P33_max_lot" value="<?php echo $P33_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P33_max_lot_uom" id="P33_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P33_max_doz" id="P33_max_doz" value="<?php echo $P33_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P33_max_doz_uom" id="P33_max_doz_uom" value="Doz"></td>
    </tr> 
    
    <tr>
    <td><input type="text" name="P35" id="P35" value="P35"></td>
    <td><input type="text" name="P35_bch_wt" id="P35_bch_wt" value="<?php echo $P35_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35_bch_uom" id="P35_bch_uom" value="Kg"></td>
    <td><input type="text" name="P35_plug_wt" id="P35_plug_wt" value="<?php echo $P35_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35_plug_uom" id="P35_plug_uom" value="g"></td>
    <td><input type="text" name="P35_max_lot" id="P35_max_lot" value="<?php echo $P35_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35_max_lot_uom" id="P35_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P35_max_doz" id="P35_max_doz" value="<?php echo $P35_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35_max_doz_uom" id="P35_max_doz_uom" value="Doz" ></td>
    </tr>  
    
    <tr>
    <td><input type="text" name="P35M" id="P35M" value="P35M" ></td>
    <td><input type="text" name="P35M_bch_wt" id="P35M_bch_wt" value="<?php echo $P35M_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35M_bch_uom" id="P35M_bch_uom" value="Kg"></td>
    <td><input type="text" name="P35M_plug_wt" id="P35M_plug_wt" value="<?php echo $P35M_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35M_plug_uom" id="P35M_plug_uom" value="g"></td>
    <td><input type="text" name="P35M_max_lot" id="P35M_max_lot" value="<?php echo $P35M_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35M_max_lot_uom" id="P35M_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P35M_max_doz" id="P35M_max_doz" value="<?php echo $P35M_max_doz; ?>" size="12" readonly="readonly" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35M_max_doz_uom" id="P35M_max_doz_uom" value="Doz"></td>
    </tr>  
    
    <tr>
    <td><input type="text" name="P35W" id="P35W" value="P35W"></td>
    <td><input type="text" name="P35W_bch_wt" id="P35W_bch_wt" value="<?php echo $P35W_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35W_bch_uom" id="P35W_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P35W_plug_wt" id="P35W_plug_wt" value="<?php echo $P35W_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35W_plug_uom" id="P35W_plug_uom" value="g" ></td>
    <td><input type="text" name="P35W_max_lot" id="P35W_max_lot" value="<?php echo $P35W_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35W_max_lot_uom" id="P35W_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P35W_max_doz" id="P35W_max_doz" value="<?php echo $P35W_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35W_max_doz_uom" id="P35W_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="P38" id="P38" value="P38"></td>
    <td><input type="text" name="P38_bch_wt" id="P38_bch_wt" value="<?php echo $P38_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P38_bch_uom" id="P38_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P38_plug_wt" id="P38_plug_wt" value="<?php echo $P38_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P38_plug_uom" id="P38_plug_uom" value="g"></td>
    <td><input type="text" name="P38_max_lot" id="P38_max_lot"  value="<?php echo $P38_max_lot; ?>"  onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P38_max_lot_uom" id="P38_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P38_max_doz" id="P38_max_doz" value="<?php echo $P38_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P38_max_doz_uom" id="P38_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="P41" id="P41" value="P41"></td>
    <td><input type="text" name="P41_bch_wt" id="P41_bch_wt" value="<?php echo $P41_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P41_bch_uom" id="P41_bch_uom" value="Kg" > </td>
    <td><input type="text" name="P41_plug_wt" id="P41_plug_wt" value="<?php echo $P41_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P41_plug_uom" id="P41_plug_uom" value="g" ></td>
    <td><input type="text" name="P41_max_lot" id="P41_max_lot" value="<?php echo $P41_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P41_max_lot_uom" id="P41_max_lot_uom" value="Lot"> </td>
    <td><b><input type="text" name="P41_max_doz" id="P41_max_doz" value="<?php echo $P41_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"><b></td>
    <td><input type="text" name="P41_max_doz_uom" id="P41_max_doz_uom" value="Doz"></td>
    </tr>  
    
    <tr>
    <td><input type="text" name="P42" id="P42" value="P42"></td> 
    <td><input type="text" name="P42_bch_wt" id="P42_bch_wt" value="<?php echo $P42_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P42_bch_uom" id="P42_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P42_plug_wt" id="P42_plug_wt" value="<?php echo $P42_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P42_plug_uom" id="P42_plug_uom" value="g"></td>
    <td><input type="text" name="P42_max_lot" id="P42_max_lot" value="<?php echo $P42_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P42_max_lot_uom" id="P42_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P42_max_doz" id="P42_max_doz" value="<?php echo $P42_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P42_max_doz_uom" id="P42_max_doz_uom" value="Doz"></td>
    </tr>  
    
    <tr>
    <td><input type="text" name="P43" id="P43" value="P43" ></td>
    <td><input type="text" name="P43_bch_wt" id="P43_bch_wt" value="<?php echo $P43_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P43_bch_uom" id="P43_bch_uom" value="Kg"></td>
    <td><input type="text" name="P43_plug_wt" id="P43_plug_wt" value="<?php echo $P43_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P43_plug_uom" id="P43_plug_uom" value="g" ></td>
    <td><input type="text" name="P43_max_lot" id="P43_max_lot" value="<?php echo $P43_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P43_max_lot_uom" id="P43_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P43_max_doz" id="P43_max_doz" value="<?php echo $P43_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P43_max_doz_uom" id="P43_max_doz_uom" value="Doz"></td>
    </tr>  
                                      
    <tr>
    <td><input type="text" name="P46" id="P46" value="P46"></td>
    <td><input type="text" name="P46_bch_wt" id="P46_bch_wt" value="<?php echo $P46_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P46_bch_uom" id="P46_bch_uom" value="Kg"></td>
    <td><input type="text" name="P46_plug_wt" id="P46_plug_wt"  value="<?php echo $P46_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P46_plug_uom" id="P46_plug_uom" value="g" ></td>
    <td><input type="text" name="P46_max_lot" id="P46_max_lot" value="<?php echo $P46_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P46_max_lot_uom" id="P46_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P46_max_doz" id="P46_max_doz"  value="<?php echo $P46_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P46_max_doz_uom" id="P46_max_doz_uom" value="Doz"></td>
    </tr>  
    
    <tr>
    <td><input type="text" name="P47" id="P47" value="P47"></td>
    <td><input type="text" name="P47_bch_wt" id="P47_bch_wt" value="<?php echo $P47_bch_wt; ?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt)"></td>
    <td><input type="text" name="P47_bch_uom" id="P47_bch_uom" value="Kg"></td>
    <td><input type="text" name="P47_plug_wt" id="P47_plug_wt" value="<?php echo $P47_plug_wt; ?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt)"></td>
    <td><input type="text" name="P47_plug_uom" id="P47_plug_uom" value="g"></td>
    <td><input type="text" name="P47_max_lot" id="P47_max_lot" value="<?php echo $P47_max_lot; ?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot)"></td>
    <td><input type="text" name="P47_max_lot_uom" id="P47_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P47_max_doz" id="P47_max_doz" value="<?php echo $P47_max_doz; ?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz)"></b></td>
    <td><input type="text" name="P47_max_doz_uom" id="P47_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="Total" id="Total" value="Total"></td>
    <td><input type="text" name="Total_bch_wt" id="Total_bch_wt" value="<?php echo $Total_bch_wt; ?>"></td>
    <td><input type="text" name="Total_bch_uom" id="Total_bch_uom" value="Kg"></td>
    <td><input type="text" name="Total_plug_wt" id="Total_plug_wt" value="<?php echo $Total_plug_wt; ?>" ></td>
    <td><input type="text" name="Total_plug_uom" id="Total_plug_uom" value="g"></td>
    <td><input type="text" name="Total_max_lot" id="Total_max_lot" value="<?php echo $Total_max_lot; ?>" ></td>
    <td><input type="text" name="Total_max_lot_uom" id="Total_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="Total_max_doz" id="Total_max_doz" value="<?php echo $Total_max_doz; ?>" ></b></td>
    <td><input type="text" name="Total_max_doz_uom" id="Total_max_doz_uom" value="Doz" ></td>
    </tr>  
    </table>
    </div>
    </form>
    </body>
    </html> 
    

     

    I attach my sample form.

     

    Thank you so muhc

    post-101569-13482403428554_thumb.jpg

    post-101569-13482403428786_thumb.jpg

  11. Hi..

     

    I need help in using for loop in saving data from while loop.

     

    Now, I encountered that the Demanded Qty was get only is the last Demanded Qty and save it to all Items.

     

    I want to happen is per Items will save the Demanded Qty.

     

    for example:

    Items Demanded Qty

    P28 ---1

    P28 ---1

    P28 ---1

    P30 ---2

    P30 ---2

    P30 ---2

    and so on..

     

    here is my code:

    <?php                                                                          
       error_reporting(0);
       date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    $sr_date =date('Y-m-d H:i:s');
    
            $sql = "SELECT sr_number FROM stock_requisition ORDER BY sr_date DESC LIMIT 1";
            $result = mysql_query($sql, $con);
            
            if (!$result) {
                echo 'failed'; 
                die();
            }
            $total = mysql_num_rows($result);
            if ($total <= 0) {
                $currentSRNum = 1;
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
    
                $currentSRYMD = substr($row['sr_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }        
                
            } 
            else {
                $row = mysql_fetch_assoc($result);
                
                $currentSRNum = (int)(substr($row['sr_number'],0,3));
                
                $currentSRYear  = (int)(substr($row['sr_number'],2,2));
                $currentSRMonth = (int)(substr($row['sr_number'],0,2));
                $currentSRNum = (int)(substr($row['sr_number'],6,4));
                $currentYear  = (int)(date('y'));
                $currentMonth = (int)(date('m'));
                $currentDay = (int)(date('d'));
    
                $currentSRYMD = substr($row['sr_number'], 0, 6);
                $currentYMD = date("ymd");
                if ($currentYMD > $currentSRYMD) 
                {  
                    $currentSRNum = 1;
                } 
                else 
                {  
                    $currentSRNum += 1;
                }                                           
            }      
            $yearMonth = date('ymd');    
            $currentSR = $currentYMD . sprintf("%04d", $currentSRNum);   
    ?>
    <html>
    <title>Stock Requisition</title>
    <head>
    <link rel="stylesheet" type="text/css" href="kanban.css">
    <script type="text/javascript">
    function save_sr(){
        var sr_date = document.getElementById("sr_date").value;
        var sr_number = document.getElementById("sr_number").value;
        var Items1 = document.getElementById("Items1").value;
        var SubItems = document.getElementById("SubItems").value;
        var ItemCode = document.getElementById("ItemCode").value;
        var DemandedQty = document.getElementById("DemandedQty").value;
        var UoM = document.getElementById("UoM").value;
        var Class = document.getElementById("Class").value;
        var Description = document.getElementById("Description").value;
        var BINLocation = document.getElementById("BINLocation").value;
        var RequestedBy = document.getElementById("RequestedBy").value;
        var ApprovedBy = document.getElementById("ApprovedBy").value;
        var ReceivedBy = document.getElementById("ReceivedBy").value;
        var IssuedBy = document.getElementById("IssuedBy").value;
        var Items = document.getElementById("Items").value;
        
        document.stock_requisition.action="StockRequisitionSave1.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+
        "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+
        Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+
        "&IssuedBy="+IssuedBy+"&Items="+Items;
        document.stock_requisition.submit();
        alert("Stock Requisition data save.");
        window.location = "StockRequisition1.php";
    }
    
    function disp(){
        document.stock_requisition.action="StockRequisitionDisplay.php";
        document.stock_requisition.submit();
    }
    </script>
    </head>
    <body>
    <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="sr_date" value="<?php echo $sr_date; ?>" size="16" readonly="readonly">    
    </div>
    <div id="SR_number">
    <label>SR# :</label>
    <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly">
    <br/> 
    </div> 
       <div>
    <table>
    <thead>
    <th>Items</th>
    <th>Sub Items</th>
    <th>Item Code</th>
    <th>Demanded Qty</th>
    <th>UoM</th>
    <th>Class</th>
    <th>Description</th>
    <th>BIN Location</th>
    </thead>
    <?php
    $sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";
    $res_bom = mysql_query($sql, $con);
    
    while($row = mysql_fetch_assoc($res_bom)){
        
        $Items = $row['Items'];
    echo "<tr>
            <td> <input type='name' value='$Items' name='Items[]' id='Items' readonly = 'readonly' size='5'></td>
            <td> </td>
            <td> </td> 
            <td><center><input type='text' name='DemandedQty' id='DemandedQty[]' value='' size='7'></center></td>
            
            </tr>";       
         
    $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error());
    
    $res_sub = mysql_query($sql, $con);  
    
    while($row_sub = mysql_fetch_assoc($res_sub)){
    
         $Items1 = $row_sub['Items'];
         $SubItems = $row_sub['SubItems'];
         $ItemCode = $row_sub['ItemCode'];
         $UoM = $row_sub['UoM'];
         $Class = $row_sub['Class'];
         $Description = $row_sub['Description'];
         $BINLocation = $row_sub['BINLocation'];         
         
        echo "<tr>
            <td> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td>
            <td> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' size='10'></td>
            <td> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' size='10'></td>
            <td> </td>
            <td> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' size='3'></td>
            <td> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' size='10'></td>
            <td> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' size='10'></td>
            <td> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' size='10'></td>     
            </tr>";    
            
    }
    }               
    ?>
    </table>
    </div>
    <?php
       $RequestedBy = array('AAA', 'BBB');
       
       $ApprovedBy = array('EEE', 'FFF');
       
       $ReceivedBy = array('III', 'JJJ');
       
       $IssuedBy = array('MMM', 'NNN'); 
    
    ?>
    
    <div id='Requested_By'>
    <label>Requested By:</label>
    <select name="RequestedBy">
    <option value="Select">Select</option>
    <option value="AAA" <?php if($_POST['RequestedBy'] == 'AAA') echo "selected='selected'"; ?>>AAA</option>
      <option value="BBB" <?php if($_POST['RequestedBy'] == 'BBB') echo "selected='selected'"; ?>>BBB</option>
    </select>
    </div>
    
    <div id='Approved_By'>
    <label>Approved By:</label>
    <select name="ApprovedBy">
    <option name='Select'>Select</option>
    <option value="EEE" <?php if($_POST['ApprovedBy'] == 'EEE') echo "selected='selected'"; ?>>EEE</option>
      <option value="FFF" <?php if($_POST['ApprovedBy'] == 'FFF') echo "selected='selected'"; ?>>FFF</option>
    </select>
    </div>
    
    <div id='Received_By'>
    <label>Issued By:</label>
    <select name="IssuedBy">
    <option name='Select'>Select</option>
    <option value="III" <?php if($_POST['ReceivedBy'] == 'III') echo "selected='selected'"; ?>>III</option>
      <option value="JJJ" <?php if($_POST['ReceivedBy'] == 'JJJ') echo "selected='selected'"; ?>>JJJ</option>
    </select>
    </div>
    
    <div id='Issued_By'>
    <label>Received By:</label>
    <select name="ReceivedBy">
    <option name='Select'>Select</option>
    <option value="MMM" <?php if($_POST['IssuedBy'] == 'MMM') echo "selected='selected'"; ?>>MMM</option>
      <option value="NNN" <?php if($_POST['IssuedBy'] == 'NNN') echo "selected='selected'"; ?>>NNN</option>  
    
    </select>
    </div>
    
    <div id="save_btn">
    <input type="button" name="button" value="save" onClick="save_sr()" style="width: 5em;">
    
    <input type="button" name="button" value="display" onclick="disp()">
    
    </div>
    </form>
    </body>
    </html>
    
    

    and here is the save code:

    <?php                                                                          
       error_reporting(0);
       date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    $sr_date = $_POST['sr_date'];
    $sr_number = $_POST['sr_number'];
    $Items1 = $_POST['Items1'];
    $SubItems = $_POST['SubItems'];
    $ItemCode = $_POST['ItemCode'];
    $DemandedQty = $_POST['DemandedQty'];
    $UoM = $_POST['UoM'];
    $Class = $_POST['Class'];
    $Description = $_POST['Description'];
    $BINLocation = $_POST['BINLocation'];
    $RequestedBy = $_POST['RequestedBy'];
    $ApprovedBy = $_POST['ApprovedBy'];
    $ReceivedBy = $_POST['ReceivedBy'];
    $IssuedBy = $_POST['IssuedBy'];
    $Items = $_POST['Items'];
    
    for($i = 0; $i < count($Items1); $i++) 
    { 
        
        if ( $DemandedQty != "" )
        {
    
        $sql = "INSERT INTO stock_requisition 
        (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, 
        ApprovedBy, ReceivedBy, IssuedBy) 
        VALUES 
        ('$sr_date', '$sr_number', '$Items1[$i]', '$SubItems[$i]', '$ItemCode[$i]', '$DemandedQty', '$UoM[$i]', '$Class[$i]', '$Description[$i]', 
        '$BINLocation[$i]', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') 
        ";
        $result = mysql_query($sql, $con);  
    
        }      
    }
    
    
    ?>
    

    I attach my sample form and the data save in database.

     

    Thank you so much

    post-101569-13482403427895_thumb.jpg

    post-101569-13482403428302_thumb.jpg

  12. Hi...

     

    I have form of uploading data to the database, but I need to delete data after 1 month. how does it possibe.

     

    here is my query of insert data to the database:

     

    $sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth) 
          VALUES 
          ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')
          ON DUPLICATE KEY UPDATE
          ProductType = '$ProductType', WorkOrder = '$WorkOrder', POIssueDate = '$POIssueDate', SalesMonth = '$SalesMonth'" or die(mysql_error());
          mysql_query($sql, $con);
    

     

    Should I need to add fields for date upload?

     

    Thank you

  13. Hi..

     

    I have code for importing data from .xml file to database.

     

    My issue is the On Dupliicate Key Update did not work, ti save again the data even the data is already exist..

     

    here is my code:

     

    $sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth) 
          VALUES 
          ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')
          ON DUPLICATE KEY UPDATE
          ProductType = '$ProductType', WorkOrder = '$WorkOrder', POIssueDate = '$POIssueDate', SalesMonth = '$SalesMonth'" or die(mysql_error());
    

     

    For example I attach file then I attahc again but I update some data I want it to update on database if the ProductType is already exist and add if not.

     

    I attach my sample upload file. and You can see on the second upload the ProductType P101 change the sales month.

     

    In my query the data that was second upload was insert again it did not update the existing data.I want the result should be the second upload not mix the first and second upload. Now the data was duplicated, thats my problem. I want it to update if the ProductType is already exist.

     

     

    Thank you

    post-101569-13482403403104_thumb.jpg

    post-101569-13482403426324_thumb.jpg

  14. <?php
    $data = array();
    
    $con = mysql_connect("localhost", "root","");
    if (!$con) { 
      die(mysql_error());
    }
    $db = mysql_select_db("mes", $con);
    if (!$db) { 
      die(mysql_error());
    }
    
      $sql = "select * from sales_order";
    $result =  mysql_query($sql);
    if (!$result) {
        die(mysql_error());
    }
      
    function add_employee($ProductType,$WorkOrder,$POIssueDate,$SalesMonth)
      {
          global $data;
          
          
          $con = mysql_connect("localhost", "root","");
          if (!$con){ die(mysql_error());}
          $db = mysql_select_db("mes", $con);
          if (!$db) { 
              die(mysql_error());
          }
    
          $ProductType= $ProductType;
          $WorkOrder = $WorkOrder;
          $POIssueDate = $POIssueDate;
          $SalesMonth = $SalesMonth;
             
          $sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth) 
          VALUES 
          ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')" or die(mysql_error());
          mysql_query($sql, $con);
          
          
          $data []= array('ProductType'=>$ProductType,'WorkOrder'=>$WorkOrder,'POIssueDate'=>$POIssueDate,'SalesMOnth'=>$SalesMonth);
      }
    //I having issue in this line first it did not import the data
    [b] if ( $_FILES['file']['tmp_name'] ['error'])
    //when I tried this commented code it import the data but It needs the .xml file is in the same folder of my php file.
    //if (empty($_FILES['file']['tmp_name']['error']))  
      { //$dom = DOMDocument::load('SalesOrder.xml');   
        $dom = DOMDocument::load($_FILES['file']['tmp_name']);
         $dom = DOMDocument::__construct();           
          $rows = $dom->getElementsByTagName('Row');
          global $last_row;
          $last_row = false;
          $first_row = true;
    
    //i think here is the code that an issue with saving not all columns only with yellow background.
    
          foreach ($rows as $row)
          {
              if ( !$first_row )
              {
                  $ProductType = "";
                  $WorkOrder = "";
                  $POIssueDate = "";
                  $SalesMonth = "";
                  
                  $index = 1;
                  $cells = $row->getElementsByTagName( 'Cell' );
              
                  foreach( $cells as $cell )
                  { 
                      $ind = $cell->getAttribute( 'Index' );
                      if ( $ind != null ) $index = $ind;
                  
                      if ( $index == 1 ) $ProductType = $cell->nodeValue;  
                      if ( $index == 2 ) $WorkOrder = $cell->nodeValue;
                      if ( $index == 3 ) $POIssueDate = $cell->nodeValue;
                      if ( $index == 4 ) $SalesMonth = $cell->nodeValue;
                      $index += 1;
                  }
    
                 if ($ProductType=='' AND $WorkOrder=='' AND $POIssueDate=='' AND $SalesMonth=='') {  
                        $last_row = true;
                  }      
                  else {
                        add_employee($ProductType,$WorkOrder,$POIssueDate,$SalesMonth);  
                  }      
              }
              if ($last_row==true) {
                  $first_row = true;
              }     
              else {
                  $first_row = false;
              }
          }
      }[/b]  ?>
      
      <html>
      <body>
      <table>
      <tr>
          <th>Sales Order</th>
      </tr>
      <?php foreach( $data as $row ) { ?>
      <tr>
      <td><?php echo( $row['ProductType'] ); ?></td>
      <td><?php echo( $row['WorkOrder'] ); ?></td>
      <td><?php echo( $row['POIssueDate']) ;?> </td>
      <td><?php echo( $row['SalesMonth'] ); ?></td>
      </tr>
      <?php } ?>
      </table>
      </body>
    </html>
    

    Actually the .xml file is created in ms excel and I save it as .xml and I printscreen so that I post it

     

    Thank you

     

     

  15. Hi..

     

    I have code for importing .xml file to database.

     

    the problem is I cannot upload my file but no error display. And also I got a problem in importing data from .xml file to database but not all row will be save.

     

    here is my code:

     

    <?php
    $data = array();
    
    $con = mysql_connect("localhost", "root","");
    if (!$con) { 
      die(mysql_error());
    }
    $db = mysql_select_db("mes", $con);
    if (!$db) { 
      die(mysql_error());
    }
    
      $sql = "select * from sales_order";
    $result =  mysql_query($sql);
    if (!$result) {
        die(mysql_error());
    }
      
    function add_employee($ProductType,$WorkOrder,$POIssueDate,$SalesMonth)
      {
          global $data;
          
          
          $con = mysql_connect("localhost", "root","");
          if (!$con){ die(mysql_error());}
          $db = mysql_select_db("mes", $con);
          if (!$db) { 
              die(mysql_error());
          }
    
          $ProductType= $ProductType;
          $WorkOrder = $WorkOrder;
          $POIssueDate = $POIssueDate;
          $SalesMonth = $SalesMonth;
             
          $sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth) 
          VALUES 
          ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')" or die(mysql_error());
          mysql_query($sql, $con);
          
          
          $data []= array('ProductType'=>$ProductType,'WorkOrder'=>$WorkOrder,'POIssueDate'=>$POIssueDate,'SalesMOnth'=>$SalesMonth);
      }
      if ( $_FILES['file']['tmp_name'] ['error'])
    //f (empty($_FILES['file']['tmp_name']['error']))  
      { //$dom = DOMDocument::load('SalesOrder.xml');   
        $dom = DOMDocument::load($_FILES['file']['tmp_name']);
         $dom = DOMDocument::__construct();           
          $rows = $dom->getElementsByTagName('Row');
          global $last_row;
          $last_row = false;
          $first_row = true;
          foreach ($rows as $row)
          {
              if ( !$first_row )
              {
                  $ProductType = "";
                  $WorkOrder = "";
                  $POIssueDate = "";
                  $SalesMonth = "";
                  
                  $index = 1;
                  $cells = $row->getElementsByTagName( 'Cell' );
              
                  foreach( $cells as $cell )
                  { 
                      $ind = $cell->getAttribute( 'Index' );
                      if ( $ind != null ) $index = $ind;
                  
                      if ( $index == 1 ) $ProductType = $cell->nodeValue;  
                      if ( $index == 2 ) $WorkOrder = $cell->nodeValue;
                      if ( $index == 3 ) $POIssueDate = $cell->nodeValue;
                      if ( $index == 4 ) $SalesMonth = $cell->nodeValue;
                      $index += 1;
                  }
    
                 if ($ProductType=='' AND $WorkOrder=='' AND $POIssueDate=='' AND $SalesMonth=='') {  
                        $last_row = true;
                  }      
                  else {
                        add_employee($ProductType,$WorkOrder,$POIssueDate,$SalesMonth);  
                  }      
              }
              if ($last_row==true) {
                  $first_row = true;
              }     
              else {
                  $first_row = false;
              }
          }
      }
      ?>
      
      <html>
      <body>
      <table>
      <tr>
          <th>Sales Order</th>
      </tr>
      <?php foreach( $data as $row ) { ?>
      <tr>
      <td><?php echo( $row['ProductType'] ); ?></td>
      <td><?php echo( $row['WorkOrder'] ); ?></td>
      <td><?php echo( $row['POIssueDate']) ;?> </td>
      <td><?php echo( $row['SalesMonth'] ); ?></td>
      </tr>
      <?php } ?>
      </table>
      </body>
    </html>
    

     

    and I will attach my sample data and the data with color yellow background is only row I want to save to my database.

     

    Thank you so much..

    18058_.doc

  16. Thank you..

     

     

     

    I resolved it using this code:

     

     

     

    
    function ApproveLeaveOP(){
    if(document.getElementById('H').checked) {
        var CHK_LEAVE = document.getElementById('H').value;
          }
    else if(document.getElementById('W').checked) { 
          var CHK_LEAVE = document.getElementById('W').value;
          }
       
        var EMP_NO = document.getElementById('EMP_NO').value;
        var DATE_LEAVE_FROM = document.getElementById('DATE_LEAVE_FROM').value;
        var DATE_LEAVE_TO = document.getElementById('DATE_LEAVE_TO').value;
        var NAME = document.getElementById('NAME').value;
        var HOURS_LEAVE = document.getElementById('HOURS_LEAVE').value;
        var Approve = document.getElementById('Approve').value;
        var TYPE = document.getElementById('TYPE').value;
        var dateprocess = document.getElementById('dateprocess').value;
        document.sampleform.action="AddLeave.php?EMP_NO="+EMP_NO+"&DATE_LEAVE_FROM="+DATE_LEAVE_FROM+"&DATE_LEAVE_TO="+DATE_LEAVE_TO+"&NAME="+NAME+"&HOURS_LEAVE="+HOURS_LEAVE+"&Approve="+Approve+"&TYPE="+TYPE+"&dateprocess="+dateprocess+"&CHK_LEAVE="+CHK_LEAVE;
        //document.sampleform.action="AddLeave.php";
       //document.sampleform.action="AddLeave.php?APPROVE="+APPROVE";
        document.sampleform.submit();
       
    
       
    
    }
    
    
    
    

     

  17. Hi..

     

    I'm new in radio button.

     

    Now I have to radio button one for H value means half and W for Whole.

     

    Now I don't know how can I get the value to save in to my database.

     

    here is my code:

     

    <input type="radio" name="CHK_LEAVE" id="H" value="H">
    <input type="radio" name="CHK_LEAVE" id="W"value="W">
    <script>
    function ApproveLeaveOP(){   
        var CHK_LEAVE = document.getElementByName('CHK_LEAVE').value;
        
        alert (CHK_LEAVE);
    }
    </script>
    

     

    I got an error Object Required.

     

    I tried this test:

     

    function chk(){
          if(document.getElementById('H').checked) {
             alert ('H')
          }else if(document.getElementById('W').checked) {  
           alert ('W')
          }
    } 
    

     

    And it works.

     

    Now How can I save it to my database

     

    I have this code and I need to insert here the code to get the value of radio button that I choose:

     

    function ApproveLeaveOP(){  
    var EMP_NO = document.getElementById('EMP_NO').value;
        var DATE_LEAVE_FROM = document.getElementById('DATE_LEAVE_FROM').value;
        var DATE_LEAVE_TO = document.getElementById('DATE_LEAVE_TO').value;
        var NAME = document.getElementById('NAME').value;
        var HOURS_LEAVE = document.getElementById('HOURS_LEAVE').value;
        var Approve = document.getElementById('Approve').value;
        var TYPE = document.getElementById('TYPE').value;
        var dateprocess = document.getElementById('dateprocess').value;
       
        document.sampleform.action="AddLeave.php?EMP_NO="+EMP_NO+"&DATE_LEAVE_FROM="+DATE_LEAVE_FROM+"&DATE_LEAVE_TO="+DATE_LEAVE_TO+"&NAME="+NAME+"&HOURS_LEAVE="+HOURS_LEAVE+"&Approve="+Approve+"&TYPE="+TYPE+"&dateprocess="+dateprocess;
           document.sampleform.submit(); 
    }
    

     

    <input type="text" name="EMP_NO" id="EMP_NO" value="{$empno}" size="8" style="background: #e2e2e2" readonly="readonly">
    <input type="text" name="NAME" id="NAME" value="{$fullname}" size="35" style="background: #e2e2e2" readonly="readonly">
    <input type="text" name="DATE_LEAVE_FROM" id="DATE_LEAVE_FROM" value="{$DATE_LEAVE_FROM}" size="9">
    <input type="text" name="DATE_LEAVE_TO" id="DATE_LEAVE_TO" value="{$DATE_LEAVE_TO}" size="9">
    
    {html_options id=TYPE name=TYPE options=$LeaveStatus selected=$TYPE style="width:140px;"}
    <input type="radio" name="CHK_LEAVE" id="H" value="H">
    <input type="radio" name="CHK_LEAVE" id="W"value="W">    
    <!--<input type="text" name="STATUS" id="STATUS" value="{$STATUS}" size="10">-->
    <input type="button" name="Approve" value="Approve" id="Approve" onclick="ApproveLeaveOP()"> 
    

     

    I need to save in to my database what I choose.

     

    Thank you

     

     

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