-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin approval/rejection, Add to cart and admin remarks added
- Loading branch information
Showing
8 changed files
with
189 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
include '../config/db_connection.php'; | ||
|
||
$conn = OpenCon(); | ||
echo $conn->error; | ||
|
||
// echo $_GET['var']; | ||
$order = $_GET['order']; | ||
|
||
$q_details = "SELECT OrderDetails FROM Orders WHERE OrderId=$order"; | ||
$details = $conn->query($q_details); | ||
|
||
$item_id = ""; | ||
$quantity = ""; | ||
|
||
if ($details->num_rows > 0) | ||
{ | ||
while($row = $details->fetch_assoc()) | ||
{ | ||
echo $row['OrderDetails']; | ||
$pieces = explode(": ", $row['OrderDetails']); | ||
|
||
$item_id_ = explode(" ", $pieces[1]); | ||
$quantity_ = explode(" ", $pieces[3]); | ||
|
||
$item_id = $item_id_[0]; | ||
$quantity = $quantity_[0]; | ||
|
||
echo $item_id; | ||
echo $quantity; | ||
} | ||
} | ||
|
||
$q_sel = "SELECT Id, quantity from Items WHERE Id=$item_id"; | ||
$q_sel_res = $conn->query($q_sel); | ||
$prev_quan = ""; | ||
|
||
if ($q_sel_res->num_rows > 0) | ||
{ | ||
while($row = $q_sel_res->fetch_assoc()) | ||
{ | ||
$prev_quan = $row['quantity']; | ||
} | ||
} | ||
|
||
echo $prev_quan; | ||
|
||
$final_quan = number_format($prev_quan)-number_format($quantity); | ||
|
||
if($_GET['var']=='1') | ||
{ | ||
$sql = "UPDATE Orders SET Status='Approved' WHERE OrderId=$order"; | ||
$result = $conn->query($sql); | ||
|
||
$sql2 = "UPDATE Orders SET Admin_Remarks='Thanks for Ordering' WHERE OrderId=$order"; | ||
$result2 = $conn->query($sql2); | ||
|
||
$update_inv = "UPDATE Items SET quantity=$final_quan WHERE Id=$item_id"; | ||
$update_inv_res = $conn->query($update_inv); | ||
|
||
echo "<script>alert('Order Approved'); window.location.href='./requests.php';</script>"; | ||
} | ||
else if($_GET['var']=='0') | ||
{ | ||
$sql = "UPDATE Orders SET Status='Rejected' WHERE OrderId=$order"; | ||
$result = $conn->query($sql); | ||
|
||
$sql2 = "UPDATE Orders SET Admin_Remarks='Your order is rejected. Please order again after 10 days.' WHERE OrderId=$order"; | ||
$result2 = $conn->query($sql2); | ||
|
||
echo "<script>alert('Order Rejected'); window.location.href='./requests.php';</script>"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
-- https://www.phpmyadmin.net/ | ||
-- | ||
-- Host: localhost:3306 | ||
-- Generation Time: Nov 16, 2020 at 05:30 AM | ||
-- Generation Time: Nov 25, 2020 at 11:50 PM | ||
-- Server version: 10.3.25-MariaDB-0ubuntu0.20.04.1 | ||
-- PHP Version: 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 | ||
|
||
|
@@ -22,18 +22,41 @@ SET time_zone = "+00:00"; | |
-- Database: `inventory` | ||
-- | ||
|
||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `inventory` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; | ||
|
||
USE `inventory`; | ||
|
||
|
||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `Items` | ||
-- Table structure for table `Cart` | ||
-- | ||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `inventory` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; | ||
|
||
USE `inventory`; | ||
DROP TABLE IF EXISTS `Cart`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
|
||
CREATE TABLE `Cart` ( | ||
`CartId` int(11) NOT NULL, | ||
`UserId` int(11) NOT NULL, | ||
`Quantity` int(11) NOT NULL, | ||
`Price` int(11) NOT NULL, | ||
`ChemName` text NOT NULL, | ||
`ChemId` int(11) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `Items` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `Items`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
|
||
CREATE TABLE `Items` ( | ||
`id` int(11) NOT NULL, | ||
`name` varchar(1000) CHARACTER SET utf8 NOT NULL, | ||
|
@@ -48,8 +71,8 @@ CREATE TABLE `Items` ( | |
|
||
INSERT INTO `Items` (`id`, `name`, `company`, `quantity`, `price`) VALUES | ||
(1, '<a href=\"https://en.wikipedia.org/wiki/Acetylacetone\" target=\"_blank\">Acetylacetone</a>', 'Alfa Aeser', 100, 50), | ||
(2, '<a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a>', 'SDFCL', 200, 50), | ||
(3, '<a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a>', 'Sigma-Aldrich', 300, 50), | ||
(2, '<a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a>', 'SDFCL', 194, 50), | ||
(3, '<a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a>', 'Sigma-Aldrich', 291, 50), | ||
(4, '<a href=\"https://en.wikipedia.org/wiki/Camphorsulfonic_acid\" target=\"_blank\">Camphorsulfonic Acid</a>', 'Sigma-Aldrich', 300, 50), | ||
(5, '<a href=\"https://en.wikipedia.org/wiki/Docusate\" target=\"_blank\">Dioctyl sulfosuccinate sodium salt</a>', 'Sigma-Aldrich', 300, 50), | ||
(6, '<a href=\"https://en.wikipedia.org/wiki/Ethylene_glycol\" target=\"_blank\">Ethanediol</a>', 'SDFCL', 400, 50), | ||
|
@@ -63,46 +86,71 @@ INSERT INTO `Items` (`id`, `name`, `company`, `quantity`, `price`) VALUES | |
-- | ||
-- Table structure for table `Orders` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `Orders`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
|
||
CREATE TABLE `Orders` ( | ||
`OrderId` int(11) NOT NULL, | ||
`UserId` int(11) NOT NULL, | ||
`OrderDetails` text NOT NULL, | ||
`Remarks` text NOT NULL, | ||
`Status` text | ||
`Status` text DEFAULT NULL, | ||
`Admin_Remarks` text NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- | ||
-- Dumping data for table `Orders` | ||
-- | ||
|
||
INSERT INTO `Orders` (`OrderId`, `UserId`, `OrderDetails`, `Remarks`, `Status`, `Admin_Remarks`) VALUES | ||
(17, 1, 'chemicalId: <a href=\"https://en.wikipedia.org/wiki/Camphorsulfonic_acid\" target=\"_blank\">Camphorsulfonic Acid</a> quantity: 3 price: 50', 'Remarks...', 'Rejected', 'Your order is rejected. Please order again after 10 days.'), | ||
(18, 1, 'chemicalId: <a href=\"https://en.wikipedia.org/wiki/Docusate\" target=\"_blank\">Dioctyl sulfosuccinate sodium salt</a> quantity: 2 price: 50', 'Remarks...', 'Approved', 'Thanks for Ordering'), | ||
(19, 1, 'chemicalId: <a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a> quantity: 1 price: 50', 'Remarks...', 'Rejected', 'Your order is rejected. Please order again after 10 days.'), | ||
(20, 1, 'chemicalId: <a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a> quantity: 1 price: 50', 'Remarks...', 'Approved', 'Thanks for Ordering'), | ||
(21, 1, 'chemicalId: 2 name: <a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a> quantity: 2 price: 50', 'Remarks...', 'Approved', 'Thanks for Ordering'), | ||
(22, 1, 'chemicalId: 3 name: <a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a> quantity: 1 price: 50', 'Remarks...', 'Approved', 'Thanks for Ordering'), | ||
(23, 1, 'chemicalId: 3 name: <a href=\"https://en.wikipedia.org/wiki/Benzoic_acid\" target=\"_blank\">Benzoic Acid</a> quantity: 1 price: 50', 'Remarks...', 'Approval pending', 'Your request will be approved soon'); | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `Users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `Users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
|
||
CREATE TABLE `Users` ( | ||
`id` int(11) NOT NULL, | ||
`firstname` varchar(30) NOT NULL, | ||
`lastname` varchar(30) NOT NULL, | ||
`email` varchar(50) DEFAULT NULL, | ||
`reg_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
`contact` varchar(15) NOT NULL | ||
`contact` varchar(15) NOT NULL, | ||
`Address` text NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- | ||
-- Dumping data for table `Users` | ||
-- | ||
|
||
INSERT INTO `Users` (`id`, `firstname`, `lastname`, `email`, `reg_date`, `contact`) VALUES | ||
(1, 'Khyati', 'Agarwal', '[email protected]', '2020-11-01 22:17:05','9876543212'), | ||
(2, 'Jai', 'Luthra', '[email protected]', '2020-11-01 22:17:32','9182736456'); | ||
INSERT INTO `Users` (`id`, `firstname`, `lastname`, `email`, `reg_date`, `contact`, `Address`) VALUES | ||
(1, 'Khyati', 'Agarwal', '[email protected]', '2020-11-25 18:12:08', '9876543212', 'Flat no. 312, Sector 83, Faridabad, Haryana'), | ||
(2, 'Jai', 'Luthra', '[email protected]', '2020-11-01 22:17:32', '9182736456', ''); | ||
|
||
-- | ||
-- Indexes for dumped tables | ||
-- | ||
|
||
-- | ||
-- Indexes for table `Cart` | ||
-- | ||
ALTER TABLE `Cart` | ||
ADD PRIMARY KEY (`CartId`); | ||
|
||
-- | ||
-- Indexes for table `Items` | ||
-- | ||
|
@@ -125,6 +173,12 @@ ALTER TABLE `Users` | |
-- AUTO_INCREMENT for dumped tables | ||
-- | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `Cart` | ||
-- | ||
ALTER TABLE `Cart` | ||
MODIFY `CartId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `Items` | ||
-- | ||
|
@@ -135,7 +189,7 @@ ALTER TABLE `Items` | |
-- AUTO_INCREMENT for table `Orders` | ||
-- | ||
ALTER TABLE `Orders` | ||
MODIFY `OrderId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; | ||
MODIFY `OrderId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24; | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `Users` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.