/**
  * Action для страницы "Удалить товар"
  */
 public function actionDelete($id)
 {
     // Обработка формы
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Удаляем товар
         Product::deleteProduct($id);
         // Перенаправляем пользователя на страницу управлениями товарами
         header('Location: /admin/product/');
     }
     // Подключаем вид
     require_once ROOT . '/views/admin_product/delete.php';
     return true;
 }
Example #2
0
 public function deleteUser($user_id)
 {
     $allTheConversations = Conversation::displayConversations($user_id);
     //delete all the conversations with all their messages
     for ($row = 0; $row < count($allTheConversations); $row++) {
         Conversation::deleteConversation($allTheConversations[$row]['conversationId']);
     }
     //get all the apartments of this user in an array
     $apartmentArray = Product::displayOwnerProducts($user_id);
     //delete all the selected apartments
     for ($row = 0; $row < count($apartmentArray); $row++) {
         Product::deleteProduct($apartmentArray[$row]['dwelling_Id'], $user_id);
     }
     //delete the user from the database
     parent::executeSqlQuery("DELETE FROM bannedusers WHERE user_id = '{$user_id}'");
     parent::executeSqlQuery("DELETE FROM users WHERE user_id = '{$user_id}'");
     header("location: adminPanel.php?action=user");
 }
Example #3
0
$price1 = $_REQUEST['price'];
$image_name1 = $_REQUEST['image_name'];
$description1 = $_REQUEST['description'];
if ($_FILES["image_path"]["error"] > 0) {
    echo "<font size = '5'><font color=\"#e31919\">Error: NO CHOSEN FILE <br />";
    echo "<p><font size = '5'><font color=\"#e31919\">INSERT TO DATABASE FAILED";
} else {
    $uploaddir = "images/";
    move_uploaded_file($_FILES["image_path"]["tmp_name"], "{$uploaddir}" . $_FILES["image_path"]["name"]);
    echo "<font size = '5'><font color=\"#0CF44A\">SAVED<br>";
}
$file1 = "{$uploaddir}" . $_FILES["image_path"]["name"];
switch ($_REQUEST['operation']) {
    case "add":
        $product->addProduct("product_details", "product_name,price,image_name,image_path,description", "'{$product_name}','{$price}','{$image_name}','{$file}','{$description}'");
        break;
    case "update":
        $product->updateProduct("product_details", "product_name='{$product_name1}',price='{$price1}',image_name='{$image_name1}',\r\n\timage_path='{$file1}',description='{$description1}'", "product_id='{$product_id1}'");
        break;
    case "delete_rec":
        $product->deleteProduct("product_details", "product_id='{$product_id}'");
        break;
    case "view":
        $product->viewProduct($product_list, $table);
        break;
    case "view_single":
        $product->viewSingleProduct($product_list, $table, $condition);
        break;
    default:
        echo "<H3 color='red'>Invalid Option Please Try again!</h3>";
}
 public function actionDelete($id)
 {
     $product = Product::getProductById($id);
     if (!$product) {
         $product = array();
     }
     if (isset($_POST['submit'])) {
         $result = Product::deleteProduct($id);
         if (!$result) {
             $message = 'Произошла ошибка при удалении.';
         } else {
             FunctionLibrary::redirectTo("/admin/product");
         }
     }
     require_once ROOT . '/views/admin-product/delete.php';
     return true;
 }
Example #5
0
        $error = 'success';
        $_SESSION['msg'] = 'Record updated successfully.';
    } else {
        $error = 'danger';
        $_SESSION['msg'] = 'Error updating record.';
    }
    $url = ADMIN_URL . "/products/index.php";
    $general->redirectUrl($url, $error);
    exit;
}
/*************************************************************************************/
if (isset($_REQUEST['FLAG']) && $_REQUEST['FLAG'] == 'DELETE') {
    $id = $_REQUEST['id'];
    $cond = array("id" => $id);
    $fieldvalues = array('is_deleted' => '1');
    $deleted = $Product->deleteProduct($fieldvalues, $cond);
    if ($deleted) {
        $general->addLogAction($_SESSION['adm_user_id'], 'Deleted', (int) $_REQUEST['id'], 'Product Management', $_SESSION['adm_status']);
        $error = 'success';
        $_SESSION['msg'] = 'Record deleted successfully.';
    } else {
        $error = 'danger';
        $_SESSION['msg'] = 'Error deleting record.';
    }
    $url = ADMIN_URL . "/products/index.php";
    $general->redirectUrl($url, $error);
    exit;
}
/*************************************************************************************/
if (isset($_REQUEST['FLAG']) && $_REQUEST['FLAG'] == 'DELSELECT') {
    $val = 0;
Example #6
0
 public function deactivateAccount()
 {
     $user_id = $this->getUserId();
     //get all the conversations of that user
     $allTheConversations = Conversation::displayConversations($user_id);
     //delete all the conversations with all their messages
     for ($row = 0; $row < count($allTheConversations); $row++) {
         Conversation::deleteConversation($allTheConversations[$row]['conversationId']);
     }
     //get all the apartments of this user in an array
     $apartmentArray = Product::displayOwnerProducts($user_id);
     //delete all the selected apartments
     for ($row = 0; $row < count($apartmentArray); $row++) {
         Product::deleteProduct($apartmentArray[$row]['dwelling_Id'], $user_id);
     }
     //delete the user from the database
     parent::executeSqlQuery("DELETE FROM bannedusers WHERE user_id = '{$user_id}'");
     parent::executeSqlQuery("DELETE FROM users WHERE user_id = '{$user_id}'");
     parent::printMessage("MESSAGE", "Your account has been delete successfully!", "login.php");
 }
 public function delete($id)
 {
     $modelProduct = new Product();
     $modelProduct->deleteProduct($id);
     header('Location: ' . BASEURL . '?c=product/index');
 }
 public function actionDelete($id)
 {
     $product = Product::getProductById($id, false);
     if (!$product) {
         $product = array();
     }
     if (isset($_POST['submit'])) {
         Product::deleteProduct($id);
         FunctionLibrary::redirectTo('/admin/product');
     }
     require_once ROOT . '/views/admin_product/delete.php';
     return true;
 }
$productModel->_setProductColor($productDetails->color);
$productModel->_setProductDescription($productDetails->description);
$productModel->_setProductPackaging($productDetails->packaging);
$productModel->_setProductType($productDetails->materialtypeid);
$productModel->_setProductOperation($productDetails->opertaion);
$productObj = new Product($productModel);
switch ($productDetails->opertaion) {
    case 'insert':
        # code...
        if (!$productObj->isAvailable($dbh)) {
            $productObj->insertProductInToDb($dbh, $userId);
        } else {
            $showAlerts->showAlert("Failure", "Product you are trying to add is already added");
        }
        break;
    case 'delete':
        # code...
        //$productObj = new Product();
        $productObj->deleteProduct($dbh, $userId, $productDetails);
        break;
    case 'modify':
        if ($productDetails->isProductMasterTable || $productDetails->isProductDetailsTable || $productDetails->isProductPackagingTable || $productDetails->isProductMaterialTable) {
            $productObj->updateProduct($dbh, $userId, $productDetails);
        } else {
            $showAlerts->showAlert('Failure', "Nothing to update");
        }
        break;
    default:
        # code...
        break;
}
Example #10
0
 public function deleteProduct()
 {
     $msg = "";
     $id = $_GET['id'];
     $product = new Product();
     if ($product->access_ModelMember_sessionExists() || $product->access_ModelMember_userAdmin()) {
         $product->setIdProduit($id);
         $delProduct = $product->deleteProduct();
         $msg .= 'Le produit a bien été supprimé !';
     } else {
         $msg .= 'Vous n\'avez pas le droit d\'accéder à cette page';
     }
     include "views/products/deleteProduct.php";
 }
<?php

require_once "../config/Autoload.php";
//class autoload
if (isset($_POST['delete'])) {
    $id = $_POST['delete'];
    $delete_stock = Stock::removeProductStorehouse($id);
    //delete stock name
    if ($delete_stock == TRUE) {
        $delete_product = Product::deleteProduct($id);
        //delete product name
        if ($delete_product == TRUE) {
            echo json_encode('The product was removed');
            //send responce to JavaScript
        } else {
            echo json_encode('Pleas try again');
            //if FALSE send responce to JavaScript
        }
    } else {
        echo json_encode('Pleas try again');
        //if FALSE send responce to JavaScript
    }
}