|
|
|
ช่วยหน่อยครับ อยากทำแบบกดยืนยันการเบิก แล้วให้รายการในนี้ เพิ่มไปยุอีกตาราง แล้วลบรายการออกไปจากตารางนี้ คล้ายๆ กับ ตระก้าสินค้า อ่ะครับ แนะนำหน่อย |
|
|
|
|
|
|
|
หน้ายืนยันการเบิกวัสดุ
<?php require_once('Connections/arunyik.php'); ?>
<?php require_once('Connections/arunyik.php'); ?>
<?php
ob_start();
require_once('Connections/arunyik.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "admin_fail.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><?php
ob_start();
require_once('Connections/arunyik.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_arunyik, $arunyik);
$query_Recordset1 = "SELECT * FROM basket ORDER BY b_id ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $arunyik) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$query_Recordset2 = "SELECT sum(price_sum)as sumprice FROM basket ";
$Recordset2 = mysql_query($query_Recordset2);
$row_Recordset2 = mysql_fetch_array($Recordset2);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ใบยืนยันการเบิกวัสดุ</title>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>
<?php
function DoFormatCurrency($theObject,$NumDigitsAfterDecimal,$DecimalSeparator,$GroupDigits,$CurrencySymbol) {
$currencyFormat=$CurrencySymbol.number_format($theObject,$NumDigitsAfterDecimal,$DecimalSeparator,$GroupDigits);
return ($currencyFormat);
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
$price_sum=$s_num * $s_price;
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE basket SET s_num=%s,price_sum='$price_sum'WHERE b_id='$b_id'",
GetSQLValueString($HTTP_POST_VARS['s_num'], "int"));
mysql_select_db($database_arunyik, $arunyik);
$Result1 = mysql_query($updateSQL, $arunyik) or die(mysql_error());
$updateGoTo = "widen_submit.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_arunyik, $arunyik);
$query_Rs_per = "SELECT * FROM personnel";
$Rs_per = mysql_query($query_Rs_per, $arunyik) or die(mysql_error());
$row_Rs_per = mysql_fetch_assoc($Rs_per);
$totalRows_Rs_per = mysql_num_rows($Rs_per);
mysql_select_db($database_arunyik, $arunyik);
$query_Rs_bas = "SELECT * FROM basket, personnel WHERE basket.p_id=personnel.p_id AND basket.b_id='$b_id'";
$Rs_bas = mysql_query($query_Rs_bas, $arunyik) or die(mysql_error());
$row_Rs_bas = mysql_fetch_assoc($Rs_bas);
$totalRows_Rs_bas = mysql_num_rows($Rs_bas);
?>
<body>
<p align="center" class="style1">ยืนยันการเบิกวัสดุ</p>
<table width="998" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td width="122">รหัส</td>
<td width="142" align="center">รายการวัสดุ</td>
<td width="132" align="center">ขนาด</td>
<td width="159" align="center">จำนวน</td>
<td width="124" align="center">หน่วยนับ</td>
<td width="140" align="center">ราคาต่อ/หน่วย</td>
<td width="163" align="center">ราคารวม</td>
<td width="163" align="center">ลบรายการ</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['b_id']; ?></td>
<td align="center"><?php echo $row_Recordset1['s_name']; ?></td>
<td align="center"><?php echo $row_Recordset1['s_size']; ?></td>
<td align="center"><form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<label><strong><font size="4" face="AngsanaUPC">
<input name="s_num" type="text" class="text01" id="s_num" value="<?php echo $row_Recordset1['s_num']; ?>" size="7" />
</font></strong></label>
<label>
<input type="submit" name="Submit2" value="ตกลง" />
</label>
<input name="b_id" type="hidden" id="b_id" value="<?php echo $row_Recordset1['b_id']; ?>" />
<input name="s_price" type="hidden" id="s_price" value="<?php echo $row_Recordset1['s_price']; ?>" />
<strong><font size="4" face="AngsanaUPC">
<input type="hidden" name="MM_update" value="form2" />
</font></strong>
</form></td>
<td align="center"><?php echo $row_Recordset1['s_unit']; ?></td>
<td align="center"><?php echo $row_Recordset1['s_price']; ?></td>
<td align="center"><?php echo $row_Recordset1['price_sum']; ?></td>
<td align="center"><a href="widen_submit_delete.php?b_id=<?php echo $row_Recordset1['b_id']; ?>"><img src="image/icon/delete.gif" width="19" height="18" border="0" /></a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<tr>
<td height="23" colspan="8"><div align="right">ราคารวม <?php echo "ผลรวมเท่ากับ ".$row_Recordset2["sumprice"];?>บาท </div></td>
</tr>
<tr>
<td colspan="8"><div align="center">
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<label> จ่ายให้พนักงาน
<select name="select">
<option value="0">กรุณาเลือกชื่อพนักงาน</option>
<?php
do {
?>
<option value="<?php echo $row_Rs_per['p_id']?>"><?php echo $row_Rs_per['p_fname']?></option>
<?php
} while ($row_Rs_per = mysql_fetch_assoc($Rs_per));
$rows = mysql_num_rows($Rs_per);
if($rows > 0) {
mysql_data_seek($Rs_per, 0);
$row_Rs_per = mysql_fetch_assoc($Rs_per);
}
?>
</select>
</label>
<select name="select2">
<option value="0">กรุณาเลือกนามสกุลพนักงาน</option>
<?php
do {
?>
<option value="<?php echo $row_Rs_per['p_id']?>"><?php echo $row_Rs_per['p_lname']?></option>
<?php
} while ($row_Rs_per = mysql_fetch_assoc($Rs_per));
$rows = mysql_num_rows($Rs_per);
if($rows > 0) {
mysql_data_seek($Rs_per, 0);
$row_Rs_per = mysql_fetch_assoc($Rs_per);
}
?>
</select>
<label><br />
<input type="submit" name="Submit" value="ยืนยันการเบิกวัสดุ" />
</label>
</form>
</div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Rs_bas);
mysql_free_result($Rs_per);
mysql_free_result($Recordset1);
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-02-12 15:56:30 |
By :
natt3021 |
View :
711 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใจความมันอยู่ที่การเลือกข้อมูลเก่ามาแล้วจะ Update/Delete น่ะครับ ลอง Copy เฉพาะ Code ที่คิดว่ามีปัญหาออกมาดูครับ
|
|
|
|
|
Date :
2013-02-13 06:30:32 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา Concept ไปก่อนน่ะครับ
1. ตอนกดยืนยันให้ส่ง id การจองรายการเบิก ไป select เอาข้อมูล ออกมาครับ
2. นำข้อมูลที่ได้จากการ select มา insert ลงตารางใหม่
3. ถ้า insert ลงตารางใหม่สำเร็จ ก็ใช้ id จากข้อ 1 ลบข้อมูลจากตารางจองรายการเบิกออกครับ
4. ถ้าไม่ผ่านข้อ 3 ให้กลับไปทำตามข้อ 1 อีกรอบครับ
|
|
|
|
|
Date :
2013-02-14 13:33:59 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|