public function update($params = array()) { global $db; if (isset($params['id'])) { $product = new product($params['id']); } // Save the event info to the eventregistration table # $event = new expRecord(); # $event->tablename = 'eventregistration'; $event->eventdate = datetimecontrol::parseData('eventdate', $params); $event->event_starttime = datetimecontrol::parseData('event_starttime', $params) + $event->eventdate; $event->event_endtime = datetimecontrol::parseData('event_endtime', $params) + $event->eventdate; $event->signup_cutoff = datetimecontrol::parseData('signup_cutoff', $params); $event->id = empty($product->product_type_id) ? null : $product->product_type_id; if (!empty($event->id)) { $db->updateObject($event, 'eventregistration'); } else { $event->id = $db->insertObject($event, 'eventregistration'); } $params['product_type_id'] = $event->id; parent::update($params); }
// { // echo 'plz, upload image type'; // } // else if($size > 42565433) // { // echo 'plz, dun exceed the max limit of size'; // } // else // { // echo "<img src='images/$name'/>"; // } $products->pName = $_POST['insert_pName']; echo $_POST['insert_pName'] . "<br/>"; $products->scID = $_POST['scNames_menu_edit']; echo $_POST['scNames_menu_edit'] . "<br/>"; $products->pPrice = $_POST['insert_pPrice']; echo $_POST['insert_pPrice'] . "<br/>"; $products->pQuantity = $_POST['insert_pQuantity']; echo $_POST['insert_pQuantity'] . "<br/>"; $products->pImg = $path; echo $path . "<br/>"; $products->pDesc = $_POST['insert_pDesc']; echo $_POST['insert_pDesc'] . "<br/>"; echo $_POST['pID']; $id = $products->update($_POST['pID']); } else { $_SESSION['errors'] = $arrErrors; } header("Location: adminEditProduct.php"); exit; }
//if(!empty(trim($_POST['scatname']))){ if (isset($_FILES['image'])) { $product_id = $_POST['product_id']; echo $product_id; $subType_id = $_POST['scatname']; $pname = $_POST['pname']; $desc = $_POST['desc']; $quantity = $_POST['quantity']; $price = $_POST['price']; $pdate = $_POST['pdate']; print_r($_FILES['image']); $product_img = $_FILES['image']['tmp_name']; $imgname = $_FILES['image']['name']; //echo $imgname; move_uploaded_file($product_img, "../images/items/{$imgname}"); /*$product->$name=$pname; $product->$id=$product_id; $product->$descr=$desc; $product->$quantity=$quantity; $product->$image=$imgname; $product->$price=$price; $product->$pdate=$pdate;*/ //$product->update($product_id); $product->update($product_id, $pname, $desc, $quantity, $imgname, $subType_id, $price, $pdate); header("location:addProduct.php"); } /* } else{ header("location:addProduct.php"); }*/ }
function updateProduct($product_id, $column, $value) { $arr = array('selector' => '#updated', 'content' => array('id' => $product_id, 'column' => $column, 'value' => $value)); $p = new product(); $p->read($product_id); //$d->__set('valid', true); $p->validate(); //id, attribute, value //$column, $equiv, $value if ($column == 'name') { $p->update($column, 'name', $value); } elseif ($column == 'description') { $p->update($column, 'description', $value); } elseif ($column == 'category_id') { $p->update($column, 'category_id', $value); $arr['content']['cat_id'] = $value; $arr['source'] = 'updateProduct'; } else { return false; } echo json_encode($arr); }
} else { $published = false; } // convert to bool the onhome box if (isset($_REQUEST['onhome'])) { $onhome = true; } else { $onhome = false; } $product->setContent($_REQUEST['title_1'], $_REQUEST['content_1'], $_REQUEST['title_2'], $_REQUEST['content_2'], $_REQUEST['title_3'], $_REQUEST['content_3'], $_REQUEST['title_4'], $_REQUEST['content_4'], $_REQUEST['title_5'], $_REQUEST['content_5'], $_REQUEST['title_6'], $_REQUEST['content_6'], $_REQUEST['code']); $product->setReference($_REQUEST['reference']); $product->setPrice($_REQUEST['price']); $product->setVAT($_REQUEST['vat']); $product->setDiscount($_REQUEST['discount']); $product->setCategory($_REQUEST['category']); $product->setDateUpdate(); $product->setService($service); $product->setPublished($published); $product->setonHome($onhome); if ($product->update()) { print 'sucess'; } else { print 'failure'; } } } else { print 'error'; } ?> </div>
$oID = $order->insert(); if ($oID == false) { $err = true; } $orderItem = new OrderItems(); foreach ($_SESSION['cart'] as $pID => $q) { $orderItem->oID = $oID; $orderItem->pID = $pID; $orderItem->quantity = $q; $orderItem->insert(); if ($orderItem == false) { $err = true; } $product = new product($pID); $product->pQuantity = $product->pQuantity - $q; $product->update($pID); if ($product == false) { $err = true; } } $customer->cridetLimit = $customer->cridetLimit - $_GET['total']; $customer->update($_SESSION['user']); if ($customer == false) { $err = true; } if ($err) { mysqli_rollback($conn); $responce = 'error happend!!'; } else { mysqli_commit($conn); $responce = "done";
$_SESSION['errors'] = $errors; } if (empty(trim($_GET['quantity'])) || !ctype_digit($_GET['quantity'])) { $errors[] = "invalid quantity"; $_SESSION['errors'] = $errors; } if (!empty($errors)) { $errors[] = $_GET["id"]; } else { $products->product_name = $_GET['name']; $products->product_desc = $_GET['desc']; $products->product_price = $_GET['price']; $products->product_quantity = $_GET['quantity']; $products->sub_cat_id = $_GET['sub']; $products->category_id = $_GET['cat']; $products->update(); } $data = $products->products(); //$jsonerrors =json_encode($errors); $response1 = []; $response1[] = $data; $response1[] = $errors; $jsondata = json_encode($response1); echo $jsondata; //echo $jsonerrors; } else { if ($_GET['value'] == 'Edit') { $products = new product($_GET['id']); $jsondata = json_encode($products); echo $jsondata; }