function editProduct($id) { $product = getProductById($id); if (isset($_POST['ok'])) { if ($_POST['name'] == "") { $error = "Chưa nhập tên sản phẩm"; } else { if ($_POST['price'] == "") { $error = "Chưa nhập giá sản phẩm"; } else { if ($_FILES['img']['name'] != "") { $img_name = "images/" . md5($_FILES['img']['name'] . time()) . ".png"; move_uploaded_file($_FILES["img"]["tmp_name"], $img_name); $product['img'] = $img_name; } $product['name'] = $_POST['name']; $product['price'] = $_POST['price']; $product['info'] = $_POST['info']; updateProduct($product); $error = "Chỉnh sửa thành công"; } } } include "view/product/edit.php"; }
function reativarproduto($id = 0) { $ids = $id ? array($id) : $this->input->post('edit'); foreach ($ids as $id) { if (!$this->auth->logged() or !isAdmin()) { redirect('home'); die; } $product = getProductById($id); if ($product['id_produto']) { if ($this->product->reativarProduto($id)) { $texto = sprintf("O produto <strong>%s</strong> foi ativado com sucesso!<br />", $product['nome']); $this->messages->add($texto, 'success'); // ser user message } } } redirect('admin'); die; }
function editProduct($data) { $product_info = getProductById($data['productId']); $sql = "UPDATE " . e07; $implode = array(); if (isset($data['brand'])) { if ($product_info['brand'] != $data['brand']) { $implode[] = " brand = '" . $data['brand'] . "'"; insertProductLog($data['productId'], 1, $product_info['brand'], $data['brand'], $data['modify_by']); } } if (isset($data['model'])) { if ($product_info['model'] != $data['model']) { $implode[] = " model = '" . $data['model'] . "'"; insertProductLog($data['productId'], 2, $product_info['model'], $data['model'], $data['modify_by']); } } if (isset($data['mprice'])) { if ($product_info['mprice'] != $data['mprice']) { $implode[] = " market_price = '" . $data['mprice'] . "'"; insertProductLog($data['productId'], 3, $product_info['mprice'], $data['mprice'], $data['modify_by']); } } if (isset($data['aprice'])) { if ($product_info['aprice'] != $data['aprice']) { $implode[] = " auction_price = '" . $data['aprice'] . "'"; insertProductLog($data['productId'], 4, $product_info['aprice'], $data['aprice'], $data['modify_by']); } } if (isset($data['category'])) { if ($product_info['category'] != $data['category']) { $implode[] = " category_id = '" . $data['category'] . "'"; insertProductLog($data['productId'], 5, $product_info['category'], $data['category'], $data['modify_by']); } } if (isset($data['availability'])) { if ($product_info['availability'] != $data['availability']) { $implode[] = " availability = '" . $data['availability'] . "'"; insertProductLog($data['productId'], 6, $product_info['availability'], $data['availability'], $data['modify_by']); } } if (isset($data['datestart'])) { if ($product_info['datestart'] != $data['datestart']) { $implode[] = " time_start = '" . $data['datestart'] . "'"; insertProductLog($data['productId'], 7, $product_info['datestart'], $data['datestart'], $data['modify_by']); } } if (isset($data['dateend'])) { if ($product_info['dateend'] != $data['dateend']) { $implode[] = " time_end = '" . $data['dateend'] . "'"; insertProductLog($data['productId'], 8, $product_info['dateend'], $data['dateend'], $data['modify_by']); } } if (isset($data['description'])) { if ($product_info['description'] != $data['description']) { $implode[] = " description = '" . $data['description'] . "'"; insertProductLog($data['productId'], 9, $product_info['description'], $data['description'], $data['modify_by']); } } if (isset($data['bids'])) { if ($product_info['bids'] != $data['bids']) { $implode[] = " total_bid = '" . $data['bids'] . "'"; insertProductLog($data['productId'], 10, $product_info['bids'], $data['bids'], $data['modify_by']); } } if ($implode) { $sql .= " SET " . implode(" , ", $implode); } $sql .= " WHERE id='" . $data['productId'] . "'"; $query = mysql_query($sql); if ($query) { return true; } return false; }
echo '{"result":0,message:"unknown command"}'; exit; } $cmd = $_REQUEST['cmd']; switch ($cmd) { case 1: signIn(); break; case 2: getUserDetails(); break; case 3: getProducts(); break; case 4: getProductById(); break; case 5: registerUser(); break; case 6: addProduct(); break; case 7: addSale(); break; case 8: signOut(); break; default: echo '{"result":0, message:"unknown command"}';
<html> <head> <meta charset="UTF-8"> <title>View Categories</title> </head> <body> <center> <?php /* Connect to DB and include functions */ include_once '../../functions/dbconnect.php'; include_once '../../functions/products-functions.php'; include_once '../../includes/session-start.req-inc.php'; include_once '../../includes/access-required.html.php'; $db = dbconnect(); $product_id = filter_input(INPUT_GET, 'product_id'); $results = getProductById(); ?> <table class="table-hover" border="2"> <thead> <tr> <th>product_id</th> <th>category_id</th> <th>product</th> <th>price</th> <th>image</th> </tr> </thead> <?php foreach ($results as $row) {
<?php $product_id = $_GET['pid']; $product = getProductById($product_id); $product_time = strtotime($product['dateend']) - time(); $token_needed = $product["bids"]; $data_setting = array('group' => 'social', 'Key' => 'fbshare'); $settings = getSettings($data_setting); foreach ($settings as $setting) { $fbshare = $setting['value']; } $title = $product['brand'] . " " . $product['model']; require_once 'models/token_function.php'; ?> <script> var poll<?php echo $product_id; ?> = function () { $.ajax({ type: 'POST', url: "controller/timer.php", data : { id : <?php echo $product_id; ?> } }).done(function (data) { $("#bid_timer_<?php echo $product_id; ?>
<?php if (!isset($logged)) { header('Location:login.html'); } if (!hasPermission($logged, 'access', 'product_form')) { header('Location:permission.html'); } if (isset($_GET['product_id'])) { $product_id = $_GET['product_id']; } if (isset($product_id) && $_SERVER['REQUEST_METHOD'] != 'POST') { $product_info = getProductById($product_id); } if (!empty($product_info)) { $brand = $product_info['brand']; } else { $brand = ''; } if (!empty($product_info)) { $model = $product_info['model']; } else { $model = ''; } if (!empty($product_info)) { $mprice = $product_info['mprice']; } else { $mprice = ''; } if (!empty($product_info)) { $aprice = $product_info['aprice'];
/** * retorna o caminho absoluto da imagem no servidor * @param int $id * @return string */ function getMediaPathById($id) { if (!$id) { return; } $media = getProductById($id); return uploadPath() . $media['media_category'] . "/" . $media['id_usuario'] . "/" . $media['media_url']; }
<?php include_once "../models/config.php"; include_once "../models/sql_function.php"; $product = getProductById($_POST['id']); $endtime = strtotime($product["dateend"]); $time = $endtime - time(); if ($time < 0) { $time = 0; } else { $days = date("d", $time - 8 * 60 * 60) - 1; $time = date("H:i:s", $time - 8 * 60 * 60); } if (isset($days)) { if ($days != 0) { echo $days . " days "; } } echo $time;
<div class="col-md-8"> <!-- MAP & BOX PANE --> <!-- /.box --> <!-- /.row --> <!-- TABLE: LATEST ORDERS --> <div class="box box-info"> <!-- /.box-header --> <div class="box-body"> <div class="table-responsive"> <!-- /.box-header --> <!-- form start --> <?php $product_id = mysql_real_escape_string($_REQUEST['id']); $result = getProductById($product_id); $product = mysql_fetch_array($result); ?> <form role="form" method="post" action="updateProduct.php" enctype="multipart/form-data"> <input type="hidden" name="product_id" value="<?php echo $product['product_id']; ?> " <div class="form-group"> <label for="exampleInputEmail1">Product Name</label> <input type="text" name="product_name" class="form-control" id="product_name" value="<?php echo $product['product_name']; ?> " placeholder="Enter product name"> </div>
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references --> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> </head> <body> <div> <header> <h1>Update Product</h1> </header> <div> <?php $product = getProductById(); ?> <form> Product Name: <input type="text" name="productName" value="<?php echo $product['productName']; ?> " /> <br /> Description: <textarea rows="4" cols="20" name="productDescription"></textarea><br /> Price: <input type="text" name="price" /> <br /> Category: <select name="categoryId"> <option value="1">Soft Drinks</option> <option value="2">Snacks </option> <option value="3">Sandwiches </option> </select>
} .btn-delete { position: absolute; top: 10px; right: 10px; } </style> </head> <body> <?php include "include/include_body.php"; ?> <?php $product = getProductById($conn, $_GET['id']); ?> <div class="container"> <h1><?php echo $product["name"]; ?> </h1> <div class="row"> <p> <dl class="dl-horizontal"> <dt>price</dt> <dd><?php echo $product["price"]; ?> </dd>
$header = $path . '/batik.cupumanik.id/header.php'; $footer = $path . '/batik.cupumanik.id/footer.php'; include $function; include $header; include $footer; ?> </head> <body> <?php echo getBatikHeader(); ?> <div class="main-body"> <?php if (isset($_GET['id'])) { $singleproduct = getProductById($_GET['id']); if (isset($singleproduct)) { ?> <script type="text/javascript"> $(document).ready(function() { canOrder(<?php echo $singleproduct->id; ?> ); }); </script> <div id="product-detail"> <div class="product-detail-content row"> <div class="product-picture col-sm-5 col-xs-12"> <?php echo "<div class=\"product-image\" style=\"background-image: url('.." . $singleproduct->imageurl . "'); background-repeat: no-repeat; background-position: center; background-size: cover\"></div>";
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references --> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> </head> <body> <div> <header> <h1>Update Product</h1> </header> <nav></nav> <div> <?$product = getProductById()?> <form> Product Name: <input type="text" name="productName" value="<?php echo $product['productName']; ?> " /> <br /> Description: <textarea rows="4" cols="20" name="productDescription" > <?php echo $product['productDescription']; ?> </textarea>
public function buy($pid, $amount) { $product = getProductById($pid); $product->amount = $product->amount - $amount; $product->save(); }