Jump to content

newphpcoder

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by newphpcoder

  1. Hi..I have form and i want to input data using barcode and it will display on textbox and after input on the first textbox the focus will go to next textbox untill it will go on the last textbox and on the last textbox it will automatically save the data's on the database.How is it possible?here is my sample 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);?><html><head><script type="text/javascript">function ini(){// Retrieve the codevar code =document.getElementById ("code_read_box1").value;var code =document.getElementById ("code_read_box2").value;var code =document.getElementById ("code_read_box3").value;var code =document.getElementById ("code_read_box4").value;var code =document.getElementById ("code_read_box5").value;var code =document.getElementById ("code_read_box6").value;// Return false to prevent the form to submitreturn false;}</script></head><body onLoad="document.barcode.code_read_box1.focus()"><form name=barcode onsubmit = "return ini()"><input type="text" id="code_read_box1" value="" /><br/><input type="text" id="code_read_box2" value="" /><br/><input type="text" id="code_read_box3" value="" /><br/><input type="text" id="code_read_box4" value="" /><br/><input type="text" id="code_read_box5" value="" /><br/><input type="text" id="code_read_box6" value="" /><br/></form></body></html>
  2. Hi..I have problem in getting the DemandedQty that was input. Only in the Demanded Qty of P28 items was read.For example I input 21 in Demanded Qty of P28 and then It alerts 21, but when I input 2 in Demanded Qty of P30 the alert was 21. It means only the P28 Demanded Qty was get.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);?><html><title>Stock Requisition</title><head><link rel="stylesheet" type="text/css" href="kanban.css"><script type="text/javascript">function showSum(element) { var clickElement = element.value; var click_id = element.id; var Table = document.getElementById('list'); var rows = Table.rows; var strSelect = document.getElementById(click_id).value; alert(strSelect); // i tried to alert to check if he gets the correct value, but I found that only the Demanded Qty of P28 was read. And when I try to input on another Demanded Qty like in P30 the alert was blank. for (var i = 0; i < rows.length; i++) { var row = rows[i]; if (row.id.substr(0,3) == strSelect) { } } }</script></head><body><form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><div><table id="list"><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$DemandedQty = $_POST['DemandedQty'];$sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";$res_bom = mysql_query($sql, $con);$rowCounter = 1;while($row = mysql_fetch_assoc($res_bom)){ $Items = $row['Items']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items_[$rowCounter]' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' style='text-align: right;' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeyup ='showSum(this);'></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error());$res_sub = mysql_query($sql, $con); $rowCounter = 1; while($row_sub = mysql_fetch_assoc($res_sub)){ $Items = $row_sub['Items']; //$Items_ = substr($Items, 12, 3); $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items' id='Items[$rowCounter]' name='Items[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty[$rowCounter]' value='' size='12' style='border:none;text-align: right;'></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; $rowCounter = $rowCounter + 1;}$rowCounter = $rowCounter + 1;} ?></table></div></form></body></html> Thank you so much
  3. Hi..I revise my function for auto compute and display of demanded qty per subitems, but it happened now is only the first Sub Items got an output, and also it works only on the first Items which is P28, when I tried to inpt demanded Qty in Items = P30 it did not work, no data display for subitems.Now I don't know how can I loop it and to check if in where Items Demanded Qty I was input Qty and also how can does display the Qty in Sub Items, because now it only display on first row. <?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);?><html><title>Stock Requisition</title><head><link rel="stylesheet" type="text/css" href="kanban.css"> <script language="JavaScript">function CheckTextbox() {var Items_; var DemandedQty;var SubQty;var Quantity;// first set a reference to the textboxItems_ = document.getElementById('Items_');DemandedQty = document.getElementById('DemandedQty');SubQty = document.getElementById('SubQty');Quantity = document.getElementById('Quantity');if (DemandedQty.value != "") {SubQty.value = DemandedQty.value * Quantity.value;} else {alert('nope');}}</script></head><body><form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><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$DemandedQty = $_POST['DemandedQty'];$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']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items_' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeyup = CheckTextbox()></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity 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']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty' value='' size='12' style></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; }} ?></table></div></form></body></html> Thank you so much
  4. Hi..I have problem on how can I automatically display the output from the computation (Demanded Qty * Quantity), after or while I input Demanded Qty.I mean I input Demanded Qty, on below it will display the output also beside the SubItems.Sorry, if i post again my problem, because I have no idea on how can I solve this problem.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);?><html><title>Stock Requisition</title><head><link rel="stylesheet" type="text/css" href="kanban.css"><script type="text/javascript">function compute_quantity(){ var DemandedQty = document.getElementById('DemandedQty').value; var SubQty = document.getElementById('SubQty').value; var Quantity = document.getElementById('Quantity').value; SubQty = (DemandedQty * Quantity);}</script></head><body><form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><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$DemandedQty = $_POST['DemandedQty'];$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']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeyup = compute_quantity()></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity 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']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty' value='' size='12' style></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; }} ?></table></div></form></body></html> If you don't understand my issue feel free to ask me for further understanding.I'm sorry again I really need to solve this and i tried to google but I can't find the solution.Thank you so much
  5. Hi..I have forms and I only need to input is the Demanded Qty, and from Demanded Qty that I input it will compute the demanded qty for each Item Code.Now my problem is I don't know on how can it possible that while i input the quantity it will also autodisplay the demanded qty for each materials.Noted: the Demanded Qty that will auto display is display only on the Demanded Qty you input per Items. For Example:On Item = P28 i input demanded qty, only on the ItemCode will display the output.and when i input on P30 the computation will display on the ItemCode for P30.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);?><html><title>Stock Requisition</title><head><link rel="stylesheet" type="text/css" href="kanban.css"><script type="text/javascript">function compute_quantity(){ var DemandedQty = document.getElementById('DemandedQty').value; var Quantity = document.getElementById('Quantity').value; var SubQty = (DemandedQty * Quantity);}</script></head><body><form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <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$DemandedQty = $_POST['DemandedQty'];$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']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeypress = compute_quantity()></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity 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']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty' value='' size='12' style></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; }} ?></table></div></form></body></html> Thank you so much
  6. hi..i have table and I put style overflow:autoNow, I notice that also the <th> was up when I up the scroll.I just to happen is the <th> will be fix/ not move. only the <tr>here is my code: <div id="kanban_table" style="overflow:auto; height:215px;"><table><th> JO No.</th><th> ETD </th><th> PO No. </th><th> SKU Code </th><th> Description </th><th> PO Req </th><th> Priority</th><?php$sql = "SELECT FromMonth , ToMonth FROM so_month";$res = mysql_query($sql, $con);$row = mysql_fetch_assoc($res);$FromMonth = $row['FromMonth'];$ToMonth = $row['ToMonth'];$sql = "SELECT ETD, PO_No, SKUCode, Description, POReqFROM sales_order WHERE NOT EXISTS (SELECT PO_No FROM job_order WHERE job_order.PO_No = sales_order.PO_No) AND MONTH(ETD) BETWEEN '$FromMonth' AND '$ToMonth' ORDER BY ETD, PO_No ASC LIMIT 10 ";$res_so = mysql_query($sql, $con);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' value='' style='border:none;' size='10'></td><td><input type='text' name='ETD' id='ETD' value='$row[ETD]' style='border:none;' 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;' size='10'></td><td><input type='submit' name='priority' value='Approved' id='priority'></td></tr>";echo "</form>";}echo "</table>";echo "</div>"; Thank you
  7. Hi..I have table which has a data so_month:FromMonth : 5ToMonth : 7and I have table working_days:MonthNameMayJunJulMonthNumber050607WorkingDays232423Now I have function to get the 3 consecutive months from FromMonth to ToMonth , which as you can see from May to JulNow I have problem in getting the SUM of Working days.here is my code: <?php $sql = "SELECT FromMonth, ToMonth FROM so_month";$res = mysql_query($sql,$con);$row = mysql_fetch_assoc($res);$FromMonth = $row['FromMonth'];$ToMonth = $row['ToMonth'];function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range;}$month_ = implode("' ', ",monthNames($FromMonth,$ToMonth));foreach( monthNames($FromMonth, $ToMonth) as $month){$sql = "SELECT MonthName, SUM(WorkingDays) AS WorkingDays FROM working_days WHERE MonthName IN ('$month') GROUP BY MonthName";$res = mysql_query($sql, $con);while($row = mysql_fetch_array($res)){$WorkingDays = $row['WorkingDays'];}echo $WorkingDays;}?> the output of this code is:232423and when I change this line:$WorkingDays = $row['WorkingDays'];to$WorkingDays += $row['WorkingDays'];the output is:234770The correct output should be: 70Any help is highly appreciated.Thank you very much..
  8. Hi..I need help in getting the 3 Months Name from my table field FromMonth and ToMonth.Here is the scenario.First, I select FromMonth and ToMonth.Ex.FromMonth = 5ToMonth = 7So it meansFromMonth is MayToMonth is July.Now I save the MonthNumber to my database:table- so_monthFromMonth = 5ToMonth = 7Now I need to get the between Months Name from FromMonth to ToMonth which are (May, June, July).How does it possible?Thank you so much.
  9. Hi...I have codes in uploading .xml file to my database table, now I only need to save or insert only the data where ETD (Month from Date) is not previous Month.ETD = dateActually it's my first time to encounter this and while I'm posting this issue in forums., I also tried to find the answer.here is my code: <?phperror_reporting(E_ALL ^ E_NOTICE);date_default_timezone_set("Asia/Singapore"); //set the time zone $data = array();$con = mysql_connect("localhost", "root","");if (!$con) { die(mysql_error());}$db = mysql_select_db("mes", $con);if (!$db) { die(mysql_error());}$date_now = date('m');function add_employee($ETD,$PO_No,$SKUCode,$Description,$POReq ,$Comp) { global $data; $con = mysql_connect("localhost", "root",""); if (!$con){ die(mysql_error());} $db = mysql_select_db("mes", $con); if (!$db) { die(mysql_error()); } $ETD= $ETD; $PO_No = $PO_No; $SKUCode = $SKUCode; $Description = $Description; $POReq = $POReq; $Comp = $Comp; $sql = "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) VALUES ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp') " or die(mysql_error()); mysql_query($sql, $con); $data []= array('ETD'=>$ETD,'PO_No'=>$PO_No,'SKUCode'=>$SKUCode,'Description'=>$Description,'POReq'=>$POReq,'Comp'=>$Comp);}if(empty($_FILES['file']['tmp_name'])){$doc = new DOMDocument();$dom = $doc->load('Sales1.xml'); $rows = $doc->getElementsByTagName('Row'); global $last_row; $last_row = false; $first_row = true; foreach ($rows as $row) { if ( !$first_row ) { $ETD = ""; $PO_No = ""; $SKUCode = ""; $Description = ""; $POReq = ""; $Comp = ""; $index = 1; $cells = $row->getElementsByTagName( 'Cell' ); foreach( $cells as $cell ) { $ind = $cell->getAttribute( 'Index' ); if ( $ind != null ) $index = $ind; if ( $index == 1 ) $ETD = $cell->nodeValue; if ( $index == 2 ) $PO_No = $cell->nodeValue; if ( $index == 3 ) $SKUCode = $cell->nodeValue; if ( $index == 4 ) $Description = $cell->nodeValue; if ( $index == 5 ) $POReq = $cell->nodeValue; if ( $index == 6 ) $Comp = $cell->nodeValue; $index += 1; } if ($ETD=='' AND $PO_No=='' AND $SKUCode=='' AND $Description=='' AND $POReq=='' AND $Comp=='') { $last_row = true; } else { add_employee($ETD,$PO_No,$SKUCode,$Description, $POReq, $Comp); } } if ($last_row==true) { $first_row = true; } else { $first_row = false; } } } ?> I tried this query: $sql = "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) VALUES ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp') WHERE $ETD_month != '$date_now'" or die(mysql_error()); but still he get date where ETD(month from date) = March.Thank you so much
  10. Hi.. I have a function for convert to dozen. 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="ddcolortabs"><ul><li id="current"> <a href="SalesOrder.php" title="Sales Order"><span>Order Management</span></a></li><li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li><li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>WIP Report</span></a></li><li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li><li><a href="ReceivingMaterials.php" title="WMS RM"><span>WMS RM</span></a></li> </ul></div><div id="ddcolortabs1"><ul><li><a href="SalesOrder.php" title="Sales Order"><span>Sales Order</span></a></li><li id="current"><a href="JobOrder.php" title="Job Order"><span>Job Order</span></a></li> </ul></div> <div id="SR_date"> <input type="hidden" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve; ?>" size="16" readonly="readonly" style="border: none;"> </div> <?php//----approve button-----//$Approved = isset($_POST['priority']);if ($Approved){ $PO_No = $_POST['PO_No']; $ETD = $_POST['ETD']; $SKUCode = $_POST['SKUCode']; $Description = $_POST['Description']; $POReq = $_POST['POReq']; $priority = $_POST['priority']; $sql = "SELECT SKUCode, Materials, Comp, Qty FROM bom WHERE SKUCode = '$SKUCode'"; $res = mysql_query($sql, $con); $row = mysql_fetch_assoc($res); $Materials = $row['Materials']; $Qty = $row['Qty']; $Comp = $row['Comp']; $ReqQty = $Qty * $POReq; $sql = "UPDATE bom SET ReqQty = '$ReqQty' WHERE SKUCode = '$SKUCode' AND Materials = '$Materials'";$resReqQty = mysql_query($sql, $con); $sql = "SELECT SUM(WEIGHING) AS WEIGHING_TOTAL, "; $sql .= "SUM(COMPOUNDING) AS COMPOUNDING_TOTAL, "; $sql .= "SUM(EXTRUSION) AS EXTRUSION_TOTAL, "; $sql .= "SUM(FORMING) AS FORMING_TOTAL, "; $sql .= "SUM(DIPPING) AS DIPPING_TOTAL, "; $sql .= "SUM(MOULDING) AS MOULDING_TOTAL "; $sql .= "FROM MES_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp'"; $result = mysql_query($sql, $con); $weighingTotal = mysql_result($result, 0, "WEIGHING_TOTAL"); $weighingTotal = convertToDozen($weighingTotal, $Comp); $weighingAccum = $weighingAccum + $weighingTotal; $compoundingTotal = mysql_result($result, 0, "COMPOUNDING_TOTAL"); $compoundingTotal = convertToDozen($compoundingTotal, $Comp); $compoundingAccum = $compoundingAccum + $compoundingTotal; $extrusionTotal = mysql_result($result, 0, "EXTRUSION_TOTAL"); $extrusionTotal = convertToDozen($extrusionTotal, $Comp); $extrusionAccum = $extrusionAccum + $extrusionTotal; $formingTotal = mysql_result($result, 0, "FORMING_TOTAL"); $formingTotal = convertToDozen($formingTotal, $Comp); $formingAccum = $formingAccum = $formingTotal; $dippingTotal = mysql_result($result, 0, "DIPPING_TOTAL"); $dippingTotal = convertToDozen($dippingTotal, $Comp); $dippingAccum = $dippingAccum + $dippingTotal; $virtualY = $weighingTotal + $compoundingTotal + $extrusionTotal + $formingTotal; $totalY = $dippingTotal + $virtualY; function convertToDozen ($total, $cmpdType) { switch ($cmpdType) { case "P28" : $convTotal = (($total * 1000) / 22.00) / 12; break; case "P30" : $convTotal = (($total * 1000) / 25.10) / 12; break; case "P32" : $convTotal = (($total * 1000) / 22.50) / 12; break; case "P33" : $convTotal = (($total * 1000) / 25.00) / 12; break; case "P35" : $convTotal = (($total * 1000) / 25.25) / 12; break; case "P35M" : $convTotal = (($total * 1000) / 22.60) / 12; break; case "P35W" : $convTotal = (($total * 1000) / 22.50) / 12; break; case "P38" : $convTotal = (($total * 1000) / 26.70) / 12; break; case "P41" : $convTotal = (($total * 1000) / 24.80) / 12; break; case "P42" : $convTotal = (($total * 1000) / 18.90) / 12; break; case "P43" : $convTotal = (($total * 1000) / 25.00) / 12; break; case "P46" : $convTotal = (($total * 1000) / 27.00) / 12; break; case "P47" : $convTotal = (($total * 1000) / 27.60) / 12; break; } return round($convTotal, 2); }}else{ } $sql = "SELECT jo_number, ETD, PO_No, SKUCode, Description, POQty, PriorityFROM job_order ORDER BY jo_number, ETD";$res = mysql_query($sql,$con);?><div id="kanban_table" style="overflow:auto; height:215px;"><table><th> JO No.</th><th> ETD </th><th> PO No. </th><th> SKU Code </th><th> Description </th><th> PO Req </th><th> Priority</th><?php$sql = "SELECT ETD, PO_No, SKUCode, Description, POReqFROM sales_order WHERE NOT EXISTS (SELECT PO_No FROM job_order WHERE job_order.PO_No = sales_order.PO_No) ORDER BY ETD, PO_No ";$res_so = mysql_query($sql, $con);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' value='' style='border:none;' size='10'></td><td><input type='text' name='ETD' id='ETD' value='$row[ETD]' style='border:none;' 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;' size='10'></td><td><input type='submit' name='priority' value='Approved' id='priority'></td></tr>";echo "</form>";}echo "</table>";echo "</div>"; echo "<div style='overflow:auto; height:215px;'>";echo "<table>";while($row_job = mysql_fetch_assoc($res)){ echo "<tr> <td><input type='text' name='JO_No_' id='JO_No_' value='$row_job[jo_number]' style='border:none;width:auto;' size='10'></td> <td><input type='text' name='ETD_' id='ETD_' value='$row_job[ETD]' style='border:none;width:auto;' size='10'></td> <td><input type='text' name='PO_No_' id='PO_No_' value='$row_job[PO_No]' style='border:none;' size='30'></td> <td><input type='text' name='SKUCode_' id='SKUCode_' value='$row_job[sKUCode]' style='border:none;' size='15'></td> <td><input type='text' name='Description_' id='Description_' value='$row_job[Description]' style='border:none;' size='35'></td> <td><input type='text' name='POReq_' id='POReq_' value='$row_job[POQty]' style='border:none;width:auto;' size='10'></td> <td><input type='text' name='priority_' value='$row_job[Priority]' id='priority_' style='border:none;width:auto;' size='10'></td> </tr>" ;}echo "</table>";echo "</div>" ?> </body></html> but I when I echo this: echo $weighingTotal; No result, then when I debug my code I got an error: Call to undefined function. I can’t configured out where in my code was wrong? Any help is highly appreciated. Thank you
  11. Hi..I notice that I got problem in my code: SELECT sec_to_time(SUM(time_to_sec(Rendered))) FROM reg_att WHERE EMP_NO = '09300139'; in this query the output is : 103:52:27 // total hours.but it's wrong it should only be 103:51 //if did not count the seconds.Now my question is what would be the syntax to correct the result.this is the sample data:08:00:0008:00:0008:00:0008:00:0008:00:0008:00:0008:00:0008:00:0008:00:0008:00:0008:00:0007:56:4207:55:45Thank you so much.
  12. Hi,I notice that in my query: $result = mysql_query("INSERT INTO payroll.reg_att(EMP_NO, LOGIN, LOGOUT, TotalHours)SELECT DISTINCT a.EMP_NO, a.LOGIN, a.LOGOUT, TIMEDIFF(a.LOGOUT, a.LOGIN) FROM payroll.date_upload d, attendance.employee_attendance a JOIN hris.employment em ON (a.EMP_NO = em.EMP_NO AND em.STATUS = 'Reg Operatives') WHERE DATE(LOGOUT) BETWEEN '$FROM_DATE' AND '$TO_DATE' AND d.EMP_STATUS = 'Reg Operatives' OR ISNULL(LOGIN) OR ISNULL(LOGOUT)") or die(mysql_error()); it did not insert data where LOGOUT is 0000-00-00 00:00:00 Thank you
  13. Hi..I have this code for checking if the date(TIMEOUT) is already exist in nrs table: $EMP_NO = $_GET['EMP_NO']; $DATE_NRS = $_GET['DATE_NRS']; $TIME_IN = strtotime($_GET['TIME_IN']); $TIME_OUT = strtotime($_GET['TIME_OUT']); $APPROVE = $_GET['APPROVE'];$sql = "SELECT EMP_NO, TIME_IN, TIME_OUT, TOTAL_HOURS, NRS_STATUS FROM nrs WHERE EMP_NO = '$EMP_NO' AND DATE(TIME_OUT) = '$TIME_OUT'"; //echo $sql; $RsOtData = $conn2->Execute($sql); $numrows = $RsOtData->RecordCount(); if($numrows > 0){ echo "<script>alert('Transaction cannot be process')</script>"; echo "<script>navigate('NRSEmp.php')</script>"; } else{ $saverec['EMP_NO'] = $EMP_NO; //$saverec['DATE_NRS'] = $DATE_NRS; $saverec['TIME_IN'] = $TIME_IN; $saverec['TIME_OUT'] = $TIME_OUT; $saverec['TOTAL_HOURS'] = $TOTAL_HOURS; $saverec['NRS_STATUS'] = $APPROVE; $insertSQL = $conn2->GetInsertSQL($RsOtData, $saverec); $conn2->Execute($insertSQL); } now I need revise my query to check also if the date from $TIME_OUT is equal to reg_att .for example of reg_att table data:EMP_NO = 00000221LOGIN = 2012-03-01 05:35:00LOGOUT = 2012-03-01 13:35:00 if Date from $TIMEOUT = date(LOGOUT) if condition will work.I trid this query SELECT n.EMP_NO, n.TIME_IN, n.TIME_OUT, TOTAL_HOURS, NRS_STATUS FROM nrs n WHERE EMP_NO = '00000221' AND DATE(TIME_OUT) = '2012-03-01' OR DATE(TIME_OUT) = (SELECT DATE(LOGOUT) FROM reg_att r WHERE r.EMP_NO = n.EMP_NO); and i got an error:Error Code : 1242Subquery returns more than 1 row(0 ms taken)Thank you
  14. 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, POReqFROM 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> Any help is highly appreciatedThank you
  15. 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, POReqFROM 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> JO.doc
  16. 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
  17. 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.615using this: $TAX = number_format($TAX, 2, '.', ''); the output was : 1417.61but it should be : 1417.62Thank you
×
×
  • Create New...