$currDate = "n"; //set valid flag to false so form will display $valid = false; // set flag to ignore validation $validate = false; } else { echo "Product not found. Please go to the <a href='list.php'>display page</a> to select another product to update</p>"; exit; } } // call the view to display the form $valid = product_form_display('Update', $prodId, $catId, $productCode, $productName, $desc, $listPrice, $discPercent, $date, $validate, $valid, $currDate); // if everything is valid, update database if ($valid) { // Call the update model function $desc = htmlentities($desc, ENT_QUOTES); $result = update_products($studentid, $studentname, $gender, $birthday, $contact, $dbConn); // If the query is successful if ($result) { // transfer to the list.php page header("Location:list.php?msg=update&prodCode={$productCode}"); //clean out the buffer ob_end_clean(); exit; } else { // If the query is not successful display the error. echo "<p class='error'>Unable to update database. " . mysql_error() . " </p>"; } } // if not valid or first time through, send the html form page to the browser from the buffer ob_end_flush();
break; case 'insert_product_B': $productID = filter_input(INPUT_POST, 'ProductID'); $catID = filter_input(INPUT_POST, 'CatID'); $plantname = filter_input(INPUT_POST, 'Plant_Name'); $description = filter_input(INPUT_POST, 'Description'); $size = filter_input(INPUT_POST, 'Size'); $instock = filter_input(INPUT_POST, 'In_Stock'); $products = insert_product_B($productID, $catID, $plantname, $description, $size, $instock); include 'view/insert_product_B.php'; break; case 'update_products': $products = get_products(); $productID = filter_input(INPUT_POST, 'ProductID'); $price = filter_input(INPUT_POST, 'Price'); $products = update_products($productID, $price); include 'update.php'; break; case 'update_products_B': $products = get_products(); $productID = filter_input(INPUT_POST, 'ProductID'); $size = filter_input(INPUT_POST, 'Size'); $instock = filter_input(INPUT_POST, 'In_Stock'); $products = update_products_B($productID, $size, $instock); include 'update_B.php'; break; case 'add': $product_key = filter_input(INPUT_POST, 'productkey'); $item_qty = filter_input(INPUT_POST, 'itemqty'); add_item($product_key, $item_qty); include 'cart.php';
$result['updateCnt'] = $updateCnt++; } if ($update_productListTbl && $result['updateCnt'] >= 1) { $result['result'] = true; $result['updated'] = 1; } return $result; } // For updating product and orders details. if (isset($_POST['cmd']) && $_POST['cmd'] == 'saveData') { check_ajax_referer('smart-manager-security', 'security'); if ($active_module == 'Products') { if (SMPRO == true) { $result = data_for_insert_update($_POST); } else { $result = update_products($_POST); } } elseif ($active_module == 'Orders') { $result = data_for_update_orders($_POST); } elseif ($_POST['active_module'] == 'Customers') { $result = update_customers($_POST); } if ($result['result']) { if ($result['updated'] && $result['inserted']) { if ($result['updateCnt'] == 1 && $result['insertCnt'] == 1) { $encoded['msg'] = "<b>" . $result['updateCnt'] . "</b> " . __('Record Updated and', $sm_text_domain) . "<br><b>" . $result['insertCnt'] . "</b> " . __('New Record Inserted Successfully', $sm_text_domain); } elseif ($result['updateCnt'] == 1 && $result['insertCnt'] != 1) { $encoded['msg'] = "<b>" . $result['updateCnt'] . "</b> " . __('Record Updated and', $sm_text_domain) . "<br><b>" . $result['insertCnt'] . "</b> " . __('New Records Inserted Successfully', $sm_text_domain); } elseif ($result['updateCnt'] != 1 && $result['insertCnt'] == 1) { $encoded['msg'] = "<b>" . $result['updateCnt'] . "</b> " . __('Records Updated and', $sm_text_domain) . "<br><b>" . $result['insertCnt'] . "</b> " . __('New Record Inserted Successfully', $sm_text_domain); } else {
function vm_edit_products_check() { $IDs = array(); $Delete_IDs = array(); $dirty_IDs = array(); // Get all IDs from Form foreach ($_POST as $index => $value) { if (startsWith($index, "ID_")) { $IDs[] = str_replace("ID_", "", $index); } elseif (startsWith($index, "Delete_")) { $Delete_IDs[] = str_replace("Delete_", "", $index); } } // Now check for dirty elements foreach ($IDs as $id) { if ($_POST['price_' . $id] != $_POST['price_new_' . $id] || $_POST['product_' . $id] != $_POST['product_new_' . $id] || $_POST['comment_' . $id] != $_POST['comment_new_' . $id]) { // This is a dirty ID $dirty_IDs[] = $id; } } $edited_users = array(); // create User Objects for edited users foreach ($dirty_IDs as $id) { $user = new Product(); $user->comment = $_POST['comment_new_' . $id]; $user->product = $_POST['product_new_' . $id]; $user->price = floatval(str_replace(",", ".", $_POST['price_new_' . $id])); $user->iD = $id; $edited_users[] = $user; } if (count($edited_users) > 0) { $response = update_products($edited_users); } if (count($Delete_IDs) > 0) { $response2 = delete_products($Delete_IDs); } $resp; if (isset($response) && !isset($response2)) { $resp = $response; } elseif (isset($response2) && !isset($response)) { $resp = $response2; } elseif (isset($response2) && isset($response)) { $resp = $response; $resp->status &= $response2->status; $resp->errorDescription = $resp->errorDescription . " " . $response2->errorDescription; } else { return ""; } return $resp; }
<?php if (isset($_GET['id'])) { $query = query("SELECT * FROM products WHERE product_id = " . escape_string($_GET['id']) . " "); confirm($query); while ($row = fetch_array($query)) { $product_title = escape_string($row['product_title']); $product_category_id = escape_string($row['product_category_id']); $product_price = escape_string($row['product_price']); $product_description = escape_string($row['product_description']); $short_desc = escape_string($row['short_desc']); $product_quantity = escape_string($row['product_quantity']); $product_image = escape_string($row['product_image']); $product_image = display_image($row['product_image']); } update_products(); } ?> <h1 class="page-header"> 商品を編集 </h1> <form action="" method="POST" enctype="multipart/form-data"> <div class="col-md-8"> <div class="form-group"> <label for="product-title">商品名</label> <input type="text" name="product_title" class="form-control" value="<?php echo $product_title; ?>
insert_products($force, $ms_sql, $pricebooks, $insert_products); $insert_products = array(); } if (count($update_products) >= 200) { // do update handling update_products($force, $ms_sql, $pricebooks, $update_products); $update_products = array(); } } if (count($insert_products) > 0) { // do insert handling insert_products($force, $ms_sql, $pricebooks, $insert_products); } if (count($update_products) > 0) { // do update handling update_products($force, $ms_sql, $pricebooks, $update_products); } } else { echo "Connection could not be established."; } function insert_accounts($force, $ms_sql, $insert_accounts) { $accounts = $force->insert_batch('Account', $insert_accounts); $contacts = array(); foreach ($accounts as $account) { if ($account->force_fields['Id']) { foreach ($account->contacts as $contact) { $contact->set_account($account->force_fields['Id']); $contact->set_owner_id($account->get_owner_id()); $contacts[] = $contact; if (count($contacts) >= 200) {