퍼스트가든에서 사용하는 사용자 함수 및 관련파일 추가
This commit is contained in:
34
manager/bakery/bakery_product_list.ajax.update.php
Normal file
34
manager/bakery/bakery_product_list.ajax.update.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include_once "_common.php";
|
||||
if(!$_SESSION['user_id']) exit; // 로그인되어있지 않으면 확인 불가
|
||||
|
||||
|
||||
|
||||
$product_name = isset($_POST['product_name']) ? trim($_POST['product_name']) : exit;
|
||||
$barcode = isset($_POST['barcode']) ? trim($_POST['barcode']) : exit;
|
||||
$used = isset($_POST['used']) ? trim($_POST['used']) : exit;
|
||||
|
||||
// bakery_stock.php에서는 idx가 넘어오지 않음.
|
||||
if (isset($_POST['idx'])) {
|
||||
$idx = intval($_POST['idx']);
|
||||
} else {
|
||||
$searchQuery = "SELECT idx FROM {$fg['bakery_product_table']} WHERE barcode = '{$barcode}'";
|
||||
$searchResult = sql_fetch($searchQuery);
|
||||
|
||||
$idx = $searchResult['idx'];
|
||||
}
|
||||
|
||||
// 업데이트 쿼리
|
||||
$query = "UPDATE {$fg['bakery_product_table']}
|
||||
SET product_name = '$product_name', barcode = '$barcode', used = $used
|
||||
WHERE idx = $idx";
|
||||
|
||||
$result = sql_query($query);
|
||||
|
||||
header("Content-Type: application/json");
|
||||
if ($result) {
|
||||
echo json_encode(["isSuccess" => true]);
|
||||
} else {
|
||||
echo json_encode(["isSuccess" => false, "message" => "수정에 실패하였습니다."]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user