<?php

require_once '../../library/config.php';
require_once '../library/functions.php';
checkUser();
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
    case 'addProduct':
        addProduct();
        break;
    case 'modifyProduct':
        modifyProduct();
        break;
    case 'deleteProduct':
        deleteProduct();
        break;
    case 'deleteImage':
        deleteImage();
        break;
    default:
        // if action is not defined or unknown
        // move to main product page
        header('Location: index.php');
}
function addProduct()
{
    $catId = $_POST['cboCategory'];
    $name = $_POST['txtName'];
    $description = $_POST['mtxDescription'];
    $price = str_replace(',', '', (double) $_POST['txtPrice']);
    $qty = (int) $_POST['txtQty'];
Example #2
0
     }
     $jTableResult['Result'] = "OK";
     $jTableResult['Records'] = $rows;
     break;
 case "addProduct":
     $res = addProduct(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "precio", FILTER_SANITIZE_STRING));
     //Return result to jTable
     if ($res) {
         $jTableResult['Result'] = "OK";
         $jTableResult['Record'] = productsList();
     } else {
         $jTableResult['Result'] = "ERROR";
     }
     break;
 case "modifyProduct":
     $res = modifyProduct(filter_input(INPUT_POST, "IDP", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "precio", FILTER_SANITIZE_STRING));
     //Return result to jTable
     if ($res) {
         $jTableResult['Result'] = "OK";
     } else {
         $jTableResult['Result'] = "ERROR";
     }
     break;
 case "removeProduct":
     $res = removeProduct(filter_input(INPUT_POST, "IDP", FILTER_SANITIZE_STRING));
     if ($res) {
         $jTableResult['Result'] = "OK";
     } else {
         $jTableResult['Result'] = "ERROR";
     }
     break;